This commit is contained in:
zhangchenbiao
2023-05-23 16:37:25 +08:00
parent 63505941d0
commit 799b6b8cf5
59 changed files with 1994 additions and 76 deletions

View File

@@ -21,5 +21,41 @@
<orderEntry type="library" name="Maven: xerces:xercesImpl:2.11.0" level="project" />
<orderEntry type="library" name="Maven: xml-apis:xml-apis:1.4.01" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.30" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:2.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:2.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:2.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-autoconfigure:2.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-logging:2.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.2.3" level="project" />
<orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.2.3" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-to-slf4j:2.12.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.12.1" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.30" level="project" />
<orderEntry type="library" name="Maven: jakarta.annotation:jakarta.annotation-api:1.3.5" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-core:5.2.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-jcl:5.2.5.RELEASE" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.yaml:snakeyaml:1.25" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-json:2.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.10.3" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.10.3" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.10.3" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.10.3" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.10.3" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.module:jackson-module-parameter-names:2.10.3" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-tomcat:2.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-core:9.0.33" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-el:9.0.33" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-websocket:9.0.33" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-validation:2.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: jakarta.validation:jakarta.validation-api:2.0.2" level="project" />
<orderEntry type="library" name="Maven: org.hibernate.validator:hibernate-validator:6.0.18.Final" level="project" />
<orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.4.1.Final" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml:classmate:1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-web:5.2.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-beans:5.2.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-webmvc:5.2.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-aop:5.2.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-context:5.2.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-expression:5.2.5.RELEASE" level="project" />
</component>
</module>

View File

