Explorar o código

feature(JPA修改): JPA修改

JPA修改
mazq %!s(int64=4) %!d(string=hai) anos
pai
achega
7bdf4d3d99

+ 1 - 1
dcuc-app-api/src/main/java/com/dragoninfo/dcuc/app/facade/sub/IDataClaFacade.java

@@ -48,7 +48,7 @@ public interface IDataClaFacade {
      * @return
      */
     @DeleteMapping("deleteById/{id}")
-    Boolean deleteById(@PathVariable("id") String id);
+    Boolean deleteAllLevel(@PathVariable("id") String id);
 
     /**
      * 四级资源分类保存

+ 1 - 1
dcuc-app-api/src/main/java/com/dragoninfo/dcuc/app/facade/sub/IFieldClaFacade.java

@@ -56,7 +56,7 @@ public interface IFieldClaFacade {
      * @return
      */
     @DeleteMapping("deleteById/{id}")
-    Boolean deleteById(@PathVariable("id") String id);
+    Boolean deleteAllLevel(@PathVariable("id") String id);
 
     /**
      * 获取该层级字段分类列表

+ 35 - 2
dcuc-app-model/src/main/java/com/dragoninfo/dcuc/app/sub/entity/DataCla.java

@@ -1,8 +1,14 @@
 package com.dragoninfo.dcuc.app.sub.entity;
 
 import com.baomidou.mybatisplus.annotation.*;
+import com.dragonsoft.duceap.base.annotations.audit.DeletedBy;
+import com.dragonsoft.duceap.base.annotations.audit.DeletedDate;
 import lombok.Data;
 import org.apache.ibatis.type.JdbcType;
+import org.springframework.data.annotation.CreatedBy;
+import org.springframework.data.annotation.CreatedDate;
+import org.springframework.data.annotation.LastModifiedBy;
+import org.springframework.data.annotation.LastModifiedDate;
 
 import java.io.Serializable;
 import java.util.Date;
@@ -73,20 +79,47 @@ public class DataCla implements Serializable {
 
 
     /**
-     * 创建时间
+     * 新增时间
+     * 新增的字段需使用  @TableField(fill = FieldFill.INSERT),否则无法新增
      */
-    @TableField(jdbcType = JdbcType.TIMESTAMP)
+    @CreatedDate
+    @TableField(jdbcType = JdbcType.TIMESTAMP,fill = FieldFill.INSERT)
     private Date createTime;
 
+    /**
+     * 新增人员账号
+     * 新增的字段需使用  @TableField(fill = FieldFill.INSERT),否则无法新增
+     */
+    @CreatedBy
+    @TableField(jdbcType = JdbcType.VARCHAR,fill = FieldFill.INSERT)
+    private String createUser;
+
     /**
      * 修改时间
      */
+    @LastModifiedDate
     @TableField(jdbcType = JdbcType.TIMESTAMP)
     private Date updateTime;
 
+    /**
+     * 更新人账号
+     */
+    @LastModifiedBy
+    private String updateUser;
+
+
     /**
      * 删除时间
      */
+    @DeletedDate
     @TableField(jdbcType = JdbcType.TIMESTAMP)
     private Date deleteTime;
+
+    /**
+     * 删除人账号
+     */
+    @DeletedBy
+    private String deleteUser;
+
+
 }

+ 29 - 0
dcuc-app-model/src/main/java/com/dragoninfo/dcuc/app/sub/entity/DataLevel.java

@@ -1,8 +1,14 @@
 package com.dragoninfo.dcuc.app.sub.entity;
 
 import com.baomidou.mybatisplus.annotation.*;
+import com.dragonsoft.duceap.base.annotations.audit.DeletedBy;
+import com.dragonsoft.duceap.base.annotations.audit.DeletedDate;
 import lombok.Data;
 import org.apache.ibatis.type.JdbcType;
+import org.springframework.data.annotation.CreatedBy;
+import org.springframework.data.annotation.CreatedDate;
+import org.springframework.data.annotation.LastModifiedBy;
+import org.springframework.data.annotation.LastModifiedDate;
 
 import java.io.Serializable;
 import java.util.Date;
