Răsfoiți Sursa

全局修改errcode

wangliang 1 an în urmă
părinte
comite
76124d1ff1
35 a modificat fișierele cu 85 adăugiri și 87 ștergeri
  1. 1 1
      sop-api/src/main/java/com/qmth/sop/server/api/SysController.java
  2. 1 1
      sop-api/src/main/java/com/qmth/sop/server/aspect/SopServerApiControllerAspect.java
  3. 3 3
      sop-business/src/main/java/com/qmth/sop/business/activiti/service/impl/ActivitiServiceImpl.java
  4. 1 1
      sop-business/src/main/java/com/qmth/sop/business/aspect/LogAspect.java
  5. 2 4
      sop-business/src/main/java/com/qmth/sop/business/service/impl/SysCustomAddrServiceImpl.java
  6. 1 1
      sop-business/src/main/java/com/qmth/sop/business/service/impl/SysCustomServiceImpl.java
  7. 2 4
      sop-business/src/main/java/com/qmth/sop/business/service/impl/SysDeviceBrandServiceImpl.java
  8. 2 4
      sop-business/src/main/java/com/qmth/sop/business/service/impl/SysDeviceModelServiceImpl.java
  9. 1 1
      sop-business/src/main/java/com/qmth/sop/business/service/impl/SysDeviceServiceImpl.java
  10. 1 4
      sop-business/src/main/java/com/qmth/sop/business/service/impl/SysDingDateServiceImpl.java
  11. 1 1
      sop-business/src/main/java/com/qmth/sop/business/service/impl/SysNoticeServiceImpl.java
  12. 1 1
      sop-business/src/main/java/com/qmth/sop/business/service/impl/SysOrgServiceImpl.java
  13. 1 1
      sop-business/src/main/java/com/qmth/sop/business/service/impl/SysRoleServiceImpl.java
  14. 1 1
      sop-business/src/main/java/com/qmth/sop/business/service/impl/SysUserServiceImpl.java
  15. 1 1
      sop-business/src/main/java/com/qmth/sop/business/service/impl/TBCrmServiceImpl.java
  16. 3 7
      sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDelayWarnDetailServiceImpl.java
  17. 1 1
      sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDelayWarnServiceImpl.java
  18. 2 2
      sop-business/src/main/java/com/qmth/sop/business/service/impl/TBTaskServiceImpl.java
  19. 1 1
      sop-business/src/main/java/com/qmth/sop/business/service/impl/TBViolationDetailServiceImpl.java
  20. 1 2
      sop-business/src/main/java/com/qmth/sop/business/service/impl/TBViolationServiceImpl.java
  21. 1 1
      sop-business/src/main/java/com/qmth/sop/business/service/impl/TDFormWidgetMetadataServiceImpl.java
  22. 12 32
      sop-business/src/main/java/com/qmth/sop/business/service/impl/TWxappInfoServiceImpl.java
  23. 1 2
      sop-business/src/main/java/com/qmth/sop/business/templete/execute/AsyncDingAttendanceExportService.java
  24. 1 1
      sop-business/src/main/java/com/qmth/sop/business/templete/execute/AsyncDingCountExportService.java
  25. 1 1
      sop-business/src/main/java/com/qmth/sop/business/templete/execute/AsyncDingSubmitExportService.java
  26. 1 1
      sop-business/src/main/java/com/qmth/sop/business/templete/execute/AsyncSysCustomImportService.java
  27. 1 2
      sop-business/src/main/java/com/qmth/sop/business/templete/execute/AsyncSysDeviceImportService.java
  28. 1 1
      sop-business/src/main/java/com/qmth/sop/business/templete/execute/AsyncSysMessageExportService.java
  29. 1 1
      sop-business/src/main/java/com/qmth/sop/business/templete/execute/AsyncUserArchivesExportService.java
  30. 1 1
      sop-business/src/main/java/com/qmth/sop/business/templete/execute/AsyncUserArchivesImportService.java
  31. 1 1
      sop-business/src/main/java/com/qmth/sop/business/templete/export/AsyncExportTaskTemplete.java
  32. 1 1
      sop-business/src/main/java/com/qmth/sop/business/templete/importData/AsyncImportTaskTemplete.java
  33. 2 0
      sop-common/src/main/java/com/qmth/sop/common/enums/ExceptionResultEnum.java
  34. 14 0
      sop-common/src/main/java/com/qmth/sop/common/util/ResultUtil.java
  35. 18 0
      sop-common/src/main/java/com/qmth/sop/common/util/ShaUtils.java

+ 1 - 1
sop-api/src/main/java/com/qmth/sop/server/api/SysController.java

@@ -170,7 +170,7 @@ public class SysController {
             log.error(SystemConstant.LOG_ERROR, e);
             basicAttachmentService.deleteAttachment(basicAttachment);
             if (e instanceof ApiException) {
-                ResultUtil.error((ApiException) e, e.getMessage());
+                ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
             } else {
                 ResultUtil.error(e.getMessage());
             }

+ 1 - 1
sop-api/src/main/java/com/qmth/sop/server/aspect/SopServerApiControllerAspect.java

@@ -75,7 +75,7 @@ public class SopServerApiControllerAspect {
         } catch (Exception e) {
             log.error(SystemConstant.LOG_ERROR, e);
             if (e instanceof ApiException) {
-                return ResultUtil.error((ApiException) e, e.getMessage());
+                return ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
             } else {
                 return ResultUtil.error(e.getMessage());
             }

+ 3 - 3
sop-business/src/main/java/com/qmth/sop/business/activiti/service/impl/ActivitiServiceImpl.java

@@ -398,7 +398,7 @@ public class ActivitiServiceImpl implements ActivitiService {
         } catch (Exception e) {
             log.error(SystemConstant.LOG_ERROR, e);
             if (e instanceof ApiException) {
-                ResultUtil.error((ApiException) e, e.getMessage());
+                ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
             } else {
                 ResultUtil.error(e.getMessage());
             }
@@ -613,7 +613,7 @@ public class ActivitiServiceImpl implements ActivitiService {
         } catch (Exception e) {
             log.error(SystemConstant.LOG_ERROR, e);
             if (e instanceof ApiException) {
-                ResultUtil.error((ApiException) e, e.getMessage());
+                ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
             } else {
                 ResultUtil.error(e.getMessage());
             }
@@ -674,7 +674,7 @@ public class ActivitiServiceImpl implements ActivitiService {
         } catch (Exception e) {
             log.error(SystemConstant.LOG_ERROR, e);
             if (e instanceof ApiException) {
-                ResultUtil.error((ApiException) e, e.getMessage());
+                ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
             } else {
                 ResultUtil.error(e.getMessage());
             }

+ 1 - 1
sop-business/src/main/java/com/qmth/sop/business/aspect/LogAspect.java

@@ -85,7 +85,7 @@ public class LogAspect {
             runStatus = "失败";
             log.error(SystemConstant.LOG_ERROR, e);
             if (e instanceof ApiException) {
-                return ResultUtil.error((ApiException) e, e.getMessage());
+                return ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
             } else {
                 return ResultUtil.error(e.getMessage());
             }

+ 2 - 4
sop-business/src/main/java/com/qmth/sop/business/service/impl/SysCustomAddrServiceImpl.java

@@ -7,7 +7,6 @@ import com.qmth.sop.business.entity.SysCustomAddr;
 import com.qmth.sop.business.entity.SysUser;
 import com.qmth.sop.business.mapper.SysCustomAddrMapper;
 import com.qmth.sop.business.service.SysCustomAddrService;
-import com.qmth.sop.common.contant.SystemConstant;
 import com.qmth.sop.common.enums.ExceptionResultEnum;
 import com.qmth.sop.common.enums.FieldUniqueEnum;
 import com.qmth.sop.common.util.ResultUtil;
@@ -15,8 +14,7 @@ import com.qmth.sop.common.util.ServletUtil;
 import org.springframework.dao.DuplicateKeyException;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
-import javax.annotation.Resource;
-import java.util.HashMap;
+
 import java.util.Map;
 import java.util.Objects;
 
@@ -65,7 +63,7 @@ public class SysCustomAddrServiceImpl extends ServiceImpl<SysCustomAddrMapper, S
 				String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length()).replaceAll("'", "");
 				throw ExceptionResultEnum.SQL_ERROR.exception("[" + FieldUniqueEnum.convertToTitle(columnStr) + "]数据不允许重复插入");
 				} else if (e instanceof ApiException) {
-				ResultUtil.error((ApiException) e, e.getMessage());
+                    ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
 				} else {
 				ResultUtil.error(e.getMessage());
 				}

+ 1 - 1
sop-business/src/main/java/com/qmth/sop/business/service/impl/SysCustomServiceImpl.java

@@ -87,7 +87,7 @@ public class SysCustomServiceImpl extends ServiceImpl<SysCustomMapper, SysCustom
                 String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length()).replaceAll("'", "");
                 throw ExceptionResultEnum.SQL_ERROR.exception("[" + FieldUniqueEnum.convertToTitle(columnStr) + "]数据不允许重复插入");
             } else if (e instanceof ApiException) {
-                ResultUtil.error((ApiException) e, e.getMessage());
+                ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
             } else {
                 ResultUtil.error(e.getMessage());
             }

+ 2 - 4
sop-business/src/main/java/com/qmth/sop/business/service/impl/SysDeviceBrandServiceImpl.java

@@ -7,7 +7,6 @@ import com.qmth.sop.business.entity.SysDeviceBrand;
 import com.qmth.sop.business.entity.SysUser;
 import com.qmth.sop.business.mapper.SysDeviceBrandMapper;
 import com.qmth.sop.business.service.SysDeviceBrandService;
-import com.qmth.sop.common.contant.SystemConstant;
 import com.qmth.sop.common.enums.ExceptionResultEnum;
 import com.qmth.sop.common.enums.FieldUniqueEnum;
 import com.qmth.sop.common.util.ResultUtil;
@@ -15,8 +14,7 @@ import com.qmth.sop.common.util.ServletUtil;
 import org.springframework.dao.DuplicateKeyException;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
-import javax.annotation.Resource;
-import java.util.HashMap;
+
 import java.util.Map;
 import java.util.Objects;
 
@@ -65,7 +63,7 @@ public class SysDeviceBrandServiceImpl extends ServiceImpl<SysDeviceBrandMapper,
 				String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length()).replaceAll("'", "");
 				throw ExceptionResultEnum.SQL_ERROR.exception("[" + FieldUniqueEnum.convertToTitle(columnStr) + "]数据不允许重复插入");
 				} else if (e instanceof ApiException) {
-				ResultUtil.error((ApiException) e, e.getMessage());
+                    ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
 				} else {
 				ResultUtil.error(e.getMessage());
 				}

+ 2 - 4
sop-business/src/main/java/com/qmth/sop/business/service/impl/SysDeviceModelServiceImpl.java

@@ -7,7 +7,6 @@ import com.qmth.sop.business.entity.SysDeviceModel;
 import com.qmth.sop.business.entity.SysUser;
 import com.qmth.sop.business.mapper.SysDeviceModelMapper;
 import com.qmth.sop.business.service.SysDeviceModelService;
-import com.qmth.sop.common.contant.SystemConstant;
 import com.qmth.sop.common.enums.ExceptionResultEnum;
 import com.qmth.sop.common.enums.FieldUniqueEnum;
 import com.qmth.sop.common.util.ResultUtil;
@@ -15,8 +14,7 @@ import com.qmth.sop.common.util.ServletUtil;
 import org.springframework.dao.DuplicateKeyException;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
-import javax.annotation.Resource;
-import java.util.HashMap;
+
 import java.util.Map;
 import java.util.Objects;
 
@@ -65,7 +63,7 @@ public class SysDeviceModelServiceImpl extends ServiceImpl<SysDeviceModelMapper,
 				String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length()).replaceAll("'", "");
 				throw ExceptionResultEnum.SQL_ERROR.exception("[" + FieldUniqueEnum.convertToTitle(columnStr) + "]数据不允许重复插入");
 				} else if (e instanceof ApiException) {
-				ResultUtil.error((ApiException) e, e.getMessage());
+                    ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
 				} else {
 				ResultUtil.error(e.getMessage());
 				}

+ 1 - 1
sop-business/src/main/java/com/qmth/sop/business/service/impl/SysDeviceServiceImpl.java

@@ -72,7 +72,7 @@ public class SysDeviceServiceImpl extends ServiceImpl<SysDeviceMapper, SysDevice
                 String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length()).replaceAll("'", "");
                 throw ExceptionResultEnum.SQL_ERROR.exception("[" + FieldUniqueEnum.convertToTitle(columnStr) + "]数据不允许重复插入");
             } else if (e instanceof ApiException) {
-                ResultUtil.error((ApiException) e, e.getMessage());
+                ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
             } else {
                 ResultUtil.error(e.getMessage());
             }

+ 1 - 4
sop-business/src/main/java/com/qmth/sop/business/service/impl/SysDingDateServiceImpl.java

@@ -8,7 +8,6 @@ import com.qmth.sop.business.entity.SysDingDate;
 import com.qmth.sop.business.entity.SysUser;
 import com.qmth.sop.business.mapper.SysDingDateMapper;
 import com.qmth.sop.business.service.SysDingDateService;
-import com.qmth.sop.common.contant.SystemConstant;
 import com.qmth.sop.common.enums.DingDateTypeEnum;
 import com.qmth.sop.common.enums.ExceptionResultEnum;
 import com.qmth.sop.common.enums.FieldUniqueEnum;
@@ -18,10 +17,8 @@ import org.springframework.dao.DuplicateKeyException;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import javax.annotation.Resource;
 import java.time.DayOfWeek;
 import java.time.LocalDate;
-import java.util.HashMap;
 import java.util.Map;
 import java.util.Objects;
 
@@ -71,7 +68,7 @@ public class SysDingDateServiceImpl extends ServiceImpl<SysDingDateMapper, SysDi
                 String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length()).replaceAll("'", "");
                 throw ExceptionResultEnum.SQL_ERROR.exception("[" + FieldUniqueEnum.convertToTitle(columnStr) + "]数据不允许重复插入");
             } else if (e instanceof ApiException) {
-                ResultUtil.error((ApiException) e, e.getMessage());
+                ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
             } else {
                 ResultUtil.error(e.getMessage());
             }

+ 1 - 1
sop-business/src/main/java/com/qmth/sop/business/service/impl/SysNoticeServiceImpl.java

@@ -84,7 +84,7 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
                 String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length()).replaceAll("'", "");
                 throw ExceptionResultEnum.SQL_ERROR.exception("[" + FieldUniqueEnum.convertToTitle(columnStr) + "]数据不允许重复插入");
             } else if (e instanceof ApiException) {
-                ResultUtil.error((ApiException) e, e.getMessage());
+                ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
             } else {
                 ResultUtil.error(e.getMessage());
             }

+ 1 - 1
sop-business/src/main/java/com/qmth/sop/business/service/impl/SysOrgServiceImpl.java

@@ -134,7 +134,7 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
                 String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length()).replaceAll("'", "");
                 throw ExceptionResultEnum.SQL_ERROR.exception("[" + FieldUniqueEnum.convertToTitle(columnStr) + "]数据不允许重复插入");
             } else if (e instanceof ApiException) {
-                ResultUtil.error((ApiException) e, e.getMessage());
+                ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
             } else {
                 ResultUtil.error(e.getMessage());
             }

+ 1 - 1
sop-business/src/main/java/com/qmth/sop/business/service/impl/SysRoleServiceImpl.java

@@ -128,7 +128,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
                 String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length()).replaceAll("'", "");
                 throw ExceptionResultEnum.SQL_ERROR.exception("[" + FieldUniqueEnum.convertToTitle(columnStr) + "]数据不允许重复插入");
             } else if (e instanceof ApiException) {
-                ResultUtil.error((ApiException) e, e.getMessage());
+                ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
             } else {
                 ResultUtil.error(e.getMessage());
             }

+ 1 - 1
sop-business/src/main/java/com/qmth/sop/business/service/impl/SysUserServiceImpl.java

@@ -345,7 +345,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
                 String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3).replaceAll("'", "");
                 throw ExceptionResultEnum.SQL_ERROR.exception("[" + FieldUniqueEnum.convertToTitle(columnStr) + "]数据不允许重复插入");
             } else if (e instanceof ApiException) {
-                ResultUtil.error((ApiException) e, e.getMessage());
+                ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
             } else {
                 ResultUtil.error(e.getMessage());
             }

+ 1 - 1
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBCrmServiceImpl.java

@@ -196,7 +196,7 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
                 String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length()).replaceAll("'", "");
                 throw ExceptionResultEnum.SQL_ERROR.exception("[" + FieldUniqueEnum.convertToTitle(columnStr) + "]数据不允许重复插入");
             } else if (e instanceof ApiException) {
-                ResultUtil.error((ApiException) e, e.getMessage());
+                ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
             } else {
                 ResultUtil.error(e.getMessage());
             }

+ 3 - 7
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDelayWarnDetailServiceImpl.java

@@ -1,13 +1,11 @@
 package com.qmth.sop.business.service.impl;
 
-import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.boot.api.exception.ApiException;
-import com.qmth.sop.business.entity.TBDelayWarnDetail;
 import com.qmth.sop.business.entity.SysUser;
+import com.qmth.sop.business.entity.TBDelayWarnDetail;
 import com.qmth.sop.business.mapper.TBDelayWarnDetailMapper;
 import com.qmth.sop.business.service.TBDelayWarnDetailService;
-import com.qmth.sop.common.contant.SystemConstant;
 import com.qmth.sop.common.enums.ExceptionResultEnum;
 import com.qmth.sop.common.enums.FieldUniqueEnum;
 import com.qmth.sop.common.util.ResultUtil;
@@ -15,10 +13,8 @@ import com.qmth.sop.common.util.ServletUtil;
 import org.springframework.dao.DuplicateKeyException;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
-import javax.annotation.Resource;
-import java.util.HashMap;
+
 import java.util.List;