@@ -54,6 +54,10 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -12,8 +12,16 @@ public class CommonConstants {
public static final String REQUEST_ID = "requestId";
public static final String ACCESS_TOKEN_KEY = "access_token";
public static final String REFRESH_TOKEN_KEY = "refresh_token";
public static final String DEFAULT_AVATAR = "DefaultAvatar";
public static final int ACTION_TOKEN_EXPIRE = 14400;
public static final int REFRESH_TOKEN_EXPIRE = 60*60*24*30;
public static final int ZERO = 0;
public static final int ONE = 1;
public static final int TWO = 2;

View File

@@ -0,0 +1,28 @@
package com.cool.store.enums;
/**
* @author zhangchenbiao
* @FileName: AppTypeEnum
* @Description:
* @date 2023-05-23 9:41
*/
public enum AppTypeEnum {
FEI_SHU("fei_shu", "飞书");
private String value;
private String message;
AppTypeEnum(String value, String message) {
this.value = value;
this.message = message;
}
public String getValue() {
return value;
}
public String getMessage() {
return message;
}
}

View File

@@ -28,6 +28,13 @@ public enum ErrorCodeEnum {
FAIL(400000, "FAIL", null),
ACCESS_TOKEN_INVALID(400005, "Invalid token", null),
PARAMS_VALIDATE_ERROR(400003, "参数校验失败!", null),
LOGIN_ERROR(400004, "登录失败", null),
ENTERPRISE_INIT(400006, "企业正在初始化,请稍后访问!",null),
NOT_AUTH(400007, "暂无权限,请联系管理员!", null),
USER_FREEZE(1021019,"账号被冻结,请联系管理员",null),
ENTERPRISE_NOT_EXIST(1021020,"企业不存在",null),
USER_NOT_EXIST(1021021,"用户不存在",null),
USER_WAIT_AUDIT(1021018,"账号审核中,请联系企业管理员",null),
;

View File

@@ -0,0 +1,115 @@
package com.cool.store.enums;
import lombok.Getter;
import lombok.Setter;
import javax.management.relation.Role;
import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
public enum RoleEnum {
/**
* 管理员
*/
MASTER("20000000", "管理员", 1,"master"),
/**
* 子管理员
*/
SUB_MASTER("80000000", "子管理员", 2,"sub_master"),
/**
* 普通员工
*/
EMPLOYEE("30000000", "未分配", 99999999,"employee"),
/**
* 部门负责人
*/
DEPT_LEADER("40000000", "部门负责人", 10,"dept_leader"),
/**
* 店长
*/
SHOPOWNER("50000000", "店长", 3,"shopowner"),
/**
* 运营
*/
OPERATOR("60000000", "运营", 4,"operator"),
/**
* 店员
*/
CLERK("70000000", "店员", 5,"clerk");
private static final Map<String, RoleEnum> MAP = Arrays.stream(values()).collect(
Collectors.toMap(RoleEnum::getRoleEnum, Function.identity()));
private static final Map<String, RoleEnum> ROLE_ID_MAP = Arrays.stream(values()).collect(
Collectors.toMap(RoleEnum::getId, Function.identity()));
private String id;
private String name;
@Getter
@Setter
private Integer priority;
private String roleEnum;
RoleEnum(String id, String name, Integer priority, String roleEnum) {
this.id = id;
this.name = name;
this.priority = priority;
this.roleEnum=roleEnum;
}
public String getId() {
return id;
}
public String getName() {
return name;
}
public String getRoleEnum() {
return roleEnum;
}
public static RoleEnum getByCode(String code) {
return MAP.get(code);
}
/**
* 是否是管理员 及 子管理员
* @param code
* @return
*/
public static boolean isAdmin(String code){
if(MASTER.getRoleEnum().equals(code) || SUB_MASTER.getRoleEnum().equals(code)){
return true;
}
return false;
}
/**
* 根据id 判断 是否是管理员 及 子管理员
* @param id
* @return
*/
public static boolean isAdminById(String id){
if(MASTER.getId().equals(id) || SUB_MASTER.getId().equals(id)){
return true;
}
return false;
}
/**
* 是否包含角色id
* @param roleId
* @return
*/
public static boolean isContainsRoleId(String roleId){
return ROLE_ID_MAP.containsKey(roleId);
}
}

View File

@@ -0,0 +1,52 @@
package com.cool.store.enums;
/**
* @author zhangchenbiao
* @FileName: UserStatusEnum
* @Description: 用户状态枚举
* @date 2021-07-19 16:27
*/
public enum UserStatusEnum {
//用户状态 0待审核 1正常 2冻结
WAIT_AUDIT(0,"待审核"),
NORMAL(1,"正常"),
FREEZE(2, "冻结")
;
private Integer code;
private String message;
UserStatusEnum(Integer code, String message) {
this.code = code;
this.message = message;
}
public Integer getCode() {
return code;
}
public String getMessage() {
return message;
}
public static String getMessageByCode(Integer code){
for(UserStatusEnum Enum: UserStatusEnum.values()){
if(Enum.code.equals(code)){
return Enum.message;
}
}
return null;
}
public static Integer getCodeByMessage(String message){
for(UserStatusEnum Enum: UserStatusEnum.values()){
if(Enum.message.equals(message)){
return Enum.code;
}
}
return null;
}
}

View File

@@ -0,0 +1,637 @@
package com.cool.store.utils;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;
import java.util.Map;
/**
*
*/
public class RestTemplateUtil {
private static final RestTemplate restTemplate = new RestTemplate();
// ----------------------------------GET-------------------------------------------------------
/**
* GET请求调用方式
*
* @param url 请求URL
* @param responseType 返回对象类型
* @return ResponseEntity 响应对象封装类
*/
public static <T> ResponseEntity<T> get(String url, Class<T> responseType) {
return restTemplate.getForEntity(url, responseType);
}
/**
* 负载均衡请求
*/
public static <T> ResponseEntity<T> loadGet(String url, Class<T> responseType) {
return getLoadBalanceTemplate().getForEntity(url, responseType);
}
/**
* GET请求调用方式
*
* @param url 请求URL
* @param responseType 返回对象类型
* @param uriVariables URL中的变量按顺序依次对应
* @return ResponseEntity 响应对象封装类
*/
public static <T> ResponseEntity<T> get(String url, Class<T> responseType, Object... uriVariables) {
return restTemplate.getForEntity(url, responseType, uriVariables);
}
/**
* GET请求调用方式
*
* @param url 请求URL
* @param responseType 返回对象类型
* @param uriVariables URL中的变量与Map中的key对应
* @return ResponseEntity 响应对象封装类
*/
public static <T> ResponseEntity<T> get(String url, Class<T> responseType, Map<String, ?> uriVariables) {
return restTemplate.getForEntity(url, responseType, uriVariables);
}
/**
* 带请求头的GET请求调用方式
*
* @param url 请求URL
* @param headers 请求头参数
* @param responseType 返回对象类型
* @param uriVariables URL中的变量按顺序依次对应
* @return ResponseEntity 响应对象封装类
*/
public static <T> ResponseEntity<T> get(String url, Map<String, String> headers, Class<T> responseType, Object... uriVariables) {
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setAll(headers);
return get(url, httpHeaders, responseType, uriVariables);
}
/**
* 带请求头的GET请求调用方式
*
* @param url 请求URL
* @param headers 请求头参数
* @param responseType 返回对象类型
* @param uriVariables URL中的变量按顺序依次对应
* @return ResponseEntity 响应对象封装类
*/
public static <T> ResponseEntity<T> get(String url, HttpHeaders headers, Class<T> responseType, Object... uriVariables) {
HttpEntity<?> requestEntity = new HttpEntity<>(headers);
return exchange(url, HttpMethod.GET, requestEntity, responseType, uriVariables);
}
/**
* 带请求头的GET请求调用方式
*
* @param url 请求URL
* @param headers 请求头参数
* @param responseType 返回对象类型
* @param uriVariables URL中的变量与Map中的key对应
* @return ResponseEntity 响应对象封装类
*/
public static <T> ResponseEntity<T> get(String url, Map<String, String> headers, Class<T> responseType, Map<String, ?> uriVariables) {
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setAll(headers);
return get(url, httpHeaders, responseType, uriVariables);
}
/**
* 带请求头的GET请求调用方式
*
* @param url 请求URL
* @param headers 请求头参数
* @param responseType 返回对象类型
* @param uriVariables URL中的变量与Map中的key对应
* @return ResponseEntity 响应对象封装类
*/
public static <T> ResponseEntity<T> get(String url, HttpHeaders headers, Class<T> responseType, Map<String, ?> uriVariables) {
HttpEntity<?> requestEntity = new HttpEntity<>(headers);
return exchange(url, HttpMethod.GET, requestEntity, responseType, uriVariables);
}
// ----------------------------------POST-------------------------------------------------------
/**
* POST请求调用方式
*
* @param url 请求URL
* @param responseType 返回对象类型
* @return
*/
public static <T> ResponseEntity<T> post(String url, Class<T> responseType) {
return restTemplate.postForEntity(url, HttpEntity.EMPTY, responseType);
}
/**
* POST请求调用方式
*
* @param url 请求URL
* @param requestBody 请求参数体
* @param responseType 返回对象类型
* @return ResponseEntity 响应对象封装类
*/
public static <T> ResponseEntity<T> post(String url, Object requestBody, Class<T> responseType) {
return restTemplate.postForEntity(url, requestBody, responseType);
}
public static <T> ResponseEntity<T> loadPost(String url, Object requestBody, Class<T> responseType) {
return getLoadBalanceTemplate().postForEntity(url, requestBody, responseType);
}
/**
* POST请求调用方式
*
* @param url 请求URL
* @param requestBody 请求参数体
* @param responseType 返回对象类型
* @param uriVariables URL中的变量按顺序依次对应
* @return ResponseEntity 响应对象封装类
*/
public static <T> ResponseEntity<T> post(String url, Object requestBody, Class<T> responseType, Object... uriVariables) {
return restTemplate.postForEntity(url, requestBody, responseType, uriVariables);
}
/**
* POST请求调用方式
*
* @param url 请求URL
* @param requestBody 请求参数体
* @param responseType 返回对象类型
* @param uriVariables URL中的变量与Map中的key对应
* @return ResponseEntity 响应对象封装类
*/
public static <T> ResponseEntity<T> post(String url, Object requestBody, Class<T> responseType, Map<String, ?> uriVariables) {
return restTemplate.postForEntity(url, requestBody, responseType, uriVariables);
}
/**
* 带请求头的POST请求调用方式
*
* @param url 请求URL
* @param headers 请求头参数
* @param requestBody 请求参数体
* @param responseType 返回对象类型
* @param uriVariables URL中的变量按顺序依次对应
* @return ResponseEntity 响应对象封装类
*/
public static <T> ResponseEntity<T> post(String url, Map<String, String> headers, Object requestBody, Class<T> responseType, Object... uriVariables) {
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setAll(headers);
return post(url, httpHeaders, requestBody, responseType, uriVariables);
}
/**
* 带请求头的POST请求调用方式
*
* @param url 请求URL
* @param headers 请求头参数
* @param requestBody 请求参数体
* @param responseType 返回对象类型
* @param uriVariables URL中的变量按顺序依次对应
* @return ResponseEntity 响应对象封装类
*/
public static <T> ResponseEntity<T> post(String url, HttpHeaders headers, Object requestBody, Class<T> responseType, Object... uriVariables) {
HttpEntity<Object> requestEntity = new HttpEntity<>(requestBody, headers);
return post(url, requestEntity, responseType, uriVariables);
}
/**
* 带请求头的POST请求调用方式
*
* @param url 请求URL
* @param headers 请求头参数
* @param requestBody 请求参数体
* @param responseType 返回对象类型
* @param uriVariables URL中的变量与Map中的key对应
* @return ResponseEntity 响应对象封装类
*/
public static <T> ResponseEntity<T> post(String url, Map<String, String> headers, Object requestBody, Class<T> responseType, Map<String, ?> uriVariables) {
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setAll(headers);
return post(url, httpHeaders, requestBody, responseType, uriVariables);
}
/**
* 带请求头的POST请求调用方式
*
* @param url 请求URL
* @param headers 请求头参数
* @param requestBody 请求参数体
* @param responseType 返回对象类型
* @param uriVariables URL中的变量与Map中的key对应
* @return ResponseEntity 响应对象封装类
*/
public static <T> ResponseEntity<T> post(String url, HttpHeaders headers, Object requestBody, Class<T> responseType, Map<String, ?> uriVariables) {
HttpEntity<Object> requestEntity = new HttpEntity<>(requestBody, headers);
return post(url, requestEntity, responseType, uriVariables);
}
/**
* 自定义请求头和请求体的POST请求调用方式
*
* @param url 请求URL
* @param requestEntity 请求头和请求体封装对象
* @param responseType 返回对象类型
* @param uriVariables URL中的变量按顺序依次对应
* @return ResponseEntity 响应对象封装类
*/
public static <T> ResponseEntity<T> post(String url, HttpEntity<?> requestEntity, Class<T> responseType, Object... uriVariables) {
return restTemplate.exchange(url, HttpMethod.POST, requestEntity, responseType, uriVariables);
}
/**
* 自定义请求头和请求体的POST请求调用方式
*
* @param url 请求URL
* @param requestEntity 请求头和请求体封装对象
* @param responseType 返回对象类型
* @param uriVariables URL中的变量与Map中的key对应
* @return ResponseEntity 响应对象封装类
*/
public static <T> ResponseEntity<T> post(String url, HttpEntity<?> requestEntity, Class<T> responseType, Map<String, ?> uriVariables) {
return restTemplate.exchange(url, HttpMethod.POST, requestEntity, responseType, uriVariables);
}
// ----------------------------------PUT-------------------------------------------------------
/**
* PUT请求调用方式
*
* @param url 请求URL
* @param responseType 返回对象类型
* @param uriVariables URL中的变量按顺序依次对应
* @return ResponseEntity 响应对象封装类
*/
public static <T> ResponseEntity<T> put(String url, Class<T> responseType, Object... uriVariables) {
return put(url, HttpEntity.EMPTY, responseType, uriVariables);
}
/**
* PUT请求调用方式
*
* @param url 请求URL
* @param requestBody 请求参数体
* @param responseType 返回对象类型
* @param uriVariables URL中的变量按顺序依次对应
* @return ResponseEntity 响应对象封装类
*/
public static <T> ResponseEntity<T> put(String url, Object requestBody, Class<T> responseType, Object... uriVariables) {
HttpEntity<Object> requestEntity = new HttpEntity<>(requestBody);
return put(url, requestEntity, responseType, uriVariables);
}
/**
* PUT请求调用方式
*
* @param url 请求URL
* @param requestBody 请求参数体
* @param responseType 返回对象类型
* @param uriVariables URL中的变量与Map中的key对应
* @return ResponseEntity 响应对象封装类
*/
public static <T> ResponseEntity<T> put(String url, Object requestBody, Class<T> responseType, Map<String, ?> uriVariables) {
HttpEntity<Object> requestEntity = new HttpEntity<>(requestBody);
return put(url, requestEntity, responseType, uriVariables);
}
/**
* 带请求头的PUT请求调用方式
*
* @param url 请求URL
* @param headers 请求头参数
* @param requestBody 请求参数体
* @param responseType 返回对象类型
* @param uriVariables URL中的变量按顺序依次对应
* @return ResponseEntity 响应对象封装类
*/
public static <T> ResponseEntity<T> put(String url, Map<String, String> headers, Object requestBody, Class<T> responseType, Object... uriVariables) {
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setAll(headers);
return put(url, httpHeaders, requestBody, responseType, uriVariables);
}
/**
* 带请求头的PUT请求调用方式
*
* @param url 请求URL
* @param headers 请求头参数
* @param requestBody 请求参数体
* @param responseType 返回对象类型
* @param uriVariables URL中的变量按顺序依次对应
* @return ResponseEntity 响应对象封装类
*/
public static <T> ResponseEntity<T> put(String url, HttpHeaders headers, Object requestBody, Class<T> responseType, Object... uriVariables) {
HttpEntity<Object> requestEntity = new HttpEntity<>(requestBody, headers);
return put(url, requestEntity, responseType, uriVariables);
}
/**
* 带请求头的PUT请求调用方式
*
* @param url 请求URL
* @param headers 请求头参数
* @param requestBody 请求参数体
* @param responseType 返回对象类型
* @param uriVariables URL中的变量与Map中的key对应
* @return ResponseEntity 响应对象封装类
*/
public static <T> ResponseEntity<T> put(String url, Map<String, String> headers, Object requestBody, Class<T> responseType, Map<String, ?> uriVariables) {
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setAll(headers);
return put(url, httpHeaders, requestBody, responseType, uriVariables);
}
/**
* 带请求头的PUT请求调用方式
*
* @param url 请求URL
* @param headers 请求头参数
* @param requestBody 请求参数体
* @param responseType 返回对象类型
* @param uriVariables URL中的变量与Map中的key对应
* @return ResponseEntity 响应对象封装类
*/
public static <T> ResponseEntity<T> put(String url, HttpHeaders headers, Object requestBody, Class<T> responseType, Map<String, ?> uriVariables) {
HttpEntity<Object> requestEntity = new HttpEntity<>(requestBody, headers);
return put(url, requestEntity, responseType, uriVariables);
}
/**
* 自定义请求头和请求体的PUT请求调用方式
*
* @param url 请求URL
* @param requestEntity 请求头和请求体封装对象
* @param responseType 返回对象类型
* @param uriVariables URL中的变量按顺序依次对应
* @return ResponseEntity 响应对象封装类
*/
public static <T> ResponseEntity<T> put(String url, HttpEntity<?> requestEntity, Class<T> responseType, Object... uriVariables) {
return restTemplate.exchange(url, HttpMethod.PUT, requestEntity, responseType, uriVariables);
}
/**
* 自定义请求头和请求体的PUT请求调用方式
*
* @param url 请求URL
* @param requestEntity 请求头和请求体封装对象
* @param responseType 返回对象类型
* @param uriVariables URL中的变量与Map中的key对应
* @return ResponseEntity 响应对象封装类
*/
public static <T> ResponseEntity<T> put(String url, HttpEntity<?> requestEntity, Class<T> responseType, Map<String, ?> uriVariables) {
return restTemplate.exchange(url, HttpMethod.PUT, requestEntity, responseType, uriVariables);
}
// ----------------------------------DELETE-------------------------------------------------------
/**
* DELETE请求调用方式
*
* @param url 请求URL
* @param responseType 返回对象类型
* @param uriVariables URL中的变量按顺序依次对应
* @return ResponseEntity 响应对象封装类
*/
public static <T> ResponseEntity<T> delete(String url, Class<T> responseType, Object... uriVariables) {
return delete(url, HttpEntity.EMPTY, responseType, uriVariables);
}
/**
* DELETE请求调用方式
*
* @param url 请求URL
* @param responseType 返回对象类型
* @param uriVariables URL中的变量与Map中的key对应
* @return ResponseEntity 响应对象封装类
*/
public static <T> ResponseEntity<T> delete(String url, Class<T> responseType, Map<String, ?> uriVariables) {
return delete(url, HttpEntity.EMPTY, responseType, uriVariables);
}
/**
* DELETE请求调用方式
*
* @param url 请求URL
* @param requestBody 请求参数体
* @param responseType 返回对象类型
* @param uriVariables URL中的变量按顺序依次对应
* @return ResponseEntity 响应对象封装类
*/
public static <T> ResponseEntity<T> delete(String url, Object requestBody, Class<T> responseType, Object... uriVariables) {
HttpEntity<Object> requestEntity = new HttpEntity<>(requestBody);
return delete(url, requestEntity, responseType, uriVariables);
}
/**
* DELETE请求调用方式
*
* @param url 请求URL
* @param requestBody 请求参数体
* @param responseType 返回对象类型
* @param uriVariables URL中的变量与Map中的key对应
* @return ResponseEntity 响应对象封装类
*/
public static <T> ResponseEntity<T> delete(String url, Object requestBody, Class<T> responseType, Map<String, ?> uriVariables) {
HttpEntity<Object> requestEntity = new HttpEntity<>(requestBody);
return delete(url, requestEntity, responseType, uriVariables);
}
/**
* 带请求头的DELETE请求调用方式
*
* @param url 请求URL
* @param headers 请求头参数
* @param responseType 返回对象类型
* @param uriVariables URL中的变量按顺序依次对应
* @return ResponseEntity 响应对象封装类
*/
public static <T> ResponseEntity<T> delete(String url, Map<String, String> headers, Class<T> responseType, Object... uriVariables) {
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setAll(headers);
return delete(url, httpHeaders, responseType, uriVariables);
}
/**
* 带请求头的DELETE请求调用方式
*
* @param url 请求URL
* @param headers 请求头参数
* @param responseType 返回对象类型
* @param uriVariables URL中的变量按顺序依次对应
* @return ResponseEntity 响应对象封装类
*/
public static <T> ResponseEntity<T> delete(String url, HttpHeaders headers, Class<T> responseType, Object... uriVariables) {
HttpEntity<Object> requestEntity = new HttpEntity<>(headers);
return delete(url, requestEntity, responseType, uriVariables);
}
/**
* 带请求头的DELETE请求调用方式
*
* @param url 请求URL
* @param headers 请求头参数
* @param responseType 返回对象类型
* @param uriVariables URL中的变量与Map中的key对应
* @return ResponseEntity 响应对象封装类
*/
public static <T> ResponseEntity<T> delete(String url, Map<String, String> headers, Class<T> responseType, Map<String, ?> uriVariables) {
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setAll(headers);
return delete(url, httpHeaders, responseType, uriVariables);
}
/**
* 带请求头的DELETE请求调用方式
*
* @param url 请求URL
* @param headers 请求头参数
* @param responseType 返回对象类型
* @param uriVariables URL中的变量与Map中的key对应
* @return ResponseEntity 响应对象封装类
*/
public static <T> ResponseEntity<T> delete(String url, HttpHeaders headers, Class<T> responseType, Map<String, ?> uriVariables) {
HttpEntity<Object> requestEntity = new HttpEntity<>(headers);
return delete(url, requestEntity, responseType, uriVariables);
}
/**
* 带请求头的DELETE请求调用方式
*
* @param url 请求URL
* @param headers 请求头参数
* @param requestBody 请求参数体
* @param responseType 返回对象类型
* @param uriVariables URL中的变量按顺序依次对应
* @return ResponseEntity 响应对象封装类
*/
public static <T> ResponseEntity<T> delete(String url, Map<String, String> headers, Object requestBody, Class<T> responseType, Object... uriVariables) {
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setAll(headers);
return delete(url, httpHeaders, requestBody, responseType, uriVariables);
}
/**
* 带请求头的DELETE请求调用方式
*
* @param url 请求URL
* @param headers 请求头参数
* @param requestBody 请求参数体
* @param responseType 返回对象类型
* @param uriVariables URL中的变量按顺序依次对应
* @return ResponseEntity 响应对象封装类
*/
public static <T> ResponseEntity<T> delete(String url, HttpHeaders headers, Object requestBody, Class<T> responseType, Object... uriVariables) {
HttpEntity<Object> requestEntity = new HttpEntity<>(requestBody, headers);
return delete(url, requestEntity, responseType, uriVariables);
}
/**
* 带请求头的DELETE请求调用方式
*
* @param url 请求URL
* @param headers 请求头参数
* @param requestBody 请求参数体
* @param responseType 返回对象类型
* @param uriVariables URL中的变量与Map中的key对应
* @return ResponseEntity 响应对象封装类
*/
public static <T> ResponseEntity<T> delete(String url, Map<String, String> headers, Object requestBody, Class<T> responseType, Map<String, ?> uriVariables) {
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setAll(headers);
return delete(url, httpHeaders, requestBody, responseType, uriVariables);
}
/**
* 带请求头的DELETE请求调用方式
*
* @param url 请求URL
* @param headers 请求头参数
* @param requestBody 请求参数体
* @param responseType 返回对象类型
* @param uriVariables URL中的变量与Map中的key对应
* @return ResponseEntity 响应对象封装类
*/
public static <T> ResponseEntity<T> delete(String url, HttpHeaders headers, Object requestBody, Class<T> responseType, Map<String, ?> uriVariables) {
HttpEntity<Object> requestEntity = new HttpEntity<>(requestBody, headers);
return delete(url, requestEntity, responseType, uriVariables);
}
/**
* 自定义请求头和请求体的DELETE请求调用方式
*
* @param url 请求URL
* @param requestEntity 请求头和请求体封装对象
* @param responseType 返回对象类型
* @param uriVariables URL中的变量按顺序依次对应
* @return ResponseEntity 响应对象封装类
*/
public static <T> ResponseEntity<T> delete(String url, HttpEntity<?> requestEntity, Class<T> responseType, Object... uriVariables) {
return restTemplate.exchange(url, HttpMethod.DELETE, requestEntity, responseType, uriVariables);
}
/**
* 自定义请求头和请求体的DELETE请求调用方式
*
* @param url 请求URL
* @param requestEntity 请求头和请求体封装对象
* @param responseType 返回对象类型
* @param uriVariables URL中的变量与Map中的key对应
* @return ResponseEntity 响应对象封装类
*/
public static <T> ResponseEntity<T> delete(String url, HttpEntity<?> requestEntity, Class<T> responseType, Map<String, ?> uriVariables) {
return restTemplate.exchange(url, HttpMethod.DELETE, requestEntity, responseType, uriVariables);
}
// ----------------------------------通用方法-------------------------------------------------------
/**
* 通用调用方式
*
* @param url 请求URL
* @param method 请求方法类型
* @param requestEntity 请求头和请求体封装对象
* @param responseType 返回对象类型
* @param uriVariables URL中的变量按顺序依次对应
* @return ResponseEntity 响应对象封装类
*/
public static <T> ResponseEntity<T> exchange(String url, HttpMethod method, HttpEntity<?> requestEntity, Class<T> responseType, Object... uriVariables) {
return restTemplate.exchange(url, method, requestEntity, responseType, uriVariables);
}
/**
* 通用调用方式
*
* @param url 请求URL
* @param method 请求方法类型
* @param requestEntity 请求头和请求体封装对象
* @param responseType 返回对象类型
* @param uriVariables URL中的变量与Map中的key对应
* @return ResponseEntity 响应对象封装类
*/
public static <T> ResponseEntity<T> exchange(String url, HttpMethod method, HttpEntity<?> requestEntity, Class<T> responseType, Map<String, ?> uriVariables) {
return restTemplate.exchange(url, method, requestEntity, responseType, uriVariables);
}
/**
* 获取RestTemplate实例对象可自由调用其方法
*
* @return RestTemplate实例对象
*/
public static RestTemplate getRestTemplate() {
return restTemplate;
}
public static RestTemplate getLoadBalanceTemplate() {
return SpringContextHolder.getBean(RestTemplate.class);
}
}

View File

@@ -0,0 +1,27 @@
package com.cool.store.utils;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
/**
*
* @author xingfeng
* @date 2018/11/26
*/
@Component
public class SpringContextHolder implements ApplicationContextAware {
private static ApplicationContext applicationContext;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
SpringContextHolder.applicationContext = applicationContext;
}
public static <T> T getBean(Class<T> clz){
return applicationContext.getBean(clz);
}
}

View File

@@ -20,7 +20,6 @@
<orderEntry type="library" name="Maven: com.github.xiaoymin:knife4j-core:2.0.4" level="project" />
<orderEntry type="library" name="Maven: org.javassist:javassist:3.25.0-GA" level="project" />
<orderEntry type="library" name="Maven: io.swagger:swagger-models:1.5.22" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.10.3" level="project" />
<orderEntry type="library" name="Maven: io.swagger:swagger-annotations:1.5.22" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger2:2.9.2" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-spi:2.9.2" level="project" />
@@ -30,7 +29,6 @@
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger-common:2.9.2" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-spring-web:2.9.2" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:20.0" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml:classmate:1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-core:1.2.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-metadata:1.2.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.mapstruct:mapstruct:1.2.0.Final" level="project" />
@@ -40,8 +38,6 @@
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:2.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:2.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-context:5.2.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-aop:5.2.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-expression:5.2.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-logging:2.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.2.3" level="project" />
<orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.2.3" level="project" />
@@ -67,6 +63,27 @@
<orderEntry type="library" name="Maven: xerces:xercesImpl:2.11.0" level="project" />
<orderEntry type="library" name="Maven: xml-apis:xml-apis:1.4.01" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.30" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:2.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-json:2.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.10.3" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.10.3" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.10.3" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.10.3" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.10.3" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.module:jackson-module-parameter-names:2.10.3" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-tomcat:2.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-core:9.0.33" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-el:9.0.33" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-websocket:9.0.33" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-validation:2.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: jakarta.validation:jakarta.validation-api:2.0.2" level="project" />
<orderEntry type="library" name="Maven: org.hibernate.validator:hibernate-validator:6.0.18.Final" level="project" />
<orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.4.1.Final" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml:classmate:1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-web:5.2.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-webmvc:5.2.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-aop:5.2.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-expression:5.2.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: mysql:mysql-connector-java:8.0.18" level="project" />
<orderEntry type="library" name="Maven: com.google.protobuf:protobuf-java:3.6.1" level="project" />
<orderEntry type="library" name="Maven: com.alibaba:druid-spring-boot-starter:1.1.20" level="project" />

View File

@@ -39,6 +39,13 @@ public class EnterpriseConfigDAO {
return enterpriseConfigMapper.getDistinctDbServer();
}
public EnterpriseConfigDO getConfigByCorpIdAndAppType(String corpId, String appType){
if(StringUtils.isAnyBlank(corpId, appType)){
return null;
}
return enterpriseConfigMapper.getConfigByCorpIdAndAppType(corpId, appType);
}
}