@@ -50,18 +56,41 @@ public class DataLevel implements Serializable {
     /**
      * 创建时间
      */
+    @CreatedDate
     @TableField(jdbcType = JdbcType.TIMESTAMP)
     private Date createTime;
 
+    /**
+     * 新增人员账号
+     * 新增的字段需使用  @TableField(fill = FieldFill.INSERT),否则无法新增
+     */
+    @CreatedBy
+    @TableField(jdbcType = JdbcType.VARCHAR,fill = FieldFill.INSERT)
+    private String createUser;
+
     /**
      * 修改时间
      */
+    @LastModifiedDate
     @TableField(jdbcType = JdbcType.TIMESTAMP)
     private Date updateTime;
 
+    /**
+     * 更新人账号
+     */
+    @LastModifiedBy
+    private String updateUser;
+
     /**
      * 删除时间
      */
+    @DeletedDate
     @TableField(jdbcType = JdbcType.TIMESTAMP)
     private Date deleteTime;
+
+    /**
+     * 删除人账号
+     */
+    @DeletedBy
+    private String deleteUser;
 }

+ 29 - 0
dcuc-app-model/src/main/java/com/dragoninfo/dcuc/app/sub/entity/DataSec.java

@@ -1,8 +1,14 @@
 package com.dragoninfo.dcuc.app.sub.entity;
 
 import com.baomidou.mybatisplus.annotation.*;
+import com.dragonsoft.duceap.base.annotations.audit.DeletedBy;
+import com.dragonsoft.duceap.base.annotations.audit.DeletedDate;
 import lombok.Data;
 import org.apache.ibatis.type.JdbcType;
+import org.springframework.data.annotation.CreatedBy;
+import org.springframework.data.annotation.CreatedDate;
+import org.springframework.data.annotation.LastModifiedBy;
+import org.springframework.data.annotation.LastModifiedDate;
 
 import java.io.Serializable;
 import java.util.Date;
@@ -49,18 +55,41 @@ public class DataSec implements Serializable {
     /**
      * 创建时间
      */
+    @CreatedDate
     @TableField(jdbcType = JdbcType.TIMESTAMP)
     private Date createTime;
 
+    /**
+     * 新增人员账号
+     * 新增的字段需使用  @TableField(fill = FieldFill.INSERT),否则无法新增
+     */
+    @CreatedBy
+    @TableField(jdbcType = JdbcType.VARCHAR,fill = FieldFill.INSERT)
+    private String createUser;
+
     /**
      * 修改时间
      */
+    @LastModifiedDate
     @TableField(jdbcType = JdbcType.TIMESTAMP)
     private Date updateTime;
 
+    /**
+     * 更新人账号
+     */
+    @LastModifiedBy
+    private String updateUser;
+
     /**
      * 删除时间
      */
+    @DeletedDate
     @TableField(jdbcType = JdbcType.TIMESTAMP)
     private Date deleteTime;
+
+    /**
+     * 删除人账号
+     */
+    @DeletedBy
+    private String deleteUser;
 }

+ 29 - 0
dcuc-app-model/src/main/java/com/dragoninfo/dcuc/app/sub/entity/FieldCla.java

@@ -1,8 +1,14 @@
 package com.dragoninfo.dcuc.app.sub.entity;
 
 import com.baomidou.mybatisplus.annotation.*;
+import com.dragonsoft.duceap.base.annotations.audit.DeletedBy;
+import com.dragonsoft.duceap.base.annotations.audit.DeletedDate;
 import lombok.Data;
 import org.apache.ibatis.type.JdbcType;
+import org.springframework.data.annotation.CreatedBy;
+import org.springframework.data.annotation.CreatedDate;
+import org.springframework.data.annotation.LastModifiedBy;
+import org.springframework.data.annotation.LastModifiedDate;
 
 import java.io.Serializable;
 import java.util.Date;
@@ -64,18 +70,41 @@ public class FieldCla implements Serializable {
     /**
      * 创建时间
      */
+    @CreatedDate
     @TableField(jdbcType = JdbcType.TIMESTAMP)
     private Date createTime;
 
+    /**
+     * 新增人员账号
+     * 新增的字段需使用  @TableField(fill = FieldFill.INSERT),否则无法新增
+     */
+    @CreatedBy
+    @TableField(jdbcType = JdbcType.VARCHAR,fill = FieldFill.INSERT)
+    private String createUser;
+
     /**
      * 修改时间
      */
+    @LastModifiedDate
     @TableField(jdbcType = JdbcType.TIMESTAMP)
     private Date updateTime;
 
+    /**
+     * 更新人账号
+     */
+    @LastModifiedBy
+    private String updateUser;
+
     /**
      * 删除时间
      */
+    @DeletedDate
     @TableField(jdbcType = JdbcType.TIMESTAMP)
     private Date deleteTime;
+
+    /**
+     * 删除人账号
+     */
+    @DeletedBy
+    private String deleteUser;
 }

