|
@@ -1,8 +1,11 @@
|
|
|
package com.platform.service.custom.impl;
|
|
|
|
|
|
import com.platform.common.bean.AbstractPageResultBean;
|
|
|
+import com.platform.common.exception.DeniedException;
|
|
|
+import com.platform.common.util.StringUtils;
|
|
|
import com.platform.dao.bean.MyPage;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
+import com.platform.dao.enums.ClassNameCodeEnum;
|
|
|
import com.platform.dao.vo.query.custom.CustomClassNameVO;
|
|
|
import com.platform.dao.dto.custom.CustomClassNameDTO;
|
|
|
import com.platform.dao.entity.custom.CustomClassName;
|
|
@@ -10,7 +13,6 @@ import com.platform.dao.mapper.custom.CustomClassNameMapper;
|
|
|
import com.platform.service.custom.CustomClassNameService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.platform.service.base.impl.BaseServiceImpl;
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
import tk.mybatis.mapper.weekend.Weekend;
|
|
|
import tk.mybatis.mapper.weekend.WeekendCriteria;
|
|
|
import lombok.AllArgsConstructor;
|
|
@@ -42,6 +44,65 @@ public class CustomClassNameServiceImpl extends BaseServiceImpl<CustomClassNameM
|
|
|
return new MyPage(mapper.selectList(record));
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public CustomClassName saveByDTO(CustomClassNameDTO record) {
|
|
|
+ checkPreview(record);
|
|
|
+ return saveModelByDTO(record);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void modByDTO(CustomClassNameDTO record) {
|
|
|
+ if(StringUtils.isBlank(record.getId())){
|
|
|
+ throw new DeniedException("修改ID不可为空");
|
|
|
+ }
|
|
|
+ CustomClassName oldCustom = mapper.selectByPrimaryKey(record.getId());
|
|
|
+ // 不给修改code类型
|
|
|
+ if(!oldCustom.getCode().equals(record.getCode())){
|
|
|
+ throw new DeniedException("配置类型不可修改");
|
|
|
+ }
|
|
|
+ modModelByDTO(record);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void checkPreview(CustomClassNameDTO record){
|
|
|
+ if(StringUtils.isBlank(record.getTitle())){
|
|
|
+ throw new DeniedException("表名不可为空");
|
|
|
+ }
|
|
|
+ if(StringUtils.isBlank(record.getTitleCode())){
|
|
|
+ throw new DeniedException("表名编码不可为空");
|
|
|
+ }
|
|
|
+ String code = record.getCode();
|
|
|
+ if(StringUtils.isBlank(code)){
|
|
|
+ throw new DeniedException("配置类型不可为空");
|
|
|
+ }
|
|
|
+ CustomClassName checkQuery = new CustomClassName();
|
|
|
+ checkQuery.setCode(record.getCode());
|
|
|
+ checkQuery.setTitleCode(record.getTitleCode());
|
|
|
+ int countNum = 0;
|
|
|
+ if(code.equals(ClassNameCodeEnum.REFLECT.getValue())){
|
|
|
+ // 反射类
|
|
|
+ if(StringUtils.isBlank(record.getHandleName())){
|
|
|
+ throw new DeniedException("处理类不可为空");
|
|
|
+ }
|
|
|
+ if(StringUtils.isBlank(record.getHandleCode())){
|
|
|
+ throw new DeniedException("处理类编码不可为空");
|
|
|
+ }
|
|
|
+ if(StringUtils.isBlank(record.getMethodCode())){
|
|
|
+ throw new DeniedException("方法名不可为空");
|
|
|
+ }
|
|
|
+ if(StringUtils.isBlank(record.getTitleColumnName())){
|
|
|
+ throw new DeniedException("具体列名不可为空");
|
|
|
+ }
|
|
|
+ // 判断数据库中是否唯一
|
|
|
+ checkQuery.setHandleCode(record.getHandleCode());
|
|
|
+ checkQuery.setMethodCode(record.getMethodCode());
|
|
|
+ checkQuery.setTitleColumnName(record.getTitleColumnName());
|
|
|
+ }
|
|
|
+ countNum = getCountByModel(checkQuery);
|
|
|
+ if(countNum > 0){
|
|
|
+ throw new DeniedException("录入数据已存在");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public AbstractPageResultBean<CustomClassName> selectPageInfo(CustomClassNameDTO record, int pageNum, int pageSize) {
|
|
|
PageHelper.startPage(pageNum, pageSize);
|