View File

@@ -0,0 +1,30 @@
package com.cool.store.dao;
import com.cool.store.mapper.EnterpriseMapper;
import com.cool.store.model.entity.EnterpriseDO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* @author zhangchenbiao
* @FileName: EnterpriseDAO
* @Description:
* @date 2023-05-23 13:52
*/
@Service
public class EnterpriseDAO {
@Resource
private EnterpriseMapper enterpriseMapper;
public EnterpriseDO getEnterpriseById(String enterpriseId){
if(StringUtils.isBlank(enterpriseId)){
return null;
}
return enterpriseMapper.getEnterpriseById(enterpriseId);
}
}

View File

@@ -1,7 +1,12 @@
package com.cool.store.dao;
import com.cool.store.entity.EnterpriseUserDO;
import com.cool.store.mapper.EnterpriseUserMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* @author zhangchenbiao
* @date 2023-05-19 02:58
@@ -9,4 +14,15 @@ import org.springframework.stereotype.Service;
@Service
public class EnterpriseUserDAO {
@Resource
private EnterpriseUserMapper enterpriseUserMapper;
public EnterpriseUserDO getUserInfoById(String enterpriseId, String userId){
if(StringUtils.isAnyBlank(enterpriseId, userId)){
return null;
}
return enterpriseUserMapper.getUserInfoById(enterpriseId, userId);
}
}

