|
@@ -10,6 +10,7 @@ import com.persagy.dmp.basic.utils.JsonNodeUtils;
|
|
|
import com.persagy.dmp.basic.utils.QueryCriteriaHelper;
|
|
|
import com.persagy.dmp.common.constant.CommonConstant;
|
|
|
import com.persagy.dmp.common.constant.ResponseCode;
|
|
|
+import com.persagy.dmp.common.context.AppContext;
|
|
|
import com.persagy.dmp.common.exception.BusinessException;
|
|
|
import com.persagy.dmp.common.model.response.CommonResult;
|
|
|
import com.persagy.dmp.common.utils.ParamCheckUtil;
|
|
@@ -18,6 +19,7 @@ import com.persagy.dmp.mybatis.utils.ConditionUtil;
|
|
|
import com.persagy.dmp.rwd.digital.entity.ObjectDigital;
|
|
|
import com.persagy.dmp.rwd.digital.service.IObjectDigitalService;
|
|
|
import com.persagy.dmp.rwd.digital.utils.ObjectDigitalCriteriaHelper;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
@@ -64,9 +66,11 @@ public class ObjectDigitalController{
|
|
|
public CommonResult<ObjectDigital> create(@Valid @RequestBody ObjectNode node){
|
|
|
//基础参数校验
|
|
|
ParamCheckUtil.checkParam(CommonConstant.QUERY_GROUPCODE,CommonConstant.QUERY_PROJECTID);
|
|
|
-
|
|
|
ObjectDigital vo = JsonNodeUtils.toEntity(node, ObjectDigital.class, ObjectDigital.EXTRA_COLUMN);
|
|
|
List<ObjectDigital> voList = CollUtil.newArrayList(vo);
|
|
|
+ //创建默认条件
|
|
|
+ createDefaultValue(voList);
|
|
|
+ //新增对象信息
|
|
|
service.insert(voList);
|
|
|
return ResultHelper.single(vo);
|
|
|
}
|
|
@@ -75,8 +79,10 @@ public class ObjectDigitalController{
|
|
|
public CommonResult<List<ObjectDigital>> createBatch(@Valid @RequestBody ArrayNode array){
|
|
|
//基础参数校验
|
|
|
ParamCheckUtil.checkParam(CommonConstant.QUERY_GROUPCODE,CommonConstant.QUERY_PROJECTID);
|
|
|
-
|
|
|
List<ObjectDigital> voList = JsonNodeUtils.toEntity(array, ObjectDigital.class, ObjectDigital.EXTRA_COLUMN);
|
|
|
+ //创建默认条件
|
|
|
+ createDefaultValue(voList);
|
|
|
+ //批量新增对象信息
|
|
|
voList = service.insert(voList);
|
|
|
return ResultHelper.multi(voList);
|
|
|
}
|
|
@@ -85,9 +91,11 @@ public class ObjectDigitalController{
|
|
|
public CommonResult<ObjectDigital> update(@Valid @RequestBody ObjectNode node){
|
|
|
//基础参数校验
|
|
|
ParamCheckUtil.checkParam(CommonConstant.QUERY_GROUPCODE,CommonConstant.QUERY_PROJECTID);
|
|
|
-
|
|
|
ObjectDigital vo = JsonNodeUtils.toEntity(node, ObjectDigital.class, ObjectDigital.EXTRA_COLUMN);
|
|
|
List<ObjectDigital> voList = CollUtil.newArrayList(vo);
|
|
|
+ //创建默认条件
|
|
|
+ createDefaultValue(voList);
|
|
|
+ //修改对象信息
|
|
|
service.update(voList);
|
|
|
return ResultHelper.single(vo);
|
|
|
}
|
|
@@ -96,21 +104,50 @@ public class ObjectDigitalController{
|
|
|
public CommonResult<List<ObjectDigital>> updateBatch(@Valid @RequestBody ArrayNode array){
|
|
|
//基础参数校验
|
|
|
ParamCheckUtil.checkParam(CommonConstant.QUERY_GROUPCODE,CommonConstant.QUERY_PROJECTID);
|
|
|
-
|
|
|
List<ObjectDigital> voList = JsonNodeUtils.toEntity(array, ObjectDigital.class, ObjectDigital.EXTRA_COLUMN);
|
|
|
+ //创建默认条件
|
|
|
+ createDefaultValue(voList);
|
|
|
+ //批量修改对象信息
|
|
|
voList = service.update(voList);
|
|
|
return ResultHelper.multi(voList);
|
|
|
}
|
|
|
|
|
|
@PostMapping("/deleteOne")
|
|
|
public CommonResult delete(@RequestBody String id){
|
|
|
+ if(StringUtils.isEmpty(id)){
|
|
|
+ throw new BusinessException(ResponseCode.A0400.getCode(), "id不能为空");
|
|
|
+ }
|
|
|
service.delete(CollUtil.newArrayList(id));
|
|
|
return ResultHelper.success();
|
|
|
}
|
|
|
|
|
|
@PostMapping("/delete")
|
|
|
- public CommonResult deleteBatch(@RequestBody List<String> id){
|
|
|
- service.delete(id);
|
|
|
+ public CommonResult deleteBatch(@RequestBody List<String> ids){
|
|
|
+ if(ids == null || ids.size()<=0){
|
|
|
+ throw new BusinessException(ResponseCode.A0400.getCode(), "id不能为空");
|
|
|
+ }
|
|
|
+ service.delete(ids);
|
|
|
return ResultHelper.success();
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 创建默认条件
|
|
|
+ * @param voList
|
|
|
+ */
|
|
|
+ private void createDefaultValue(List<ObjectDigital> voList){
|
|
|
+ String groupCode = AppContext.getContext().getGroupCode();
|
|
|
+ if(StringUtils.isEmpty(groupCode)){
|
|
|
+ //默认集团
|
|
|
+ groupCode = CommonConstant.DEFAULT_ID;
|
|
|
+ }
|
|
|
+ String projectId = AppContext.getContext().getProjectId();
|
|
|
+ if(StringUtils.isEmpty(projectId)){
|
|
|
+ //默认项目
|
|
|
+ projectId = CommonConstant.DEFAULT_ID;
|
|
|
+ }
|
|
|
+ for (ObjectDigital vo : voList) {
|
|
|
+ vo.setGroupCode(groupCode);
|
|
|
+ vo.setProjectId(projectId);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|