初始化
parent
fac31cb7a8
commit
14da1917c3
|
@ -4,7 +4,7 @@ server:
|
||||||
|
|
||||||
# nacos线上地址
|
# nacos线上地址
|
||||||
nacos:
|
nacos:
|
||||||
addr: 47.116.173.119:8848
|
addr: 159.75.188.178:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: eight
|
namespace: eight
|
||||||
|
|
|
@ -11,6 +11,11 @@ public class SecurityConstants {
|
||||||
*/
|
*/
|
||||||
public static final String DETAILS_USER_ID = "user_id";
|
public static final String DETAILS_USER_ID = "user_id";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 企业ID字段
|
||||||
|
*/
|
||||||
|
public static final String DETAILS_FIRM_ID = "firm_id";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户名字段
|
* 用户名字段
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -44,6 +44,7 @@ public class TokenService {
|
||||||
String token = IdUtils.fastUUID();
|
String token = IdUtils.fastUUID();
|
||||||
Long userId = loginUser.getSysUser().getUserId();
|
Long userId = loginUser.getSysUser().getUserId();
|
||||||
String userName = loginUser.getSysUser().getUserName();
|
String userName = loginUser.getSysUser().getUserName();
|
||||||
|
Integer firmId = loginUser.getSysUser().getFirmId();
|
||||||
loginUser.setToken(token);
|
loginUser.setToken(token);
|
||||||
loginUser.setUserid(userId);
|
loginUser.setUserid(userId);
|
||||||
loginUser.setUsername(userName);
|
loginUser.setUsername(userName);
|
||||||
|
@ -55,11 +56,13 @@ public class TokenService {
|
||||||
claimsMap.put(SecurityConstants.USER_KEY, token);
|
claimsMap.put(SecurityConstants.USER_KEY, token);
|
||||||
claimsMap.put(SecurityConstants.DETAILS_USER_ID, userId);
|
claimsMap.put(SecurityConstants.DETAILS_USER_ID, userId);
|
||||||
claimsMap.put(SecurityConstants.DETAILS_USERNAME, userName);
|
claimsMap.put(SecurityConstants.DETAILS_USERNAME, userName);
|
||||||
|
claimsMap.put(SecurityConstants.DETAILS_FIRM_ID,firmId);
|
||||||
|
|
||||||
// 接口返回信息
|
// 接口返回信息
|
||||||
Map<String, Object> rspMap = new HashMap<String, Object>();
|
Map<String, Object> rspMap = new HashMap<String, Object>();
|
||||||
rspMap.put("access_token", JwtUtils.createToken(claimsMap));
|
rspMap.put("access_token", JwtUtils.createToken(claimsMap));
|
||||||
rspMap.put("expires_in", expireTime);
|
rspMap.put("expires_in", expireTime);
|
||||||
|
|
||||||
return rspMap;
|
return rspMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
package com.muyu.common.system.domain;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:张腾
|
||||||
|
* @Package:com.muyu.common.system.domain
|
||||||
|
* @Project:cloud-server-8
|
||||||
|
* @name:DatasourceInfo
|
||||||
|
* @Date:2024/9/18 19:25
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class DatasourceInfo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 键
|
||||||
|
*/
|
||||||
|
private String key;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 地址
|
||||||
|
*/
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户名
|
||||||
|
*/
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 密码
|
||||||
|
*/
|
||||||
|
private String password;
|
||||||
|
}
|
|
@ -0,0 +1,99 @@
|
||||||
|
package com.muyu.common.system.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:张腾
|
||||||
|
* @Package:com.muyu.common.system.domain
|
||||||
|
* @Project:cloud-server-8
|
||||||
|
* @name:SysFirm
|
||||||
|
* @Date:2024/9/18 19:04
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName(value = "sys_firm",autoResultMap = true)
|
||||||
|
public class SysFirm extends BaseEntity {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*自增主键
|
||||||
|
*/
|
||||||
|
@TableId(value = "id",type = IdType.AUTO)
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*统一社会信用代码
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "统一社会信用代码不能为空")
|
||||||
|
private String firmCreditCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*企业营业执照
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "请上传对应的营业执照")
|
||||||
|
private String firmImages;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*企业名称
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "企业名称不能为空")
|
||||||
|
private String firmName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*企业LOGO
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "请上传企业logo")
|
||||||
|
private String firmLogo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*企业法人
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "企业法人不能为空")
|
||||||
|
private String firmLegalPerson;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*联系电话
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "请输入联系电话")
|
||||||
|
private String firmPhone;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*联系邮箱
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "请输入联系邮箱")
|
||||||
|
private String firmEmail;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*联系网址
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "联系网址不能为空")
|
||||||
|
private String firmWebsite;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*企业地址
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "企业地址不能为空")
|
||||||
|
private String firmAddress;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*企业描述
|
||||||
|
*/
|
||||||
|
private String firmDesc;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*启用状态(1.开业 2.停业 3.休业)
|
||||||
|
*/
|
||||||
|
private Integer state;
|
||||||
|
}
|
|
@ -83,6 +83,11 @@ public class SysUser extends BaseEntity {
|
||||||
*/
|
*/
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 企业ID
|
||||||
|
*/
|
||||||
|
private Integer firmId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 帐号状态(0正常 1停用)
|
* 帐号状态(0正常 1停用)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class ValidateCodeServiceImpl implements ValidateCodeService {
|
||||||
CaptchaCodeResp.CaptchaCodeRespBuilder respBuilder = CaptchaCodeResp.builder()
|
CaptchaCodeResp.CaptchaCodeRespBuilder respBuilder = CaptchaCodeResp.builder()
|
||||||
.captchaEnabled(captchaEnabled);
|
.captchaEnabled(captchaEnabled);
|
||||||
if (!captchaEnabled) {
|
if (!captchaEnabled) {
|
||||||
return Result.success(respBuilder);
|
return Result.success(respBuilder.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 保存验证码信息
|
// 保存验证码信息
|
||||||
|
|
|
@ -4,7 +4,7 @@ server:
|
||||||
|
|
||||||
# nacos线上地址
|
# nacos线上地址
|
||||||
nacos:
|
nacos:
|
||||||
addr: 47.116.173.119:8848
|
addr: 159.75.188.178:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: eight
|
namespace: eight
|
||||||
|
|
|
@ -4,7 +4,7 @@ server:
|
||||||
|
|
||||||
# nacos线上地址
|
# nacos线上地址
|
||||||
nacos:
|
nacos:
|
||||||
addr: 47.116.173.119:8848
|
addr: 159.75.188.178:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: eight
|
namespace: eight
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.muyu.common.security.annotation.EnableCustomConfig;
|
||||||
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 代码生成
|
* 代码生成
|
||||||
|
|
|
@ -4,7 +4,7 @@ server:
|
||||||
|
|
||||||
# nacos线上地址
|
# nacos线上地址
|
||||||
nacos:
|
nacos:
|
||||||
addr: 47.116.173.119:8848
|
addr: 159.75.188.178:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: eight
|
namespace: eight
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.muyu.system.config;
|
||||||
|
|
||||||
|
import com.muyu.system.interceptor.DataSourceInterceptor;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:张腾
|
||||||
|
* @Package:com.muyu.system.config
|
||||||
|
* @Project:cloud-server-8
|
||||||
|
* @name:WebConfig
|
||||||
|
* @Date:2024/9/18 19:51
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class WebConfig implements WebMvcConfigurer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
|
registry.addInterceptor(new DataSourceInterceptor())
|
||||||
|
.addPathPatterns("/**")
|
||||||
|
.excludePathPatterns("/");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.muyu.system.holder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:张腾
|
||||||
|
* @Package:com.muyu.system.holder
|
||||||
|
* @Project:cloud-server-8
|
||||||
|
* @name:DataSourcceContextHolder
|
||||||
|
* @Date:2024/9/18 19:45
|
||||||
|
*/
|
||||||
|
public class DataSourceContextHolder {
|
||||||
|
private static final ThreadLocal<String> DYNAMIC_DATASOURCE_KEY = new ThreadLocal<>();
|
||||||
|
|
||||||
|
public static void setDatasourceMsg(String datasourceKey){
|
||||||
|
DYNAMIC_DATASOURCE_KEY.set(datasourceKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getDatasourceMsg(){
|
||||||
|
return DYNAMIC_DATASOURCE_KEY.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void clearDataSourceKey(){
|
||||||
|
DYNAMIC_DATASOURCE_KEY.remove();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
package com.muyu.system.interceptor;
|
||||||
|
|
||||||
|
import com.muyu.system.holder.DataSourceContextHolder;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import org.springframework.web.servlet.HandlerInterceptor;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:张腾
|
||||||
|
* @Package:com.muyu.system.interceptor
|
||||||
|
* @Project:cloud-server-8
|
||||||
|
* @name:DataSourceInterceptor
|
||||||
|
* @Date:2024/9/18 19:40
|
||||||
|
*/
|
||||||
|
public class DataSourceInterceptor implements HandlerInterceptor {
|
||||||
|
@Override
|
||||||
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||||
|
//从请求当中获取数据源标识符
|
||||||
|
String database = request.getParameter("database");
|
||||||
|
if (null != database){
|
||||||
|
DataSourceContextHolder.setDatasourceMsg(database);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
|
||||||
|
//请求完成之后进行清理操作
|
||||||
|
DataSourceContextHolder.clearDataSourceKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
|
||||||
|
//请求完成之后进行清理操作
|
||||||
|
DataSourceContextHolder.clearDataSourceKey();
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,7 +4,7 @@ server:
|
||||||
|
|
||||||
# nacos线上地址
|
# nacos线上地址
|
||||||
nacos:
|
nacos:
|
||||||
addr: 47.116.173.119:8848
|
addr: 159.75.188.178:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: eight
|
namespace: eight
|
||||||
|
|
|
@ -4,7 +4,7 @@ server:
|
||||||
|
|
||||||
# nacos线上地址
|
# nacos线上地址
|
||||||
nacos:
|
nacos:
|
||||||
addr: 47.116.173.119:8848
|
addr: 159.75.188.178:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: eight
|
namespace: eight
|
||||||
|
|
Loading…
Reference in New Issue