View File

@@ -0,0 +1,28 @@
package com.cool.store.dao;
import com.cool.store.mapper.LoginRecordMapper;
import com.cool.store.model.entity.LoginRecordDO;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* @author zhangchenbiao
* @FileName: LoginRecordDAO
* @Description:
* @date 2023-05-23 15:48
*/
@Service
public class LoginRecordDAO {
@Resource
private LoginRecordMapper loginRecordMapper;
public void addLoginRecord(String enterpriseId, String userId){
LoginRecordDO record = new LoginRecordDO();
record.setUserId(userId);
record.setCreateTime(System.currentTimeMillis());
loginRecordMapper.insertSelective(record, enterpriseId);
}
}

View File

@@ -1,7 +1,12 @@
package com.cool.store.dao;
import com.cool.store.entity.SysRoleDO;
import com.cool.store.mapper.SysRoleMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* @author zhangchenbiao
* @date 2023-05-19 03:00
@@ -9,4 +14,20 @@ import org.springframework.stereotype.Service;
@Service
public class SysRoleDAO {
@Resource
private SysRoleMapper sysRoleMapper;
/**
* 获取高优先级的角色
* @param enterpriseId
* @param userId
* @return
*/
public SysRoleDO getHighestPrioritySysRoleDoByUserId(String enterpriseId, String userId){
if(StringUtils.isAnyBlank(enterpriseId, userId)){
return null;
}
return sysRoleMapper.getHighestPrioritySysRoleDoByUserId(enterpriseId, userId);
}
}

View File

@@ -31,4 +31,12 @@ public interface EnterpriseConfigMapper {
*/
EnterpriseConfigDO getDbInfoByDbName(@Param("dbName")String dbName);
/**
* 根据corpId 和 appType 获取config信息
* @param corpId
* @param appType
* @return
*/
EnterpriseConfigDO getConfigByCorpIdAndAppType(@Param("corpId")String corpId, @Param("appType")String appType);
}

View File

@@ -0,0 +1,32 @@
package com.cool.store.mapper;
import com.cool.store.model.entity.EnterpriseDO;
import org.apache.ibatis.annotations.Param;
/**
* @author zhangchenbiao
* @date 2023-05-23 11:36
*/
public interface EnterpriseMapper {
/**
*
* 默认插入方法,只会给有值的字段赋值
* 会对传进来的字段做判空处理如果字段为空则使用数据库默认字段或者null
* dateTime:2023-05-23 11:36
*/
int insertSelective(EnterpriseDO record);
/**
*
* 默认更新方法根据主键更新不会把null值更新到数据库避免覆盖之前有值的
* dateTime:2023-05-23 11:36
*/
int updateByPrimaryKeySelective(EnterpriseDO record);
/**
* 获取企业信息
* @param enterpriseId
* @return
*/
EnterpriseDO getEnterpriseById(@Param("enterpriseId") String enterpriseId);
}

View File

@@ -22,4 +22,12 @@ public interface EnterpriseUserMapper {
* dateTime:2023-05-19 02:58
*/
int updateByPrimaryKeySelective(@Param("record") EnterpriseUserDO record, @Param("enterpriseId") String enterpriseId);
/**
*
* @param enterpriseId
* @param userId
* @return
*/
EnterpriseUserDO getUserInfoById(@Param("enterpriseId")String enterpriseId, @Param("userId")String userId);
}

View File

@@ -0,0 +1,25 @@
package com.cool.store.mapper;
import com.cool.store.model.entity.LoginRecordDO;
import org.apache.ibatis.annotations.Param;
/**
* @author zhangchenbiao
* @date 2023-05-23 03:46
*/
public interface LoginRecordMapper {
/**
*
* 默认插入方法,只会给有值的字段赋值
* 会对传进来的字段做判空处理如果字段为空则使用数据库默认字段或者null
* dateTime:2023-05-23 03:46
*/
int insertSelective(@Param("record") LoginRecordDO record, @Param("enterpriseId") String enterpriseId);
/**
*
* 默认更新方法根据主键更新不会把null值更新到数据库避免覆盖之前有值的
* dateTime:2023-05-23 03:46
*/
int updateByPrimaryKeySelective(@Param("record") LoginRecordDO record, @Param("enterpriseId") String enterpriseId);
}

View File

@@ -22,4 +22,7 @@ public interface SysRoleMapper {
* dateTime:2023-05-19 03:00
*/
int updateByPrimaryKeySelective(@Param("record") SysRoleDO record, @Param("enterpriseId") String enterpriseId);
SysRoleDO getHighestPrioritySysRoleDoByUserId(@Param("enterpriseId") String enterpriseId, @Param("userId") String userId);
}

View File

@@ -57,4 +57,13 @@
where
db_name = #{dbName} limit 1
</select>
<select id="getConfigByCorpIdAndAppType" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from
enterprise_config
where
ding_corp_id = #{corpId} and app_type = #{appType}
</select>
</mapper>

View File

