init
This commit is contained in:
@@ -2,7 +2,7 @@ package com.ruoyi.dk.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
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.log.annotation.Log;
|
||||
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.dto.admin.req.UpdatePwdCustomerReq;
|
||||
import com.ruoyi.dk.dto.admin.resp.CustomerAdminResp;
|
||||
import com.ruoyi.dk.dto.admin.resp.CustomerExportVo;
|
||||
import com.ruoyi.dk.mapper.CustomerMapper;
|
||||
import com.ruoyi.dk.dto.common.IdReq;
|
||||
import com.ruoyi.dk.service.CustomerService;
|
||||
import com.ruoyi.component.core.domain.R;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
@@ -36,8 +31,6 @@ import java.util.stream.Stream;
|
||||
public class DkCustomerController extends BaseController {
|
||||
|
||||
private final CustomerService customerService;
|
||||
@Resource
|
||||
private CustomerMapper customerMapper;
|
||||
|
||||
@SaCheckPermission("dk:dkCustomer:list")
|
||||
@GetMapping("/list")
|
||||
@@ -46,15 +39,6 @@ public class DkCustomerController extends BaseController {
|
||||
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")
|
||||
@GetMapping("/{id}")
|
||||
public R<Customer> getInfo(@NotNull(message = "主键不能为空")
|
||||
@@ -82,6 +66,13 @@ public class DkCustomerController extends BaseController {
|
||||
@Log(title = "修改密码" , businessType = BusinessType.DELETE)
|
||||
@PostMapping("/resetPwd")
|
||||
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;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import cn.hutool.core.lang.UUID;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
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.web.bind.annotation.*;
|
||||
|
||||
@RequestMapping("/customer/open")
|
||||
@RequestMapping("/app/customer/open")
|
||||
@RestController
|
||||
@Tag(name = "用户开放接口")
|
||||
@SaIgnore
|
||||
public class AppCustomerOpenController {
|
||||
@Autowired
|
||||
private CodeService codeService;
|
||||
@@ -80,7 +82,7 @@ public class AppCustomerOpenController {
|
||||
if(!updatePwdOpenReq.getPassword().equals(updatePwdOpenReq.getConfirmPassword())){
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
|
||||
package com.ruoyi.dk.controller.app;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.ruoyi.dk.domain.HomeSetting;
|
||||
import com.ruoyi.dk.domain.LoansSetting;
|
||||
@@ -28,6 +29,7 @@ import java.util.Random;
|
||||
@RestController
|
||||
@RequestMapping("/app/home/loans")
|
||||
@Tag(name = "首页开放")
|
||||
@SaIgnore
|
||||
public class AppHomeController {
|
||||
|
||||
@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.tags.Tag;
|
||||
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.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package com.ruoyi.dk.controller.app;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import com.ruoyi.dk.dto.app.req.LoginPhoneBody;
|
||||
import com.ruoyi.dk.kit.DkLoginKit;
|
||||
import com.ruoyi.component.core.domain.R;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
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.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@@ -17,8 +19,9 @@ public class LoginV2Controller {
|
||||
@Autowired
|
||||
private DkLoginKit dkLoginKit;
|
||||
|
||||
@PostMapping("/customer/login")
|
||||
@PostMapping("/app/customer/login")
|
||||
@Operation(summary = "用户登陆")
|
||||
@SaIgnore
|
||||
public R<Map<String, Object>> loginCustomer(@RequestBody LoginPhoneBody loginBody) {
|
||||
Map<String, Object> ajax = new HashMap<>();
|
||||
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 lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
@@ -23,6 +21,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
*/
|
||||
@RestController
|
||||
@Tag(name = "通用接口")
|
||||
@RequestMapping("/app/v2/common")
|
||||
@Slf4j
|
||||
public class V2CommonController {
|
||||
@Autowired
|
||||
@@ -30,7 +29,7 @@ public class V2CommonController {
|
||||
@Autowired
|
||||
private ISysOssService iSysOssService;
|
||||
|
||||
@GetMapping("/v2/common/sts")
|
||||
@GetMapping("/sts")
|
||||
@Operation(summary = "文件上传")
|
||||
public R getSts(){
|
||||
StsResult stsToken = stsOssKit.getStsToken();
|
||||
@@ -40,7 +39,7 @@ public class V2CommonController {
|
||||
return R.ok(stsToken);
|
||||
}
|
||||
|
||||
@PostMapping("/v2/common/upload")
|
||||
@PostMapping("/upload")
|
||||
@Operation(summary = "文件上传")
|
||||
public R uploadFile(MultipartFile file) {
|
||||
if (ObjectUtil.isNull(file)) {
|
||||
|
||||
@@ -38,6 +38,9 @@ public class Customer implements Serializable {
|
||||
@Schema(description = "用户名称")
|
||||
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.ruoyi.component.core.constant.TenantConstants;
|
||||
import com.ruoyi.dk.domain.AgreementSetting;
|
||||
import com.ruoyi.dk.domain.HomeSetting;
|
||||
import com.ruoyi.dk.domain.LoansSetting;
|
||||
import com.ruoyi.dk.service.AgreementSettingService;
|
||||
import com.ruoyi.dk.service.HomeSettingService;
|
||||
import com.ruoyi.dk.service.LoansSettingService;
|
||||
import com.ruoyi.system.event.AddTenantEvent;
|
||||
@@ -20,6 +22,8 @@ public class AddTenantEventListener {
|
||||
private HomeSettingService homeSettingService;
|
||||
@Autowired
|
||||
private LoansSettingService loansSettingService;
|
||||
@Autowired
|
||||
private AgreementSettingService agreementSettingService;
|
||||
|
||||
@EventListener
|
||||
public void event(AddTenantEvent addTenantEvent){
|
||||
@@ -34,6 +38,12 @@ public class AddTenantEventListener {
|
||||
setting.setTenantId(addTenantEvent.getTenantId());
|
||||
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);
|
||||
loansSettingService.saveBatch(loansSettingList);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,10 @@ import com.aliyuncs.auth.sts.AssumeRoleResponse;
|
||||
import com.aliyuncs.exceptions.ClientException;
|
||||
import com.aliyuncs.exceptions.ServerException;
|
||||
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.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -27,7 +31,9 @@ public class StsOssKit {
|
||||
@Getter
|
||||
private OssConfig ossConfig;
|
||||
@Getter
|
||||
public IAcsClient acsClient = null;
|
||||
private IAcsClient acsClient = null;
|
||||
@Autowired
|
||||
private ISysTenantService tenantService;
|
||||
|
||||
@PostConstruct
|
||||
public void init(){
|
||||
@@ -41,6 +47,10 @@ public class StsOssKit {
|
||||
|
||||
|
||||
public StsResult getStsToken(){
|
||||
SysTenantVo tenant = tenantService.queryByTenantId(LoginHelper.getTenantId());
|
||||
if(tenant == null){
|
||||
throw new ServiceException("平台错误");
|
||||
}
|
||||
// 创建API请求并设置参数
|
||||
AssumeRoleRequest request = new AssumeRoleRequest();
|
||||
request.setDurationSeconds(ossConfig.getDurationSeconds());
|
||||
@@ -58,7 +68,7 @@ public class StsOssKit {
|
||||
stsResult.setRegion("oss-"+ossConfig.getEndpoint());
|
||||
stsResult.setBucket(ossConfig.getBucketName());
|
||||
String nowStr = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
|
||||
stsResult.setKey(ossConfig.getKey()+nowStr+"/");
|
||||
stsResult.setKey(ossConfig.getKey()+tenant.getPrefix()+"/"+nowStr+"/");
|
||||
stsResult.setCdnDomain(ossConfig.getCdnDomain());
|
||||
return stsResult;
|
||||
} catch (ServerException e) {
|
||||
|
||||
@@ -14,7 +14,7 @@ public interface CustomerService extends IService<Customer> {
|
||||
|
||||
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);
|
||||
|
||||
@@ -23,4 +23,6 @@ public interface CustomerService extends IService<Customer> {
|
||||
void dk(Long customerId);
|
||||
|
||||
IPage<CustomerAdminResp> pageAdmin(PageQuery pageQuery, CustomerAdminResp bo);
|
||||
|
||||
void loginOut(Long id);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
package com.ruoyi.dk.service.impl;
|
||||
|
||||
import cn.dev33.satoken.secure.BCrypt;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
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.satoken.utils.LoginHelper;
|
||||
import com.ruoyi.component.tenant.helper.TenantHelper;
|
||||
import com.ruoyi.dk.domain.BorrowLog;
|
||||
import com.ruoyi.dk.domain.Customer;
|
||||
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.component.core.exception.CustomException;
|
||||
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.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> implements CustomerService {
|
||||
@@ -28,6 +35,8 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
||||
private CustomerInfoService customerInfoService;
|
||||
@Resource
|
||||
private BorrowLogMapper borrowLogMapper;
|
||||
@Autowired
|
||||
private ISysTenantService sysTenantService;
|
||||
@Override
|
||||
public Customer getCustomerByName(String mobile) {
|
||||
return this.getOne(Wrappers.lambdaQuery(Customer.class)
|
||||
@@ -42,7 +51,12 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
||||
if(customer != null){
|
||||
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.setUserCode(generateUserCode(vo.getPrefix()));
|
||||
customer.setPhoneNumber(phoneNumber);
|
||||
customer.setNickName(MessageUtils.message("dk.user.name")+phoneNumber.substring(phoneNumber.length() - 4));
|
||||
customer.setPassword(BCrypt.hashpw(register.getPassword()));
|
||||
@@ -52,11 +66,24 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
||||
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
|
||||
public boolean updatePwd(Long id, String password) {
|
||||
return this.update(Wrappers.lambdaUpdate(Customer.class)
|
||||
.eq(Customer::getId,id)
|
||||
.set(Customer::getPassword,BCrypt.hashpw(password)));
|
||||
public boolean updatePwd(Long id, String password,boolean logout) {
|
||||
boolean update = this.update(Wrappers.lambdaUpdate(Customer.class)
|
||||
.eq(Customer::getId, id)
|
||||
.set(Customer::getPassword, BCrypt.hashpw(password)));
|
||||
if(update && logout){
|
||||
LoginHelper.logoutApp(id);
|
||||
}
|
||||
return update;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -88,4 +115,9 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
||||
public IPage<CustomerAdminResp> pageAdmin(PageQuery pageQuery, CustomerAdminResp 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 != ''">
|
||||
and t1.phone_number like concat('%',#{bo.phoneNumber},'%')
|
||||
</if>
|
||||
<if test="bo.userCode != null and bo.userCode != ''">
|
||||
and t1.user_code = #{bo.userCode}
|
||||
</if>
|
||||
<if test="bo.nickName != null and bo.nickName != ''">
|
||||
and (t1.nick_name like concat('%',#{bo.nickName},'%') or t2.real_name like concat('%',#{bo.nickName},'%'))
|
||||
</if>
|
||||
@@ -42,6 +45,9 @@
|
||||
<if test="bo.phoneNumber != null and bo.phoneNumber != ''">
|
||||
and t1.phone_number like concat('%',#{bo.phoneNumber},'%')
|
||||
</if>
|
||||
<if test="bo.userCode != null and bo.userCode != ''">
|
||||
and t1.user_code = #{bo.userCode}
|
||||
</if>
|
||||
<if test="bo.nickName != null and bo.nickName != ''">
|
||||
and (t1.nick_name like concat('%',#{bo.nickName},'%') or t2.real_name like concat('%',#{bo.nickName},'%'))
|
||||
</if>
|
||||
|
||||
Reference in New Issue
Block a user