init
This commit is contained in:
@@ -0,0 +1,96 @@
|
|||||||
|
package com.ruoyi.web.config;
|
||||||
|
|
||||||
|
import com.ruoyi.dk.service.HomeSettingService;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.web.servlet.LocaleResolver;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* i18n配置,用于处理语言本地化设置。
|
||||||
|
*
|
||||||
|
* @author liuyanqiang
|
||||||
|
* @version 1.0.0
|
||||||
|
* @since 2023/06/15 09:41
|
||||||
|
**/
|
||||||
|
@Configuration
|
||||||
|
public class I18nConfig implements LocaleResolver {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private HomeSettingService homeSettingService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据请求中的Accept-Language头部解析出语言设置。
|
||||||
|
* 如果没有指定语言或语言设置不完整,则默认为中文设置。
|
||||||
|
*
|
||||||
|
* @param request HTTP请求对象
|
||||||
|
* @return {@link Locale } 解析后的语言设置Locale对象
|
||||||
|
* @author liuyanqiang
|
||||||
|
* @since 2023/06/15 09:42
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public Locale resolveLocale(HttpServletRequest request) {
|
||||||
|
// 默认语言设置为中文
|
||||||
|
String defaultLocal = homeSettingService.getHomeSetting().getDefaultLocal();
|
||||||
|
Locale locale = null;
|
||||||
|
// 从请求的头部获取Accept-Language标头,该标头指定了客户端期望的语言
|
||||||
|
String language = request.getHeader("Sass-Language");
|
||||||
|
String lang = request.getParameter("lang");
|
||||||
|
if (StringUtils.isNotBlank(lang)) {
|
||||||
|
language = lang;
|
||||||
|
}
|
||||||
|
if(StringUtils.isBlank(language)){
|
||||||
|
language = defaultLocal;
|
||||||
|
}
|
||||||
|
// 检查请求的语言是否非空
|
||||||
|
if (StringUtils.isNotBlank(language)) {
|
||||||
|
// 将语言字符串拆分为语言和国家/地区代码
|
||||||
|
String[] splitLanguage = language.split("_");
|
||||||
|
// 检查是否有语言和国家/地区代码
|
||||||
|
if (splitLanguage.length > 1) {
|
||||||
|
// 根据语言和国家/地区代码创建新的Locale对象
|
||||||
|
locale = new Locale(splitLanguage[0], splitLanguage[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(locale == null){
|
||||||
|
locale = Locale.CHINA;
|
||||||
|
}
|
||||||
|
// 返回解析得到的Locale对象作为解析后的语言设置
|
||||||
|
return locale;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置语言设置时的回调方法。
|
||||||
|
* 在此实现中,不执行任何操作,忽略对语言设置的更改。
|
||||||
|
* @param request HTTP请求对象
|
||||||
|
* @param response HTTP响应对象
|
||||||
|
* @param locale 语言设置的Locale对象
|
||||||
|
* @author liuyanqiang
|
||||||
|
* @since 2023/06/15 09:43
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public void setLocale(
|
||||||
|
HttpServletRequest request,
|
||||||
|
HttpServletResponse response,
|
||||||
|
Locale locale) {
|
||||||
|
// 此方法不执行任何操作,忽略对语言设置的更改
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建LocaleResolver bean,用于处理语言设置。
|
||||||
|
*
|
||||||
|
* @return {@link LocaleResolver }
|
||||||
|
* @author liuyanqiang
|
||||||
|
* @since 2023/06/15 09:44
|
||||||
|
**/
|
||||||
|
@Bean
|
||||||
|
public LocaleResolver localeResolver() {
|
||||||
|
// 返回当前类作为LocaleResolver的实例
|
||||||
|
return new I18nConfig();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -195,7 +195,7 @@ mybatis-encryptor:
|
|||||||
springdoc:
|
springdoc:
|
||||||
api-docs:
|
api-docs:
|
||||||
# 是否开启接口文档
|
# 是否开启接口文档
|
||||||
enabled: true
|
enabled: false
|
||||||
swagger-ui:
|
swagger-ui:
|
||||||
path: /swagger-ui.html
|
path: /swagger-ui.html
|
||||||
tags-sorter: alpha
|
tags-sorter: alpha
|
||||||
@@ -209,11 +209,11 @@ springdoc:
|
|||||||
# 防止XSS攻击
|
# 防止XSS攻击
|
||||||
xss:
|
xss:
|
||||||
# 过滤开关
|
# 过滤开关
|
||||||
enabled: true
|
enabled: false
|
||||||
# 排除链接(多个用逗号分隔)
|
# 排除链接(多个用逗号分隔)
|
||||||
excludes: /cai/agreementSetting
|
excludes: /app/*
|
||||||
# 匹配链接
|
# 匹配链接
|
||||||
urlPatterns: /system/*,/monitor/*,/tool/*,/cai/*,/api/*
|
urlPatterns: /system/*,/monitor/*,/tool/*,/api/*
|
||||||
|
|
||||||
# 全局线程池相关配置
|
# 全局线程池相关配置
|
||||||
thread-pool:
|
thread-pool:
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ public class TenantConfig {
|
|||||||
registration.setFilter(new TenantFilter());
|
registration.setFilter(new TenantFilter());
|
||||||
registration.addUrlPatterns("/*");
|
registration.addUrlPatterns("/*");
|
||||||
registration.setName("tenantFilter");
|
registration.setName("tenantFilter");
|
||||||
registration.setOrder(FilterRegistrationBean.LOWEST_PRECEDENCE);
|
// registration.setOrder(FilterRegistrationBean.LOWEST_PRECEDENCE + 1000);
|
||||||
return registration;
|
return registration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,6 +68,10 @@ public class TenantFilter implements Filter {
|
|||||||
}else{
|
}else{
|
||||||
TenantHelper.setTenantId(tenantHeader);
|
TenantHelper.setTenantId(tenantHeader);
|
||||||
}
|
}
|
||||||
|
if(StringUtils.isBlank(TenantHelper.getTenantId())){
|
||||||
|
ServletUtils.renderString(response, JSONUtil.toJsonStr(R.fail("未找到对应的平台")));
|
||||||
|
return;
|
||||||
|
}
|
||||||
filterChain.doFilter(servletRequest, servletResponse);
|
filterChain.doFilter(servletRequest, servletResponse);
|
||||||
} finally {
|
} finally {
|
||||||
TenantHelper.clearTenant();
|
TenantHelper.clearTenant();
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
package com.ruoyi.component.web.config;
|
package com.ruoyi.component.web.config;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
|
||||||
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.web.servlet.LocaleResolver;
|
import org.springframework.web.servlet.LocaleResolver;
|
||||||
|
|
||||||
@@ -15,7 +13,7 @@ import java.util.Locale;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@AutoConfiguration(before = WebMvcAutoConfiguration.class)
|
//@AutoConfiguration(before = WebMvcAutoConfiguration.class)
|
||||||
public class I18nConfig {
|
public class I18nConfig {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ package com.ruoyi.component.web.config;
|
|||||||
|
|
||||||
import com.ruoyi.component.web.interceptor.PlusWebInvokeTimeInterceptor;
|
import com.ruoyi.component.web.interceptor.PlusWebInvokeTimeInterceptor;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
|
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.core.Ordered;
|
||||||
import org.springframework.web.cors.CorsConfiguration;
|
import org.springframework.web.cors.CorsConfiguration;
|
||||||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
||||||
import org.springframework.web.filter.CorsFilter;
|
import org.springframework.web.filter.CorsFilter;
|
||||||
@@ -28,25 +30,22 @@ public class ResourcesConfig implements WebMvcConfigurer {
|
|||||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||||
* 跨域配置
|
|
||||||
*/
|
|
||||||
@Bean
|
@Bean
|
||||||
public CorsFilter corsFilter() {
|
public FilterRegistrationBean corsFilter() {
|
||||||
CorsConfiguration config = new CorsConfiguration();
|
CorsConfiguration config = new CorsConfiguration();
|
||||||
config.setAllowCredentials(true);
|
config.setAllowCredentials(true); // 允许cookies跨域
|
||||||
// 设置访问源地址
|
config.addAllowedOriginPattern("*");// #允许向该服务器提交请求的URI,*表示全部允许,自定义可以添加多个,在SpringMVC中,如果设成*,会自动转成当前请求头中的Origin
|
||||||
config.addAllowedOriginPattern("*");
|
config.addAllowedHeader("*");// #允许访问的头信息,*表示全部,可以添加多个
|
||||||
// 设置访问源请求头
|
config.addAllowedMethod("*");// 允许提交请求的方法,*表示全部允许,一般OPTIONS,GET,POST三个够了
|
||||||
config.addAllowedHeader("*");
|
config.setMaxAge(1800L);// 预检请求的缓存时间(秒),即在这个时间段里,对于相同的跨域请求不会再预检了
|
||||||
// 设置访问源请求方法
|
|
||||||
config.addAllowedMethod("*");
|
|
||||||
// 有效期 1800秒
|
|
||||||
config.setMaxAge(1800L);
|
|
||||||
// 添加映射路径,拦截一切请求
|
|
||||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||||
source.registerCorsConfiguration("/**", config);
|
source.registerCorsConfiguration("/**", config);//对所有接口都有效
|
||||||
// 返回新的CorsFilter
|
FilterRegistrationBean registration = new FilterRegistrationBean(new CorsFilter(source));
|
||||||
return new CorsFilter(source);
|
registration.addUrlPatterns("/*");
|
||||||
|
registration.setName("corsFilter");
|
||||||
|
registration.setOrder(Ordered.HIGHEST_PRECEDENCE); // 优先级最高
|
||||||
|
return registration;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
com.ruoyi.component.web.config.CaptchaConfig
|
com.ruoyi.component.web.config.CaptchaConfig
|
||||||
com.ruoyi.component.web.config.FilterConfig
|
com.ruoyi.component.web.config.FilterConfig
|
||||||
com.ruoyi.component.web.config.I18nConfig
|
|
||||||
com.ruoyi.component.web.config.ResourcesConfig
|
com.ruoyi.component.web.config.ResourcesConfig
|
||||||
com.ruoyi.component.web.config.UndertowConfig
|
com.ruoyi.component.web.config.UndertowConfig
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package com.ruoyi.dk.controller;
|
|||||||
|
|
||||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.ruoyi.component.excel.utils.ExcelUtil;
|
import com.ruoyi.component.core.domain.R;
|
||||||
import com.ruoyi.component.idempotent.annotation.RepeatSubmit;
|
import com.ruoyi.component.idempotent.annotation.RepeatSubmit;
|
||||||
import com.ruoyi.component.log.annotation.Log;
|
import com.ruoyi.component.log.annotation.Log;
|
||||||
import com.ruoyi.component.log.enums.BusinessType;
|
import com.ruoyi.component.log.enums.BusinessType;
|
||||||
@@ -12,18 +12,13 @@ import com.ruoyi.component.web.core.BaseController;
|
|||||||
import com.ruoyi.dk.domain.Customer;
|
import com.ruoyi.dk.domain.Customer;
|
||||||
import com.ruoyi.dk.dto.admin.req.UpdatePwdCustomerReq;
|
import com.ruoyi.dk.dto.admin.req.UpdatePwdCustomerReq;
|
||||||
import com.ruoyi.dk.dto.admin.resp.CustomerAdminResp;
|
import com.ruoyi.dk.dto.admin.resp.CustomerAdminResp;
|
||||||
import com.ruoyi.dk.dto.admin.resp.CustomerExportVo;
|
import com.ruoyi.dk.dto.common.IdReq;
|
||||||
import com.ruoyi.dk.mapper.CustomerMapper;
|
|
||||||
import com.ruoyi.dk.service.CustomerService;
|
import com.ruoyi.dk.service.CustomerService;
|
||||||
import com.ruoyi.component.core.domain.R;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import javax.validation.constraints.NotEmpty;
|
import javax.validation.constraints.NotEmpty;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -36,8 +31,6 @@ import java.util.stream.Stream;
|
|||||||
public class DkCustomerController extends BaseController {
|
public class DkCustomerController extends BaseController {
|
||||||
|
|
||||||
private final CustomerService customerService;
|
private final CustomerService customerService;
|
||||||
@Resource
|
|
||||||
private CustomerMapper customerMapper;
|
|
||||||
|
|
||||||
@SaCheckPermission("dk:dkCustomer:list")
|
@SaCheckPermission("dk:dkCustomer:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
@@ -46,15 +39,6 @@ public class DkCustomerController extends BaseController {
|
|||||||
return TableDataInfo.build(page);
|
return TableDataInfo.build(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "导出客户列表")
|
|
||||||
@SaCheckPermission("dk:dkCustomer:export")
|
|
||||||
@Log(title = "客户", businessType = BusinessType.EXPORT)
|
|
||||||
@GetMapping("/export")
|
|
||||||
public void export(@Validated CustomerAdminResp bo, HttpServletResponse response) {
|
|
||||||
List<CustomerExportVo> list = customerMapper.exportAdmin(bo);
|
|
||||||
ExcelUtil.exportExcel(list, "客户", CustomerExportVo.class, response);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SaCheckPermission("dk:dkCustomer:query")
|
@SaCheckPermission("dk:dkCustomer:query")
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
public R<Customer> getInfo(@NotNull(message = "主键不能为空")
|
public R<Customer> getInfo(@NotNull(message = "主键不能为空")
|
||||||
@@ -82,6 +66,13 @@ public class DkCustomerController extends BaseController {
|
|||||||
@Log(title = "修改密码" , businessType = BusinessType.DELETE)
|
@Log(title = "修改密码" , businessType = BusinessType.DELETE)
|
||||||
@PostMapping("/resetPwd")
|
@PostMapping("/resetPwd")
|
||||||
public R<Void> resetPwd(@RequestBody UpdatePwdCustomerReq customer) {
|
public R<Void> resetPwd(@RequestBody UpdatePwdCustomerReq customer) {
|
||||||
return toAjax(customerService.updatePwd(customer.getCustomerId(),customer.getPassword()));
|
return toAjax(customerService.updatePwd(customer.getCustomerId(),customer.getPassword(),true));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Log(title = "强制T人" , businessType = BusinessType.DELETE)
|
||||||
|
@PostMapping("/loginOut")
|
||||||
|
public R<Void> loginOut(@RequestBody IdReq id) {
|
||||||
|
customerService.loginOut(id.getId());
|
||||||
|
return R.ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.ruoyi.dk.controller.app;
|
package com.ruoyi.dk.controller.app;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.annotation.SaIgnore;
|
||||||
import cn.hutool.core.lang.UUID;
|
import cn.hutool.core.lang.UUID;
|
||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
import com.ruoyi.component.redis.util.RedisUtils;
|
import com.ruoyi.component.redis.util.RedisUtils;
|
||||||
@@ -17,9 +18,10 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@RequestMapping("/customer/open")
|
@RequestMapping("/app/customer/open")
|
||||||
@RestController
|
@RestController
|
||||||
@Tag(name = "用户开放接口")
|
@Tag(name = "用户开放接口")
|
||||||
|
@SaIgnore
|
||||||
public class AppCustomerOpenController {
|
public class AppCustomerOpenController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private CodeService codeService;
|
private CodeService codeService;
|
||||||
@@ -80,7 +82,7 @@ public class AppCustomerOpenController {
|
|||||||
if(!updatePwdOpenReq.getPassword().equals(updatePwdOpenReq.getConfirmPassword())){
|
if(!updatePwdOpenReq.getPassword().equals(updatePwdOpenReq.getConfirmPassword())){
|
||||||
throw new CustomException(MessageUtils.message("dk.password.check.error"));
|
throw new CustomException(MessageUtils.message("dk.password.check.error"));
|
||||||
}
|
}
|
||||||
customerService.updatePwd(customer.getId(),updatePwdOpenReq.getPassword());
|
customerService.updatePwd(customer.getId(),updatePwdOpenReq.getPassword(),true);
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
package com.ruoyi.dk.controller.app;
|
package com.ruoyi.dk.controller.app;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.annotation.SaIgnore;
|
||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
import com.ruoyi.dk.domain.HomeSetting;
|
import com.ruoyi.dk.domain.HomeSetting;
|
||||||
import com.ruoyi.dk.domain.LoansSetting;
|
import com.ruoyi.dk.domain.LoansSetting;
|
||||||
@@ -28,6 +29,7 @@ import java.util.Random;
|
|||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/app/home/loans")
|
@RequestMapping("/app/home/loans")
|
||||||
@Tag(name = "首页开放")
|
@Tag(name = "首页开放")
|
||||||
|
@SaIgnore
|
||||||
public class AppHomeController {
|
public class AppHomeController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import com.ruoyi.component.core.util.BeanConvertUtil;
|
|||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
package com.ruoyi.dk.controller.app;
|
package com.ruoyi.dk.controller.app;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.annotation.SaIgnore;
|
||||||
import com.ruoyi.dk.dto.app.req.LoginPhoneBody;
|
import com.ruoyi.dk.dto.app.req.LoginPhoneBody;
|
||||||
import com.ruoyi.dk.kit.DkLoginKit;
|
import com.ruoyi.dk.kit.DkLoginKit;
|
||||||
import com.ruoyi.component.core.domain.R;
|
import com.ruoyi.component.core.domain.R;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
@@ -17,8 +19,9 @@ public class LoginV2Controller {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private DkLoginKit dkLoginKit;
|
private DkLoginKit dkLoginKit;
|
||||||
|
|
||||||
@PostMapping("/customer/login")
|
@PostMapping("/app/customer/login")
|
||||||
@Operation(summary = "用户登陆")
|
@Operation(summary = "用户登陆")
|
||||||
|
@SaIgnore
|
||||||
public R<Map<String, Object>> loginCustomer(@RequestBody LoginPhoneBody loginBody) {
|
public R<Map<String, Object>> loginCustomer(@RequestBody LoginPhoneBody loginBody) {
|
||||||
Map<String, Object> ajax = new HashMap<>();
|
Map<String, Object> ajax = new HashMap<>();
|
||||||
String token = dkLoginKit.login(loginBody.getMobile(),loginBody.getPassword());
|
String token = dkLoginKit.login(loginBody.getMobile(),loginBody.getPassword());
|
||||||
|
|||||||
@@ -12,9 +12,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
|||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,6 +21,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@Tag(name = "通用接口")
|
@Tag(name = "通用接口")
|
||||||
|
@RequestMapping("/app/v2/common")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class V2CommonController {
|
public class V2CommonController {
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -30,7 +29,7 @@ public class V2CommonController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ISysOssService iSysOssService;
|
private ISysOssService iSysOssService;
|
||||||
|
|
||||||
@GetMapping("/v2/common/sts")
|
@GetMapping("/sts")
|
||||||
@Operation(summary = "文件上传")
|
@Operation(summary = "文件上传")
|
||||||
public R getSts(){
|
public R getSts(){
|
||||||
StsResult stsToken = stsOssKit.getStsToken();
|
StsResult stsToken = stsOssKit.getStsToken();
|
||||||
@@ -40,7 +39,7 @@ public class V2CommonController {
|
|||||||
return R.ok(stsToken);
|
return R.ok(stsToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/v2/common/upload")
|
@PostMapping("/upload")
|
||||||
@Operation(summary = "文件上传")
|
@Operation(summary = "文件上传")
|
||||||
public R uploadFile(MultipartFile file) {
|
public R uploadFile(MultipartFile file) {
|
||||||
if (ObjectUtil.isNull(file)) {
|
if (ObjectUtil.isNull(file)) {
|
||||||
|
|||||||
@@ -38,6 +38,9 @@ public class Customer implements Serializable {
|
|||||||
@Schema(description = "用户名称")
|
@Schema(description = "用户名称")
|
||||||
private String nickName;
|
private String nickName;
|
||||||
|
|
||||||
|
@Schema(description = "用户编号")
|
||||||
|
private String userCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户密码
|
* 用户密码
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package com.ruoyi.dk.dto.common;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class IdReq {
|
||||||
|
private Long id;
|
||||||
|
}
|
||||||
@@ -2,8 +2,10 @@ package com.ruoyi.dk.listener;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.ruoyi.component.core.constant.TenantConstants;
|
import com.ruoyi.component.core.constant.TenantConstants;
|
||||||
|
import com.ruoyi.dk.domain.AgreementSetting;
|
||||||
import com.ruoyi.dk.domain.HomeSetting;
|
import com.ruoyi.dk.domain.HomeSetting;
|
||||||
import com.ruoyi.dk.domain.LoansSetting;
|
import com.ruoyi.dk.domain.LoansSetting;
|
||||||
|
import com.ruoyi.dk.service.AgreementSettingService;
|
||||||
import com.ruoyi.dk.service.HomeSettingService;
|
import com.ruoyi.dk.service.HomeSettingService;
|
||||||
import com.ruoyi.dk.service.LoansSettingService;
|
import com.ruoyi.dk.service.LoansSettingService;
|
||||||
import com.ruoyi.system.event.AddTenantEvent;
|
import com.ruoyi.system.event.AddTenantEvent;
|
||||||
@@ -20,6 +22,8 @@ public class AddTenantEventListener {
|
|||||||
private HomeSettingService homeSettingService;
|
private HomeSettingService homeSettingService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private LoansSettingService loansSettingService;
|
private LoansSettingService loansSettingService;
|
||||||
|
@Autowired
|
||||||
|
private AgreementSettingService agreementSettingService;
|
||||||
|
|
||||||
@EventListener
|
@EventListener
|
||||||
public void event(AddTenantEvent addTenantEvent){
|
public void event(AddTenantEvent addTenantEvent){
|
||||||
@@ -34,6 +38,12 @@ public class AddTenantEventListener {
|
|||||||
setting.setTenantId(addTenantEvent.getTenantId());
|
setting.setTenantId(addTenantEvent.getTenantId());
|
||||||
setting.setId(null);
|
setting.setId(null);
|
||||||
}
|
}
|
||||||
|
List<AgreementSetting> agreementSettingList = agreementSettingService.list(Wrappers.lambdaQuery(AgreementSetting.class).eq(AgreementSetting::getTenantId, defaultTenantId));
|
||||||
|
for (AgreementSetting setting : agreementSettingList) {
|
||||||
|
setting.setTenantId(addTenantEvent.getTenantId());
|
||||||
|
setting.setId(null);
|
||||||
|
}
|
||||||
|
agreementSettingService.saveBatch(agreementSettingList);
|
||||||
homeSettingService.saveBatch(homeSettingList);
|
homeSettingService.saveBatch(homeSettingList);
|
||||||
loansSettingService.saveBatch(loansSettingList);
|
loansSettingService.saveBatch(loansSettingList);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ import com.aliyuncs.auth.sts.AssumeRoleResponse;
|
|||||||
import com.aliyuncs.exceptions.ClientException;
|
import com.aliyuncs.exceptions.ClientException;
|
||||||
import com.aliyuncs.exceptions.ServerException;
|
import com.aliyuncs.exceptions.ServerException;
|
||||||
import com.aliyuncs.profile.DefaultProfile;
|
import com.aliyuncs.profile.DefaultProfile;
|
||||||
|
import com.ruoyi.component.core.exception.ServiceException;
|
||||||
|
import com.ruoyi.component.satoken.utils.LoginHelper;
|
||||||
|
import com.ruoyi.system.domain.vo.SysTenantVo;
|
||||||
|
import com.ruoyi.system.service.ISysTenantService;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -27,7 +31,9 @@ public class StsOssKit {
|
|||||||
@Getter
|
@Getter
|
||||||
private OssConfig ossConfig;
|
private OssConfig ossConfig;
|
||||||
@Getter
|
@Getter
|
||||||
public IAcsClient acsClient = null;
|
private IAcsClient acsClient = null;
|
||||||
|
@Autowired
|
||||||
|
private ISysTenantService tenantService;
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void init(){
|
public void init(){
|
||||||
@@ -41,6 +47,10 @@ public class StsOssKit {
|
|||||||
|
|
||||||
|
|
||||||
public StsResult getStsToken(){
|
public StsResult getStsToken(){
|
||||||
|
SysTenantVo tenant = tenantService.queryByTenantId(LoginHelper.getTenantId());
|
||||||
|
if(tenant == null){
|
||||||
|
throw new ServiceException("平台错误");
|
||||||
|
}
|
||||||
// 创建API请求并设置参数
|
// 创建API请求并设置参数
|
||||||
AssumeRoleRequest request = new AssumeRoleRequest();
|
AssumeRoleRequest request = new AssumeRoleRequest();
|
||||||
request.setDurationSeconds(ossConfig.getDurationSeconds());
|
request.setDurationSeconds(ossConfig.getDurationSeconds());
|
||||||
@@ -58,7 +68,7 @@ public class StsOssKit {
|
|||||||
stsResult.setRegion("oss-"+ossConfig.getEndpoint());
|
stsResult.setRegion("oss-"+ossConfig.getEndpoint());
|
||||||
stsResult.setBucket(ossConfig.getBucketName());
|
stsResult.setBucket(ossConfig.getBucketName());
|
||||||
String nowStr = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
|
String nowStr = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
|
||||||
stsResult.setKey(ossConfig.getKey()+nowStr+"/");
|
stsResult.setKey(ossConfig.getKey()+tenant.getPrefix()+"/"+nowStr+"/");
|
||||||
stsResult.setCdnDomain(ossConfig.getCdnDomain());
|
stsResult.setCdnDomain(ossConfig.getCdnDomain());
|
||||||
return stsResult;
|
return stsResult;
|
||||||
} catch (ServerException e) {
|
} catch (ServerException e) {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public interface CustomerService extends IService<Customer> {
|
|||||||
|
|
||||||
void register(CustomerRegisterReq register);
|
void register(CustomerRegisterReq register);
|
||||||
|
|
||||||
boolean updatePwd(Long id, String password);
|
boolean updatePwd(Long id, String password, boolean logout);
|
||||||
|
|
||||||
void borrowAmount(Long customerId, BigDecimal totalLoanMoney,BigDecimal totalRepayment);
|
void borrowAmount(Long customerId, BigDecimal totalLoanMoney,BigDecimal totalRepayment);
|
||||||
|
|
||||||
@@ -23,4 +23,6 @@ public interface CustomerService extends IService<Customer> {
|
|||||||
void dk(Long customerId);
|
void dk(Long customerId);
|
||||||
|
|
||||||
IPage<CustomerAdminResp> pageAdmin(PageQuery pageQuery, CustomerAdminResp bo);
|
IPage<CustomerAdminResp> pageAdmin(PageQuery pageQuery, CustomerAdminResp bo);
|
||||||
|
|
||||||
|
void loginOut(Long id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
package com.ruoyi.dk.service.impl;
|
package com.ruoyi.dk.service.impl;
|
||||||
|
|
||||||
import cn.dev33.satoken.secure.BCrypt;
|
import cn.dev33.satoken.secure.BCrypt;
|
||||||
|
import cn.hutool.core.util.RandomUtil;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.ruoyi.component.core.exception.ServiceException;
|
||||||
import com.ruoyi.component.mybatis.core.page.PageQuery;
|
import com.ruoyi.component.mybatis.core.page.PageQuery;
|
||||||
|
import com.ruoyi.component.satoken.utils.LoginHelper;
|
||||||
|
import com.ruoyi.component.tenant.helper.TenantHelper;
|
||||||
import com.ruoyi.dk.domain.BorrowLog;
|
import com.ruoyi.dk.domain.BorrowLog;
|
||||||
import com.ruoyi.dk.domain.Customer;
|
import com.ruoyi.dk.domain.Customer;
|
||||||
import com.ruoyi.dk.domain.CustomerInfo;
|
import com.ruoyi.dk.domain.CustomerInfo;
|
||||||
@@ -16,11 +20,14 @@ import com.ruoyi.dk.service.CustomerInfoService;
|
|||||||
import com.ruoyi.dk.service.CustomerService;
|
import com.ruoyi.dk.service.CustomerService;
|
||||||
import com.ruoyi.component.core.exception.CustomException;
|
import com.ruoyi.component.core.exception.CustomException;
|
||||||
import com.ruoyi.component.core.util.MessageUtils;
|
import com.ruoyi.component.core.util.MessageUtils;
|
||||||
|
import com.ruoyi.system.domain.vo.SysTenantVo;
|
||||||
|
import com.ruoyi.system.service.ISysTenantService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> implements CustomerService {
|
public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> implements CustomerService {
|
||||||
@@ -28,6 +35,8 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
|||||||
private CustomerInfoService customerInfoService;
|
private CustomerInfoService customerInfoService;
|
||||||
@Resource
|
@Resource
|
||||||
private BorrowLogMapper borrowLogMapper;
|
private BorrowLogMapper borrowLogMapper;
|
||||||
|
@Autowired
|
||||||
|
private ISysTenantService sysTenantService;
|
||||||
@Override
|
@Override
|
||||||
public Customer getCustomerByName(String mobile) {
|
public Customer getCustomerByName(String mobile) {
|
||||||
return this.getOne(Wrappers.lambdaQuery(Customer.class)
|
return this.getOne(Wrappers.lambdaQuery(Customer.class)
|
||||||
@@ -42,7 +51,12 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
|||||||
if(customer != null){
|
if(customer != null){
|
||||||
throw new CustomException(MessageUtils.message("dk.user.already.having"));
|
throw new CustomException(MessageUtils.message("dk.user.already.having"));
|
||||||
}
|
}
|
||||||
|
SysTenantVo vo = sysTenantService.queryByTenantId(TenantHelper.getTenantId());
|
||||||
|
if(vo == null){
|
||||||
|
throw new ServiceException("未找到对应的平台错误");
|
||||||
|
}
|
||||||
customer = new Customer();
|
customer = new Customer();
|
||||||
|
customer.setUserCode(generateUserCode(vo.getPrefix()));
|
||||||
customer.setPhoneNumber(phoneNumber);
|
customer.setPhoneNumber(phoneNumber);
|
||||||
customer.setNickName(MessageUtils.message("dk.user.name")+phoneNumber.substring(phoneNumber.length() - 4));
|
customer.setNickName(MessageUtils.message("dk.user.name")+phoneNumber.substring(phoneNumber.length() - 4));
|
||||||
customer.setPassword(BCrypt.hashpw(register.getPassword()));
|
customer.setPassword(BCrypt.hashpw(register.getPassword()));
|
||||||
@@ -52,11 +66,24 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
|||||||
customerInfoService.save(customerInfo);
|
customerInfoService.save(customerInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String generateUserCode(String prefix) {
|
||||||
|
String userCode = prefix + "-" + RandomUtil.randomNumbers(6);
|
||||||
|
boolean exists = this.exists(Wrappers.lambdaQuery(Customer.class).eq(Customer::getUserCode, userCode));
|
||||||
|
if (exists) {
|
||||||
|
this.generateUserCode(prefix);
|
||||||
|
}
|
||||||
|
return userCode;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updatePwd(Long id, String password) {
|
public boolean updatePwd(Long id, String password,boolean logout) {
|
||||||
return this.update(Wrappers.lambdaUpdate(Customer.class)
|
boolean update = this.update(Wrappers.lambdaUpdate(Customer.class)
|
||||||
.eq(Customer::getId,id)
|
.eq(Customer::getId, id)
|
||||||
.set(Customer::getPassword,BCrypt.hashpw(password)));
|
.set(Customer::getPassword, BCrypt.hashpw(password)));
|
||||||
|
if(update && logout){
|
||||||
|
LoginHelper.logoutApp(id);
|
||||||
|
}
|
||||||
|
return update;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -88,4 +115,9 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
|||||||
public IPage<CustomerAdminResp> pageAdmin(PageQuery pageQuery, CustomerAdminResp bo) {
|
public IPage<CustomerAdminResp> pageAdmin(PageQuery pageQuery, CustomerAdminResp bo) {
|
||||||
return baseMapper.pageAdmin(pageQuery.build(),bo);
|
return baseMapper.pageAdmin(pageQuery.build(),bo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loginOut(Long id) {
|
||||||
|
LoginHelper.logoutApp(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,9 @@
|
|||||||
<if test="bo.phoneNumber != null and bo.phoneNumber != ''">
|
<if test="bo.phoneNumber != null and bo.phoneNumber != ''">
|
||||||
and t1.phone_number like concat('%',#{bo.phoneNumber},'%')
|
and t1.phone_number like concat('%',#{bo.phoneNumber},'%')
|
||||||
</if>
|
</if>
|
||||||
|
<if test="bo.userCode != null and bo.userCode != ''">
|
||||||
|
and t1.user_code = #{bo.userCode}
|
||||||
|
</if>
|
||||||
<if test="bo.nickName != null and bo.nickName != ''">
|
<if test="bo.nickName != null and bo.nickName != ''">
|
||||||
and (t1.nick_name like concat('%',#{bo.nickName},'%') or t2.real_name like concat('%',#{bo.nickName},'%'))
|
and (t1.nick_name like concat('%',#{bo.nickName},'%') or t2.real_name like concat('%',#{bo.nickName},'%'))
|
||||||
</if>
|
</if>
|
||||||
@@ -42,6 +45,9 @@
|
|||||||
<if test="bo.phoneNumber != null and bo.phoneNumber != ''">
|
<if test="bo.phoneNumber != null and bo.phoneNumber != ''">
|
||||||
and t1.phone_number like concat('%',#{bo.phoneNumber},'%')
|
and t1.phone_number like concat('%',#{bo.phoneNumber},'%')
|
||||||
</if>
|
</if>
|
||||||
|
<if test="bo.userCode != null and bo.userCode != ''">
|
||||||
|
and t1.user_code = #{bo.userCode}
|
||||||
|
</if>
|
||||||
<if test="bo.nickName != null and bo.nickName != ''">
|
<if test="bo.nickName != null and bo.nickName != ''">
|
||||||
and (t1.nick_name like concat('%',#{bo.nickName},'%') or t2.real_name like concat('%',#{bo.nickName},'%'))
|
and (t1.nick_name like concat('%',#{bo.nickName},'%') or t2.real_name like concat('%',#{bo.nickName},'%'))
|
||||||
</if>
|
</if>
|
||||||
|
|||||||
@@ -149,6 +149,13 @@ public class SysLoginController {
|
|||||||
return R.ok(menuService.buildMenus(menus));
|
return R.ok(menuService.buildMenus(menus));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("auth/tenant/get")
|
||||||
|
public R<SysTenantVo> getCurrentTenant(HttpServletRequest request){
|
||||||
|
String tenantId = TenantHelper.getTenantId();
|
||||||
|
SysTenantVo vo = tenantService.queryByTenantId(tenantId);
|
||||||
|
return R.ok(vo);
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("auth/tenant/list")
|
@GetMapping("auth/tenant/list")
|
||||||
public R<List<SysTenantVo>> tenantList(HttpServletRequest request){
|
public R<List<SysTenantVo>> tenantList(HttpServletRequest request){
|
||||||
Long userId = LoginHelper.getUserId();
|
Long userId = LoginHelper.getUserId();
|
||||||
|
|||||||
@@ -8,12 +8,14 @@ import cn.hutool.core.util.ArrayUtil;
|
|||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.ruoyi.component.core.constant.UserConstants;
|
import com.ruoyi.component.core.constant.UserConstants;
|
||||||
import com.ruoyi.component.core.domain.R;
|
import com.ruoyi.component.core.domain.R;
|
||||||
|
import com.ruoyi.component.core.exception.ServiceException;
|
||||||
import com.ruoyi.component.excel.core.ExcelResult;
|
import com.ruoyi.component.excel.core.ExcelResult;
|
||||||
import com.ruoyi.component.excel.utils.ExcelUtil;
|
import com.ruoyi.component.excel.utils.ExcelUtil;
|
||||||
import com.ruoyi.component.log.annotation.Log;
|
import com.ruoyi.component.log.annotation.Log;
|
||||||
import com.ruoyi.component.log.enums.BusinessType;
|
import com.ruoyi.component.log.enums.BusinessType;
|
||||||
import com.ruoyi.component.mybatis.core.page.PageQuery;
|
import com.ruoyi.component.mybatis.core.page.PageQuery;
|
||||||
import com.ruoyi.component.mybatis.core.page.TableDataInfo;
|
import com.ruoyi.component.mybatis.core.page.TableDataInfo;
|
||||||
|
import com.ruoyi.component.tenant.helper.TenantHelper;
|
||||||
import com.ruoyi.component.web.core.BaseController;
|
import com.ruoyi.component.web.core.BaseController;
|
||||||
import com.ruoyi.system.domain.SysDept;
|
import com.ruoyi.system.domain.SysDept;
|
||||||
import com.ruoyi.system.domain.SysRole;
|
import com.ruoyi.system.domain.SysRole;
|
||||||
@@ -22,13 +24,11 @@ import com.ruoyi.component.satoken.utils.LoginHelper;
|
|||||||
import com.ruoyi.component.core.util.StreamUtils;
|
import com.ruoyi.component.core.util.StreamUtils;
|
||||||
import com.ruoyi.component.core.util.StringUtils;
|
import com.ruoyi.component.core.util.StringUtils;
|
||||||
import com.ruoyi.system.domain.SysPost;
|
import com.ruoyi.system.domain.SysPost;
|
||||||
|
import com.ruoyi.system.domain.vo.SysTenantVo;
|
||||||
import com.ruoyi.system.domain.vo.SysUserExportVo;
|
import com.ruoyi.system.domain.vo.SysUserExportVo;
|
||||||
import com.ruoyi.system.domain.vo.SysUserImportVo;
|
import com.ruoyi.system.domain.vo.SysUserImportVo;
|
||||||
import com.ruoyi.system.listener.SysUserImportListener;
|
import com.ruoyi.system.listener.SysUserImportListener;
|
||||||
import com.ruoyi.system.service.ISysDeptService;
|
import com.ruoyi.system.service.*;
|
||||||
import com.ruoyi.system.service.ISysPostService;
|
|
||||||
import com.ruoyi.system.service.ISysRoleService;
|
|
||||||
import com.ruoyi.system.service.ISysUserService;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@@ -40,6 +40,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户信息
|
* 用户信息
|
||||||
@@ -56,6 +57,7 @@ public class SysUserController extends BaseController {
|
|||||||
private final ISysRoleService roleService;
|
private final ISysRoleService roleService;
|
||||||
private final ISysPostService postService;
|
private final ISysPostService postService;
|
||||||
private final ISysDeptService deptService;
|
private final ISysDeptService deptService;
|
||||||
|
private final ISysTenantService sysTenantService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户列表
|
* 获取用户列表
|
||||||
@@ -141,8 +143,18 @@ public class SysUserController extends BaseController {
|
|||||||
@Log(title = "用户管理", businessType = BusinessType.INSERT)
|
@Log(title = "用户管理", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public R<Void> add(@Validated @RequestBody SysUser user) {
|
public R<Void> add(@Validated @RequestBody SysUser user) {
|
||||||
|
SysTenantVo vo = sysTenantService.queryByTenantId(TenantHelper.getTenantId());
|
||||||
|
if(vo == null){
|
||||||
|
throw new ServiceException("未找到对应的平台");
|
||||||
|
}
|
||||||
|
user.setUserName(vo.getPrefix()+"-"+user.getUserName());
|
||||||
|
user.setPrefix(vo.getPrefix());
|
||||||
deptService.checkDeptDataScope(user.getDeptId());
|
deptService.checkDeptDataScope(user.getDeptId());
|
||||||
if (!userService.checkUserNameUnique(user)) {
|
AtomicBoolean checkUserName = new AtomicBoolean(false);
|
||||||
|
TenantHelper.ignore(() -> {
|
||||||
|
checkUserName.set(userService.checkUserNameUnique(user));
|
||||||
|
});
|
||||||
|
if (!checkUserName.get()) {
|
||||||
return R.fail("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
|
return R.fail("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
|
||||||
} else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) {
|
} else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) {
|
||||||
return R.fail("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
|
return R.fail("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||||
|
|||||||
@@ -56,7 +56,6 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
|||||||
private final SysPostMapper postMapper;
|
private final SysPostMapper postMapper;
|
||||||
private final SysUserRoleMapper userRoleMapper;
|
private final SysUserRoleMapper userRoleMapper;
|
||||||
private final SysUserPostMapper userPostMapper;
|
private final SysUserPostMapper userPostMapper;
|
||||||
private final ISysTenantService sysTenantService;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableDataInfo<SysUser> selectPageUserList(SysUser user, PageQuery pageQuery) {
|
public TableDataInfo<SysUser> selectPageUserList(SysUser user, PageQuery pageQuery) {
|
||||||
@@ -274,11 +273,6 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public int insertUser(SysUser user) {
|
public int insertUser(SysUser user) {
|
||||||
SysTenantVo vo = sysTenantService.queryByTenantId(TenantHelper.getTenantId());
|
|
||||||
if(vo == null){
|
|
||||||
throw new ServiceException("未找到对应的平台");
|
|
||||||
}
|
|
||||||
user.setUserName(vo.getPrefix()+"-"+user.getUserName());
|
|
||||||
// 新增用户信息
|
// 新增用户信息
|
||||||
int rows = baseMapper.insert(user);
|
int rows = baseMapper.insert(user);
|
||||||
// 新增用户岗位关联
|
// 新增用户岗位关联
|
||||||
|
|||||||
Reference in New Issue
Block a user