|
@@ -7,6 +7,7 @@ import com.gis.domain.dto.GoodsPageDateDto;
|
|
|
import com.gis.domain.po.FileEntity;
|
|
|
import com.gis.domain.po.GoodsEntity;
|
|
|
import com.gis.domain.vo.GoodsVo;
|
|
|
+import com.gis.service.FileService;
|
|
|
import com.gis.service.GoodsService;
|
|
|
import com.gis.web.aop.WebControllerLog;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
@@ -37,6 +38,11 @@ public class GoodsController extends BaseController {
|
|
|
@Autowired
|
|
|
private GoodsService goodsService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private FileService fileService;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -61,10 +67,18 @@ public class GoodsController extends BaseController {
|
|
|
BeanUtils.copyProperties(param, entity);
|
|
|
goodsService.save(entity);
|
|
|
|
|
|
- // 图片信息跟goodsId绑定
|
|
|
- String fkId= "goods_" + entity.getId();
|
|
|
|
|
|
- fileService.setFkIdByIds(param.getFileIds(), fkId);
|
|
|
+ String modelType = null;
|
|
|
+ if (entity.getType() == 1) {
|
|
|
+ modelType = TypeCode.MODEL_GOODS_IMG;
|
|
|
+ } else if (entity.getType() == 2) {
|
|
|
+ modelType = TypeCode.MODEL_GOODS_VIDEO;
|
|
|
+ } else if (entity.getType() == 3) {
|
|
|
+ modelType = TypeCode.MODEL_GOODS_MODEL;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 图片信息跟goodsId绑定
|
|
|
+ fileService.setFkIdByIds(param.getFileId(), entity.getId(), modelType);
|
|
|
|
|
|
} else {
|
|
|
entity = goodsService.findById(param.getId());
|
|
@@ -102,19 +116,13 @@ public class GoodsController extends BaseController {
|
|
|
*
|
|
|
*/
|
|
|
@ApiOperation("设置封面")
|
|
|
- @GetMapping("setCover/{fileId}/{goodsId}")
|
|
|
- public Result setCover(@PathVariable Long fileId, @PathVariable String goodsId) {
|
|
|
- List<FileEntity> entityList = fileService.findByFkId(TypeCode.FILE_GOODS + goodsId);
|
|
|
- for (FileEntity entity: entityList) {
|
|
|
- if (entity.getId() == fileId) {
|
|
|
- // 1:设置封面
|
|
|
- entity.setCover(1);
|
|
|
- } else {
|
|
|
- entity.setCover(0);
|
|
|
- }
|
|
|
- entity.setUpdateTime(new Date());
|
|
|
- fileService.update(entity);
|
|
|
- }
|
|
|
+ @GetMapping("setCover/{fileId}")
|
|
|
+ public Result setCover(@PathVariable Long fileId) {
|
|
|
+ // 对应模块封面设置默认
|
|
|
+ fileService.setCoverDefault(TypeCode.MODEL_GOODS_IMG);
|
|
|
+ // 设置封面
|
|
|
+ fileService.setCover(fileId);
|
|
|
+
|
|
|
|
|
|
return Result.success();
|
|
|
}
|