|
@@ -1,6 +1,11 @@
|
|
package com.platform.service.custom.impl;
|
|
package com.platform.service.custom.impl;
|
|
|
|
|
|
import com.platform.common.bean.AbstractPageResultBean;
|
|
import com.platform.common.bean.AbstractPageResultBean;
|
|
|
|
+import com.platform.common.exception.DeniedException;
|
|
|
|
+import com.platform.common.util.BeanConverterUtil;
|
|
|
|
+import com.platform.common.util.IdGeneratorUtils;
|
|
|
|
+import com.platform.common.util.SecurityUtils;
|
|
|
|
+import com.platform.common.util.StringUtils;
|
|
import com.platform.dao.bean.MyPage;
|
|
import com.platform.dao.bean.MyPage;
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.platform.dao.vo.query.custom.CustomRelationVO;
|
|
import com.platform.dao.vo.query.custom.CustomRelationVO;
|
|
@@ -15,6 +20,7 @@ import tk.mybatis.mapper.weekend.Weekend;
|
|
import tk.mybatis.mapper.weekend.WeekendCriteria;
|
|
import tk.mybatis.mapper.weekend.WeekendCriteria;
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
|
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -42,6 +48,64 @@ public class CustomRelationServiceImpl extends BaseServiceImpl<CustomRelationMap
|
|
return new MyPage(mapper.selectList(record));
|
|
return new MyPage(mapper.selectList(record));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public CustomRelation saveByDTO(CustomRelationDTO record) {
|
|
|
|
+ checkPreview(record);
|
|
|
|
+ // 保证唯一性
|
|
|
|
+ checkExists(record.getType(),record.getCategory(),"新增的模板和表单分类已存在,前往修改即可");
|
|
|
|
+ CustomRelation relation = BeanConverterUtil.copyObjectProperties(record, CustomRelation.class);
|
|
|
|
+ relation.setId(IdGeneratorUtils.getObjectId());
|
|
|
|
+ relation.setCreatedTime(LocalDateTime.now());
|
|
|
|
+ relation.setCreatedUserId(SecurityUtils.getUserInfo().getUserId());
|
|
|
|
+ relation.setCreatedUserName(SecurityUtils.getUserInfo().getRealName());
|
|
|
|
+ mapper.insert(relation);
|
|
|
|
+ return relation;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void modByDTO(CustomRelationDTO record) {
|
|
|
|
+ checkPreview(record);
|
|
|
|
+ if(StringUtils.isBlank(record.getId())){
|
|
|
|
+ throw new DeniedException("ID不可为空");
|
|
|
|
+ }
|
|
|
|
+ CustomRelation oldRelation = mapper.selectByPrimaryKey(record.getId());
|
|
|
|
+ String oldCategory = oldRelation.getCategory();
|
|
|
|
+ String oldType = oldRelation.getType();
|
|
|
|
+ if(!oldType.equals(record.getType()) || !oldCategory.equals(record.getCategory())){
|
|
|
|
+ // 触发校验规则
|
|
|
|
+ checkExists(record.getType(),record.getCategory(),"将要修改的模板和表单分类已存在");
|
|
|
|
+ }
|
|
|
|
+ CustomRelation updInfo = BeanConverterUtil.copyObjectProperties(record, CustomRelation.class);
|
|
|
|
+ updInfo.setUpdateTime(LocalDateTime.now());
|
|
|
|
+ updInfo.setUpdateUserId(SecurityUtils.getUserInfo().getUserId());
|
|
|
|
+ updInfo.setUpdateUserName(SecurityUtils.getUserInfo().getRealName());
|
|
|
|
+ mapper.updateByPrimaryKey(updInfo);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void checkExists(String type, String category,String msg) {
|
|
|
|
+ CustomRelation query = new CustomRelation();
|
|
|
|
+ query.setCategory(category);
|
|
|
|
+ query.setType(type);
|
|
|
|
+ if(mapper.selectCount(query) > 0) {
|
|
|
|
+ throw new DeniedException(msg);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void checkPreview(CustomRelationDTO record){
|
|
|
|
+ if(StringUtils.isBlank(record.getType())){
|
|
|
|
+ throw new DeniedException("表单分类不可为空");
|
|
|
|
+ }
|
|
|
|
+ if(StringUtils.isBlank(record.getCategory())){
|
|
|
|
+ throw new DeniedException("模板分类不可为空");
|
|
|
|
+ }
|
|
|
|
+ if(StringUtils.isBlank(record.getRemark())){
|
|
|
|
+ throw new DeniedException("备注说明不可为空");
|
|
|
|
+ }
|
|
|
|
+ if(StringUtils.isBlank(record.getJson())){
|
|
|
|
+ throw new DeniedException("json不可为空");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public AbstractPageResultBean<CustomRelation> selectPageInfo(CustomRelationDTO record, int pageNum, int pageSize) {
|
|
public AbstractPageResultBean<CustomRelation> selectPageInfo(CustomRelationDTO record, int pageNum, int pageSize) {
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
PageHelper.startPage(pageNum, pageSize);
|