@@ -0,0 +1,295 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cool.store.mapper.EnterpriseMapper">
<resultMap id="BaseResultMap" type="com.cool.store.model.entity.EnterpriseDO">
<id column="id" jdbcType="VARCHAR" property="id"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="original_name" jdbcType="VARCHAR" property="originalName"/>
<result column="mobile" jdbcType="CHAR" property="mobile"/>
<result column="province" jdbcType="VARCHAR" property="province"/>
<result column="city" jdbcType="VARCHAR" property="city"/>
<result column="status" jdbcType="INTEGER" property="status"/>
<result column="logo" jdbcType="VARCHAR" property="logo"/>
<result column="is_vip" jdbcType="INTEGER" property="isVip"/>
<result column="auth_type" jdbcType="INTEGER" property="authType"/>
<result column="auth_user_id" jdbcType="VARCHAR" property="authUserId"/>
<result column="industry" jdbcType="VARCHAR" property="industry"/>
<result column="logo_name" jdbcType="VARCHAR" property="logoName"/>
<result column="corp_logo_url" jdbcType="VARCHAR" property="corpLogoUrl"/>
<result column="is_authenticated" jdbcType="INTEGER" property="isAuthenticated"/>
<result column="auth_level" jdbcType="INTEGER" property="authLevel"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
<result column="package_begin_date" jdbcType="TIMESTAMP" property="packageBeginDate"/>
<result column="package_end_date" jdbcType="TIMESTAMP" property="packageEndDate"/>
<result column="aliyun_person_group_crop_id" jdbcType="VARCHAR" property="aliyunPersonGroupCropId"/>
<result column="app_type" jdbcType="VARCHAR" property="appType"/>
<result column="tag" jdbcType="VARCHAR" property="tag"/>
<result column="dataware_config" jdbcType="VARCHAR" property="datawareConfig"/>
<result column="is_leave_info" jdbcType="BIT" property="isLeaveInfo"/>
<result column="limit_store_count" jdbcType="INTEGER" property="limitStoreCount"/>
<result column="limit_device_count" jdbcType="INTEGER" property="limitDeviceCount"/>
</resultMap>
<sql id="Base_Column_List">
id, name, original_name, mobile, province, city, status, logo, is_vip, auth_type,
auth_user_id, industry, logo_name, corp_logo_url, is_authenticated, auth_level, create_time,
update_time, package_begin_date, package_end_date, aliyun_person_group_crop_id, app_type,
tag, dataware_config, is_leave_info, limit_store_count, limit_device_count
</sql>
<insert id="insertSelective" keyColumn="id" keyProperty="record.id" useGeneratedKeys="true">
insert into enterprise
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null">
name,
</if>
<if test="originalName != null">
original_name,
</if>
<if test="mobile != null">
mobile,
</if>
<if test="province != null">
province,
</if>
<if test="city != null">
city,
</if>
<if test="status != null">
status,
</if>
<if test="logo != null">
logo,
</if>
<if test="isVip != null">
is_vip,
</if>
<if test="authType != null">
auth_type,
</if>
<if test="authUserId != null">
auth_user_id,
</if>
<if test="industry != null">
industry,
</if>
<if test="logoName != null">
logo_name,
</if>
<if test="corpLogoUrl != null">
corp_logo_url,
</if>
<if test="isAuthenticated != null">
is_authenticated,
</if>
<if test="authLevel != null">
auth_level,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="packageBeginDate != null">
package_begin_date,
</if>
<if test="packageEndDate != null">
package_end_date,
</if>
<if test="aliyunPersonGroupCropId != null">
aliyun_person_group_crop_id,
</if>
<if test="appType != null">
app_type,
</if>
<if test="tag != null">
tag,
</if>
<if test="datawareConfig != null">
dataware_config,
</if>
<if test="isLeaveInfo != null">
is_leave_info,
</if>
<if test="limitStoreCount != null">
limit_store_count,
</if>
<if test="limitDeviceCount != null">
limit_device_count,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null">
#{name},
</if>
<if test="originalName != null">
#{originalName},
</if>
<if test="mobile != null">
#{mobile},
</if>
<if test="province != null">
#{province},
</if>
<if test="city != null">
#{city},
</if>
<if test="status != null">
#{status},
</if>
<if test="logo != null">
#{logo},
</if>
<if test="isVip != null">
#{isVip},
</if>
<if test="authType != null">
#{authType},
</if>
<if test="authUserId != null">
#{authUserId},
</if>
<if test="industry != null">
#{industry},
</if>
<if test="logoName != null">
#{logoName},
</if>
<if test="corpLogoUrl != null">
#{corpLogoUrl},
</if>
<if test="isAuthenticated != null">
#{isAuthenticated},
</if>
<if test="authLevel != null">
#{authLevel},
</if>
<if test="createTime != null">
#{createTime},
</if>
<if test="updateTime != null">
#{updateTime},
</if>
<if test="packageBeginDate != null">
#{packageBeginDate},
</if>
<if test="packageEndDate != null">
#{packageEndDate},
</if>
<if test="aliyunPersonGroupCropId != null">
#{aliyunPersonGroupCropId},
</if>
<if test="appType != null">
#{appType},
</if>
<if test="tag != null">
#{tag},
</if>
<if test="datawareConfig != null">
#{datawareConfig},
</if>
<if test="isLeaveInfo != null">
#{isLeaveInfo},
</if>
<if test="limitStoreCount != null">
#{limitStoreCount},
</if>
<if test="limitDeviceCount != null">
#{limitDeviceCount},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective">
update enterprise
<set>
<if test="name != null">
name = #{name},
</if>
<if test="originalName != null">
original_name = #{originalName},
</if>
<if test="mobile != null">
mobile = #{mobile},
</if>
<if test="province != null">
province = #{province},
</if>
<if test="city != null">
city = #{city},
</if>
<if test="status != null">
status = #{status},
</if>
<if test="logo != null">
logo = #{logo},
</if>
<if test="isVip != null">
is_vip = #{isVip},
</if>
<if test="authType != null">
auth_type = #{authType},
</if>
<if test="authUserId != null">
auth_user_id = #{authUserId},
</if>
<if test="industry != null">
industry = #{industry},
</if>
<if test="logoName != null">
logo_name = #{logoName},
</if>
<if test="corpLogoUrl != null">
corp_logo_url = #{corpLogoUrl},
</if>
<if test="isAuthenticated != null">
is_authenticated = #{isAuthenticated},
</if>
<if test="authLevel != null">
auth_level = #{authLevel},
</if>
<if test="createTime != null">
create_time = #{createTime},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
<if test="packageBeginDate != null">
package_begin_date = #{packageBeginDate},
</if>
<if test="packageEndDate != null">
package_end_date = #{packageEndDate},
</if>
<if test="aliyunPersonGroupCropId != null">
aliyun_person_group_crop_id = #{aliyunPersonGroupCropId},
</if>
<if test="appType != null">
app_type = #{appType},
</if>
<if test="tag != null">
tag = #{tag},
</if>
<if test="datawareConfig != null">
dataware_config = #{datawareConfig},
</if>
<if test="isLeaveInfo != null">
is_leave_info = #{isLeaveInfo},
</if>
<if test="limitStoreCount != null">
limit_store_count = #{limitStoreCount},
</if>
<if test="limitDeviceCount != null">
limit_device_count = #{limitDeviceCount},
</if>
</set>
where id = #{id}
</update>
<select id="getEnterpriseById" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from
enterprise
where
id = #{id}
</select>
</mapper>

View File

@@ -388,4 +388,14 @@
</set>
where id = #{record.id}
</update>
<select id="getUserInfoById" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>,
<include refid="Blob_Column_List"/>
from
enterprise_user_${enterpriseId}
where
user_id = #{userId}
</select>
</mapper>

View File

@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cool.store.mapper.LoginRecordMapper">
<resultMap id="BaseResultMap" type="com.cool.store.model.entity.LoginRecordDO">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="user_id" jdbcType="VARCHAR" property="userId" />
<result column="create_time" jdbcType="BIGINT" property="createTime" />
</resultMap>
<sql id="Base_Column_List">
id, user_id, create_time
</sql>
<insert id="insertSelective" keyColumn="id" keyProperty="record.id" useGeneratedKeys="true">
insert into login_record_${enterpriseId}
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="record.userId != null">
user_id,
</if>
<if test="record.createTime != null">
create_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="record.userId != null">
#{record.userId},
</if>
<if test="record.createTime != null">
#{record.createTime},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective">
update login_record_${enterpriseId}
<set>
<if test="record.userId != null">
user_id = #{record.userId},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime},
</if>
</set>
where id = #{record.id}
</update>
</mapper>

View File

@@ -161,4 +161,23 @@
</set>
where id = #{record.id}
</update>
<select id="getHighestPrioritySysRoleDoByUserId" resultMap="BaseResultMap">
select
c.id as id,
c.role_name as roleName,
c.role_auth as roleAuth,
c.position_type as positionType,
c.app_menu as appMenu,
c.role_enum as roleEnum
from
enterprise_user_${enterpriseId} a
left join enterprise_user_role_${enterpriseId} b on a.user_id =b.user_id
left join sys_role_${enterpriseId} c on c.id=b.role_id
where
a.user_id= #{userId} and a.active = true
order by
c.priority is null, c.priority, position_type desc
LIMIT 1
</select>
</mapper>

View File

@@ -3,4 +3,4 @@ jdbc.url = jdbc:mysql://dingpushcoolcollege.mysql.rds.aliyuncs.com:3306/coolcoll
jdbc.user= coolstore
jdbc.password = CSCErYcXniNYm7bT
table.name = sys_role_menu_e88b6a2bc1334164b54977a4dbfe5d9d
table.name = login_record_e88b6a2bc1334164b54977a4dbfe5d9d

View File

