Commit fa057b85 authored by 廖旭伟's avatar 廖旭伟

修改素材分组bug

parent bd9d0c0d
......@@ -6,6 +6,7 @@ import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result;
import com.mortals.framework.util.DataUtil;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.model.ParamEntity;
import com.mortals.xhx.base.system.param.service.ParamService;
......@@ -21,6 +22,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -41,17 +43,26 @@ public class PictureGroupController extends BaseCRUDJsonBodyMappingController<Pa
if(StringUtils.isEmpty(entity.getPictureGroupName())){
throw new AppException("分组名称不能为空");
}
if(entity.getId()==null){
ParamEntity query = new ParamEntity();
query.setFirstOrganize("PictureMaterial");
query.setSecondOrganize("pictureGroupId");
List<ParamEntity> paramEntities = this.service.find(query);
int size = (paramEntities==null?0:paramEntities.size()) + 1;
entity.setParamKey(size+"");
int max = 0;
if(paramEntities.isEmpty()){
max = 1;
}else {
ParamEntity maxEntity = paramEntities.stream().max(Comparator.comparing(ParamEntity::getParamKey)).get();
max = DataUtil.converStr2Int(maxEntity.getParamKey(),paramEntities.size())+1;
}
entity.setParamKey(max+"");
entity.setName("素材分组");
entity.setParamValue(entity.getPictureGroupName());
entity.setFirstOrganize("PictureMaterial");
entity.setSecondOrganize("pictureGroupId");
}
entity.setParamValue(entity.getPictureGroupName());
}
@Override
public String list(@RequestBody ParamEntity entity) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment