ソースを参照

新增返回实例,修改登录存储逻辑,移除部分导致无法启动的实现类

haiqiu 2 年 前
コミット
b25ae8378f
30 ファイル変更776 行追加519 行削除
  1. 1 1
      common-baseapi/pom.xml
  2. 7 6
      common-baseapi/src/main/java/com/tofly/baseapi/controller/CommonInterfaceController.java
  3. 4 0
      common-core/src/main/java/com/tofly/common/core/constant/CommonConstants.java
  4. 0 19
      common-core/src/main/java/com/tofly/common/core/constant/ResponeStatus.java
  5. 8 2
      common-core/src/main/java/com/tofly/common/core/constant/SecurityConstants.java
  6. 0 71
      common-core/src/main/java/com/tofly/common/core/entity/ResultRespone.java
  7. 23 0
      common-core/src/main/java/com/tofly/common/core/result/BaseController.java
  8. 20 0
      common-core/src/main/java/com/tofly/common/core/result/ConstantData.java
  9. 77 0
      common-core/src/main/java/com/tofly/common/core/result/ResultData.java
  10. 32 0
      common-core/src/main/java/com/tofly/common/core/result/ResultEnum.java
  11. 6 6
      common-core/src/main/java/com/tofly/common/core/util/io/ExcelUtil.java
  12. 1 1
      common-data-es/pom.xml
  13. 124 30
      common-entity/src/main/java/com/tofly/entity/pojo/User.java
  14. 1 1
      common-file-ftp/pom.xml
  15. 2 2
      common-log/src/main/java/com/tofly/common/log/service/BaseLogService.java
  16. 3 2
      common-log/src/main/java/com/tofly/common/log/service/BaseLogServiceFallbackImpl.java
  17. 1 1
      common-oauth/pom.xml
  18. 132 47
      common-oauth/src/main/java/com/tofly/common/oauth/auth/ToflyUser.java
  19. 4 7
      common-oauth/src/main/java/com/tofly/common/oauth/compent/ResourceAuthExceptionEntryPoint.java
  20. 28 26
      common-oauth/src/main/java/com/tofly/common/oauth/compent/ToFlyUserAuthenticationConverter.java
  21. 4 3
      common-oauth/src/main/java/com/tofly/common/oauth/compent/ToflyAccessDeniedHandler.java
  22. 1 1
      common-oauth/src/main/java/com/tofly/common/oauth/exception/CommonControllerExceptionAdvice.java
  23. 5 5
      common-oauth/src/main/java/com/tofly/common/oauth/util/SecurityUtils.java
  24. 6 0
      common-orm-mybatisplus/src/main/java/com/tofly/mybatisplus/config/AutoConfigConfiguration.java
  25. 27 27
      common-orm-mybatisplus/src/main/java/com/tofly/mybatisplus/config/DataTypeUtil.java
  26. 47 45
      common-orm-mybatisplus/src/main/java/com/tofly/mybatisplus/config/MybatisKeyGenerator.java
  27. 140 139
      common-orm-mybatisplus/src/main/java/com/tofly/mybatisplus/config/MybatisPlusConfigurer.java
  28. 5 18
      common-orm-mybatisplus/src/main/java/com/tofly/mybatisplus/config/MybatisPlusHandler.java
  29. 46 44
      common-orm-mybatisplus/src/main/java/com/tofly/mybatisplus/config/ToflyDataTypeConstant.java
  30. 21 15
      common-web/src/main/java/com/tofly/web/config/CommonControllerExceptionAdvice.java

+ 1 - 1
common-baseapi/pom.xml

@@ -22,7 +22,7 @@
         <dependency>
             <groupId>com.tofly</groupId>
             <artifactId>common-web</artifactId>
-            <version>1.0.3</version>
+            <version>1.0.4</version>
         </dependency>
     </dependencies>
 </project>

+ 7 - 6
common-baseapi/src/main/java/com/tofly/baseapi/controller/CommonInterfaceController.java

@@ -1,7 +1,8 @@
 package com.tofly.baseapi.controller;
 
 import com.tofly.baseapi.service.CommonInterfaceService;
-import com.tofly.common.core.entity.ResultRespone;
+import com.tofly.common.core.result.BaseController;
+import com.tofly.common.core.result.ResultData;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
@@ -25,7 +26,7 @@ import java.util.Map;
 @Api(tags="公共接口")
 @AllArgsConstructor
 @Slf4j
-public class CommonInterfaceController {
+public class CommonInterfaceController extends BaseController {
     private final CommonInterfaceService commonInterfaceService;
 
     @GetMapping("/isExists" )
@@ -35,8 +36,8 @@ public class CommonInterfaceController {
             @ApiImplicitParam(name = "tableColumn", value = "列名(例如name)", required = true, dataType = "String"),
             @ApiImplicitParam(name = "columnValue", value = "列值(例如admin)", required = true, dataType = "String")
     })
-    public ResultRespone<Boolean> isExists(@RequestParam @ApiIgnore Map map){
-        return ResultRespone.success(commonInterfaceService.getExistsNum(map));
+    public ResultData isExists(@RequestParam @ApiIgnore Map map){
+        return decide(commonInterfaceService.getExistsNum(map));
     }
 
     @GetMapping("/getDBTable")
@@ -44,7 +45,7 @@ public class CommonInterfaceController {
     @ApiImplicitParams({
             @ApiImplicitParam(name = "filter", value = "表的描述信息(可选参数,模糊查询)", required = false, dataType = "String")
     })
-    public ResultRespone getDBTable(@RequestParam(required = false) String filter) {
-        return ResultRespone.success(commonInterfaceService.getDBTable(filter));
+    public ResultData getDBTable(@RequestParam(required = false) String filter) {
+        return decide(commonInterfaceService.getDBTable(filter));
     }
 }

+ 4 - 0
common-core/src/main/java/com/tofly/common/core/constant/CommonConstants.java

@@ -142,4 +142,8 @@ public interface CommonConstants {
      */
     String POSTIONKEY="position";
 
+
+    /********************分割线*********************/
+    String TENEANT_ID = "tenantId";
+
 }

+ 0 - 19
common-core/src/main/java/com/tofly/common/core/constant/ResponeStatus.java

@@ -1,19 +0,0 @@
-package com.tofly.common.core.constant;
-
-import lombok.Getter;
-
-/**
- * @author Administrator
- * @date 2019/9/3  13:38
- */
-public enum ResponeStatus {
-    SUCCESS(1),
-    FAIL(-1);
-
-    @Getter
-    private int code;
-    ResponeStatus(int code){
-        this.code=code;
-    }
-
-}

+ 8 - 2
common-core/src/main/java/com/tofly/common/core/constant/SecurityConstants.java

@@ -86,7 +86,7 @@ public interface SecurityConstants {
     /**
      * 用户部门字段
      */
-    String DETAILS_DEPT_ID = "departmentId";
+    String DETAILS_DEPT_ID = "deptId";
 
 
     /**
@@ -112,7 +112,7 @@ public interface SecurityConstants {
     /**
      * 总公司,子公司
      */
-    String PARENT_COMPANY_ID = "parentCompanyId";
+    String PARENT_COMPANY_ID = "tenantId";
     String PARENT_COMPANY_NAME = "parentCompanyName";
     String COMPANY_ID = "companyId";
     String COMPANY_NAME = "companyName";
@@ -143,4 +143,10 @@ public interface SecurityConstants {
 
     Long REDIS_LOCK_TIME=20000L;
 
+
+    String POST_IDS = "postIds";
+
+    String DEPT_IDS = "deptIds";
+
+    String ROLE_IDS = "roleIds";
 }

+ 0 - 71
common-core/src/main/java/com/tofly/common/core/entity/ResultRespone.java

@@ -1,71 +0,0 @@
-package com.tofly.common.core.entity;
-
-
-import com.tofly.common.core.constant.ResponeStatus;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-import java.io.Serializable;
-
-/**
- * @author Administrator
- * @date 2019/8/30  15:27
- */
-@ToString
-public class ResultRespone<T> implements Serializable {
-
-
-    private static final long serialVersionUID = -7275852267551207696L;
-    @Getter
-    @Setter
-    private int code;
-
-    @Getter
-    @Setter
-    private String message;
-
-    @Getter
-    @Setter
-    private T result;
-
-    public ResultRespone() {
-        this.code = ResponeStatus.SUCCESS.getCode();
-    }
-
-    public static <T> ResultRespone<T> success() {
-        return restResult(null, ResponeStatus.SUCCESS.getCode(), null);
-    }
-
-    public static <T> ResultRespone<T> success(T result) {
-        return restResult(result, ResponeStatus.SUCCESS.getCode(), null);
-    }
-
-    public static <T> ResultRespone<T> success(T result, String message) {
-        return restResult(result, ResponeStatus.SUCCESS.getCode(), message);
-    }
-
-    public static <T> ResultRespone<T> failed() {
-        return restResult(null, ResponeStatus.FAIL.getCode(), null);
-    }
-
-    public static <T> ResultRespone<T> failed(String message) {
-        return restResult(null, ResponeStatus.FAIL.getCode(), message);
-    }
-
-    public static <T> ResultRespone<T> failed(T result) {
-        return restResult(result, ResponeStatus.FAIL.getCode(), null);
-    }
-
-    public static <T> ResultRespone<T> failed(T result, String message) {
-        return restResult(result, ResponeStatus.FAIL.getCode(), message);
-    }
-
-    private static <T> ResultRespone<T> restResult(T result, int code, String message) {
-        ResultRespone<T> apiResult = new ResultRespone<>();
-        apiResult.setCode(code);
-        apiResult.setResult(result);
-        apiResult.setMessage(message);
-        return apiResult;
-    }
-}

+ 23 - 0
common-core/src/main/java/com/tofly/common/core/result/BaseController.java

@@ -0,0 +1,23 @@
+package com.tofly.common.core.result;
+
+/**
+ * @author haiqiu
+ * @date 2022/6/23
+ */
+public abstract class BaseController {
+    public ResultData decide(boolean b){
+        return b ? ResultData.ok() : ResultData.fail();
+    }
+
+    public ResultData decide(boolean b,ResultEnum ok,ResultEnum fail){
+        return b ? ResultData.ok(ok) : ResultData.fail(fail);
+    }
+
+    public ResultData decide(Object o){
+        return ResultData.ok(o);
+    }
+
+    public ResultData decide(Object o,ResultEnum resultEnum){
+        return ResultData.ok(resultEnum.getCode(),resultEnum.getMessage(),o);
+    }
+}

+ 20 - 0
common-core/src/main/java/com/tofly/common/core/result/ConstantData.java

@@ -0,0 +1,20 @@
+package com.tofly.common.core.result;
+
+/**
+ * @author HaiQiu
+ * @date 2022/7/1
+ * 常量
+ */
+public class ConstantData {
+
+    public final static boolean OFF = false;
+    public final static boolean ON = true;
+
+    public final static int PID = 0;
+    public final static int MENU = 0;
+    public final static int BUTTON = 1;
+    public final static int EXTERNAL = 2;
+
+    public final static int ENABLE = 1;
+    public final static int DISABLE = 0;
+}

+ 77 - 0
common-core/src/main/java/com/tofly/common/core/result/ResultData.java

@@ -0,0 +1,77 @@
+package com.tofly.common.core.result;
+
+import lombok.Data;
+
+@Data
+public class ResultData {
+    private String code;
+
+    private Object data;
+
+    private String message;
+
+    public ResultData(){}
+
+    public ResultData(String message){
+        this.code = ResultEnum.OK.getCode();
+        this.message = message;
+    }
+
+    public ResultData(String code,String message){
+        this.code = code;
+        this.message = message;
+    }
+
+    public ResultData(String code,String message,Object data){
+        this.code = code;
+        this.message = message;
+        this.data = data;
+    }
+
+    public ResultData(ResultEnum resultEnum){
+        this.code = resultEnum.getCode();
+        this.message = resultEnum.getMessage();
+    }
+
+    public static ResultData ok(){
+        return new ResultData(ResultEnum.OK);
+    }
+
+    public static ResultData ok(String message){
+        return new ResultData(message);
+    }
+
+    public static ResultData ok(Object data){
+        ResultData resultData = new ResultData(ResultEnum.OK);
+        resultData.setData(data);
+        return resultData;
+    }
+
+
+    public static ResultData ok(String code,String message,Object data){
+        return new ResultData(code,message,data);
+    }
+
+    public static ResultData ok(ResultEnum resultEnum){
+        return new ResultData(resultEnum);
+    }
+
+    public static ResultData fail(){
+        return new ResultData(ResultEnum.Fail);
+    }
+
+    public static ResultData fail(String message){
+         ResultData resultData = new ResultData(ResultEnum.Fail);
+         resultData.setMessage(message);
+         return resultData;
+    }
+
+    public static ResultData fail(String code,String messge){
+        return new ResultData(code,messge);
+    }
+
+    public static ResultData fail(ResultEnum resultEnum){
+        return new ResultData(resultEnum);
+    }
+
+}

+ 32 - 0
common-core/src/main/java/com/tofly/common/core/result/ResultEnum.java

@@ -0,0 +1,32 @@
+package com.tofly.common.core.result;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+
+@AllArgsConstructor
+public enum ResultEnum {
+    OK("200","成功"),
+
+    ADD_SUCCESS("200","新增成功"),
+    ADD_FAIL("500","新增失败"),
+    UPDATE_SUCCESS("200","修改成功"),
+    UPDATE_FAIL("500","修改失败"),
+    DELETE_SUCCESS("200","删除成功"),
+    DELETE_FAIL("500","删除失败"),
+    FIND_SUCCESS("200","查询成功"),
+    FIND_FAIL("500","查询失败"),
+    LOGIN("200","登陆成功"),
+    LOGIN_FAIL("500","登陆失败"),
+    NOT_LOGIN_FAIL("401","未登录"),
+    LOGIN_TOKEN_FAIL("402","登录信息失效"),
+    AUTH_FAIL("403","无权访问"),
+    Fail("500","失败");
+
+    @Getter
+    private final String code;
+
+    @Getter
+    private final String message;
+
+}

+ 6 - 6
common-core/src/main/java/com/tofly/common/core/util/io/ExcelUtil.java

@@ -2,7 +2,7 @@ package com.tofly.common.core.util.io;
 
 
 import com.tofly.common.core.annotation.Excel;
-import com.tofly.common.core.entity.ResultRespone;
+import com.tofly.common.core.result.ResultData;
 import com.tofly.common.core.util.Convert;
 import com.tofly.common.core.util.ReflectUtil;
 import com.tofly.common.core.util.StringUtil;
@@ -218,7 +218,7 @@ public class ExcelUtil<T> {
 	 *            工作表的名称
 	 * @return 结果
 	 */
-	public ResultRespone exportExcel(List<T> list, String sheetName) {
+	public ResultData exportExcel(List<T> list, String sheetName) {
 		this.init(list, sheetName, Excel.Type.EXPORT);
 		return exportExcel();
 	}
@@ -230,7 +230,7 @@ public class ExcelUtil<T> {
 	 *            工作表的名称
 	 * @return 结果
 	 */
-	public ResultRespone importTemplateExcel(String sheetName) {
+	public ResultData importTemplateExcel(String sheetName) {
 		this.init(null, sheetName, Excel.Type.IMPORT);
 		return exportExcel();
 	}
@@ -240,7 +240,7 @@ public class ExcelUtil<T> {
 	 * 
 	 * @return 结果
 	 */
-	public ResultRespone exportExcel() {
+	public ResultData exportExcel() {
 		OutputStream out = null;
 		try {
 			// 取出一共有多少个sheet.
@@ -304,11 +304,11 @@ public class ExcelUtil<T> {
 			String filename = encodingFilename(sheetName);
 			out = new FileOutputStream(getAbsoluteFile(filename));
 			wb.write(out);
-			return ResultRespone.success(filename);
+			return ResultData.ok(filename);
 
 		} catch (Exception e) {
 			log.error("导出Excel异常{}", e.getMessage());
-			return ResultRespone.failed("导出Excel失败,请联系网站管理员");
+			return ResultData.ok("导出Excel失败,请联系网站管理员");
 		} finally {
 			if (wb != null) {
 				try {

+ 1 - 1
common-data-es/pom.xml

@@ -21,7 +21,7 @@
         <dependency>
             <groupId>com.tofly</groupId>
             <artifactId>common-core</artifactId>
-            <version>1.0.3</version>
+            <version>1.0.4</version>
         </dependency>
         <dependency>
             <groupId>com.baomidou</groupId>

+ 124 - 30
common-entity/src/main/java/com/tofly/entity/pojo/User.java

@@ -20,64 +20,158 @@ import java.util.Date;
 public class User implements Serializable {
 
     private static final long serialVersionUID = 6348311758268973122L;
+    /**
+     * 用户ID,主键
+     */
     private Long id;
 
+    /**
+     * 用户名
+     */
     private String username;
 
+    /**
+     * 密码
+     */
     private String password;
 
+    /**
+     * 随机数
+     */
     private String salt;
 
+    /**
+     * 电话
+     */
     private String phone;
 
+    /**
+     * 头像
+     */
     private String avatar;
 
-    private Long departmentId;
+    /**
+     * 是否锁定,1正常,0锁定
+     */
+    private Integer lockFlag;
 
-    private String departmentName;
-
-    private Date createTime;
-
-    private Date updateTime;
-
-    private String lockFlag;
-
-    private String statusFlag;
+    /**
+     * 是否启用禁用,1启用,0禁用
+     */
+    private Integer active;
 
+    /**
+     * 扩展功能,微信openid
+     */
     private String wxOpenid;
 
+    /**
+     * 扩展功能,QQ openid
+     */
     private String qqOpenid;
 
+    /**
+     * 用户email
+     */
     private String email;
 
+    /**
+     * 用户姓名
+     */
     private String realName;
 
+    /**
+     * 最后一次登录时间
+     */
     private Date loginTime;
 
-    private String lastIp;
-
-    private Short pwderrtimes;
-
-    private String worknumber;
-
-    private String findpwdkey;
-
-    private String aliasname;
-
+    /**
+     * 最后一次访问IP
+     */
+    private String loginIp;
+
+    /**
+     * 密码错误次数
+     */
+    private Integer loginFail;
+
+    /**
+     * 工号
+     */
+    private String jobNumber;
+
+    /**
+     * 找回密码关键字
+     */
+    private String passwordCrux;
+
+    /**
+     * 别名
+     */
+    private String aliasName;
+
+    /**
+     * 生日
+     */
     private Date birthday;
 
-    private String belong;
+    /**
+     * 用户级别  用于超级管理员与其他用户区分等  。0 超级管理员1普通管理员,2其他公司管理员
+     */
+    private Integer userLevel;
+
+    /**
+     * 首次登陆状态,1 首次登录,0 非首次登录
+     */
+    private Integer firstLogin;
+
+    /**
+     * 用户账号详情
+     */
+    private String details;
+
+    /**
+     * 备注
+     */
+    private String note;
+
+    /**
+     * 原始密码
+     */
+    private String originalPassword;
+
+    /**
+     * 公司ID
+     */
+    private Long tenantId;
+
+    /**
+     * 排序
+     */
+    private Long sort;
+
+    /**
+     * 逻辑删除,1删除,0不删除
+     */
+    private Integer deleted;
+
+    /**
+     * 创建时间
+     */
+    private Date createTime;
 
+    /**
+     * 创建人
+     */
     private Long createUser;
 
-    private String userLevel;
-
-
-    private Long parentCompanyId;
-
-    private String parentCompanyName;
-
-    private Long companyId;
+    /**
+     * 更新时间
+     */
+    private Date updateTime;
 
-    private String companyName;
+    /**
+     * 修改人
+     */
+    private Long updateUser;
 }

+ 1 - 1
common-file-ftp/pom.xml

@@ -22,7 +22,7 @@
         <dependency>
             <groupId>com.tofly</groupId>
             <artifactId>common-core</artifactId>
-            <version>1.0.3</version>
+            <version>1.0.4</version>
             <scope>provided</scope>
         </dependency>
 

+ 2 - 2
common-log/src/main/java/com/tofly/common/log/service/BaseLogService.java

@@ -1,7 +1,7 @@
 package com.tofly.common.log.service;
 
 import com.tofly.common.core.constant.SecurityConstants;
-import com.tofly.common.core.entity.ResultRespone;
+import com.tofly.common.core.result.ResultData;
 import com.tofly.entity.pojo.Log;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -17,5 +17,5 @@ public interface BaseLogService {
 
 //    @PostMapping("/log/add")
     @PostMapping("${toflylog.apiName}")
-    ResultRespone saveLog(@RequestBody Log log, @RequestHeader(SecurityConstants.FROM) String from);
+    ResultData saveLog(@RequestBody Log log, @RequestHeader(SecurityConstants.FROM) String from);
 }

+ 3 - 2
common-log/src/main/java/com/tofly/common/log/service/BaseLogServiceFallbackImpl.java

@@ -1,6 +1,7 @@
 package com.tofly.common.log.service;
 
-import com.tofly.common.core.entity.ResultRespone;
+
+import com.tofly.common.core.result.ResultData;
 import com.tofly.entity.pojo.Log;
 import lombok.Setter;
 import lombok.extern.slf4j.Slf4j;
@@ -18,7 +19,7 @@ public class BaseLogServiceFallbackImpl implements BaseLogService {
     private Throwable throwable;
 
     @Override
-    public ResultRespone saveLog(Log logs, String from) {
+    public ResultData saveLog(Log logs, String from) {
         log.error("插入日志失败",throwable);
         return null;
     }

+ 1 - 1
common-oauth/pom.xml

@@ -20,7 +20,7 @@
         <dependency>
             <groupId>com.tofly</groupId>
             <artifactId>common-core</artifactId>
-            <version>1.0.3</version>
+            <version>1.0.4</version>
         </dependency>
         <dependency>
             <groupId>org.springframework.security.oauth.boot</groupId>

+ 132 - 47
common-oauth/src/main/java/com/tofly/common/oauth/auth/ToflyUser.java

@@ -1,74 +1,159 @@
 package com.tofly.common.oauth.auth;
 
 import lombok.Getter;
+import lombok.Setter;
 import org.springframework.security.core.GrantedAuthority;
 import org.springframework.security.core.userdetails.User;
 
 import java.util.Collection;
+import java.util.List;
 
 /**
  * @author Administrator
  * @date 2019/10/12  13:06
  */
+@Getter
+@Setter
 public class ToflyUser extends User{
 
-    @Getter
-    private Long userid;
+    /**
+     * 用户ID,主键
+     */
 
-    @Getter
-    private Long departmentId;
+    private Long id;
 
-    @Getter
-    private String userLevel;
+    /**
+     * 电话
+     */
+    private String phone;
 
-    @Getter
+    /**
+     * 头像
+     */
+    private String avatar;
+
+    /**
+     * 是否锁定,1正常,0锁定
+     */
+    private Integer lockFlag;
+
+    /**
+     * 是否启用禁用,1启用,0禁用
+     */
+    private Integer active;
+
+    /**
+     * 密码错误次数
+     */
+    private Integer loginFail;
+
+    /**
+     * 用户email
+     */
+    private String email;
+
+    /**
+     * 用户姓名
+     */
     private String realName;
 
-    @Getter
-    private String departemntName;
 
-    @Getter
-    private String avatar;
+    /**
+     * 工号
+     */
+    private String jobNumber;
+
+
+    /**
+     * 别名
+     */
+    private String aliasName;
+
 
-    @Getter
-    private Short pwderrtimes;
-    @Getter
-    private Long parentCompanyId;
-    @Getter
-    private String parentCompanyName;
-    @Getter
-    private Long companyId;
-    @Getter
-    private String companyName;
-
-
-    public ToflyUser(Short pwderrtimes,Long parentCompanyId,String parentCompanyName,Long companyId,String companyName,Long useid,Long departmentId,String userLevel,String realName, String departemntName,String avatar,
-                     String username, String password, boolean enabled, boolean accountNonExpired,
-                     boolean credentialsNonExpired, boolean accountNonLocked, Collection<? extends GrantedAuthority> authorities) {
+    /**
+     * 用户级别  用于超级管理员与其他用户区分等  。0 超级管理员1普通管理员,2其他公司管理员
+     */
+    private Integer userLevel;
+
+    /**
+     * 公司ID
+     */
+    private Long tenantId;
+
+    /**
+     * 角色ID集合
+     */
+    private List<Long> roleIds;
+
+    /**
+     * 部门ID集合
+     */
+    private List<Long> deptIds;
+
+    /**
+     * 岗位ID集合
+     */
+    private List<Long> postIds;
+
+    public ToflyUser(String username, String password, Collection<? extends GrantedAuthority> authorities) {
+        super(username, password, authorities);
+    }
+
+    public ToflyUser(String username, String password, boolean enabled, boolean accountNonExpired, boolean credentialsNonExpired,
+                     boolean accountNonLocked, Collection<? extends GrantedAuthority> authorities) {
         super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities);
-        this.parentCompanyId = parentCompanyId;
-        this.parentCompanyName = parentCompanyName;
-        this.companyId = companyId;
-        this.companyName = companyName;
-        this.userid=useid;
-        this.departmentId=departmentId;
-        this.userLevel=userLevel;
-        this.realName=realName;
-        this.departemntName=departemntName;
-        this.avatar=avatar;
-        this.pwderrtimes=pwderrtimes;
     }
 
-    public ToflyUser(Short pwderrtimes,Long useid,Long departmentId,String userLevel,String realName, String departemntName,String avatar,
-                     String username, String password, boolean enabled, boolean accountNonExpired,
-                     boolean credentialsNonExpired, boolean accountNonLocked, Collection<? extends GrantedAuthority> authorities) {
+    public ToflyUser(String username, String password, Collection<? extends GrantedAuthority> authorities,
+                     Long id, String phone, String avatar, Integer lockFlag,
+                     Integer active, String email,
+                     String realName, Integer loginFail,
+                     String jobNumber,
+                     Integer userLevel,
+                     Long tenantId,
+                     List<Long> roleIds, List<Long> deptIds, List<Long> postIds) {
+        super(username, password, authorities);
+        this.id = id;
+        this.loginFail = loginFail;
+        this.phone = phone;
+        this.avatar = avatar;
+        this.lockFlag = lockFlag;
+        this.active = active;
+        this.email = email;
+        this.realName = realName;
+        this.jobNumber = jobNumber;
+        this.userLevel = userLevel;
+        this.tenantId = tenantId;
+        this.roleIds = roleIds;
+        this.deptIds = deptIds;
+        this.postIds = postIds;
+    }
+
+    public ToflyUser(String username, String password, boolean enabled, boolean accountNonExpired,
+                     boolean credentialsNonExpired, boolean accountNonLocked,
+                     Collection<? extends GrantedAuthority> authorities, Long id,
+                      String phone, String avatar, Integer lockFlag,
+                     Integer active,Integer loginFail,
+                     String realName,
+                     String jobNumber,
+                     Integer userLevel,
+                     Long tenantId,
+                     List<Long> roleIds, List<Long> deptIds, List<Long> postIds) {
         super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities);
-        this.userid=useid;
-        this.departmentId=departmentId;
-        this.userLevel=userLevel;
-        this.realName=realName;
-        this.departemntName=departemntName;
-        this.avatar=avatar;
-        this.pwderrtimes=pwderrtimes;
+        this.id = id;
+        this.loginFail = loginFail;
+        this.phone = phone;
+        this.avatar = avatar;
+        this.lockFlag = lockFlag;
+        this.active = active;
+        this.email = email;
+        this.realName = realName;
+        this.jobNumber = jobNumber;
+        this.aliasName = aliasName;
+        this.userLevel = userLevel;
+        this.tenantId = tenantId;
+        this.roleIds = roleIds;
+        this.deptIds = deptIds;
+        this.postIds = postIds;
     }
 }

+ 4 - 7
common-oauth/src/main/java/com/tofly/common/oauth/compent/ResourceAuthExceptionEntryPoint.java

@@ -2,7 +2,8 @@ package com.tofly.common.oauth.compent;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.tofly.common.core.constant.CommonConstants;
-import com.tofly.common.core.entity.ResultRespone;
+import com.tofly.common.core.result.ResultData;
+import com.tofly.common.core.result.ResultEnum;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.http.HttpStatus;
@@ -31,13 +32,9 @@ public class ResourceAuthExceptionEntryPoint implements AuthenticationEntryPoint
     public void commence(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AuthenticationException e) throws IOException, ServletException {
         httpServletResponse.setCharacterEncoding(CommonConstants.UTF8);
         httpServletResponse.setContentType(CommonConstants.CONTENT_TYPE);
-        ResultRespone<String> result = new ResultRespone<>();
-        result.setCode(HttpStatus.UNAUTHORIZED.value());
-        if (e != null) {
-            result.setMessage("没有访问权限:"+e.getMessage());
-        }
         httpServletResponse.setStatus(HttpStatus.UNAUTHORIZED.value());
         PrintWriter printWriter = httpServletResponse.getWriter();
-        printWriter.append(objectMapper.writeValueAsString(result));
+        //未登录
+        printWriter.append(objectMapper.writeValueAsString(ResultData.fail(ResultEnum.NOT_LOGIN_FAIL)));
     }
 }

+ 28 - 26
common-oauth/src/main/java/com/tofly/common/oauth/compent/ToFlyUserAuthenticationConverter.java

@@ -10,9 +10,7 @@ import org.springframework.security.core.authority.AuthorityUtils;
 import org.springframework.security.oauth2.provider.token.UserAuthenticationConverter;
 import org.springframework.util.StringUtils;
 
-import java.util.Collection;
-import java.util.LinkedHashMap;
-import java.util.Map;
+import java.util.*;
 
 /**
  * @author Administrator
@@ -24,8 +22,8 @@ public class ToFlyUserAuthenticationConverter implements UserAuthenticationConve
 
     @Override
     public Map<String, ?> convertUserAuthentication(Authentication authentication) {
-        Map<String,Object> returnMap=new LinkedHashMap();
-        returnMap.put(USERNAME,authentication.getName());
+        Map<String, Object> returnMap = new LinkedHashMap<>();
+        returnMap.put(USERNAME, authentication.getName());
         if (authentication.getAuthorities() != null && !authentication.getAuthorities().isEmpty()) {
             returnMap.put(AUTHORITIES, AuthorityUtils.authorityListToSet(authentication.getAuthorities()));
         }
@@ -38,37 +36,41 @@ public class ToFlyUserAuthenticationConverter implements UserAuthenticationConve
             Collection<? extends GrantedAuthority> authorities = getAuthorities(map);
 
             String username = (String) map.get(SecurityConstants.DETAILS_USERNAME);
-            Long id=null;
-            if(map.get(SecurityConstants.DETAILS_USER_ID)!=null){
-                 id = ((Integer) map.get(SecurityConstants.DETAILS_USER_ID)).longValue();
+            Long id = null;
+            if (map.get(SecurityConstants.DETAILS_USER_ID) != null) {
+                id = ((Integer) map.get(SecurityConstants.DETAILS_USER_ID)).longValue();
             }
-            Long deptId=null;
-            if(map.get(SecurityConstants.DETAILS_DEPT_ID)!=null){
-                 deptId = ((Integer) map.get(SecurityConstants.DETAILS_DEPT_ID)).longValue();
+
+            String deptId = null;
+            if (map.get(SecurityConstants.DETAILS_DEPT_ID) != null) {
+                deptId = (String) map.get(SecurityConstants.DETAILS_DEPT_ID);
             }
 
-            String userLevel = (String)map.get(SecurityConstants.DETAILS_USER_LEVEL);
-            String realName = (String)map.get(SecurityConstants.DETAILS_REAL_NAME);
+            Integer userLevel = (Integer) map.get(SecurityConstants.DETAILS_USER_LEVEL);
+            String realName = (String) map.get(SecurityConstants.DETAILS_REAL_NAME);
 
-            String deptName = (String)map.get(SecurityConstants.DETAILS_DEPT_NAME);
+            String deptName = (String) map.get(SecurityConstants.DETAILS_DEPT_NAME);
 
-            String avatar = (String)map.get(SecurityConstants.DETAILS_USER_AVATAR);
+            String avatar = (String) map.get(SecurityConstants.DETAILS_USER_AVATAR);
 
-            Long parentCompanyId=null;
-            if(map.get(SecurityConstants.PARENT_COMPANY_ID)!=null){
-                parentCompanyId = ((Integer) map.get(SecurityConstants.PARENT_COMPANY_ID)).longValue();
+            Long parentCompanyId = null;
+            if (map.get(SecurityConstants.PARENT_COMPANY_ID) != null) {
+                parentCompanyId = (Long) map.get(SecurityConstants.PARENT_COMPANY_ID);
             }
-            String parentCompanyName = (String)map.get(SecurityConstants.PARENT_COMPANY_NAME);
-            Long companyId=null;
-            if(map.get(SecurityConstants.COMPANY_ID)!=null){
+            String parentCompanyName = (String) map.get(SecurityConstants.PARENT_COMPANY_NAME);
+            Long companyId = null;
+            if (map.get(SecurityConstants.COMPANY_ID) != null) {
                 parentCompanyId = ((Integer) map.get(SecurityConstants.COMPANY_ID)).longValue();
             }
-            String companyName = (String)map.get(SecurityConstants.COMPANY_NAME);
-            Short pwderrtimes = (Short) map.get("pwderrtimes");
-            ToflyUser user = new ToflyUser(pwderrtimes,parentCompanyId,parentCompanyName,companyId,companyName,id, deptId, userLevel,realName,deptName,avatar,username, N_A, true
-                    , true, true, true, authorities);
+            String companyName = (String) map.get(SecurityConstants.COMPANY_NAME);
+            Integer pwderrtimes = (Integer) map.get("pwderrtimes");
+            ToflyUser user = new ToflyUser(username, N_A, true
+                    , true, true, true, authorities, id, "",
+                    avatar, 0, 1, pwderrtimes, realName,
+                    "xxx", userLevel, parentCompanyId, Collections.emptyList(),
+                    Collections.emptyList(), Collections.emptyList());
             return new UsernamePasswordAuthenticationToken(user, N_A, authorities);
-        }else {
+        } else {
             throw new ToflyAuth2Exception("参数非法");
         }
 

+ 4 - 3
common-oauth/src/main/java/com/tofly/common/oauth/compent/ToflyAccessDeniedHandler.java

@@ -2,7 +2,8 @@ package com.tofly.common.oauth.compent;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.tofly.common.core.constant.CommonConstants;
-import com.tofly.common.core.entity.ResultRespone;
+import com.tofly.common.core.result.ResultData;
+import com.tofly.common.core.result.ResultEnum;
 import com.tofly.common.oauth.exception.ToflyDeniedException;
 import lombok.AllArgsConstructor;
 import lombok.SneakyThrows;
@@ -38,9 +39,9 @@ public class ToflyAccessDeniedHandler extends OAuth2AccessDeniedHandler {
         log.info("授权失败,禁止访问 {}", request.getRequestURI());
         response.setCharacterEncoding(CommonConstants.UTF8);
         response.setContentType(CommonConstants.CONTENT_TYPE);
-        ResultRespone<ToflyDeniedException> result = ResultRespone.failed(new ToflyDeniedException("授权失败,禁止访问"));
         response.setStatus(HttpStatus.FORBIDDEN.value());
         PrintWriter printWriter = response.getWriter();
-        printWriter.append(objectMapper.writeValueAsString(result));
+        //无权限
+        printWriter.append(objectMapper.writeValueAsString(ResultData.fail(ResultEnum.AUTH_FAIL)));
     }
 }

+ 1 - 1
common-oauth/src/main/java/com/tofly/common/oauth/exception/CommonControllerExceptionAdvice.java

@@ -1,6 +1,6 @@
 package com.tofly.common.oauth.exception;
 
-import com.tofly.common.core.entity.ResultRespone;
+
 import com.tofly.common.core.util.StringUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.web.bind.annotation.ControllerAdvice;

+ 5 - 5
common-oauth/src/main/java/com/tofly/common/oauth/util/SecurityUtils.java

@@ -64,15 +64,15 @@ public class SecurityUtils {
      */
     public Long getUserId() {
        ToflyUser toflyUser=getUser();
-       return toflyUser.getUserid();
+       return toflyUser.getId();
     }
 
     /**
      * 获取用户部门ID
      */
-    public Long getUserDeptId() {
+    public List<Long> getUserDeptId() {
         ToflyUser toflyUser=getUser();
-        return toflyUser.getDepartmentId();
+        return toflyUser.getDeptIds();
 
     }
 
@@ -81,7 +81,7 @@ public class SecurityUtils {
      */
     public Long getUserParentCompanyId() {
         ToflyUser toflyUser=getUser();
-        return toflyUser.getParentCompanyId();
+        return toflyUser.getTenantId();
 
     }
 
@@ -90,7 +90,7 @@ public class SecurityUtils {
      */
     public Long getUserCompanyId() {
         ToflyUser toflyUser=getUser();
-        return toflyUser.getCompanyId();
+        return toflyUser.getTenantId();
 
     }
     /**

+ 6 - 0
common-orm-mybatisplus/src/main/java/com/tofly/mybatisplus/config/AutoConfigConfiguration.java

@@ -1,5 +1,6 @@
 package com.tofly.mybatisplus.config;
 
+import com.alibaba.druid.pool.DruidDataSource;
 import lombok.SneakyThrows;
 import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.cloud.client.loadbalancer.LoadBalanced;
@@ -18,6 +19,11 @@ import org.springframework.web.client.RestTemplate;
 @ComponentScan({"com.tofly"})
 @MapperScan({"com.tofly.*.mapper","com.tofly.*.custom.mapper"})
 public class AutoConfigConfiguration {
+
+    @Bean
+    public DruidDataSource druidDataSource(){
+        return new DruidDataSource();
+    }
     @Bean
     public RestTemplate restTemplate() {
         return new RestTemplate();

+ 27 - 27
common-orm-mybatisplus/src/main/java/com/tofly/mybatisplus/config/DataTypeUtil.java

@@ -1,27 +1,27 @@
-package com.tofly.mybatisplus.config;
-
-import com.tofly.common.core.util.SpringContextHolder;
-import lombok.experimental.UtilityClass;
-
-/**
- * @author tuonbed
- * @date 2020/3/24  16:03
- */
-@UtilityClass
-public class DataTypeUtil {
-
-
-    public static String getDataType(){
-        return SpringContextHolder.getBean(ToflyDataTypeConstant.class).getDataType();
-    }
-
-    public static String getKeywordBydatatype(String key){
-        String datatype=getDataType();
-        switch (datatype){
-            case "mysql":
-                return "`"+key+"`";
-            default:
-                return key;
-        }
-    }
-}
+//package com.tofly.mybatisplus.config;
+//
+//import com.tofly.common.core.util.SpringContextHolder;
+//import lombok.experimental.UtilityClass;
+//
+///**
+// * @author tuonbed
+// * @date 2020/3/24  16:03
+// */
+//@UtilityClass
+//public class DataTypeUtil {
+//
+//
+//    public static String getDataType(){
+//        return SpringContextHolder.getBean(ToflyDataTypeConstant.class).getDataType();
+//    }
+//
+//    public static String getKeywordBydatatype(String key){
+//        String datatype=getDataType();
+//        switch (datatype){
+//            case "mysql":
+//                return "`"+key+"`";
+//            default:
+//                return key;
+//        }
+//    }
+//}

+ 47 - 45
common-orm-mybatisplus/src/main/java/com/tofly/mybatisplus/config/MybatisKeyGenerator.java

@@ -1,45 +1,47 @@
-package com.tofly.mybatisplus.config;
-
-import com.alibaba.druid.pool.DruidDataSource;
-import com.baomidou.mybatisplus.core.incrementer.IKeyGenerator;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.ibatis.executor.keygen.KeyGenerator;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * @author Administrator
- * @date 2019/10/10  11:40
- * 自定义主键生成
- */
-@Slf4j
-@Component
-public class MybatisKeyGenerator implements IKeyGenerator {
-
-    @Autowired
-    private DruidDataSource druidDataSource;
-
-    @Override
-    public String executeSql(String incrementerName) {
-        log.info("incrementerName:{}",incrementerName);
-        KeyGenerator keyGenerator;
-        String dbtype=druidDataSource.getDbType();
-        String sql;
-        switch (dbtype){
-            case "oracle":
-                if(incrementerName.indexOf("_SEQ")!=-1){
-                    sql = "select "+ incrementerName+".nextval from dual";
-                }else{
-                    sql="select nvl(max(id),0)+1 from  "+incrementerName;
-                }
-                break;
-            case "mysql":
-                sql="select IFNULL(max(id),0)+1 from  "+incrementerName;
-                break;
-            default:
-                sql = "";
-        }
-
-        return sql;
-    }
-}
+//package com.tofly.mybatisplus.config;
+//
+//import com.alibaba.druid.pool.DruidDataSource;
+//import com.baomidou.mybatisplus.core.incrementer.IKeyGenerator;
+//import lombok.AllArgsConstructor;
+//import lombok.extern.slf4j.Slf4j;
+//import org.apache.ibatis.executor.keygen.KeyGenerator;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.stereotype.Component;
+//
+///**
+// * @author Administrator
+// * @date 2019/10/10  11:40
+// * 自定义主键生成
+// */
+//@Slf4j
+//@Component
+//@AllArgsConstructor
+//public class MybatisKeyGenerator implements IKeyGenerator {
+//
+//
+//    private final DruidDataSource druidDataSource;
+//
+//    @Override
+//    public String executeSql(String incrementerName) {
+//        log.info("incrementerName:{}",incrementerName);
+//        KeyGenerator keyGenerator;
+//        String dbtype=druidDataSource.getDbType();
+//        String sql;
+//        switch (dbtype){
+//            case "oracle":
+//                if(incrementerName.indexOf("_SEQ")!=-1){
+//                    sql = "select "+ incrementerName+".nextval from dual";
+//                }else{
+//                    sql="select nvl(max(id),0)+1 from  "+incrementerName;
+//                }
+//                break;
+//            case "mysql":
+//                sql="select IFNULL(max(id),0)+1 from  "+incrementerName;
+//                break;
+//            default:
+//                sql = "";
+//        }
+//
+//        return sql;
+//    }
+//}

+ 140 - 139
common-orm-mybatisplus/src/main/java/com/tofly/mybatisplus/config/MybatisPlusConfigurer.java

@@ -1,144 +1,145 @@
-package com.tofly.mybatisplus.config;
-
-import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer;
-import com.baomidou.mybatisplus.core.MybatisConfiguration;
-import com.baomidou.mybatisplus.core.config.GlobalConfig;
-import com.baomidou.mybatisplus.extension.parsers.DynamicTableNameParser;
-import com.baomidou.mybatisplus.extension.parsers.ITableNameHandler;
-import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
-import org.apache.ibatis.mapping.DatabaseIdProvider;
-import org.apache.ibatis.mapping.VendorDatabaseIdProvider;
-import org.apache.ibatis.reflection.MetaObject;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Scope;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Properties;
-
-/**
- * @author Administrator
- * @date 2019/9/4  15:58
- */
-@Configuration
-public class MybatisPlusConfigurer {
-
-
-    @Autowired
-    private ToflyDataTypeConstant toflyDataTypeConstant;
-
-
-    /**
-     * 分页插件
-     *
-     */
-    @Bean
-    public PaginationInterceptor paginationInterceptor() {
-        PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
-        paginationInterceptor.setLimit(1000);
-
-        //增加mysql的关键字处理
-        String datatype=toflyDataTypeConstant.getDataType();
-        switch (datatype){
-            case "mysql":
-            {
-                DynamicTableNameParser dynamicTableNameParser = new DynamicTableNameParser();
-                dynamicTableNameParser.setTableNameHandlerMap(new HashMap<String, ITableNameHandler>(2) {{
-                    put("TF_SMPN_CODE_X", new ITableNameHandler() {
-                        @Override
-                        public String dynamicTableName(MetaObject metaObject, String sql, String tableName) {
-                            return null;
-                        }
-                        @Override
-                        public String process(MetaObject metaObject, String sql, String tableName) {
-//                            String dynamicTableName = this.dynamicTableName(metaObject, sql, tableName);
-//                            return null != dynamicTableName && !dynamicTableName.equalsIgnoreCase(tableName) ? sql.replaceAll(tableName, dynamicTableName) : sql;
-                            sql=sql.replaceAll(String.format("(?<=[,\\s])%s(?=[,\\s])", "key"),"`key`");
-                            sql=sql.replaceAll(String.format("(?<=[,\\s])%s(?=[,\\s])", "value"),"`value`");
-                            return sql;
-                        }
-                    });
-                }});
-                paginationInterceptor.setSqlParserList(Collections.singletonList(dynamicTableNameParser));
-            }
-            break;
-        }
-        return paginationInterceptor;
-    }
-
-
-
-    /**
-     * 自动填充功能
-     * @return
-     */
-    @Bean
-    @Scope("prototype")
-    public GlobalConfig globalConfig() {
-        GlobalConfig globalConfig = new GlobalConfig();
-        globalConfig.setMetaObjectHandler(new MybatisPlusHandler());
-
-        return globalConfig;
-    }
-
-
-    @Bean
-    public ConfigurationCustomizer mybatisConfigurationCustomizer(){
-
-        return new ConfigurationCustomizer() {
-            @Override
-            public void customize(org.apache.ibatis.session.Configuration configuration) {
-                configuration.setObjectWrapperFactory(new MapWrapperFactory());
-            }
-
-//            @Override
-//            public void customize(MybatisConfiguration configuration) {
+//package com.tofly.mybatisplus.config;
 //
-//            }
-        };
-    }
-
-    /**
-     * 数据库兼容,在mybatis里设置相应的databaseId即可
-     */
-    @Bean
-    public DatabaseIdProvider databaseIdProvider(){
-        DatabaseIdProvider databaseIdProvider=new VendorDatabaseIdProvider();
-        Properties properties=new Properties();
-        properties.setProperty("Oracle","oracle");
-        properties.setProperty("MySQL","mysql");
-        databaseIdProvider.setProperties(properties);
-        return databaseIdProvider;
-    }
-
+//import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer;
+//import com.baomidou.mybatisplus.core.MybatisConfiguration;
+//import com.baomidou.mybatisplus.core.config.GlobalConfig;
+//import com.baomidou.mybatisplus.extension.parsers.DynamicTableNameParser;
+//import com.baomidou.mybatisplus.extension.parsers.ITableNameHandler;
+//import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
+//import lombok.AllArgsConstructor;
+//import org.apache.ibatis.mapping.DatabaseIdProvider;
+//import org.apache.ibatis.mapping.VendorDatabaseIdProvider;
+//import org.apache.ibatis.reflection.MetaObject;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.context.annotation.Bean;
+//import org.springframework.context.annotation.Configuration;
+//import org.springframework.context.annotation.Scope;
+//
+//import java.util.Collections;
+//import java.util.HashMap;
+//import java.util.Properties;
+//
+///**
+// * @author Administrator
+// * @date 2019/9/4  15:58
+// */
+//@Configuration
+//@AllArgsConstructor
+//public class MybatisPlusConfigurer {
+//
+//
+//    private final ToflyDataTypeConstant toflyDataTypeConstant;
+//
+//
+//    /**
+//     * 分页插件
+//     *
+//     */
 //    @Bean
-//    public ToflySqlCondition toflySqlCondition(){
-//        ToflySqlCondition toflySqlCondition=new ToflySqlCondition();
-//        String type=druidDataSource.getDbType();
-//        if(StringUtil.isNotEmpty(type)){
-//            type=type.toLowerCase();
-//        }
-//        switch (type){
-//            case "oracle":
-//                toflySqlCondition.like = "%s LIKE '%%'||#{%s}||'%%'";
-//                break;
+//    public PaginationInterceptor paginationInterceptor() {
+//        PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
+//        paginationInterceptor.setLimit(1000);
+//
+//        //增加mysql的关键字处理
+//        String datatype=toflyDataTypeConstant.getDataType();
+//        switch (datatype){
 //            case "mysql":
-//                toflySqlCondition.like = "%s LIKE CONCAT('%%',#{%s},'%%')";
-//                break;
-//            default:
-//                toflySqlCondition.like = "%s LIKE CONCAT('%%',#{%s},'%%')";
+//            {
+//                DynamicTableNameParser dynamicTableNameParser = new DynamicTableNameParser();
+//                dynamicTableNameParser.setTableNameHandlerMap(new HashMap<String, ITableNameHandler>(2) {{
+//                    put("TF_SMPN_CODE_X", new ITableNameHandler() {
+//                        @Override
+//                        public String dynamicTableName(MetaObject metaObject, String sql, String tableName) {
+//                            return null;
+//                        }
+//                        @Override
+//                        public String process(MetaObject metaObject, String sql, String tableName) {
+////                            String dynamicTableName = this.dynamicTableName(metaObject, sql, tableName);
+////                            return null != dynamicTableName && !dynamicTableName.equalsIgnoreCase(tableName) ? sql.replaceAll(tableName, dynamicTableName) : sql;
+//                            sql=sql.replaceAll(String.format("(?<=[,\\s])%s(?=[,\\s])", "key"),"`key`");
+//                            sql=sql.replaceAll(String.format("(?<=[,\\s])%s(?=[,\\s])", "value"),"`value`");
+//                            return sql;
+//                        }
+//                    });
+//                }});
+//                paginationInterceptor.setSqlParserList(Collections.singletonList(dynamicTableNameParser));
+//            }
+//            break;
 //        }
-//        return toflySqlCondition;
+//        return paginationInterceptor;
 //    }
-
-    /* *//**
-     * oracle 配置自增
-     * @return
-     *//*
-    @Bean
-    public OracleKeyGenerator oracleKeyGenerator(){
-        return new OracleKeyGenerator();
-    }*/
-}
+//
+//
+//
+//    /**
+//     * 自动填充功能
+//     * @return
+//     */
+//    @Bean
+//    @Scope("prototype")
+//    public GlobalConfig globalConfig() {
+//        GlobalConfig globalConfig = new GlobalConfig();
+//        globalConfig.setMetaObjectHandler(new MybatisPlusHandler());
+//
+//        return globalConfig;
+//    }
+//
+//
+//    @Bean
+//    public ConfigurationCustomizer mybatisConfigurationCustomizer(){
+//
+//        return new ConfigurationCustomizer() {
+//            @Override
+//            public void customize(org.apache.ibatis.session.Configuration configuration) {
+//                configuration.setObjectWrapperFactory(new MapWrapperFactory());
+//            }
+//
+////            @Override
+////            public void customize(MybatisConfiguration configuration) {
+////
+////            }
+//        };
+//    }
+//
+//    /**
+//     * 数据库兼容,在mybatis里设置相应的databaseId即可
+//     */
+//    @Bean
+//    public DatabaseIdProvider databaseIdProvider(){
+//        DatabaseIdProvider databaseIdProvider=new VendorDatabaseIdProvider();
+//        Properties properties=new Properties();
+//        properties.setProperty("Oracle","oracle");
+//        properties.setProperty("MySQL","mysql");
+//        databaseIdProvider.setProperties(properties);
+//        return databaseIdProvider;
+//    }
+//
+////    @Bean
+////    public ToflySqlCondition toflySqlCondition(){
+////        ToflySqlCondition toflySqlCondition=new ToflySqlCondition();
+////        String type=druidDataSource.getDbType();
+////        if(StringUtil.isNotEmpty(type)){
+////            type=type.toLowerCase();
+////        }
+////        switch (type){
+////            case "oracle":
+////                toflySqlCondition.like = "%s LIKE '%%'||#{%s}||'%%'";
+////                break;
+////            case "mysql":
+////                toflySqlCondition.like = "%s LIKE CONCAT('%%',#{%s},'%%')";
+////                break;
+////            default:
+////                toflySqlCondition.like = "%s LIKE CONCAT('%%',#{%s},'%%')";
+////        }
+////        return toflySqlCondition;
+////    }
+//
+//    /* *//**
+//     * oracle 配置自增
+//     * @return
+//     *//*
+//    @Bean
+//    public OracleKeyGenerator oracleKeyGenerator(){
+//        return new OracleKeyGenerator();
+//    }*/
+//}

+ 5 - 18
common-orm-mybatisplus/src/main/java/com/tofly/mybatisplus/config/MybatisPlusHandler.java

@@ -26,21 +26,11 @@ public class MybatisPlusHandler implements MetaObjectHandler {
 
         ToflyUser toflyUser= SecurityUtils.getUser();
         this.setFieldValByName(CommonConstants.createTimeField, DateUtil.getCurrentTime(), metaObject);
-        this.setFieldValByName(CommonConstants.creatLastTimeField, DateUtil.getCurrentTime(), metaObject);
         this.setFieldValByName(CommonConstants.updateTimeField, DateUtil.getCurrentTime(), metaObject);
-        this.setFieldValByName(CommonConstants.changeDateField, DateUtil.getCurrentTime(), metaObject);
-        this.setFieldValByName(CommonConstants.createDateField, DateUtil.getCurrentTime(), metaObject);
-        this.setFieldValByName(CommonConstants.CREATEDATE, DateUtil.getCurrentTime(), metaObject);
         if(toflyUser!=null){
-            this.setFieldValByName(CommonConstants.PARENT_COMPANY_ID,toflyUser.getParentCompanyId(),metaObject);
-            this.setFieldValByName(CommonConstants.COMPANY_ID,toflyUser.getCompanyId(),metaObject);
-            this.setFieldValByName(CommonConstants.createUserIdField, toflyUser.getUserid(), metaObject);
-            this.setFieldValByName(CommonConstants.CREATORID, toflyUser.getUserid(), metaObject);
-            if(metaObject.hasGetter(CommonConstants.UserIdField) && metaObject.getValue(CommonConstants.UserIdField)==null){
-                this.setFieldValByName(CommonConstants.UserIdField, toflyUser.getUserid(), metaObject);
-            }
-            this.setFieldValByName(CommonConstants.updateUserIdField, toflyUser.getUserid(), metaObject);
-            this.setFieldValByName(CommonConstants.changeUserIdField, toflyUser.getUserid(), metaObject);
+            this.setFieldValByName(CommonConstants.TENEANT_ID,toflyUser.getTenantId(),metaObject);
+            this.setFieldValByName(CommonConstants.createUserIdField, toflyUser.getId(), metaObject);
+            this.setFieldValByName(CommonConstants.updateUserIdField, toflyUser.getId(), metaObject);
         }
     }
 
@@ -52,12 +42,9 @@ public class MybatisPlusHandler implements MetaObjectHandler {
     public void updateFill(MetaObject metaObject) {
         ToflyUser toflyUser= SecurityUtils.getUser();
         this.setFieldValByName(CommonConstants.updateTimeField, DateUtil.getCurrentTime(), metaObject);
-        this.setFieldValByName(CommonConstants.updateLastTimeField, DateUtil.getCurrentTime(), metaObject);
-        this.setFieldValByName(CommonConstants.changeDateField, DateUtil.getCurrentTime(), metaObject);
         if(toflyUser!=null){
-            this.setFieldValByName(CommonConstants.updateUserIdField, toflyUser.getUserid(), metaObject);
-            this.setFieldValByName(CommonConstants.changeUserIdField, toflyUser.getUserid(), metaObject);
+            this.setFieldValByName(CommonConstants.TENEANT_ID,toflyUser.getTenantId(),metaObject);
+            this.setFieldValByName(CommonConstants.updateUserIdField, toflyUser.getId(), metaObject);
         }
-
     }
 }

+ 46 - 44
common-orm-mybatisplus/src/main/java/com/tofly/mybatisplus/config/ToflyDataTypeConstant.java

@@ -1,44 +1,46 @@
-package com.tofly.mybatisplus.config;
-
-import com.alibaba.druid.pool.DruidDataSource;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * @author tuonbed
- * @date 2020/3/19  10:39
- */
-@Component
-public class ToflyDataTypeConstant {
-
-    @Autowired
-    private DruidDataSource druidDataSource;
-
-    public String getDataType(){
-        return druidDataSource.getDbType();
-    }
-
-    public String getNowTimeSql(){
-        String dataType=getDataType();
-        switch (dataType){
-            case "oracle":
-                return "sysdate";
-            case "mysql":
-                return "now()";
-            default:
-                return "";
-        }
-    }
-
-    public String limitSql(int end,int start){
-        String dataType=getDataType();
-        switch (dataType){
-            case "oracle":
-                return " and rownum <= "+end+" and rownum>"+start;
-            case "mysql":
-                return "limit "+start+","+end;
-            default:
-                return "";
-        }
-    }
-}
+//package com.tofly.mybatisplus.config;
+//
+//import com.alibaba.druid.pool.DruidDataSource;
+//import lombok.AllArgsConstructor;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.stereotype.Component;
+//
+///**
+// * @author tuonbed
+// * @date 2020/3/19  10:39
+// */
+//@Component
+//@AllArgsConstructor
+//public class ToflyDataTypeConstant {
+//
+//
+//    private final DruidDataSource druidDataSource;
+//
+//    public String getDataType(){
+//        return druidDataSource.getDbType();
+//    }
+//
+//    public String getNowTimeSql(){
+//        String dataType=getDataType();
+//        switch (dataType){
+//            case "oracle":
+//                return "sysdate";
+//            case "mysql":
+//                return "now()";
+//            default:
+//                return "";
+//        }
+//    }
+//
+//    public String limitSql(int end,int start){
+//        String dataType=getDataType();
+//        switch (dataType){
+//            case "oracle":
+//                return " and rownum <= "+end+" and rownum>"+start;
+//            case "mysql":
+//                return "limit "+start+","+end;
+//            default:
+//                return "";
+//        }
+//    }
+//}

+ 21 - 15
common-web/src/main/java/com/tofly/web/config/CommonControllerExceptionAdvice.java

@@ -1,8 +1,9 @@
 package com.tofly.web.config;
 
-import com.tofly.common.core.entity.ResultRespone;
+import com.tofly.common.core.result.ResultData;
 import com.tofly.common.core.util.StringUtil;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.MethodArgumentNotValidException;
 import org.springframework.web.bind.annotation.ControllerAdvice;
 import org.springframework.web.bind.annotation.ExceptionHandler;
 import org.springframework.web.bind.annotation.ResponseBody;
@@ -20,17 +21,22 @@ import java.lang.reflect.UndeclaredThrowableException;
 @Slf4j
 public class CommonControllerExceptionAdvice {
     @ExceptionHandler(value = Exception.class)
-    public ResultRespone errorHandle(Exception e){
-        String ret="";
-        if(StringUtil.isEmpty(e.getMessage())){
-            if(e instanceof UndeclaredThrowableException){
+    public ResultData errorHandle(Exception e) {
+        if (e instanceof MethodArgumentNotValidException) {
+            MethodArgumentNotValidException validException = (MethodArgumentNotValidException) e;
+            String message = validException.getBindingResult().getAllErrors().get(0).getDefaultMessage();
+            return ResultData.fail(message);
+        }
+        String ret = "";
+        if (StringUtil.isEmpty(e.getMessage())) {
+            if (e instanceof UndeclaredThrowableException) {
                 Throwable undeclaredThrowable = ((UndeclaredThrowableException) e).getUndeclaredThrowable();
-                if(undeclaredThrowable instanceof Exception){
-                    ret = ((Exception)undeclaredThrowable).getLocalizedMessage();
+                if (undeclaredThrowable instanceof Exception) {
+                    ret = ((Exception) undeclaredThrowable).getLocalizedMessage();
                 }
             }
 
-            if(StringUtil.isEmpty(ret)){
+            if (StringUtil.isEmpty(ret)) {
                 ByteArrayOutputStream out = new ByteArrayOutputStream();
                 PrintStream pout = new PrintStream(out);
                 e.printStackTrace(pout);
@@ -41,14 +47,14 @@ public class CommonControllerExceptionAdvice {
                 } catch (Exception ee) {
                 }
             }
-        }else {
-            ret=e.getMessage();
+        } else {
+            ret = e.getMessage();
         }
-        if("No AuthenticationProvider found for org.springframework.security.authentication.UsernamePasswordAuthenticationToken"
-        .equals(ret)){
-            return ResultRespone.failed("密码输入错误");
-        }else {
-            return ResultRespone.failed(ret);
+        if ("No AuthenticationProvider found for org.springframework.security.authentication.UsernamePasswordAuthenticationToken"
+                .equals(ret)) {
+            return ResultData.fail("密码输入错误");
+        } else {
+            return ResultData.fail(ret);
         }
     }
 }