@@ -22,6 +22,42 @@
<orderEntry type="library" name="Maven: xerces:xercesImpl:2.11.0" level="project" />
<orderEntry type="library" name="Maven: xml-apis:xml-apis:1.4.01" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.30" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:2.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:2.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:2.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-autoconfigure:2.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-logging:2.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.2.3" level="project" />
<orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.2.3" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-to-slf4j:2.12.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.12.1" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.30" level="project" />
<orderEntry type="library" name="Maven: jakarta.annotation:jakarta.annotation-api:1.3.5" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-core:5.2.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-jcl:5.2.5.RELEASE" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.yaml:snakeyaml:1.25" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-json:2.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.10.3" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.10.3" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.10.3" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.10.3" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.10.3" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.module:jackson-module-parameter-names:2.10.3" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-tomcat:2.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-core:9.0.33" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-el:9.0.33" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-websocket:9.0.33" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-validation:2.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: jakarta.validation:jakarta.validation-api:2.0.2" level="project" />
<orderEntry type="library" name="Maven: org.hibernate.validator:hibernate-validator:6.0.18.Final" level="project" />
<orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.4.1.Final" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml:classmate:1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-web:5.2.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-beans:5.2.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-webmvc:5.2.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-aop:5.2.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-context:5.2.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-expression:5.2.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: com.github.xiaoymin:knife4j-spring-boot-starter:2.0.4" level="project" />
<orderEntry type="library" name="Maven: com.github.xiaoymin:knife4j-spring-boot-autoconfigure:2.0.4" level="project" />
<orderEntry type="library" name="Maven: com.github.xiaoymin:knife4j-spring:2.0.4" level="project" />
@@ -29,7 +65,6 @@
<orderEntry type="library" name="Maven: com.github.xiaoymin:knife4j-core:2.0.4" level="project" />
<orderEntry type="library" name="Maven: org.javassist:javassist:3.25.0-GA" level="project" />
<orderEntry type="library" name="Maven: io.swagger:swagger-models:1.5.22" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.10.3" level="project" />
<orderEntry type="library" name="Maven: io.swagger:swagger-annotations:1.5.22" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger2:2.9.2" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-spi:2.9.2" level="project" />
@@ -39,14 +74,7 @@
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger-common:2.9.2" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-spring-web:2.9.2" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:20.0" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml:classmate:1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-core:1.2.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-beans:5.2.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-core:5.2.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-jcl:5.2.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-context:5.2.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-expression:5.2.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-aop:5.2.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-metadata:1.2.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.mapstruct:mapstruct:1.2.0.Final" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-bean-validators:2.9.2" level="project" />

View File

@@ -0,0 +1,26 @@
package com.cool.store.dto.login;
/**
* @author zhangchenbiao
* @FileName: RefreshUser
* @Description:
* @date 2023-05-23 14:29
*/
public class RefreshUser {
/**
* 用户Id
*/
private String userId;
/**
* 钉钉业务id
*/
private String corpId;
/**
* 企业id
*/
private String eid;
}

View File

@@ -0,0 +1,101 @@
package com.cool.store.model.entity;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.Date;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
*
* @author zhangchenbiao
* @date 2023-05-23 11:36
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class EnterpriseDO implements Serializable {
@ApiModelProperty("企业主键")
private String id;
@ApiModelProperty("企业名称")
private String name;
@ApiModelProperty("原始名称")
private String originalName;
@ApiModelProperty("电话")
private String mobile;
@ApiModelProperty("")
private String province;
@ApiModelProperty("")
private String city;
@ApiModelProperty("状态")
private Integer status;
@ApiModelProperty("")
private String logo;
@ApiModelProperty("用户类型(1:普通用户 2:付费用户 3:试用用户 4:共创用户)")
private Integer isVip;
@ApiModelProperty("授权人数")
private Integer authType;
@ApiModelProperty("")
private String authUserId;
@ApiModelProperty("")
private String industry;
@ApiModelProperty("logo名称")
private String logoName;
@ApiModelProperty("企业logo")
private String corpLogoUrl;
@ApiModelProperty("企业是否认证")
private Integer isAuthenticated;
@ApiModelProperty("企业认证等级0未认证1高级认证2中级认证3初级认证")
private Integer authLevel;
@ApiModelProperty("注册时间")
private Date createTime;
@ApiModelProperty("修改时间")
private Date updateTime;
@ApiModelProperty("套餐开始时间")
private Date packageBeginDate;
@ApiModelProperty("套餐结束时间")
private Date packageEndDate;
@ApiModelProperty("人员分组的cropId")
private String aliyunPersonGroupCropId;
@ApiModelProperty("来源类型默认dingding钉钉,qw企业微信 mobile")
private String appType;
@ApiModelProperty("企业标签")
private String tag;
@ApiModelProperty("数仓设置")
private String datawareConfig;
@ApiModelProperty("是否留资")
private Boolean isLeaveInfo;
@ApiModelProperty("限制的门店数量")
private Integer limitStoreCount;
@ApiModelProperty("设备数量")
private Integer limitDeviceCount;
}

View File

@@ -0,0 +1,28 @@
package com.cool.store.model.entity;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
*
* @author zhangchenbiao
* @date 2023-05-23 03:46
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class LoginRecordDO implements Serializable {
@ApiModelProperty("主键")
private Long id;
@ApiModelProperty("用户ID")
private String userId;
@ApiModelProperty("创建时间")
private Long createTime;
}

View File

@@ -22,13 +22,9 @@
<orderEntry type="library" name="Maven: xerces:xercesImpl:2.11.0" level="project" />
<orderEntry type="library" name="Maven: xml-apis:xml-apis:1.4.01" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.30" level="project" />
<orderEntry type="module" module-name="coolstore-partner-dao" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-jdbc:3.0.2" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:2.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:2.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:2.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-context:5.2.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-aop:5.2.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-expression:5.2.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-logging:2.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.2.3" level="project" />
<orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.2.3" level="project" />
@@ -39,9 +35,32 @@
<orderEntry type="library" name="Maven: org.springframework:spring-core:5.2.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-jcl:5.2.5.RELEASE" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.yaml:snakeyaml:1.25" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-json:2.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.10.3" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.10.3" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.10.3" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.10.3" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.10.3" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.module:jackson-module-parameter-names:2.10.3" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-tomcat:2.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-core:9.0.33" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-el:9.0.33" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-websocket:9.0.33" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-validation:2.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: jakarta.validation:jakarta.validation-api:2.0.2" level="project" />
<orderEntry type="library" name="Maven: org.hibernate.validator:hibernate-validator:6.0.18.Final" level="project" />
<orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.4.1.Final" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml:classmate:1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-web:5.2.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-beans:5.2.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-webmvc:5.2.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-aop:5.2.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-context:5.2.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-expression:5.2.5.RELEASE" level="project" />
<orderEntry type="module" module-name="coolstore-partner-dao" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-jdbc:3.0.2" level="project" />
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP:3.4.2" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-jdbc:5.2.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-beans:5.2.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-tx:5.2.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: mysql:mysql-connector-java:8.0.18" level="project" />
<orderEntry type="library" name="Maven: com.google.protobuf:protobuf-java:3.6.1" level="project" />
@@ -64,7 +83,6 @@
<orderEntry type="library" name="Maven: com.github.xiaoymin:knife4j-core:2.0.4" level="project" />
<orderEntry type="library" name="Maven: org.javassist:javassist:3.25.0-GA" level="project" />
<orderEntry type="library" name="Maven: io.swagger:swagger-models:1.5.22" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.10.3" level="project" />
<orderEntry type="library" name="Maven: io.swagger:swagger-annotations:1.5.22" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger2:2.9.2" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-spi:2.9.2" level="project" />
@@ -74,11 +92,12 @@
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger-common:2.9.2" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-spring-web:2.9.2" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:20.0" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml:classmate:1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-core:1.2.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-metadata:1.2.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.mapstruct:mapstruct:1.2.0.Final" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-bean-validators:2.9.2" level="project" />
<orderEntry type="library" name="Maven: com.github.xiaoymin:knife4j-spring-ui:2.0.4" level="project" />
<orderEntry type="library" name="Maven: org.apache.shiro:shiro-core:1.2.3" level="project" />
<orderEntry type="library" name="Maven: commons-beanutils:commons-beanutils:1.8.3" level="project" />
</component>
</module>

View File

@@ -29,6 +29,10 @@
<groupId>com.coolstore</groupId>
<artifactId>coolstore-partner-model</artifactId>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-core</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -1,4 +1,4 @@
package com.cool.store.service.config.redis;
package com.cool.store.config.redis;
import com.cool.store.utils.RedisUtilPool;
import org.springframework.beans.factory.annotation.Value;

View File

@@ -0,0 +1,17 @@
package com.cool.store.config.rest;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
/**
* @author dong_gui on 2020/5/20.
*/
@Configuration
public class RestTemplateConfig {
@Bean
public RestTemplate restTemplate() {
return new RestTemplate();
}
}

View File

@@ -1,5 +1,6 @@
package com.cool.store.service.context;
package com.cool.store.context;
import com.cool.store.entity.SysRoleDO;
import lombok.Data;
@@ -36,4 +37,6 @@ public class CurrentUser {
private String roleAuth;
private String mainCorpId;
private SysRoleDO sysRoleDO;
}

View File

@@ -1,4 +1,4 @@
package com.cool.store.service.context;
package com.cool.store.context;
import java.util.ArrayList;
import java.util.List;

View File

@@ -1,4 +1,4 @@
package com.cool.store.service.context;
package com.cool.store.context;
import com.alibaba.fastjson.JSON;
import org.apache.commons.lang3.StringUtils;

