Bladeren bron

Merge branches 'develop' and 'huangyuan-user' of http://132.232.206.88:3000/lift-manager/lift-server into huangyuan-user

黄远 5 jaren geleden
bovenliggende
commit
0189d61d28
18 gewijzigde bestanden met toevoegingen van 327 en 384 verwijderingen
  1. 3 3
      lift-business-service/src/main/java/cn/com/ty/lift/business/annualinspection/controller/AnnualInspectionController.java
  2. 1 1
      lift-business-service/src/main/java/cn/com/ty/lift/business/annualinspection/dto/InspectionRequest.java
  3. 24 8
      lift-business-service/src/main/java/cn/com/ty/lift/business/common/CommonController.java
  4. 13 15
      lift-business-service/src/main/java/cn/com/ty/lift/business/framework/aspect/VerifyMethodInterceptor.java
  5. 0 6
      lift-common/pom.xml
  6. 8 42
      lift-common/src/main/java/cn.com.ty.lift.common/aliservice/aliyunoss/AliyunOSS.java
  7. 0 23
      lift-common/src/main/java/cn.com.ty.lift.common/aliservice/aliyunoss/OssEntity.java
  8. 82 75
      lift-common/src/main/java/cn.com.ty.lift.common/sql/SqlIllegalInterceptor.java
  9. 143 158
      lift-common/src/main/java/cn.com.ty.lift.common/verify/Verification.java
  10. 0 1
      lift-enterprise-service/src/main/java/cn/com/ty/lift/enterprise/config/SystemConfiguration.java
  11. 14 16
      lift-enterprise-service/src/main/java/cn/com/ty/lift/enterprise/common/VerifyMethodInterceptor.java
  12. 3 1
      lift-enterprise-service/src/main/java/cn/com/ty/lift/enterprise/oa/controller/AnnouncementController.java
  13. 3 2
      lift-enterprise-service/src/main/java/cn/com/ty/lift/enterprise/oa/entity/Announcement.java
  14. 3 2
      lift-enterprise-service/src/main/java/cn/com/ty/lift/enterprise/oa/entity/Attendance.java
  15. 2 0
      lift-enterprise-service/src/main/java/cn/com/ty/lift/enterprise/oa/entity/LiftCertificate.java
  16. 2 1
      lift-enterprise-service/src/main/java/cn/com/ty/lift/enterprise/oa/service/AnnouncementImgService.java
  17. 13 15
      lift-quan-service/src/main/java/cn/com/ty/lift/quan/config/VerifyMethodInterceptor.java
  18. 13 15
      lift-system-service/src/main/java/cn/com/ty/lift/system/config/VerifyMethodInterceptor.java

+ 3 - 3
lift-business-service/src/main/java/cn/com/ty/lift/business/annualinspection/controller/AnnualInspectionController.java