-import java.util.Map;
 import java.util.Objects;
 
 /**
@@ -57,7 +53,7 @@ public class TBDelayWarnDetailServiceImpl extends ServiceImpl<TBDelayWarnDetailM
 				String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length()).replaceAll("'", "");
 				throw ExceptionResultEnum.SQL_ERROR.exception("[" + FieldUniqueEnum.convertToTitle(columnStr) + "]数据不允许重复插入");
 				} else if (e instanceof ApiException) {
-				ResultUtil.error((ApiException) e, e.getMessage());
+                    ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
 				} else {
 				ResultUtil.error(e.getMessage());
 				}

+ 1 - 1
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDelayWarnServiceImpl.java

@@ -72,7 +72,7 @@ public class TBDelayWarnServiceImpl extends ServiceImpl<TBDelayWarnMapper, TBDel
                 String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length()).replaceAll("'", "");
                 throw ExceptionResultEnum.SQL_ERROR.exception("[" + FieldUniqueEnum.convertToTitle(columnStr) + "]数据不允许重复插入");
             } else if (e instanceof ApiException) {
-                ResultUtil.error((ApiException) e, e.getMessage());
+                ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
             } else {
                 ResultUtil.error(e.getMessage());
             }

+ 2 - 2
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBTaskServiceImpl.java

@@ -66,7 +66,7 @@ public class TBTaskServiceImpl extends ServiceImpl<TBTaskMapper, TBTask> impleme
             log.error(SystemConstant.LOG_ERROR, e);
             basicAttachmentService.deleteAttachment(basicAttachment);
             if (e instanceof ApiException) {
-                ResultUtil.error((ApiException) e, e.getMessage());
+                ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
             } else {
                 ResultUtil.error(e.getMessage());
             }
@@ -96,7 +96,7 @@ public class TBTaskServiceImpl extends ServiceImpl<TBTaskMapper, TBTask> impleme
         } catch (Exception e) {
             log.error(SystemConstant.LOG_ERROR, e);
             if (e instanceof ApiException) {
-                ResultUtil.error((ApiException) e, e.getMessage());
+                ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
             } else {
                 ResultUtil.error(e.getMessage());
             }

+ 1 - 1
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBViolationDetailServiceImpl.java

@@ -53,7 +53,7 @@ public class TBViolationDetailServiceImpl extends ServiceImpl<TBViolationDetailM
                 String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length()).replaceAll("'", "");
                 throw ExceptionResultEnum.SQL_ERROR.exception("[" + FieldUniqueEnum.convertToTitle(columnStr) + "]数据不允许重复插入");
             } else if (e instanceof ApiException) {
-                ResultUtil.error((ApiException) e, e.getMessage());
+                ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
             } else {
                 ResultUtil.error(e.getMessage());
             }

+ 1 - 2
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBViolationServiceImpl.java

@@ -2,7 +2,6 @@ package com.qmth.sop.business.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.boot.api.exception.ApiException;
 import com.qmth.sop.business.bean.result.TBViolationResult;
@@ -110,7 +109,7 @@ public class TBViolationServiceImpl extends ServiceImpl<TBViolationMapper, TBVio
                 String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length()).replaceAll("'", "");
                 throw ExceptionResultEnum.SQL_ERROR.exception("[" + FieldUniqueEnum.convertToTitle(columnStr) + "]数据不允许重复插入");
             } else if (e instanceof ApiException) {
-                ResultUtil.error((ApiException) e, e.getMessage());
+                ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
             } else {
                 ResultUtil.error(e.getMessage());
             }

+ 1 - 1
sop-business/src/main/java/com/qmth/sop/business/service/impl/TDFormWidgetMetadataServiceImpl.java

@@ -57,7 +57,7 @@ public class TDFormWidgetMetadataServiceImpl extends ServiceImpl<TDFormWidgetMet
         } catch (Exception e) {
             log.error(SystemConstant.LOG_ERROR, e);
             if (e instanceof ApiException) {
-                ResultUtil.error((ApiException) e, e.getMessage());
+                ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
             } else {
                 ResultUtil.error(e.getMessage());
             }

+ 12 - 32
sop-business/src/main/java/com/qmth/sop/business/service/impl/TWxappInfoServiceImpl.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.boot.core.solar.model.WxappAccessToken;
+import com.qmth.boot.core.solar.model.WxappSession;
 import com.qmth.boot.core.solar.service.SolarService;
 import com.qmth.sop.business.bean.result.LoginResult;
 import com.qmth.sop.business.cache.CommonCacheService;
@@ -63,10 +64,11 @@ public class TWxappInfoServiceImpl extends ServiceImpl<TWxappInfoMapper, TWxappI
      */
     @Override
     public LoginResult wxappLogin(String loginCode) throws NoSuchAlgorithmException {
-        JSONObject auth = getAuthorization(loginCode);
-        String openId = ByteUtil.toHexAscii(ShaUtils.sha256(auth.getString(SystemConstant.OPEN_ID)));
+        WxappSession wxappSession = getAuthorization(loginCode);
+        String openId = ByteUtil.toHexAscii(ShaUtils.encode(wxappSession.getOpenId()));
         TWxappInfo tWxappInfo = tWxappInfoService.getOne(new QueryWrapper<TWxappInfo>().lambda().eq(TWxappInfo::getOpenId, openId));
-        Optional.ofNullable(tWxappInfo).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("微信用户未绑定"));
+//        Optional.ofNullable(tWxappInfo).orElseThrow(() -> ParameterExceptions.OPENID_NOT_FOUND);
+        Optional.ofNullable(tWxappInfo).orElseThrow(() -> ExceptionResultEnum.WXAPP_OPENID_NO_DATA.exception());
         List<SysUser> sysUserList = sysUserService.list(new QueryWrapper<SysUser>().lambda().eq(SysUser::getMobileNumber, tWxappInfo.getPhone()));
         if (CollectionUtils.isEmpty(sysUserList)) {
             throw ExceptionResultEnum.ERROR.exception("用户不存在");
@@ -124,8 +126,8 @@ public class TWxappInfoServiceImpl extends ServiceImpl<TWxappInfoMapper, TWxappI
         if (!sysUser.getEnable()) {
             throw ExceptionResultEnum.ERROR.exception("该用户已禁用");
         }
-        JSONObject auth = getAuthorization(loginCode);
-        String openId = ByteUtil.toHexAscii(ShaUtils.sha256(auth.getString(SystemConstant.OPEN_ID)));
+        WxappSession wxappSession = getAuthorization(loginCode);
+        String openId = ByteUtil.toHexAscii(ShaUtils.encode(wxappSession.getOpenId()));
         TWxappInfo tWxappInfo = tWxappInfoService.getOne(new QueryWrapper<TWxappInfo>().lambda().eq(TWxappInfo::getOpenId, openId));
         tWxappInfo = Objects.isNull(tWxappInfo) ? new TWxappInfo(openId, phone) : tWxappInfo;
         tWxappInfoService.saveOrUpdate(tWxappInfo);
@@ -143,9 +145,9 @@ public class TWxappInfoServiceImpl extends ServiceImpl<TWxappInfoMapper, TWxappI
     @Override
     @Transactional
     public LoginResult wxappLoginByEncryptedData(String loginCode, String encryptedData, String iv) throws NoSuchAlgorithmException {
-        JSONObject auth = getAuthorization(loginCode);
-        String openId = ByteUtil.toHexAscii(ShaUtils.sha256(auth.getString(SystemConstant.OPEN_ID)));
-        JSONObject jo = decrypt(encryptedData, iv, auth.getString(SystemConstant.SESSION_KEY));
+        WxappSession wxappSession = getAuthorization(loginCode);
+        String openId = ByteUtil.toHexAscii(ShaUtils.sha256(wxappSession.getOpenId()));
+        JSONObject jo = decrypt(encryptedData, iv, wxappSession.getSessionKey());
         String phone = jo.getString(SystemConstant.PURE_PHONE_NUMBER);
         List<SysUser> sysUserList = sysUserService.list(new QueryWrapper<SysUser>().lambda().eq(SysUser::getMobileNumber, phone));
         if (CollectionUtils.isEmpty(sysUserList)) {
@@ -207,31 +209,9 @@ public class TWxappInfoServiceImpl extends ServiceImpl<TWxappInfoMapper, TWxappI
      * @param loginCode
      * @return
      */
-    private JSONObject getAuthorization(String loginCode) {
+    private WxappSession getAuthorization(String loginCode) {
         SysConfig sysConfigWxappId = commonCacheService.addSysConfigCache(SystemConstant.WXAPP_APP_ID);
         Optional.ofNullable(sysConfigWxappId).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未配置微信小程序appid"));
-
-        SysConfig sysConfigWxappRequestUrl = commonCacheService.addSysConfigCache(SystemConstant.WXAPP_REQUEST_URL);
-        Optional.ofNullable(sysConfigWxappRequestUrl).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未配置微信小程序请求url"));
-
-        WxappAccessToken wxappAccessToken = solarService.getWxappAccessToken(sysConfigWxappId.getConfigValue());
-        Optional.ofNullable(wxappAccessToken).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未查询到微信accessToken"));
-
-        Map<String, Object> params = new HashMap<>();
-        params.put(SystemConstant.APP_ID, sysConfigWxappId.getConfigValue());
-        params.put(SystemConstant.SECRET, wxappAccessToken.getAccessToken());
-        params.put(SystemConstant.JS_CODE, loginCode);
-        params.put(SystemConstant.GRANT_TYPE, SystemConstant.AUTHORIZATION_CODE);
-        String ret = null;
-        try {
-            ret = HttpUtil.get(sysConfigWxappRequestUrl.getConfigValue(), params, null, null);
-        } catch (Exception e) {
-            throw ExceptionResultEnum.ERROR.exception("登录失败");
-        }
-        JSONObject jo = JSONObject.parseObject(ret);
-        if (jo.containsKey(SystemConstant.ERR_CODE)) {
-            throw ExceptionResultEnum.ERROR.exception("登录失败," + jo.getString(SystemConstant.ERR_MSG));
-        }
-        return jo;
+        return solarService.getWxappSessionByCode(sysConfigWxappId.getConfigValue(), loginCode);
     }
 }

+ 1 - 2
sop-business/src/main/java/com/qmth/sop/business/templete/execute/AsyncDingAttendanceExportService.java

@@ -3,7 +3,6 @@ package com.qmth.sop.business.templete.execute;
 import cn.hutool.core.date.DateUtil;
 import com.qmth.boot.api.exception.ApiException;
 import com.qmth.sop.business.bean.result.TBDingAttendanceResult;
-import com.qmth.sop.business.bean.result.TBDingCountQueryResult;
 import com.qmth.sop.business.entity.BasicAttachment;
 import com.qmth.sop.business.entity.TBTask;
 import com.qmth.sop.business.service.TBTaskService;
@@ -67,7 +66,7 @@ public class AsyncDingAttendanceExportService extends AsyncExportTaskTemplete {
             stringJoinerSummary.add(MessageFormat.format("{0}{1}{2}{3}", DateUtil.format(new Date(), SystemConstant.DEFAULT_DATE_PATTERN), EXCEPTION_TITLE, EXCEPTION_DATA, e.getMessage()));
             tbTask.setResult(TaskResultEnum.ERROR);
             if (e instanceof ApiException) {
-                ResultUtil.error((ApiException) e, e.getMessage());
+                ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
             } else {
                 ResultUtil.error(e.getMessage());
             }

+ 1 - 1
sop-business/src/main/java/com/qmth/sop/business/templete/execute/AsyncDingCountExportService.java

@@ -66,7 +66,7 @@ public class AsyncDingCountExportService extends AsyncExportTaskTemplete {
             stringJoinerSummary.add(MessageFormat.format("{0}{1}{2}{3}", DateUtil.format(new Date(), SystemConstant.DEFAULT_DATE_PATTERN), EXCEPTION_TITLE, EXCEPTION_DATA, e.getMessage()));
             tbTask.setResult(TaskResultEnum.ERROR);
             if (e instanceof ApiException) {
-                ResultUtil.error((ApiException) e, e.getMessage());
+                ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
             } else {
                 ResultUtil.error(e.getMessage());
             }

+ 1 - 1
sop-business/src/main/java/com/qmth/sop/business/templete/execute/AsyncDingSubmitExportService.java

@@ -64,7 +64,7 @@ public class AsyncDingSubmitExportService extends AsyncExportTaskTemplete {
             stringJoinerSummary.add(MessageFormat.format("{0}{1}{2}{3}", DateUtil.format(new Date(), SystemConstant.DEFAULT_DATE_PATTERN), EXCEPTION_TITLE, EXCEPTION_DATA, e.getMessage()));
             tbTask.setResult(TaskResultEnum.ERROR);
             if (e instanceof ApiException) {
-                ResultUtil.error((ApiException) e, e.getMessage());
+                ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
             } else {
                 ResultUtil.error(e.getMessage());
             }

+ 1 - 1
sop-business/src/main/java/com/qmth/sop/business/templete/execute/AsyncSysCustomImportService.java

@@ -69,7 +69,7 @@ public class AsyncSysCustomImportService extends AsyncImportTaskTemplete {
             stringJoinerSummary.add(MessageFormat.format("{0}{1}{2}{3}", DateUtil.format(new Date(), SystemConstant.DEFAULT_DATE_PATTERN), EXCEPTION_TITLE, EXCEPTION_DATA, e.getMessage()));
             tbTask.setResult(TaskResultEnum.ERROR);
             if (e instanceof ApiException) {
-                ResultUtil.error((ApiException) e, e.getMessage());
+                ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
             } else {
                 ResultUtil.error(e.getMessage());
             }

+ 1 - 2
sop-business/src/main/java/com/qmth/sop/business/templete/execute/AsyncSysDeviceImportService.java

@@ -2,7 +2,6 @@ package com.qmth.sop.business.templete.execute;
 
 import cn.hutool.core.date.DateUtil;
 import com.qmth.boot.api.exception.ApiException;
-import com.qmth.sop.business.bean.dto.CustomImportDto;
 import com.qmth.sop.business.bean.dto.DeviceImportDto;
 import com.qmth.sop.business.entity.TBTask;
 import com.qmth.sop.business.service.TBTaskService;
@@ -70,7 +69,7 @@ public class AsyncSysDeviceImportService extends AsyncImportTaskTemplete {
             stringJoinerSummary.add(MessageFormat.format("{0}{1}{2}{3}", DateUtil.format(new Date(), SystemConstant.DEFAULT_DATE_PATTERN), EXCEPTION_TITLE, EXCEPTION_DATA, e.getMessage()));
             tbTask.setResult(TaskResultEnum.ERROR);
             if (e instanceof ApiException) {
-                ResultUtil.error((ApiException) e, e.getMessage());
+                ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
             } else {
                 ResultUtil.error(e.getMessage());
             }

+ 1 - 1
sop-business/src/main/java/com/qmth/sop/business/templete/execute/AsyncSysMessageExportService.java

@@ -66,7 +66,7 @@ public class AsyncSysMessageExportService extends AsyncExportTaskTemplete {
             stringJoinerSummary.add(MessageFormat.format("{0}{1}{2}{3}", DateUtil.format(new Date(), SystemConstant.DEFAULT_DATE_PATTERN), EXCEPTION_TITLE, EXCEPTION_DATA, e.getMessage()));
             tbTask.setResult(TaskResultEnum.ERROR);
             if (e instanceof ApiException) {
-                ResultUtil.error((ApiException) e, e.getMessage());
+                ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
             } else {
                 ResultUtil.error(e.getMessage());
             }

+ 1 - 1
sop-business/src/main/java/com/qmth/sop/business/templete/execute/AsyncUserArchivesExportService.java

@@ -66,7 +66,7 @@ public class AsyncUserArchivesExportService extends AsyncExportTaskTemplete {
             stringJoinerSummary.add(MessageFormat.format("{0}{1}{2}{3}", DateUtil.format(new Date(), SystemConstant.DEFAULT_DATE_PATTERN), EXCEPTION_TITLE, EXCEPTION_DATA, e.getMessage()));
             tbTask.setResult(TaskResultEnum.ERROR);
             if (e instanceof ApiException) {
-                ResultUtil.error((ApiException) e, e.getMessage());
+                ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
             } else {
                 ResultUtil.error(e.getMessage());
             }

+ 1 - 1
sop-business/src/main/java/com/qmth/sop/business/templete/execute/AsyncUserArchivesImportService.java

@@ -69,7 +69,7 @@ public class AsyncUserArchivesImportService extends AsyncImportTaskTemplete {
             stringJoinerSummary.add(MessageFormat.format("{0}{1}{2}{3}", DateUtil.format(new Date(), SystemConstant.DEFAULT_DATE_PATTERN), EXCEPTION_TITLE, EXCEPTION_DATA, e.getMessage()));
             tbTask.setResult(TaskResultEnum.ERROR);
             if (e instanceof ApiException) {
-                ResultUtil.error((ApiException) e, e.getMessage());
+                ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
             } else {
                 ResultUtil.error(e.getMessage());
             }

+ 1 - 1
sop-business/src/main/java/com/qmth/sop/business/templete/export/AsyncExportTaskTemplete.java

@@ -66,7 +66,7 @@ public abstract class AsyncExportTaskTemplete {
             tbTask.setSummary(stringJoinerSummary.toString());
             tbTask.setResult(TaskResultEnum.ERROR);
             if (e instanceof ApiException) {
-                ResultUtil.error((ApiException) e, e.getMessage());
+                ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
             } else {
                 ResultUtil.error(e.getMessage());
             }

+ 1 - 1
sop-business/src/main/java/com/qmth/sop/business/templete/importData/AsyncImportTaskTemplete.java

@@ -69,7 +69,7 @@ public abstract class AsyncImportTaskTemplete {
             tbTask.setSummary(stringJoinerSummary.toString());
             tbTask.setResult(TaskResultEnum.ERROR);
             if (e instanceof ApiException) {
-                ResultUtil.error((ApiException) e, e.getMessage());
+                ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
             } else {
                 ResultUtil.error(e.getMessage());
             }

+ 2 - 0
sop-common/src/main/java/com/qmth/sop/common/enums/ExceptionResultEnum.java

@@ -95,6 +95,8 @@ public enum ExceptionResultEnum {
 
     SERVICE_ID_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000034, "服务单元id不能为空"),
 
+    WXAPP_OPENID_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000035, "微信用户未绑定"),
+
     /**
      * 401
      */

+ 14 - 0
sop-common/src/main/java/com/qmth/sop/common/util/ResultUtil.java

@@ -47,6 +47,20 @@ public class ResultUtil {
         throw ExceptionResultEnum.EXCEPTION_ERROR.exception();
     }
 
+    public static Result error(ApiException e, int code, String message) {
+        try {
+            StringJoiner stringJoiner = new StringJoiner("");
+            HttpServletRequest request = ServletUtil.getRequest();
+            stringJoiner.add("[error path]:").add(request.getServletPath()).add("\r\n");
+            stringJoiner.add("[status]:").add(String.valueOf(e.getStatus().value())).add("\r\n");
+            stringJoiner.add("[code]:").add(String.valueOf(code)).add("\r\n");
+            stringJoiner.add("[message]:").add(message);
+            log.error(SystemConstant.LOG_ERROR, stringJoiner.toString());
+        } catch (Exception e1) {
+        }
+        throw new ApiException(e.getStatus(), code, message, message);
+    }
+
     public static Result error(ApiException e, String message) {
         try {
             StringJoiner stringJoiner = new StringJoiner("");

+ 18 - 0
sop-common/src/main/java/com/qmth/sop/common/util/ShaUtils.java

@@ -4,6 +4,7 @@ package com.qmth.sop.common.util;
 import com.qmth.sop.common.contant.SystemConstant;
 
 import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
 
 public class ShaUtils {
 
@@ -23,4 +24,21 @@ public class ShaUtils {
         }
     }
 
+    /**
+     * 加密
+     *
+     * @param str
+     * @return
+     * @author
+     */
+    public static byte[] encode(String str) {
+        MessageDigest messageDigest;
+        try {
+            messageDigest = MessageDigest.getInstance("SHA-256");
+        } catch (NoSuchAlgorithmException e) {
+            throw new RuntimeException(e);
+        }
+        messageDigest.update(str.getBytes());
+        return messageDigest.digest();
+    }
 }