+ 2 - 2
dcuc-app-service/src/main/java/com/dragoninfo/dcuc/app/sub/facade/DataClaFacade.java

@@ -46,8 +46,8 @@ public class DataClaFacade implements IDataClaFacade {
     }
 
     @Override
-    public Boolean deleteById(String id) {
-        return dataClaService.deleteById(id);
+    public Boolean deleteAllLevel(String id) {
+        return dataClaService.deleteAllLevel(id);
     }
 
     @Override

+ 2 - 2
dcuc-app-service/src/main/java/com/dragoninfo/dcuc/app/sub/facade/FieldClaFacade.java

@@ -49,8 +49,8 @@ public class FieldClaFacade implements IFieldClaFacade {
     }
 
     @Override
-    public Boolean deleteById(String id) {
-        return fieldClaService.deleteById(id);
+    public Boolean deleteAllLevel(String id) {
+        return fieldClaService.deleteAllLevel(id);
     }
 
     @Override

+ 2 - 1
dcuc-app-service/src/main/java/com/dragoninfo/dcuc/app/sub/service/IDataClaService.java

@@ -64,7 +64,7 @@ public interface IDataClaService {
      * @param id
      * @return
      */
-    Boolean deleteById(String id);
+    Boolean deleteAllLevel(String id);
 
     /**
      * 四级分类更新
@@ -116,4 +116,5 @@ public interface IDataClaService {
      */
     List<DataCla> getAllDataCla();
 
+    void delete(String id);
 }

+ 3 - 1
dcuc-app-service/src/main/java/com/dragoninfo/dcuc/app/sub/service/IFieldClaService.java

@@ -57,7 +57,7 @@ public interface IFieldClaService {
      * @param id
      * @return
      */
-    Boolean deleteById(String id);
+    Boolean deleteAllLevel(String id);
 
     /**
      * 获取该层级字段分类列表
@@ -107,4 +107,6 @@ public interface IFieldClaService {
      * @return
      */
     List<FieldCla> getAllFieldCla();
+
+    void delete(String id);
 }

+ 10 - 11
dcuc-app-service/src/main/java/com/dragoninfo/dcuc/app/sub/service/impl/DataClaServiceImpl.java

@@ -8,6 +8,7 @@ import com.dragoninfo.dcuc.app.enumresources.DataAuthTypeCodeEnum;
 import com.dragoninfo.dcuc.app.sub.dto.DataClaAcceptDTO;
 import com.dragoninfo.dcuc.app.sub.dto.DataClaDTO;
 import com.dragoninfo.dcuc.app.sub.entity.DataCla;
+import com.dragoninfo.dcuc.app.sub.entity.FieldCla;
 import com.dragoninfo.dcuc.app.sub.enumresources.DataClaTypeEnum;
 import com.dragoninfo.dcuc.app.sub.mapper.DataClaMapper;
 import com.dragoninfo.dcuc.app.sub.service.IDataClaService;
@@ -15,6 +16,7 @@ import com.dragoninfo.dcuc.app.vo.DataResourceTreeVo;
 import com.dragoninfo.dcuc.auth.auth.enumresources.AuthDataTypeEnum;
 import com.dragonsoft.duceap.base.entity.search.SearchDTO;
 import com.dragonsoft.duceap.base.enums.BooleanEnum;
+import com.dragonsoft.duceap.base.utils.UserContextUtils;
 import com.dragonsoft.duceap.commons.util.collections.CollectionUtils;
 import com.dragonsoft.duceap.commons.util.string.StringUtils;
 import com.dragonsoft.duceap.core.search.Searchable;
@@ -205,13 +207,13 @@ public class DataClaServiceImpl implements IDataClaService {
     }
 
     @Override
-    public Boolean deleteById(String id) {
+    public Boolean deleteAllLevel(String id) {
         DataCla dataCla = dataClaMapper.selectById(id);
         if(null == dataCla) {
             return false;
         }
-        deleteSelf(dataCla.getId());
-        deleteAllLevel(dataCla);
+        delete(dataCla.getId());
+        deleteChildLevel(dataCla);
         return true;
     }
 
@@ -440,7 +442,7 @@ public class DataClaServiceImpl implements IDataClaService {
         dataClaMapper.update(null, updateWrapper);
     }
 
-    private void deleteAllLevel(DataCla dataCla) {
+    private void deleteChildLevel(DataCla dataCla) {
         String level = dataCla.getLevel();
         String id = dataCla.getId();
         LambdaUpdateWrapper<DataCla> updateWrapper = new LambdaUpdateWrapper<>();
@@ -455,17 +457,14 @@ public class DataClaServiceImpl implements IDataClaService {
         }
         updateWrapper
                 .set(DataCla::getDeleted, BooleanEnum.TRUE.value)
+                .set(DataCla::getDeleteUser, UserContextUtils.getCurrentUser().getId())
                 .set(DataCla::getDeleteTime, new Date());
         dataClaMapper.update(null, updateWrapper);
     }
 
-    private void deleteSelf(String id) {
-        LambdaUpdateWrapper<DataCla> updateWrapper = new LambdaUpdateWrapper<>();
-        updateWrapper
-                .eq(DataCla::getId, id)
-                .set(DataCla::getDeleted, BooleanEnum.TRUE.value)
-                .set(DataCla::getDeleteTime, new Date());
-        dataClaMapper.update(null, updateWrapper);
+    @Override
+    public void delete(String id) {
+       dataClaMapper.deleteById(id);
     }
 
     /**

+ 6 - 17
dcuc-app-service/src/main/java/com/dragoninfo/dcuc/app/sub/service/impl/DataLevelServiceImpl.java

@@ -1,7 +1,6 @@
 package com.dragoninfo.dcuc.app.sub.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.dragoninfo.dcuc.app.enumresources.DataAuthTypeCodeEnum;
 import com.dragoninfo.dcuc.app.sub.dto.DataLevelDTO;
 import com.dragoninfo.dcuc.app.sub.dto.ExcelDataLevel;
@@ -10,8 +9,6 @@ import com.dragoninfo.dcuc.app.sub.mapper.DataLevelMapper;
 import com.dragoninfo.dcuc.app.sub.service.IDataLevelService;
 import com.dragoninfo.dcuc.app.util.ImportUtil;
 import com.dragoninfo.dcuc.app.vo.DataLevelVo;
-import com.dragoninfo.dcuc.auth.auth.enumresources.AuthDataTypeEnum;
-import com.dragoninfo.dcuc.auth.sub.dto.ExcelImpOrgInfo;
 import com.dragoninfo.dcuc.duceap.facade.IDuceapUploadFacade;
 import com.dragoninfo.dcuc.duceap.upload.dto.DocContentDTO;
 import com.dragonsoft.duceap.base.entity.http.ResponseStatus;
@@ -21,7 +18,10 @@ import com.dragonsoft.duceap.commons.util.collections.CollectionUtils;
 import com.dragonsoft.duceap.commons.util.string.StringUtils;
 import com.dragonsoft.duceap.core.search.Searchable;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
@@ -33,8 +33,6 @@ import java.io.InputStream;
 import java.util.*;
 import java.util.stream.Collectors;
 
-import static com.dragoninfo.dcuc.app.enumresources.DataResourceEnum.getByCode;
-
 /**
  * 主客体授权-数据分级业务类
  * @author mazq
@@ -93,17 +91,8 @@ public class DataLevelServiceImpl implements IDataLevelService {
 
     @Override
     public Boolean deleteById(String id) {
-        DataLevel dataLevel = dataLevelMapper.selectById(id);
-        if(null == dataLevel){
-            return false;
-        }
-        LambdaUpdateWrapper<DataLevel> updateWrapper = new LambdaUpdateWrapper<>();
-        updateWrapper
-                .eq(DataLevel::getId, id)
-                .set(DataLevel::getDeleted, BooleanEnum.TRUE.value)
-                .set(DataLevel::getDeleteTime, new Date());
-        dataLevelMapper.update(null, updateWrapper);
-        return true;
+        int i = dataLevelMapper.deleteById(id);
+        return i>0;
     }
 
     @Override

+ 1 - 11
dcuc-app-service/src/main/java/com/dragoninfo/dcuc/app/sub/service/impl/DataSecServiceImpl.java

@@ -95,17 +95,7 @@ public class DataSecServiceImpl implements IDataSecService {
 
     @Override
     public Boolean deleteById(String id) {
-        DataSec dataSec = dataSecMapper.selectById(id);
-        if (null == dataSec) {
-            return false;
-        }
-        LambdaUpdateWrapper<DataSec> updateWrapper = new LambdaUpdateWrapper<>();
-        updateWrapper
-                .eq(DataSec::getId, id)
-                .set(DataSec::getDeleted, BooleanEnum.TRUE.value)
-                .set(DataSec::getDeleteTime, new Date());
-        dataSecMapper.update(null, updateWrapper);
-        return true;
+        return dataSecMapper.deleteById(id) > 0;
     }
 
     @Override

+ 9 - 12
dcuc-app-service/src/main/java/com/dragoninfo/dcuc/app/sub/service/impl/FieldClaServiceImpl.java

@@ -6,15 +6,14 @@ import com.dragoninfo.dcuc.app.cons.CommonCons;
 import com.dragoninfo.dcuc.app.enumresources.DataAuthTypeCodeEnum;
 import com.dragoninfo.dcuc.app.sub.dto.FieldClaAcceptDTO;
 import com.dragoninfo.dcuc.app.sub.dto.FieldClaDTO;
-import com.dragoninfo.dcuc.app.sub.entity.DataCla;
 import com.dragoninfo.dcuc.app.sub.entity.FieldCla;
-import com.dragoninfo.dcuc.app.sub.enumresources.DataClaTypeEnum;
 import com.dragoninfo.dcuc.app.sub.enumresources.FieldClaTypeEnum;
 import com.dragoninfo.dcuc.app.sub.mapper.FieldClaMapper;
 import com.dragoninfo.dcuc.app.sub.service.IFieldClaService;
 import com.dragoninfo.dcuc.app.vo.DataResourceTreeVo;
 import com.dragonsoft.duceap.base.entity.search.SearchDTO;
 import com.dragonsoft.duceap.base.enums.BooleanEnum;
+import com.dragonsoft.duceap.base.utils.UserContextUtils;
 import com.dragonsoft.duceap.commons.util.collections.CollectionUtils;
 import com.dragonsoft.duceap.commons.util.string.StringUtils;
 import com.dragonsoft.duceap.core.search.Searchable;
@@ -146,13 +145,13 @@ public class FieldClaServiceImpl implements IFieldClaService {
     }
 
     @Override
-    public Boolean deleteById(String id) {
+    public Boolean deleteAllLevel(String id) {
         FieldCla fieldCla = fieldClaMapper.selectById(id);
         if(null == fieldCla) {
             return false;
         }
-        deleteSelf(fieldCla);
-        deleteAllLevel(fieldCla);
+        delete(fieldCla.getId());
+        deleteChildLevel(fieldCla);
         return true;
     }
 
@@ -326,7 +325,7 @@ public class FieldClaServiceImpl implements IFieldClaService {
         }
     }
 
-    private void deleteAllLevel(FieldCla fieldCla) {
+    private void deleteChildLevel(FieldCla fieldCla) {
         String level = fieldCla.getLevel();
         if(FieldClaTypeEnum.SEC.getLevel().equals(level)) {
             return;
@@ -334,16 +333,14 @@ public class FieldClaServiceImpl implements IFieldClaService {
         LambdaUpdateWrapper<FieldCla> updateWrapper = new LambdaUpdateWrapper<>();
         updateWrapper.set(FieldCla::getDeleteTime, new Date())
                 .set(FieldCla::getDeleted, BooleanEnum.TRUE.value)
+                .set(FieldCla::getDeleteUser, UserContextUtils.getCurrentUser().getId())
                 .eq(FieldCla::getFirId, fieldCla.getId());
         fieldClaMapper.update(null, updateWrapper);
     }
 
-    private void deleteSelf(FieldCla fieldCla) {
-        LambdaUpdateWrapper<FieldCla> updateWrapper = new LambdaUpdateWrapper<>();
-        updateWrapper.set(FieldCla::getDeleteTime, new Date())
-                     .set(FieldCla::getDeleted, BooleanEnum.TRUE.value)
-                     .eq(FieldCla::getId, fieldCla.getId());
-        fieldClaMapper.update(null, updateWrapper);
+    @Override
+    public void delete(String id) {
+        fieldClaMapper.deleteById(id);
     }
 
     private void updateCodeName(FieldClaDTO fieldClaDTO) {