@@ -184,7 +184,7 @@ public class AnnualInspectionController {
     public RestResponse update(@Ver @RequestBody InspectionRequest entity){
         AnnualInspection old = annualInspectionService.findByMtCompanyId(entity.getId(), entity.getMtCompanyId());
         Verify.notNull(old, Verify.Inspection.confirm);
-        Integer oldStepName = old.getStepName();
+        Integer oldStepName = old.getStepName() == null ? 1 : old.getStepName();
         Verify.isTrue(oldStepName == 1, "年检第一阶段才能修改");
         old.setIsCheckGoverner(entity.getIsCheckGoverner());
         old.setLoadInspectionSetting(entity.getLoadInspectionSetting());
@@ -297,8 +297,8 @@ public class AnnualInspectionController {
     public RestResponse stepFour(@Ver @RequestBody InspectionRequest entity){
         AnnualInspection old = annualInspectionService.findByMtCompanyId(entity.getId(), entity.getMtCompanyId());
         Verify.notNull(old, Verify.Inspection.confirm);
-        Integer oldStepName = old.getStepName();
-        Integer oldStepStatus = old.getStepStatus();
+        Integer oldStepName = old.getStepName() == null ? 3 : old.getStepName();
+        Integer oldStepStatus = old.getStepStatus() == null ? 5 : old.getStepStatus();
         Integer stepStatus = entity.getStepStatus();
         Verify.isTrue(oldStepName == 3 || oldStepName == 4, "请先完成第三阶段再进行第四阶段");
         Verify.isTrue(oldStepStatus >= 5 && oldStepStatus <= 10, "请进行第四阶段操作");

+ 1 - 1
lift-business-service/src/main/java/cn/com/ty/lift/business/annualinspection/dto/InspectionRequest.java

@@ -132,7 +132,7 @@ public class InspectionRequest extends PageRequest {
     /**
      * 联系电话
      */
-    @Size(min = 7,max = 11,message = "联系电话格式有误")
+    @Pattern(regexp = "^1[34578]\\d{9}|0[1-9](\\d{1,2}\\-?)[1-9]\\d{6,7}$",message = "联系电话格式有误")
     private String telephone;
 
     /**

+ 24 - 8
lift-business-service/src/main/java/cn/com/ty/lift/business/common/CommonController.java

@@ -3,7 +3,6 @@ package cn.com.ty.lift.business.common;
 import cn.com.ty.lift.business.framework.conf.SystemConfiguration;
 import cn.com.ty.lift.business.framework.util.MessageUtils;
 import cn.com.ty.lift.business.library.dao.entity.LiftBrand;
-import cn.com.ty.lift.common.aliservice.aliyunoss.AliyunOSS;
 import cn.com.ty.lift.common.constants.RedisConstants;
 import cn.com.ty.lift.common.model.AreaCode;
 import cn.com.ty.lift.common.utils.StrPool;
@@ -23,7 +22,9 @@ import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * @author bieao
@@ -81,17 +82,33 @@ public class CommonController {
     public RestResponse uploads(@RequestParam("files") MultipartFile[] files){
         Verify.notTrue(null == files || files.length == 0,Verify.Upload.fileDataMissing);
         try {
-            List<String> urls = new ArrayList<>();
+            Map<String, MultipartFile> fileMap = new HashMap<>();
+            //1 先解析文件格式
             for (MultipartFile file : files) {
                 String fileName = handleFile(file);
                 if(StrUtil.isEmpty(fileName)){
                     return RestResponse.fail(Verify.Upload.fileFormatNotSupport);
                 }
-                AliyunOSS aliyunOSS = systemConfiguration.build();
-                String url = aliyunOSS.putObject(fileName, file.getBytes());
+                fileMap.put(fileName, file);
+            }
+            //2 批量上传
+            List<String> urls = new ArrayList<>();
+            List<String> success = new ArrayList<>();
+            for (Map.Entry<String, MultipartFile> entry : fileMap.entrySet()){
+                String url = systemConfiguration.build().putObject(entry.getKey(), entry.getValue().getBytes());
                 log.info("上传文件,文件URL: {}",url);
-                Verify.notNull(url);
-                urls.add(url);
+                if(null == url){
+                    // 删除已经成功上传的文件
+                    if(!success.isEmpty()){
+                        for (String filename : success) {
+                            systemConfiguration.build().deleteObject(filename);
+                        }
+                    }
+                    return RestResponse.fail(Verify.Upload.fileUploadFail);
+                }else{
+                    success.add(entry.getKey());
+                    urls.add(url);
+                }
             }
             return RestResponse.success(urls);
         }catch (Exception e){
@@ -114,8 +131,7 @@ public class CommonController {
             if(StrUtil.isEmpty(fileName)){
                 return RestResponse.fail(Verify.Upload.fileFormatNotSupport);
             }
-            AliyunOSS aliyunOSS = systemConfiguration.build();
-            String url = aliyunOSS.putObject(fileName, file.getBytes());
+            String url = systemConfiguration.build().putObject(fileName, file.getBytes());
             log.info("上传文件,文件URL: {}",url);
             return RestResponse.success(url);
         }catch (Exception e){

+ 13 - 15
lift-business-service/src/main/java/cn/com/ty/lift/business/framework/aspect/VerifyMethodInterceptor.java

@@ -1,8 +1,8 @@
 package cn.com.ty.lift.business.framework.aspect;
 
 import cn.com.ty.lift.common.verify.Ver;
-import cn.com.ty.lift.common.verify.Verification;
 import cn.com.ty.lift.common.verify.Verifier;
+import cn.com.ty.lift.common.verify.VerifyProcessor;
 import org.aopalliance.intercept.MethodInterceptor;
 import org.aopalliance.intercept.MethodInvocation;
 
@@ -10,41 +10,39 @@ import java.lang.reflect.Method;
 import java.lang.reflect.Parameter;
 
 /**
- * the {@link MethodInterceptor} to verify the parameters
+ * the {@link MethodInterceptor} for verify parameter.
  *
  * @author wcz
- * @since 2020/2/25
+ * @since 2020/3/15
  */
 public class VerifyMethodInterceptor implements MethodInterceptor {
     @Override
     public Object invoke(MethodInvocation invocation) throws Throwable {
-        //get the method
-        Method method = invocation.getMethod();
         //check whether the method is present with verifier annotation.
-        if (!method.isAnnotationPresent(Verifier.class)) {
+        Method method = invocation.getMethod();
+        boolean annotationPresent = method.isAnnotationPresent(Verifier.class);
+        if(!annotationPresent){
             return invocation.proceed();
         }
-
-        Object[] arguments = invocation.getArguments();
-        //just return if there is not any argument.
-        if (arguments.length == 0) {
+        //check the list of parameters.
+        Parameter[] parameters = method.getParameters();
+        if(null == parameters || parameters.length == 0){
             return invocation.proceed();
         }
+        //if the parameter is present with Ver. return the index.
         Object object = null;
-        //by default, verify the first arg present with Ver,
-        Parameter[] parameters = method.getParameters();
+        Object[] arguments = invocation.getArguments();
         for (int i = 0; i < parameters.length; i++) {
             if(parameters[i].isAnnotationPresent(Ver.class)){
                 object = arguments[i];
                 break;
             }
         }
-        if (null == object) {
+        if(null == object){
             return invocation.proceed();
         }
-        //get the verifier
         Verifier verifier = method.getDeclaredAnnotation(Verifier.class);
-        Verification.getInstance().action(object, verifier.fields());
+        VerifyProcessor.perform(object, verifier.fields());
         return invocation.proceed();
     }
 }

+ 0 - 6
lift-common/pom.xml

@@ -103,12 +103,6 @@
             <!--<artifactId>hibernate-validator</artifactId>-->
             <!--<version>6.0.16.Final</version>-->
         <!--</dependency>-->
-        <!-- https://mvnrepository.com/artifact/com.innowhere/relproxy -->
-        <!--<dependency>-->
-            <!--<groupId>com.innowhere</groupId>-->
-            <!--<artifactId>relproxy</artifactId>-->
-            <!--<version>0.8.6</version>-->
-        <!--</dependency>-->
 
     </dependencies>
 

+ 8 - 42
lift-common/src/main/java/cn.com.ty.lift.common/aliservice/aliyunoss/AliyunOSS.java

@@ -33,12 +33,14 @@ public class AliyunOSS {
     //OSSClient实例
     private OSS ossClient;
 
+    private static class Builder{
+        private static OSSClientBuilder ossClientBuilder = new OSSClientBuilder();
+    }
     /**
      * 无参构造,初始化oss
      */
     private AliyunOSS() {
-        hint("Default");
-        init();
+        init("Default");
     }
     /**
      * 全参构造方法
@@ -53,20 +55,16 @@ public class AliyunOSS {
         this.accessKeyId = accessKeyId;
         this.accessKeySecret = accessKeySecret;
         this.bucketName = bucketName;
-        hint("Custom");
-        init();
-    }
-
-    private void hint(String type){
-        log.info("Hint: Using the {} Configuration To Create Aliyun OSS Client.",type);
+        init("Custom");
     }
 
     /**
      * 初始化,创建OSSClient实例
      */
-    private void init() {
+    private void init(String type) {
+        log.info("Hint: Using the {} Configuration To Create Aliyun OSS Client.",type);
         if (null == ossClient) {
-            ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
+            ossClient = Builder.ossClientBuilder.build(endpoint, accessKeyId, accessKeySecret);
         }
     }
 
@@ -151,38 +149,6 @@ public class AliyunOSS {
             destroy();
         }
     }
-
-    /**
-     * 批量上传文件到oss,返回 key:objectName ,value:url
-     *
-     * @param bucketName
-     * @param ossEntities
-     * @return
-     */
-    public Map<String, String> putObjects(String bucketName, List<OssEntity> ossEntities) {
-        try {
-            if (IterUtil.isEmpty(ossEntities)) {
-                return null;
-            }
-            Map<String, String> urls = new HashMap<>();
-            ossEntities.forEach(entity -> {
-                // 上传内容到指定的存储空间(bucketName)并保存为指定的文件名称(objectName)。
-                String objectName = entity.getObjectName();
-                ossClient.putObject(bucketName, objectName, new ByteArrayInputStream(entity.getContent()));
-                String url = getObjectUrl(bucketName, objectName);
-                log.info("objectName: {}, url: {}", objectName, url);
-                urls.put(objectName, url);
-            });
-            return urls;
-        } catch (Exception e) {
-            log.error("上传文件异常: {}", e);
-            return null;
-        } finally {
-            destroy();
-        }
-    }
-
-
     public String putObject(String objectName, byte[] content) {
         if (StrUtil.isEmpty(objectName)) {
             return null;

+ 0 - 23
lift-common/src/main/java/cn.com.ty.lift.common/aliservice/aliyunoss/OssEntity.java

@@ -1,23 +0,0 @@
-package cn.com.ty.lift.common.aliservice.aliyunoss;
-
-import lombok.Data;
-
-/**
- * <p>
- *     封装上传数据
- * </p>
- * @author wcz
- * @since  2020/1/14 17:17
- */
-@Data
-public class OssEntity {
-
-    /**
-     * 对象名
-     */
-    private String objectName;
-    /**
-     * 对象数据字节数组
-     */
-    private byte[] content;
-}

+ 82 - 75
lift-common/src/main/java/cn.com.ty.lift.common/sql/SqlIllegalInterceptor.java

@@ -70,18 +70,21 @@ public class SqlIllegalInterceptor implements Interceptor {
     /**
      * cache the legal sql result.
      */
-    private final Set<String>                   legalSqlCacheSet  = new HashSet<>();
+    private final Set<String> legalSqlCacheSet  = new HashSet<>();
     /**
      * cache the index info exist on the column.
      */
-    private final Set<String>                   indexInfoCacheSet = new CopyOnWriteArraySet<>();
+    private static final Set<String> indexInfoCacheSet = new CopyOnWriteArraySet<>();
     /**
      * cache the table had load index info from the connection.
      */
-    private final Set<String>                   tableCacheSet     = new HashSet<>();
+    private static final Set<String> tableCacheSet     = new HashSet<>();
     @Getter
     @Setter
-    private       boolean                       devMode           = true;
+    private       boolean     devMode           = true;
+    @Getter
+    @Setter
+    private       boolean     sqlWrite          = false;
     @Override
     public Object intercept(Invocation invocation) throws Throwable {
         StatementHandler statementHandler = SqlUtils.realTarget(invocation.getTarget());
@@ -93,7 +96,7 @@ public class SqlIllegalInterceptor implements Interceptor {
         }
         String originalSql = statementHandler.getBoundSql().getSql();
         log.info("Verifying SQL ID: {}", mappedStatement.getId());
-        if (!devMode) {
+        if (sqlWrite) {
             log.info("Verifying SQL:");
             log.info(originalSql);
         }
@@ -142,15 +145,19 @@ public class SqlIllegalInterceptor implements Interceptor {
     @Override
     public void setProperties(Properties prop) {
         String devMode = prop.getProperty("devMode");
+        String sqlWrite = prop.getProperty("sqlWrite");
         if (SqlUtils.isBoolean(devMode)) {
             this.devMode = Boolean.valueOf(devMode);
         }
+        if (SqlUtils.isBoolean(devMode)) {
+            this.sqlWrite = Boolean.valueOf(sqlWrite);
+        }
     }
 
     /**
      * the rules of illegal sql.
      */
-    private class IllegalRule {
+    private static class IllegalRule {
         // the list of where exp parse from the sql to verify.
         private List<Expression> wheres         = new ArrayList<>();
         // the list of index info parse from the sql to verify.
@@ -294,51 +301,52 @@ public class SqlIllegalInterceptor implements Interceptor {
          * @param indexInfo include catalog & schema & tableName & columnName to Specify a unique index.
          */
         private int columnNoUseIndex(IndexInfo indexInfo) {
-            String indexCache = indexInfo.fullyQualifiedColumn();
+            String fullyQualifiedColumn = indexInfo.fullyQualifiedColumn();
             //if the column has set. and the cache contains the column.
-            if (indexInfo.fullyColumn() && indexInfoCacheSet.contains(indexCache)) {
+            if (indexInfo.fullyColumn() && indexInfoCacheSet.contains(fullyQualifiedColumn)) {
                 return 1;
             }
             //if the table has set. and the cache do not contains the table.
-            String tableCache = indexInfo.fullyQualifiedTable();
+            String fullyQualifiedTable = indexInfo.fullyQualifiedTable();
             // if new create index on the column. must to reload index,
-            if (indexInfo.fullyTable() && !tableCacheSet.contains(tableCache)) {
-                //get index info from the connection.
-                try (ResultSet resultSet = databaseMetaData.getIndexInfo(indexInfo.catalog, indexInfo.schema, indexInfo.tableName, false, true)){
-                    int indexCount = 0;
-                    while (resultSet.next()) {
-                        //索引中的列序列号等于1,才有效, index: 8, label: ORDINAL_POSITION
-                        if (resultSet.getShort("ORDINAL_POSITION") == 1) {
-                            //在索引中的列名列 index:9, label: COLUMN_NAME
-                            IndexInfo index = IndexInfo.newInstance();
-                            //TABLE_CAT
-                            index.setCatalog(indexInfo.catalog);
-                            //TABLE_SCHEM
-                            index.setSchema(indexInfo.schema);
-                            //TABLE_NAME
-                            index.setTableName(indexInfo.tableName);
-                            //COLUMN_NAME
-                            index.setColumnName(resultSet.getString("COLUMN_NAME"));
-                            indexInfoCacheSet.add(index.fullyQualifiedColumn());
-                            indexCount++;
-                            //cache table, no reload index every time.
-                            tableCacheSet.add(index.fullyQualifiedTable());
-                        }
-                    }
-                    if (indexCount > 6) {
-                        addMessage("Too many indexes (%s > 6) use on table (%s).", indexCount, tableCache);
+            if (indexInfo.fullyTable() && tableCacheSet.contains(fullyQualifiedTable)) {
+                addMessage("Index not use on %s. Example sql: CREATE [UNIQUE|CLUSTERED] INDEX idx_%s ON %s(%s)", fullyQualifiedColumn, indexInfo.columnName, indexInfo.tableName, indexInfo.columnName);
+                return 0;
+            }
+            //get index info from the connection.
+            try (ResultSet resultSet = databaseMetaData.getIndexInfo(indexInfo.catalog, indexInfo.schema, indexInfo.tableName, false, true)) {
+                int indexCount = 0;
+                while (resultSet.next()) {
+                    //索引中的列序列号等于1,才有效, index: 8, label: ORDINAL_POSITION
+                    if (resultSet.getShort("ORDINAL_POSITION") == 1) {
+                        //在索引中的列名列 index:9, label: COLUMN_NAME
+                        IndexInfo index = IndexInfo.newInstance();
+                        //TABLE_CAT
+                        index.setCatalog(indexInfo.catalog);
+                        //TABLE_SCHEM
+                        index.setSchema(indexInfo.schema);
+                        //TABLE_NAME
+                        index.setTableName(indexInfo.tableName);
+                        //COLUMN_NAME
+                        index.setColumnName(resultSet.getString("COLUMN_NAME"));
+                        indexInfoCacheSet.add(index.fullyQualifiedColumn());
+                        indexCount++;
+                        //cache table, no reload index every time.
+                        tableCacheSet.add(index.fullyQualifiedTable());
                     }
-                    log.info("Cache index: {}, table: {}", indexInfoCacheSet.size(), tableCacheSet.size());
-                } catch (SQLException e) {
-                    log.error("get index info from DatabaseMetaData fail.");
                 }
+                if (indexCount > 6) {
+                    addMessage("Too many indexes (%s > 6) use on table (%s).", indexCount, fullyQualifiedTable);
+                }
+                log.info("Cache index: {}, table: {}", indexInfoCacheSet.size(), tableCacheSet.size());
+            } catch (SQLException e) {
+                log.error("get index info from DatabaseMetaData fail.");
             }
-            boolean useIndex = indexInfoCacheSet.contains(indexCache);
-            if (!useIndex) {
-                addMessage("Index not use on %s. Example sql: CREATE [UNIQUE|CLUSTERED] INDEX idx_%s ON %s(%s)", indexCache, indexInfo.columnName, indexInfo.tableName, indexInfo.columnName);
-                return 0;
+            if (indexInfo.fullyColumn() && indexInfoCacheSet.contains(fullyQualifiedColumn)) {
+                return 1;
             }
-            return 1;
+            addMessage("Index not use on %s. Example sql: CREATE [UNIQUE|CLUSTERED] INDEX idx_%s ON %s(%s)", fullyQualifiedColumn, indexInfo.columnName, indexInfo.tableName, indexInfo.columnName);
+            return 0;
         }
 
         /**
@@ -647,6 +655,33 @@ public class SqlIllegalInterceptor implements Interceptor {
                 });
             }
         }
+        private boolean isSelect(Statement statement) {
+            return (statement instanceof Select);
+        }
+
+        private boolean isUpdate(Statement statement) {
+            return (statement instanceof Update);
+        }
+
+        private boolean isDelete(Statement statement) {
+            return (statement instanceof Delete);
+        }
+
+        private boolean isPlainSelect(Object object) {
+            return (object instanceof PlainSelect);
+        }
+
+        private boolean isSubSelect(Object object) {
+            return (object instanceof SubSelect);
+        }
+
+        private boolean isBinary(Expression expression) {
+            return (expression instanceof BinaryExpression);
+        }
+
+        private boolean isColumn(Expression expression) {
+            return (expression instanceof Column);
+        }
     }
 
     @Data
@@ -736,23 +771,23 @@ public class SqlIllegalInterceptor implements Interceptor {
         private String tableName;
         private String columnName;
 
-        public static IndexInfo newInstance(){
+        private static IndexInfo newInstance() {
             return new IndexInfo();
         }
 
-        public boolean fullyColumn() {
+        private boolean fullyColumn() {
             return SqlUtils.notNull(getTableName(), getColumnName());
         }
 
-        public boolean fullyTable() {
+        private boolean fullyTable() {
             return SqlUtils.notNull(getTableName());
         }
 
-        public String fullyQualifiedColumn() {
+        private String fullyQualifiedColumn() {
             return fullyColumn() ? String.format("%s.%s.%s.%s", fixCatalog(), fixSchema(), getTableName(), getColumnName()) : null;
         }
 
-        public String fullyQualifiedTable() {
+        private String fullyQualifiedTable() {
             return fullyTable() ? String.format("%s.%s.%s", fixCatalog(), fixSchema(), getTableName()) : null;
         }
 
@@ -764,32 +799,4 @@ public class SqlIllegalInterceptor implements Interceptor {
             return null == this.schema ? "<schema>" : this.schema;
         }
     }
-
-    private boolean isSelect(Statement statement) {
-        return (statement instanceof Select);
-    }
-
-    private boolean isUpdate(Statement statement) {
-        return (statement instanceof Update);
-    }
-
-    private boolean isDelete(Statement statement) {
-        return (statement instanceof Delete);
-    }
-
-    private boolean isPlainSelect(Object object) {
-        return (object instanceof PlainSelect);
-    }
-
-    private boolean isSubSelect(Object object) {
-        return (object instanceof SubSelect);
-    }
-
-    private boolean isBinary(Expression expression) {
-        return (expression instanceof BinaryExpression);
-    }
-
-    private boolean isColumn(Expression expression) {
-        return (expression instanceof Column);
-    }
 }

File diff suppressed because it is too large
+ 143 - 158
lift-common/src/main/java/cn.com.ty.lift.common/verify/Verification.java


+ 0 - 1
lift-enterprise-service/src/main/java/cn/com/ty/lift/enterprise/config/SystemConfiguration.java

@@ -4,7 +4,6 @@ import cn.com.ty.lift.common.aliservice.aliyunoss.AliyunOSS;
 import cn.com.ty.lift.common.export.ExportUtils;
 import cn.com.ty.lift.common.sql.SqlAnalysisInterceptor;
 import cn.com.ty.lift.common.verify.Verifier;
-import cn.com.ty.lift.enterprise.common.VerifyMethodInterceptor;
 import cn.hutool.core.date.DatePattern;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.extension.plugins.PerformanceInterceptor;

+ 14 - 16
lift-enterprise-service/src/main/java/cn/com/ty/lift/enterprise/common/VerifyMethodInterceptor.java

@@ -1,8 +1,8 @@
-package cn.com.ty.lift.enterprise.common;
+package cn.com.ty.lift.enterprise.config;
 
 import cn.com.ty.lift.common.verify.Ver;
-import cn.com.ty.lift.common.verify.Verification;
 import cn.com.ty.lift.common.verify.Verifier;
+import cn.com.ty.lift.common.verify.VerifyProcessor;
 import org.aopalliance.intercept.MethodInterceptor;
 import org.aopalliance.intercept.MethodInvocation;
 
@@ -10,41 +10,39 @@ import java.lang.reflect.Method;
 import java.lang.reflect.Parameter;
 
 /**
- * the {@link MethodInterceptor} to verify the parameters
+ * the {@link MethodInterceptor} for verify parameter.
  *
  * @author wcz
- * @since 2020/2/25
+ * @since 2020/3/15
  */
 public class VerifyMethodInterceptor implements MethodInterceptor {
     @Override
     public Object invoke(MethodInvocation invocation) throws Throwable {
-        //get the method
-        Method method = invocation.getMethod();
         //check whether the method is present with verifier annotation.
-        if (!method.isAnnotationPresent(Verifier.class)) {
+        Method method = invocation.getMethod();
+        boolean annotationPresent = method.isAnnotationPresent(Verifier.class);
+        if(!annotationPresent){
             return invocation.proceed();
         }
-
-        Object[] arguments = invocation.getArguments();
-        //just return if there is not any argument.
-        if (arguments.length == 0) {
+        //check the list of parameters.
+        Parameter[] parameters = method.getParameters();
+        if(null == parameters || parameters.length == 0){
             return invocation.proceed();
         }
+        //if the parameter is present with Ver. return the index.
         Object object = null;
-        //by default, verify the first arg present with Ver,
-        Parameter[] parameters = method.getParameters();
+        Object[] arguments = invocation.getArguments();
         for (int i = 0; i < parameters.length; i++) {
             if(parameters[i].isAnnotationPresent(Ver.class)){
                 object = arguments[i];
                 break;
             }
         }
-        if (null == object) {
+        if(null == object){
             return invocation.proceed();
         }
-        //get the verifier
         Verifier verifier = method.getDeclaredAnnotation(Verifier.class);
-        Verification.getInstance().action(object, verifier.fields());
+        VerifyProcessor.perform(object, verifier.fields());
         return invocation.proceed();
     }
 }

+ 3 - 1
lift-enterprise-service/src/main/java/cn/com/ty/lift/enterprise/oa/controller/AnnouncementController.java

@@ -21,6 +21,7 @@ import org.springframework.web.bind.annotation.RestController;
 import javax.validation.Valid;
 import java.time.LocalDateTime;
 import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
 
 
@@ -71,8 +72,9 @@ public class AnnouncementController {
         if(records.size() > 0){
             List<Long> idList = records.stream().map(Announcement::getId).collect(Collectors.toList());
             List<AnnouncementImg> imgList = announcementImgService.listByAnnouncementIds(idList);
+            Map<Long, List<AnnouncementImg>> listMap = imgList.stream().collect(Collectors.groupingBy(AnnouncementImg::getAnnouncementId));
             for (AnnouncementResponse record : records) {
-                record.setImgs(imgList.stream().filter(img -> img.getAnnouncementId().equals(record.getId())).collect(Collectors.toList()));
+                record.setImgs(listMap.get(record.getId()));
             }
         }
         return RestResponse.success(CountPage.getCountPage(count, pages));

+ 3 - 2
lift-enterprise-service/src/main/java/cn/com/ty/lift/enterprise/oa/entity/Announcement.java

@@ -9,6 +9,7 @@ import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
 
 import javax.validation.constraints.Min;
+import javax.validation.constraints.NotEmpty;
 import javax.validation.constraints.NotNull;
 import java.time.LocalDateTime;
 import java.util.List;
@@ -41,13 +42,13 @@ public class Announcement extends BaseEntity {
     /**
      * 标题
      */
-    @NotNull(message = "公告标题不能为空")
+    @NotEmpty(message = "公告标题不能为空")
     private String title;
 
     /**
      * 内容
      */
-    @NotNull(message = "公告内容不能为空")
+    @NotEmpty(message = "公告内容不能为空")
     private String content;
 
     /**

+ 3 - 2
lift-enterprise-service/src/main/java/cn/com/ty/lift/enterprise/oa/entity/Attendance.java

@@ -7,6 +7,7 @@ import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
 
 import javax.validation.constraints.Min;
+import javax.validation.constraints.NotEmpty;
 import javax.validation.constraints.NotNull;
 import javax.validation.constraints.Size;
 
@@ -45,7 +46,7 @@ public class Attendance extends BaseEntity {
     /**
      * 经纬度
      */
-    @NotNull(message = "经纬度不能为空")
+    @NotEmpty(message = "经纬度不能为空")
     private String coordinate;
 
     /**
@@ -56,7 +57,7 @@ public class Attendance extends BaseEntity {
     /**
      * 地址
      */
-    @NotNull(message = "地址不能为空")
+    @NotEmpty(message = "地址不能为空")
     private String address;
 
     /**

+ 2 - 0
lift-enterprise-service/src/main/java/cn/com/ty/lift/enterprise/oa/entity/LiftCertificate.java

@@ -70,11 +70,13 @@ public class LiftCertificate extends BaseEntity {
     /**
      * 第一张图片路径
      */
+    @NotEmpty(message = "缺少操作证正反面图片")
     private String firstImgUrl;
 
     /**
      * 第二张图片路径
      */
+    @NotEmpty(message = "缺少操作证正反面图片")
     private String secondImgUrl;
 
     /**

+ 2 - 1
lift-enterprise-service/src/main/java/cn/com/ty/lift/enterprise/oa/service/AnnouncementImgService.java

@@ -27,7 +27,8 @@ public class AnnouncementImgService extends ServiceImpl<AnnouncementImgMapper, A
      */
     public List<AnnouncementImg> listByAnnouncement(Long announcementId){
         LambdaQueryWrapper<AnnouncementImg> lambdaQueryWrapper = Wrappers.lambdaQuery();
-        lambdaQueryWrapper.eq(AnnouncementImg::getAnnouncementId,announcementId);
+        lambdaQueryWrapper.eq(AnnouncementImg::getAnnouncementId, announcementId);
+        lambdaQueryWrapper.orderByAsc(AnnouncementImg::getSort);
         return list(lambdaQueryWrapper);
     }
 

+ 13 - 15
lift-quan-service/src/main/java/cn/com/ty/lift/quan/config/VerifyMethodInterceptor.java

@@ -1,8 +1,8 @@
 package cn.com.ty.lift.quan.config;
 
 import cn.com.ty.lift.common.verify.Ver;
-import cn.com.ty.lift.common.verify.Verification;
 import cn.com.ty.lift.common.verify.Verifier;
+import cn.com.ty.lift.common.verify.VerifyProcessor;
 import org.aopalliance.intercept.MethodInterceptor;
 import org.aopalliance.intercept.MethodInvocation;
 
@@ -10,41 +10,39 @@ import java.lang.reflect.Method;
 import java.lang.reflect.Parameter;
 
 /**
- * the {@link MethodInterceptor} to verify the parameters
+ * the {@link MethodInterceptor} for verify parameter.
  *
  * @author wcz
- * @since 2020/2/25
+ * @since 2020/3/15
  */
 public class VerifyMethodInterceptor implements MethodInterceptor {
     @Override
     public Object invoke(MethodInvocation invocation) throws Throwable {
-        //get the method
-        Method method = invocation.getMethod();
         //check whether the method is present with verifier annotation.
-        if (!method.isAnnotationPresent(Verifier.class)) {
+        Method method = invocation.getMethod();
+        boolean annotationPresent = method.isAnnotationPresent(Verifier.class);
+        if(!annotationPresent){
             return invocation.proceed();
         }
-
-        Object[] arguments = invocation.getArguments();
-        //just return if there is not any argument.
-        if (arguments.length == 0) {
+        //check the list of parameters.
+        Parameter[] parameters = method.getParameters();
+        if(null == parameters || parameters.length == 0){
             return invocation.proceed();
         }
+        //if the parameter is present with Ver. return the index.
         Object object = null;
-        //by default, verify the first arg present with Ver
-        Parameter[] parameters = method.getParameters();
+        Object[] arguments = invocation.getArguments();
         for (int i = 0; i < parameters.length; i++) {
             if(parameters[i].isAnnotationPresent(Ver.class)){
                 object = arguments[i];
                 break;
             }
         }
-        if (null == object) {
+        if(null == object){
             return invocation.proceed();
         }
-        //get the verifier
         Verifier verifier = method.getDeclaredAnnotation(Verifier.class);
-        Verification.getInstance().action(object, verifier.fields());
+        VerifyProcessor.perform(object, verifier.fields());
         return invocation.proceed();
     }
 }

+ 13 - 15
lift-system-service/src/main/java/cn/com/ty/lift/system/config/VerifyMethodInterceptor.java

@@ -1,8 +1,8 @@
 package cn.com.ty.lift.system.config;
 
 import cn.com.ty.lift.common.verify.Ver;
-import cn.com.ty.lift.common.verify.Verification;
 import cn.com.ty.lift.common.verify.Verifier;
+import cn.com.ty.lift.common.verify.VerifyProcessor;
 import org.aopalliance.intercept.MethodInterceptor;
 import org.aopalliance.intercept.MethodInvocation;
 
@@ -10,41 +10,39 @@ import java.lang.reflect.Method;
 import java.lang.reflect.Parameter;
 
 /**
- * the {@link MethodInterceptor} to verify the parameters
+ * the {@link MethodInterceptor} for verify parameter.
  *
  * @author wcz
- * @since 2020/2/25
+ * @since 2020/3/15
  */
 public class VerifyMethodInterceptor implements MethodInterceptor {
     @Override
     public Object invoke(MethodInvocation invocation) throws Throwable {
-        //get the method
-        Method method = invocation.getMethod();
         //check whether the method is present with verifier annotation.
-        if (!method.isAnnotationPresent(Verifier.class)) {
+        Method method = invocation.getMethod();
+        boolean annotationPresent = method.isAnnotationPresent(Verifier.class);
+        if(!annotationPresent){
             return invocation.proceed();
         }
-
-        Object[] arguments = invocation.getArguments();
-        //just return if there is not any argument.
-        if (arguments.length == 0) {
+        //check the list of parameters.
+        Parameter[] parameters = method.getParameters();
+        if(null == parameters || parameters.length == 0){
             return invocation.proceed();
         }
+        //if the parameter is present with Ver. return the index.
         Object object = null;
-        //by default, verify the first arg present with Ver
-        Parameter[] parameters = method.getParameters();
+        Object[] arguments = invocation.getArguments();
         for (int i = 0; i < parameters.length; i++) {
             if(parameters[i].isAnnotationPresent(Ver.class)){
                 object = arguments[i];
                 break;
             }
         }
-        if (null == object) {
+        if(null == object){
             return invocation.proceed();
         }
-        //get the verifier
         Verifier verifier = method.getDeclaredAnnotation(Verifier.class);
-        Verification.getInstance().action(object, verifier.fields());
+        VerifyProcessor.perform(object, verifier.fields());
         return invocation.proceed();
     }
 }