View File

@@ -0,0 +1,43 @@
package com.cool.store.http;
import com.alibaba.fastjson.JSONObject;
import com.cool.store.utils.RestTemplateUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import java.util.Objects;
/**
* @author zhangchenbiao
* @FileName: ISVHttpRequest
* @Description:
* @date 2023-05-23 16:03
*/
@Service
@Slf4j
public class ISVHttpRequest {
@Value("${isv.domain:null}")
private String isvDomain;
@Value("${get.user.id.by.code:null}")
private String getUserIdByCode;
public JSONObject getUserIdByCode(String paramStr){
String url = isvDomain + getUserIdByCode + paramStr;
ResponseEntity<JSONObject> responseEntity = null;
try {
responseEntity = RestTemplateUtil.loadGet(url, JSONObject.class);
log.info("url:{}, response:{}", url, JSONObject.toJSONString(responseEntity));
} catch (Exception e) {
log.info("调用isv出错{}", e);
}
if(Objects.isNull(responseEntity)){
return null;
}
return responseEntity.getBody();
}
}

View File

@@ -0,0 +1,9 @@
package com.cool.store.service;
public interface LoginService {
Object feiShuLogin(String userId, String corpId, Boolean needRefreshToken , String appType, String avatar);
}

View File

@@ -1,8 +1,8 @@
package com.cool.store.service.impl;
import com.cool.store.service.EnterpriseConfigService;
import com.cool.store.dao.EnterpriseConfigDAO;
import com.cool.store.entity.EnterpriseConfigDO;
import com.cool.store.service.EnterpriseConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

View File

@@ -0,0 +1,132 @@
package com.cool.store.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.cool.store.constants.CommonConstants;
import com.cool.store.context.CurrentUser;
import com.cool.store.context.DataSourceContext;
import com.cool.store.dao.*;
import com.cool.store.dto.login.RefreshUser;
import com.cool.store.entity.EnterpriseConfigDO;
import com.cool.store.entity.EnterpriseUserDO;
import com.cool.store.entity.SysRoleDO;
import com.cool.store.enums.AppTypeEnum;
import com.cool.store.enums.ErrorCodeEnum;
import com.cool.store.enums.UserStatusEnum;
import com.cool.store.exception.ServiceException;
import com.cool.store.model.entity.EnterpriseDO;
import com.cool.store.service.LoginService;
import com.cool.store.utils.DataSourceHelper;
import com.cool.store.utils.RedisUtilPool;
import com.github.xiaoymin.knife4j.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.crypto.RandomNumberGenerator;
import org.apache.shiro.crypto.SecureRandomNumberGenerator;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Objects;
import java.util.Optional;
/**
* @author zhangchenbiao
* @FileName: LoginServiceImpl
* @Description:
* @date 2023-05-23 9:57
*/
@Service
@Slf4j
public class LoginServiceImpl implements LoginService {
@Resource
private EnterpriseConfigDAO enterpriseConfigDAO;
@Resource
private EnterpriseDAO enterpriseDAO;
@Resource
private EnterpriseUserDAO enterpriseUserDAO;
@Resource
private SysRoleDAO sysRoleDAO;
@Resource
private LoginRecordDAO loginRecordDAO;
@Resource
private RedisUtilPool redisUtilPool;
@Override
public Object feiShuLogin(String userId, String corpId, Boolean needRefreshToken, String appType, String avatar) {
log.info("isvLogin, corpId={}, userId={}, appType={}", corpId, userId, appType);
DataSourceContext.clearDataSourceType();
if (StringUtils.isEmpty(userId)) {
throw new ServiceException(ErrorCodeEnum.USER_NOT_EXIST);
}
if (StringUtils.isEmpty(corpId)) {
throw new ServiceException(ErrorCodeEnum.ENTERPRISE_NOT_EXIST);
}
EnterpriseConfigDO enterpriseConfig = enterpriseConfigDAO.getConfigByCorpIdAndAppType(corpId, appType);
if (enterpriseConfig == null) {
throw new ServiceException(ErrorCodeEnum.ENTERPRISE_INIT);
}
EnterpriseDO enterprise = enterpriseDAO.getEnterpriseById(enterpriseConfig.getEnterpriseId());
if (enterprise == null || enterprise.getStatus() == CommonConstants.ZERO) {
throw new ServiceException(ErrorCodeEnum.ENTERPRISE_INIT);
}
CurrentUser currentUser = new CurrentUser();
RefreshUser refreshUser = new RefreshUser();
String dbName = enterpriseConfig.getDbName();
// 切到企业库
DataSourceContext.setDataSourceType(dbName);
// 查企业用户
EnterpriseUserDO enterpriseUser = enterpriseUserDAO.getUserInfoById(enterprise.getId(), userId);
if(enterpriseUser == null){
throw new ServiceException(ErrorCodeEnum.NOT_AUTH);
}
//冻结登录 超登用户过滤
if (enterprise.getStatus() == CommonConstants.HUNDRED && !StringUtils.equals(enterpriseUser.getUserId(), "a100000001")) {
throw new ServiceException(ErrorCodeEnum.PARAMS_VALIDATE_ERROR.getCode(), "企业被冻结");
}
SysRoleDO sysRole = sysRoleDAO.getHighestPrioritySysRoleDoByUserId(enterprise.getId(), userId);
if(Objects.isNull(sysRole)){
log.info("当前用户没角色:{}", userId);
throw new ServiceException(ErrorCodeEnum.NOT_AUTH);
}
if(UserStatusEnum.FREEZE.getCode().equals(enterpriseUser.getUserStatus())){
throw new ServiceException(ErrorCodeEnum.USER_FREEZE);
}
if(UserStatusEnum.WAIT_AUDIT.getCode().equals(enterpriseUser.getUserStatus())){
throw new ServiceException(ErrorCodeEnum.USER_WAIT_AUDIT);
}
//用户是否已有头像
Boolean hasAvatar = StringUtils.isNotEmpty(enterpriseUser.getAvatar()) && !enterpriseUser.getAvatar().contains(CommonConstants.DEFAULT_AVATAR);
String finalAvatar = hasAvatar ? enterpriseUser.getAvatar() : avatar;
enterpriseUser.setAvatar(finalAvatar);
enterpriseUser.setFaceUrl(finalAvatar);
currentUser.setUserId(enterpriseUser.getUserId());
currentUser.setDbName(enterpriseConfig.getDbName());
currentUser.setIsAdmin(enterpriseUser.getIsAdmin());
currentUser.setMainCorpId(enterpriseConfig.getMainCorpId());
//设置当前登录人使用的企业相关信息
currentUser.setRoleAuth(sysRole.getRoleAuth());
currentUser.setSysRoleDO(sysRole);
currentUser.setEnterpriseId(enterprise.getId());
//生成令牌
RandomNumberGenerator randomNumberGenerator = new SecureRandomNumberGenerator();
String token = randomNumberGenerator.nextBytes().toHex();
String refreshToken = randomNumberGenerator.nextBytes().toHex();
currentUser.setName(enterpriseUser.getName());
currentUser.setDingCorpId(enterpriseConfig.getDingCorpId());
currentUser.setAccessToken(token);
currentUser.setAppType(appType);
JSONObject jsonObject = new JSONObject();
jsonObject.put("action_token", token);
jsonObject.put("user", currentUser);
redisUtilPool.setString(CommonConstants.ACCESS_TOKEN_KEY + ":" + token, JSON.toJSONString(currentUser), CommonConstants.ACTION_TOKEN_EXPIRE);
jsonObject.put("expire", CommonConstants.ACTION_TOKEN_EXPIRE);
redisUtilPool.setString(currentUser.getUserId(), token);
redisUtilPool.setString(CommonConstants.REFRESH_TOKEN_KEY+":"+refreshToken,JSON.toJSONString(refreshUser), CommonConstants.REFRESH_TOKEN_EXPIRE);
jsonObject.put("refresh_token",refreshToken);
loginRecordDAO.addLoginRecord(currentUser.getEnterpriseId(),currentUser.getUserId());
log.info("[" + enterpriseUser.getName() + "; action_token"+ token + "; userId" + currentUser.getUserId() +"]登入系统成功");
return jsonObject;
}
}

View File

@@ -1,7 +1,7 @@
package com.cool.store.service.utils;
package com.cool.store.utils;
import com.cool.store.service.context.DataSourceContext;
import com.cool.store.service.context.UserContext;
import com.cool.store.context.DataSourceContext;
import com.cool.store.context.UserContext;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@@ -62,6 +62,8 @@
<orderEntry type="library" name="Maven: org.mapstruct:mapstruct:1.2.0.Final" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-bean-validators:2.9.2" level="project" />
<orderEntry type="library" name="Maven: com.github.xiaoymin:knife4j-spring-ui:2.0.4" level="project" />
<orderEntry type="library" name="Maven: org.apache.shiro:shiro-core:1.2.3" level="project" />
<orderEntry type="library" name="Maven: commons-beanutils:commons-beanutils:1.8.3" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:2.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:2.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:2.2.6.RELEASE" level="project" />

View File

@@ -1,16 +1,12 @@
package com.cool.store.config;
import com.alibaba.fastjson.JSON;
import com.cool.store.constants.CommonConstants;
import com.cool.store.entity.SysRoleDO;
import com.cool.store.enums.ErrorCodeEnum;
import com.cool.store.mapper.SysRoleMapper;
import com.cool.store.response.ResponseResult;
import com.cool.store.service.context.DataSourceContext;
import com.cool.store.service.context.UserContext;
import com.cool.store.service.utils.DataSourceHelper;
import com.cool.store.context.UserContext;
import com.cool.store.utils.DataSourceHelper;
import com.cool.store.utils.RedisUtilPool;
import com.cool.store.service.context.CurrentUser;
import com.cool.store.context.CurrentUser;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;

View File

@@ -1,7 +1,7 @@
package com.cool.store.config.datasource;
import com.cool.store.constants.CommonConstants;
import com.cool.store.service.context.DataSourceContext;
import com.cool.store.context.DataSourceContext;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@@ -3,9 +3,9 @@ package com.cool.store.config.datasource;
import com.cool.store.constants.CommonConstants;
import com.cool.store.dto.DatasourceInfoDTO;
import com.cool.store.entity.EnterpriseConfigDO;
import com.cool.store.utils.RedisUtilPool;
import com.cool.store.service.EnterpriseConfigService;
import com.cool.store.service.context.DataSourceContext;
import com.cool.store.utils.RedisUtilPool;
import com.cool.store.context.DataSourceContext;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.zaxxer.hikari.HikariConfig;

View File

@@ -3,10 +3,15 @@ package com.cool.store.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.cool.store.dto.login.FeiShuLoginDTO;
import com.cool.store.enums.AppTypeEnum;
import com.cool.store.enums.ErrorCodeEnum;
import com.google.protobuf.ServiceException;
import com.cool.store.exception.ServiceException;
import com.cool.store.http.ISVHttpRequest;
import com.cool.store.service.LoginService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
@@ -21,45 +26,37 @@ import org.springframework.web.bind.annotation.RestController;
@Slf4j
public class LoginController {
/*@PostMapping(value = "/v3/feiShuLogin")
@Autowired
private LoginService loginService;
@Autowired
private ISVHttpRequest isvHttpRequest;
@PostMapping(value = "/v3/feiShuLogin")
public Object feiShuLogin(@RequestBody FeiShuLoginDTO param) {
log.info("isvLoginV2 data={}", JSONObject.toJSONString(param));
log.info("feiShuLogin data={}", JSONObject.toJSONString(param));
String code = param.getCode();
String appId = param.getAppId();
String userId = "", corpId = "", appType = AppTypeEnum.FEI_SHU.getValue();
try {
String value = "code=" + code + "&appType=" + appType + "&appId=" + appId;
log.info("url:{}", ding_token_userId + value);
JSONObject userInfo = JSON.parseObject(HttpRequest.sendGet(ding_token_userId, value));
logger.info("userInfo:{}", JSONObject.toJSONString(userInfo));
//todo zcb
JSONObject userInfo = isvHttpRequest.getUserIdByCode(value);
log.info("userInfo:{}", JSONObject.toJSONString(userInfo));
userId = userInfo.getString("openId");
corpId = userInfo.getString("corpId");
String errorCode = userInfo.getString("error_code");
if (StringUtils.isBlank(userId) && StringUtils.isNotBlank(errorCode)) {
DingLoginErrorEnum dingLoginErrorEnum = DingLoginErrorEnum.getByCode(Integer.getInteger(errorCode));
if (dingLoginErrorEnum != null) {
throw new ServiceException(dingLoginErrorEnum.getCode(), dingLoginErrorEnum.getMsg());
}
throw new ServiceException(ErrorCodeEnum.LOGIN_ERROR);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
if (e instanceof ServiceException) {
throw e;
} else {
throw new ServiceException(ErrorCodeEnum.PARAMS_VALIDATE_ERROR.getCode(), "用户不存在");
}
}
try {
return loginService.isvLogin(userId, corpId, Boolean.TRUE, appType, StringUtils.EMPTY);
return loginService.feiShuLogin(userId, corpId, Boolean.TRUE, appType, StringUtils.EMPTY);
} catch (ServiceException e) {
log.error(e.getMessage(), e);
throw new ServiceException(e.getErrorCode(), e.getErrorMessage());
throw new ServiceException(ErrorCodeEnum.LOGIN_ERROR);
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new ServiceException(ErrorCodeEnum.PARAMS_VALIDATE_ERROR.getCode(), "登陆失败");
throw new ServiceException(ErrorCodeEnum.LOGIN_ERROR);
}
}*/
}
}

View File

@@ -35,3 +35,6 @@ mybatis.configuration.map-underscore-to-camel-case=true
com.alipay.sofa.rpc.registry.address=zookeeper://tzk.coolcollege.cn:2188
com.alipay.sofa.rpc.bolt.port=31010
isv.domain = https://tstore-isv.coolcollege.cn
get.user.id.by.code = /isv/v2/get_user_id_by_code

View File

@@ -38,4 +38,7 @@ mybatis.configuration.call-setters-on-nulls=true
mybatis.configuration.map-underscore-to-camel-case=true
com.alipay.sofa.rpc.registry.address=zookeeper://dzk.coolcollege.cn:2188
com.alipay.sofa.rpc.bolt.port=31010
com.alipay.sofa.rpc.bolt.port=31010
isv.domain = https://dstore-isv.coolcollege.cn
get.user.id.by.code = /isv/v2/get_user_id_by_code

View File

@@ -34,4 +34,7 @@ mybatis.configuration.call-setters-on-nulls=true
mybatis.configuration.map-underscore-to-camel-case=true
com.alipay.sofa.rpc.registry.address=zookeeper://10.7.53.199:2188
com.alipay.sofa.rpc.bolt.port=31010
com.alipay.sofa.rpc.bolt.port=31010
isv.domain = https://hdstore-isv.coolcollege.cn
get.user.id.by.code = /isv/v2/get_user_id_by_code

View File

@@ -41,4 +41,7 @@ mybatis.configuration.call-setters-on-nulls=true
mybatis.configuration.map-underscore-to-camel-case=true
com.alipay.sofa.rpc.registry.address=zookeeper://localhost:2181
com.alipay.sofa.rpc.bolt.port=31010
com.alipay.sofa.rpc.bolt.port=31010
isv.domain = https://tstore-isv.coolcollege.cn
get.user.id.by.code = /isv/v2/get_user_id_by_code

View File

@@ -34,4 +34,7 @@ mybatis.configuration.call-setters-on-nulls=true
mybatis.configuration.map-underscore-to-camel-case=true
com.alipay.sofa.rpc.registry.address=zookeeper://10.6.49.221:2188,10.6.49.222:2188,10.6.49.223:2188
com.alipay.sofa.rpc.bolt.port=31010
com.alipay.sofa.rpc.bolt.port=31010
isv.domain = https://store-isv.coolcollege.cn
get.user.id.by.code = /isv/v2/get_user_id_by_code

View File

@@ -34,4 +34,7 @@ mybatis.configuration.call-setters-on-nulls=true
mybatis.configuration.map-underscore-to-camel-case=true
com.alipay.sofa.rpc.registry.address=zookeeper://10.7.54.149:2188
com.alipay.sofa.rpc.bolt.port=31010
com.alipay.sofa.rpc.bolt.port=31010
isv.domain = https://store-isv.coolcollege.cn
get.user.id.by.code = /isv/v2/get_user_id_by_code

View File

@@ -34,4 +34,7 @@ mybatis.configuration.call-setters-on-nulls=true
mybatis.configuration.map-underscore-to-camel-case=true
com.alipay.sofa.rpc.registry.address=zookeeper://tzk.coolcollege.cn:2188
com.alipay.sofa.rpc.bolt.port=31010
com.alipay.sofa.rpc.bolt.port=31010
isv.domain = https://tstore-isv.coolcollege.cn
get.user.id.by.code = /isv/v2/get_user_id_by_code

View File

@@ -62,6 +62,8 @@
<orderEntry type="library" name="Maven: org.mapstruct:mapstruct:1.2.0.Final" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-bean-validators:2.9.2" level="project" />
<orderEntry type="library" name="Maven: com.github.xiaoymin:knife4j-spring-ui:2.0.4" level="project" />
<orderEntry type="library" name="Maven: org.apache.shiro:shiro-core:1.2.3" level="project" />
<orderEntry type="library" name="Maven: commons-beanutils:commons-beanutils:1.8.3" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:2.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-json:2.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.10.3" level="project" />

View File

@@ -3,9 +3,9 @@ package com.cool.store.config;
import com.alibaba.fastjson.JSON;
import com.cool.store.enums.ErrorCodeEnum;
import com.cool.store.response.ResponseResult;
import com.cool.store.service.context.CurrentUser;
import com.cool.store.service.context.UserContext;
import com.cool.store.service.utils.DataSourceHelper;
import com.cool.store.context.CurrentUser;
import com.cool.store.context.UserContext;
import com.cool.store.utils.DataSourceHelper;
import com.cool.store.utils.RedisUtilPool;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;

View File

@@ -1,7 +1,7 @@
package com.cool.store.config.datasource;
import com.cool.store.constants.CommonConstants;
import com.cool.store.service.context.DataSourceContext;
import com.cool.store.context.DataSourceContext;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@@ -4,8 +4,8 @@ import com.cool.store.constants.CommonConstants;
import com.cool.store.dto.DatasourceInfoDTO;
import com.cool.store.entity.EnterpriseConfigDO;
import com.cool.store.utils.RedisUtilPool;
import com.cool.store.service.EnterpriseConfigService;
import com.cool.store.service.context.DataSourceContext;
import com.cool.store.service.config.EnterpriseConfigService;
import com.cool.store.context.DataSourceContext;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.zaxxer.hikari.HikariConfig;

View File

@@ -121,6 +121,11 @@
<artifactId>xercesImpl</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-core</artifactId>
<version>1.2.3</version>
</dependency>
</dependencies>
</dependencyManagement>