This commit is contained in:
dute7liang
2023-12-19 22:25:27 +08:00
parent 5676aa7fde
commit 5b04a92a55
385 changed files with 31644 additions and 0 deletions

View File

@@ -0,0 +1,103 @@
package com.bashi.dk.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.bashi.common.annotation.Log;
import com.bashi.common.annotation.RepeatSubmit;
import com.bashi.common.com.Condition;
import com.bashi.common.com.PageParams;
import com.bashi.common.core.controller.BaseController;
import com.bashi.common.core.domain.AjaxResult;
import com.bashi.common.core.page.TableDataInfo;
import com.bashi.common.enums.BusinessType;
import com.bashi.common.utils.PageUtils;
import com.bashi.dk.domain.BorrowStatus;
import com.bashi.dk.enums.BankTypeEnums;
import com.bashi.dk.service.BorrowStatusService;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/dk/BorrowStatus")
public class BorrowStatusController extends BaseController {
private final BorrowStatusService borrowStatusService;
/**
* 查询借款状态列表
*/
@PreAuthorize("@ss.hasPermi('dk:BorrowStatus:list')")
@GetMapping("/list")
public TableDataInfo<BorrowStatus> list(PageParams pageParams, @Validated BorrowStatus bo) {
IPage<BorrowStatus> page = borrowStatusService.page(Condition.getPage(pageParams), Wrappers.query(bo));
return PageUtils.buildDataInfo(page);
}
@GetMapping("/bankType")
public AjaxResult<List<String>> bankType(){
List<String> list = Arrays.stream(BankTypeEnums.values()).map(BankTypeEnums::getName).collect(Collectors.toList());
return AjaxResult.success(list);
}
@GetMapping("/all")
public AjaxResult<List<BorrowStatus>> all(){
List<BorrowStatus> list = borrowStatusService.list();
return AjaxResult.success(list);
}
/**
* 获取借款状态详细信息
*/
@PreAuthorize("@ss.hasPermi('dk:BorrowStatus:query')")
@GetMapping("/{id}")
public AjaxResult<BorrowStatus> getInfo(@NotNull(message = "主键不能为空")
@PathVariable("id") Long id) {
return AjaxResult.success(borrowStatusService.getById(id));
}
/**
* 新增借款状态
*/
@PreAuthorize("@ss.hasPermi('dk:BorrowStatus:add')")
@Log(title = "借款状态", businessType = BusinessType.INSERT)
@RepeatSubmit
@PostMapping()
public AjaxResult<Void> add(@Validated @RequestBody BorrowStatus bo) {
return toAjax(borrowStatusService.save(bo) ? 1 : 0);
}
/**
* 修改借款状态
*/
@PreAuthorize("@ss.hasPermi('dk:BorrowStatus:edit')")
@Log(title = "借款状态", businessType = BusinessType.UPDATE)
@RepeatSubmit
@PutMapping()
public AjaxResult<Void> edit(@Validated @RequestBody BorrowStatus bo) {
return toAjax(borrowStatusService.updateById(bo) ? 1 : 0);
}
/**
* 删除借款状态
*/
@PreAuthorize("@ss.hasPermi('dk:BorrowStatus:remove')")
@Log(title = "借款状态" , businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult<Void> remove(@NotEmpty(message = "主键不能为空")
@PathVariable String ids) {
List<String> idList = Stream.of(ids.split(",")).collect(Collectors.toList());
return toAjax(borrowStatusService.removeByIds(idList) ? 1 : 0);
}
}

View File

@@ -0,0 +1,43 @@
package com.bashi.dk.controller;
import com.bashi.common.annotation.Log;
import com.bashi.common.annotation.RepeatSubmit;
import com.bashi.common.core.controller.BaseController;
import com.bashi.common.core.domain.AjaxResult;
import com.bashi.common.enums.BusinessType;
import com.bashi.dk.domain.AgreementSetting;
import com.bashi.dk.service.AgreementSettingService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/dk/AgreementSetting")
public class DkAgreementSettingController extends BaseController {
private final AgreementSettingService agreementSettingService;
/**
* 获取协议设置详细信息
*/
@PreAuthorize("@ss.hasPermi('dk:AgreementSetting:query')")
@GetMapping("/info")
public AjaxResult<AgreementSetting> getInfo() {
return AjaxResult.success(agreementSettingService.getAgreementSetting());
}
/**
* 修改协议设置
*/
@PreAuthorize("@ss.hasPermi('dk:AgreementSetting:edit')")
@Log(title = "协议设置", businessType = BusinessType.UPDATE)
@RepeatSubmit
@PutMapping()
public AjaxResult<Void> edit(@Validated @RequestBody AgreementSetting bo) {
return toAjax(agreementSettingService.updateById(bo) ? 1 : 0);
}
}

View File

@@ -0,0 +1,124 @@
package com.bashi.dk.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.bashi.common.annotation.Log;
import com.bashi.common.annotation.RepeatSubmit;
import com.bashi.common.com.Condition;
import com.bashi.common.com.PageParams;
import com.bashi.common.core.controller.BaseController;
import com.bashi.common.core.domain.AjaxResult;
import com.bashi.common.core.page.TableDataInfo;
import com.bashi.common.enums.BusinessType;
import com.bashi.common.utils.PageUtils;
import com.bashi.dk.domain.Borrow;
import com.bashi.dk.dto.admin.req.BorrowUpdateStatusReq;
import com.bashi.dk.dto.admin.resp.BorrowResp;
import com.bashi.dk.service.BorrowService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/dk/borrow")
public class DkBorrowController extends BaseController {
private final BorrowService borrowService;
/**
* 查询借款计划列表
*/
@PreAuthorize("@ss.hasPermi('dk:borrow:list')")
@GetMapping("/list")
public TableDataInfo<BorrowResp> list(PageParams pageParams, @Validated Borrow bo) {
IPage<BorrowResp> page = borrowService.pageAdmin(pageParams, bo);
return PageUtils.buildDataInfo(page);
}
/**
* 获取借款计划详细信息
*/
@PreAuthorize("@ss.hasPermi('dk:borrow:query')")
@GetMapping("/{id}")
public AjaxResult<Borrow> getInfo(@NotNull(message = "主键不能为空")
@PathVariable("id") Long id) {
return AjaxResult.success(borrowService.getById(id));
}
/**
* 新增借款计划
*/
@PreAuthorize("@ss.hasPermi('dk:borrow:add')")
@Log(title = "借款计划", businessType = BusinessType.INSERT)
@RepeatSubmit
@PostMapping()
public AjaxResult<Void> add(@Validated @RequestBody Borrow bo) {
return toAjax(borrowService.save(bo) ? 1 : 0);
}
/**
* 修改借款计划
*/
@PreAuthorize("@ss.hasPermi('dk:borrow:edit')")
@Log(title = "借款计划", businessType = BusinessType.UPDATE)
@RepeatSubmit
@PutMapping()
public AjaxResult<Void> edit(@Validated @RequestBody Borrow bo) {
return toAjax(borrowService.updateById(bo) ? 1 : 0);
}
@Log(title = "修改接口银行卡", businessType = BusinessType.UPDATE)
@PostMapping("updateBank")
public AjaxResult<Void> updateBank(@RequestBody Borrow bo) {
return toAjax(borrowService.updateBank(bo));
}
@PreAuthorize("@ss.hasPermi('dk:borrow:edit')")
@Log(title = "修改借款", businessType = BusinessType.UPDATE)
@RepeatSubmit
@PostMapping("/updateLoan")
public AjaxResult<Void> updateLoan(@Validated @RequestBody Borrow bo) {
return toAjax(borrowService.updateLoan(bo));
}
@PreAuthorize("@ss.hasPermi('dk:borrow:edit')")
@Log(title = "修改借款状态", businessType = BusinessType.UPDATE)
@RepeatSubmit
@PostMapping("/updateStatus")
public AjaxResult<Void> updateStatus(@Validated @RequestBody BorrowUpdateStatusReq bo) {
return toAjax(borrowService.updateStatus(bo));
}
/**
* 删除借款计划
*/
@PreAuthorize("@ss.hasPermi('dk:borrow:remove')")
@Log(title = "借款计划" , businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult<Void> remove(@NotEmpty(message = "主键不能为空")
@PathVariable String ids) {
List<String> idList = Stream.of(ids.split(",")).collect(Collectors.toList());
return toAjax(borrowService.removeByIds(idList) ? 1 : 0);
}
@GetMapping("/getContract")
public AjaxResult<String> getContract(String tradeNo){
String contract = borrowService.getContract(tradeNo);
AjaxResult<String> success = AjaxResult.success();
success.setData(contract);
return success;
}
}

View File

@@ -0,0 +1,88 @@
package com.bashi.dk.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.bashi.common.annotation.Log;
import com.bashi.common.annotation.RepeatSubmit;
import com.bashi.common.com.PageParams;
import com.bashi.common.core.controller.BaseController;
import com.bashi.common.core.domain.AjaxResult;
import com.bashi.common.core.domain.entity.Customer;
import com.bashi.common.core.page.TableDataInfo;
import com.bashi.common.enums.BusinessType;
import com.bashi.common.utils.PageUtils;
import com.bashi.common.utils.poi.ExcelUtil;
import com.bashi.dk.dto.admin.req.UpdatePwdCustomerReq;
import com.bashi.dk.dto.admin.resp.CustomerAdminResp;
import com.bashi.dk.dto.admin.resp.CustomerExportVo;
import com.bashi.dk.mapper.CustomerMapper;
import com.bashi.dk.service.CustomerService;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/dk/dkCustomer")
public class DkCustomerController extends BaseController {
private final CustomerService customerService;
@Resource
private CustomerMapper customerMapper;
@PreAuthorize("@ss.hasPermi('dk:dkCustomer:list')")
@GetMapping("/list")
public TableDataInfo<CustomerAdminResp> list(PageParams pageParams, @Validated CustomerAdminResp bo) {
IPage<CustomerAdminResp> page = customerService.pageAdmin(pageParams, bo);
return PageUtils.buildDataInfo(page);
}
@ApiOperation("导出客户列表")
@PreAuthorize("@ss.hasPermi('dk:dkCustomer:export')")
@Log(title = "客户", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult<CustomerExportVo> export(@Validated CustomerAdminResp bo) {
List<CustomerExportVo> list = customerMapper.exportAdmin(bo);
ExcelUtil<CustomerExportVo> util = new ExcelUtil<>(CustomerExportVo.class);
return util.exportExcel(list, "客户");
}
@PreAuthorize("@ss.hasPermi('dk:dkCustomer:query')")
@GetMapping("/{id}")
public AjaxResult<Customer> getInfo(@NotNull(message = "主键不能为空")
@PathVariable("id") Long id) {
return AjaxResult.success(customerService.getById(id));
}
@PreAuthorize("@ss.hasPermi('dk:dkCustomer:edit')")
@Log(title = "客户", businessType = BusinessType.UPDATE)
@RepeatSubmit
@PutMapping()
public AjaxResult<Void> edit(@Validated @RequestBody Customer bo) {
return toAjax(customerService.updateById(bo) ? 1 : 0);
}
@DeleteMapping("/{ids}")
public AjaxResult<Void> remove(@NotEmpty(message = "主键不能为空")
@PathVariable String ids) {
List<String> idList = Stream.of(ids.split(",")).collect(Collectors.toList());
return toAjax(customerService.removeByIds(idList) ? 1 : 0);
}
@Log(title = "修改密码" , businessType = BusinessType.DELETE)
@PostMapping("/resetPwd")
public AjaxResult<Void> resetPwd(@RequestBody UpdatePwdCustomerReq customer) {
return toAjax(customerService.updatePwd(customer.getCustomerId(),customer.getPassword()));
}
}

View File

@@ -0,0 +1,64 @@
package com.bashi.dk.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.bashi.common.annotation.Log;
import com.bashi.common.annotation.RepeatSubmit;
import com.bashi.common.com.Condition;
import com.bashi.common.com.PageParams;
import com.bashi.common.core.controller.BaseController;
import com.bashi.common.core.domain.AjaxResult;
import com.bashi.common.core.page.TableDataInfo;
import com.bashi.common.enums.BusinessType;
import com.bashi.common.utils.PageUtils;
import com.bashi.dk.domain.CustomerInfo;
import com.bashi.dk.service.CustomerInfoService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotNull;
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/dk/dkCustomerInfo")
public class DkCustomerInfoController extends BaseController {
private final CustomerInfoService customerInfoService;
@PreAuthorize("@ss.hasPermi('dk:dkCustomerInfo:list')")
@GetMapping("/list")
public TableDataInfo<CustomerInfo> list(PageParams pageParams, @Validated CustomerInfo bo) {
IPage<CustomerInfo> page = customerInfoService.page(Condition.getPage(pageParams), Wrappers.query(bo));
return PageUtils.buildDataInfo(page);
}
@GetMapping("/getInfoByCustomerId")
public AjaxResult<CustomerInfo> getInfoByCustomer(Long customerId) {
return AjaxResult.success(customerInfoService.getByCustomerId(customerId));
}
@PostMapping("/updateAllowSignature")
public AjaxResult<Void> updateAllowSignature(@RequestBody CustomerInfo bo) {
customerInfoService.updateAllowSignature(bo);
return AjaxResult.success();
}
@PreAuthorize("@ss.hasPermi('dk:dkCustomerInfo:query')")
@GetMapping("/{id}")
public AjaxResult<CustomerInfo> getInfo(@NotNull(message = "主键不能为空")
@PathVariable("id") Long id) {
return AjaxResult.success(customerInfoService.getById(id));
}
@PreAuthorize("@ss.hasPermi('dk:dkCustomerInfo:edit')")
@Log(title = "客户资料", businessType = BusinessType.UPDATE)
@RepeatSubmit
@PutMapping()
public AjaxResult<Void> edit(@Validated @RequestBody CustomerInfo bo) {
return toAjax(customerInfoService.updateById(bo) ? 1 : 0);
}
}

View File

@@ -0,0 +1,51 @@
package com.bashi.dk.controller;
import com.bashi.common.annotation.Log;
import com.bashi.common.annotation.RepeatSubmit;
import com.bashi.common.core.controller.BaseController;
import com.bashi.common.core.domain.AjaxResult;
import com.bashi.common.enums.BusinessType;
import com.bashi.dk.domain.HomeSetting;
import com.bashi.dk.service.HomeSettingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/**
* 常规设置Controller
*
* @author duteliang
* @date 2023-11-29
*/
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/dk/HomeSetting")
public class DkHomeSettingController extends BaseController {
private final HomeSettingService homeSettingService;
/**
* 获取常规设置详细信息
*/
@PreAuthorize("@ss.hasPermi('dk:HomeSetting:query')")
@GetMapping("/info")
public AjaxResult<HomeSetting> getInfo() {
return AjaxResult.success(homeSettingService.getHomeSetting());
}
/**
* 修改常规设置
*/
@PreAuthorize("@ss.hasPermi('dk:HomeSetting:edit')")
@Log(title = "常规设置", businessType = BusinessType.UPDATE)
@RepeatSubmit
@PutMapping()
public AjaxResult<Void> edit(@Validated @RequestBody HomeSetting bo) {
return toAjax(homeSettingService.updateById(bo) ? 1 : 0);
}
}

View File

@@ -0,0 +1,50 @@
package com.bashi.dk.controller;
import com.bashi.common.annotation.Log;
import com.bashi.common.annotation.RepeatSubmit;
import com.bashi.common.core.controller.BaseController;
import com.bashi.common.core.domain.AjaxResult;
import com.bashi.common.enums.BusinessType;
import com.bashi.dk.domain.LoansSetting;
import com.bashi.dk.service.LoansSettingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/**
* 贷款设置Controller
*
* @author duteliang
* @date 2023-11-29
*/
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/dk/LoansSetting")
public class DkLoansSettingController extends BaseController {
private final LoansSettingService loansSettingService;
/**
* 获取贷款设置详细信息
*/
@PreAuthorize("@ss.hasPermi('dk:LoansSetting:query')")
@GetMapping("/info")
public AjaxResult<LoansSetting> getInfo() {
return AjaxResult.success(loansSettingService.getLoansSetting());
}
/**
* 修改贷款设置
*/
@PreAuthorize("@ss.hasPermi('dk:LoansSetting:edit')")
@Log(title = "贷款设置", businessType = BusinessType.UPDATE)
@RepeatSubmit
@PutMapping()
public AjaxResult<Void> edit(@Validated @RequestBody LoansSetting bo) {
return toAjax(loansSettingService.updateById(bo) ? 1 : 0);
}
}

View File

@@ -0,0 +1,88 @@
package com.bashi.dk.controller.app;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.bashi.common.com.Condition;
import com.bashi.common.com.PageParams;
import com.bashi.common.core.domain.AjaxResult;
import com.bashi.common.core.page.TableDataInfo;
import com.bashi.common.utils.BeanConvertUtil;
import com.bashi.common.utils.PageUtils;
import com.bashi.common.utils.SecurityUtils;
import com.bashi.dk.domain.Borrow;
import com.bashi.dk.dto.app.req.BorrowStartReq;
import com.bashi.dk.dto.app.resp.BorrowInfo;
import com.bashi.dk.dto.app.resp.LoanProcessResp;
import com.bashi.dk.service.BorrowService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/app/borrow")
@Api(value = "贷款相关的接口", tags = {"贷款相关的接口"})
public class AppBorrowController {
@Autowired
private BorrowService borrowService;
@PostMapping("/start")
@ApiOperation(value = "发起贷款")
public AjaxResult<Borrow> start(@RequestBody BorrowStartReq req){
req.setCustomerId(SecurityUtils.getLoginUser().getCustomer().getId());
Borrow borrow = borrowService.borrow(req);
return AjaxResult.success(borrow);
}
@GetMapping("/withdraw")
@ApiOperation(value = "提现")
public AjaxResult<Void> withdraw(@ApiParam("提现金额") Double withdrawAmount){
Long customerId = SecurityUtils.getLoginUser().getCustomer().getId();
borrowService.withdraw(withdrawAmount,customerId);
return AjaxResult.success();
}
@GetMapping("/getStepBorrow")
@ApiOperation(value = "获取贷款进度")
public AjaxResult<LoanProcessResp> getStepBorrow(){
Long customerId = SecurityUtils.getLoginUser().getCustomer().getId();
LoanProcessResp stepBorrow = borrowService.getStepBorrow(customerId);
return AjaxResult.success(stepBorrow);
}
@GetMapping("/info")
@ApiOperation(value = "查看贷款详情")
public AjaxResult<BorrowInfo> info(String tradeNo){
Borrow borrow = borrowService.getByTradeNo(tradeNo);
BorrowInfo borrowInfo = BeanConvertUtil.convertTo(borrow, BorrowInfo::new);
LoanProcessResp stepBorrow = borrowService.parseStepBorrow(borrow);
borrowInfo.setLoanProcessResp(stepBorrow);
return AjaxResult.success(borrowInfo);
}
@GetMapping("/page")
@ApiOperation(value = "分页查询贷款我的贷款")
public TableDataInfo<Borrow> page(PageParams pageParams){
Long customerId = SecurityUtils.getLoginUser().getCustomer().getId();
LambdaQueryWrapper<Borrow> query = Wrappers.lambdaQuery(Borrow.class)
.eq(Borrow::getCustomerId,customerId)
.orderByDesc(Borrow::getCreateTime);
IPage<Borrow> page = borrowService.page(Condition.getPage(pageParams), query);
return PageUtils.buildDataInfo(page);
}
@GetMapping("/getContract")
public AjaxResult<String> getContract(String tradeNo){
String contract = borrowService.getContract(tradeNo);
AjaxResult<String> success = AjaxResult.success();
success.setData(contract);
return success;
}
}

View File

@@ -0,0 +1,50 @@
package com.bashi.dk.controller.app;
import com.bashi.common.core.domain.AjaxResult;
import com.bashi.common.core.domain.entity.Customer;
import com.bashi.common.utils.SecurityUtils;
import com.bashi.dk.domain.CustomerInfo;
import com.bashi.dk.service.CustomerInfoService;
import com.bashi.dk.service.CustomerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/app/customer")
@Api(value = "客户接口", tags = {"客户接口"})
public class AppCustomerController {
@Autowired
private CustomerInfoService customerInfoService;
@Autowired
private CustomerService customerService;
@GetMapping("/info")
@ApiOperation(value = "客户信息")
public AjaxResult<Customer> info(){
Customer customer = SecurityUtils.getLoginUser().getCustomer();
customer = customerService.getById(customer.getId());
return AjaxResult.success(customer);
}
@GetMapping("/card/info")
@ApiOperation(value = "客户资料信息")
public AjaxResult<CustomerInfo> cardInfo(){
Customer customer = SecurityUtils.getLoginUser().getCustomer();
CustomerInfo customerInfo = customerInfoService.getByCustomerId(customer.getId());
return AjaxResult.success(customerInfo);
}
@PostMapping("/updateCustomerCard")
@ApiOperation(value = "修改客户资料信息")
public AjaxResult<Void> updateCustomerCard(@RequestBody CustomerInfo customerInfo){
Customer customer = SecurityUtils.getLoginUser().getCustomer();
customerInfo.setCustomerId(customer.getId());
customerInfoService.updateCustomerInfo(customerInfo);
return AjaxResult.success();
}
}

View File

@@ -0,0 +1,89 @@
package com.bashi.dk.controller.app;
import cn.hutool.core.lang.UUID;
import cn.hutool.core.util.RandomUtil;
import com.bashi.common.core.domain.AjaxResult;
import com.bashi.common.core.domain.entity.Customer;
import com.bashi.common.core.redis.RedisCache;
import com.bashi.common.exception.CustomException;
import com.bashi.dk.dto.app.req.CustomerRegisterReq;
import com.bashi.dk.dto.app.req.UpdatePwdOpenReq;
import com.bashi.dk.service.CustomerService;
import com.bashi.framework.constant.CodeType;
import com.bashi.framework.web.service.CodeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RequestMapping("/customer/open")
@RestController
@Api(value = "用户开放接口", tags = {"用户开放接口"})
public class AppCustomerOpenController {
@Autowired
private CodeService codeService;
@Autowired
private CustomerService customerService;
@Autowired
private RedisCache redisCache;
@GetMapping("/sms/register")
@ApiOperation("用户注册-验证码")
public AjaxResult<String> customerRegister(String phoneNumber) {
String numbers = RandomUtil.randomNumbers(6);
codeService.put(phoneNumber, CodeType.CUSTOMER_REGISTER,numbers);
AjaxResult<String> success = AjaxResult.success();
success.setData(numbers);
return success;
}
@PostMapping("/register")
@ApiOperation("用户注册")
public AjaxResult<Void> customerRegister(@RequestBody CustomerRegisterReq register) {
if(!codeService.check(register.getPhoneNumber(), CodeType.CUSTOMER_REGISTER,register.getCode())){
throw new CustomException("验证码错误");
}
customerService.register(register);
return AjaxResult.success();
}
@GetMapping("/sms/forget")
@ApiOperation("忘记密码-验证码")
public AjaxResult<String> customerForgetPassword(String phoneNumber) {
String numbers = RandomUtil.randomNumbers(6);
codeService.put(phoneNumber, CodeType.CUSTOMER_FORGET_PASSWORD,numbers);
AjaxResult<String> success = AjaxResult.success();
success.setData(numbers);
return success;
}
@GetMapping("/sms/forget/check")
@ApiOperation("忘记密码-验证码-校验")
public AjaxResult<String> customerForgetPasswordCheck(String phoneNumber,String code) {
if(!codeService.check(phoneNumber, CodeType.CUSTOMER_REGISTER,code)){
throw new CustomException("验证码错误");
}
Customer customer = customerService.getCustomerByName(phoneNumber);
String uuid = UUID.randomUUID().toString();
redisCache.setCacheObject(uuid,customer);
AjaxResult<String> success = AjaxResult.success();
success.setData(uuid);
return success;
}
@PostMapping("/updatePwd")
@ApiOperation("修改密码")
public AjaxResult<String> customerForgetPasswordCheck(@RequestBody UpdatePwdOpenReq updatePwdOpenReq) {
Customer customer = redisCache.getCacheObject(updatePwdOpenReq.getCheckCode());
if(customer == null){
throw new CustomException("密码修改失败,请重新获取验证码操作");
}
if(!updatePwdOpenReq.getPassword().equals(updatePwdOpenReq.getConfirmPassword())){
throw new CustomException("密码不一致");
}
customerService.updatePwd(customer.getId(),updatePwdOpenReq.getPassword());
AjaxResult<String> success = AjaxResult.success();
return success;
}
}

View File

@@ -0,0 +1,65 @@
package com.bashi.dk.controller.app;
import cn.hutool.core.util.RandomUtil;
import com.bashi.common.core.domain.AjaxResult;
import com.bashi.common.utils.BeanConvertUtil;
import com.bashi.dk.domain.LoansSetting;
import com.bashi.dk.dto.app.req.CalLoanReq;
import com.bashi.dk.dto.app.resp.CalLoanResp;
import com.bashi.dk.dto.app.resp.LoanUser;
import com.bashi.dk.kit.CalLoanManager;
import com.bashi.dk.service.LoansSettingService;
import com.bashi.dk.util.Loan;
import com.bashi.dk.util.PhoneRandomUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.aspectj.weaver.loadtime.Aj;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Random;
@RestController
@RequestMapping("/app/home/loans")
@Api(value = "首页开放", tags = {"首页开放"})
public class AppHomeController {
@Autowired
private CalLoanManager calLoanManager;
@Autowired
private LoansSettingService loansSettingService;
@PostMapping("/calLoan")
@ApiOperation(value = "计算每月还款")
public AjaxResult<CalLoanResp> calLoan(@RequestBody CalLoanReq calLoanReq) {
if(calLoanReq.getTotalLoanMoney() == null || calLoanReq.getTotalMonth() == null){
LoansSetting loansSetting = loansSettingService.getLoansSetting();
if(calLoanReq.getTotalLoanMoney() == null){
calLoanReq.setTotalLoanMoney(loansSetting.getLoansInitAccount());
}
if(calLoanReq.getTotalMonth() == null){
calLoanReq.setTotalMonth(Integer.valueOf(loansSetting.getLoansInitMonth()));
}
}
Loan loan = calLoanManager.calLoan(calLoanReq);
CalLoanResp calLoanResp = BeanConvertUtil.convertTo(loan, CalLoanResp::new);
return AjaxResult.success(calLoanResp);
}
@GetMapping("/loansUser")
@ApiOperation(value = "获取贷款用户")
public AjaxResult<LoanUser> loansUser() {
Random random = new Random();
LoanUser loanUser = new LoanUser();
loanUser.setPhone(PhoneRandomUtil.gen());
loanUser.setAmount(RandomUtil.randomInt(10,100)+"000");
loanUser.setTime(LocalDate.now().plusDays(-random.nextInt(7)).format(DateTimeFormatter.ofPattern("yyyy/MM/dd")));
return AjaxResult.success(loanUser);
}
}

View File

@@ -0,0 +1,74 @@
package com.bashi.dk.controller.app;
import cn.hutool.core.util.NumberUtil;
import com.bashi.common.core.domain.AjaxResult;
import com.bashi.common.utils.BeanConvertUtil;
import com.bashi.dk.domain.AgreementSetting;
import com.bashi.dk.domain.HomeSetting;
import com.bashi.dk.domain.LoansSetting;
import com.bashi.dk.dto.app.resp.LoansSettingVO;
import com.bashi.dk.enums.BankTypeEnums;
import com.bashi.dk.service.AgreementSettingService;
import com.bashi.dk.service.HomeSettingService;
import com.bashi.dk.service.LoansSettingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
@RestController
@RequestMapping("/app/home/setting")
@Api(value = "设置信息", tags = {"设置信息"})
public class AppSettingController {
@Autowired
private AgreementSettingService agreementSettingService;
@Autowired
private HomeSettingService homeSettingService;
@Autowired
private LoansSettingService loansSettingService;
@GetMapping("/agreement")
@ApiOperation(value = "协议内容")
public AjaxResult<AgreementSetting> agreement() {
AgreementSetting setting = agreementSettingService.getAgreementSetting();
return AjaxResult.success(setting);
}
@GetMapping("/home")
@ApiOperation(value = "常规内容")
public AjaxResult<HomeSetting> home() {
HomeSetting setting = homeSettingService.getHomeSetting();
return AjaxResult.success(setting);
}
@GetMapping("/bankType")
@ApiOperation(value = "获取银行列表")
public AjaxResult<List<String>> bankType(){
List<String> list = Arrays.stream(BankTypeEnums.values()).map(BankTypeEnums::getName).collect(Collectors.toList());
return AjaxResult.success(list);
}
@GetMapping("/loans")
@ApiOperation(value = "贷款信息")
public AjaxResult<LoansSetting> loans() {
LoansSetting setting = loansSettingService.getLoansSetting();
LoansSettingVO vo = BeanConvertUtil.convertTo(setting, LoansSettingVO::new);
Double minDayServiceRate = Arrays.stream(setting.getServiceRate().split(","))
.map(Double::valueOf).min(Double::compareTo).orElse(null);
if(minDayServiceRate != null){
minDayServiceRate = NumberUtil.div(minDayServiceRate, new Double(30D), 4);
}else{
minDayServiceRate = 0D;
}
vo.setMinDayServiceRate(minDayServiceRate);
return AjaxResult.success(setting);
}
}

View File

@@ -0,0 +1,33 @@
package com.bashi.dk.controller.app;
import com.bashi.common.constant.Constants;
import com.bashi.common.core.domain.AjaxResult;
import com.bashi.common.core.domain.model.LoginPhoneBody;
import com.bashi.dk.kit.DkLoginKit;
import com.bashi.framework.security.sms.LoginTypeEnums;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
@RestController
public class LoginV2Controller {
@Autowired
private DkLoginKit dkLoginKit;
@PostMapping("/customer/login")
@ApiOperation("用户登陆")
public AjaxResult loginCustomer(@RequestBody LoginPhoneBody loginBody) {
Map<String, Object> ajax = new HashMap<>();
loginBody.setLoginRole(LoginTypeEnums.CUSTOMER_PASSWORD.getCode());
// 生成令牌
String token = dkLoginKit.login(loginBody);
ajax.put(Constants.TOKEN, token);
return AjaxResult.success(ajax);
}
}

View File

@@ -0,0 +1,44 @@
package com.bashi.dk.controller.app;
import com.alibaba.fastjson.JSON;
import com.bashi.common.core.domain.AjaxResult;
import com.bashi.dk.manager.FileUploadManager;
import com.bashi.dk.manager.FileUploadRes;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.dromara.x.file.storage.core.FileInfo;
import org.dromara.x.file.storage.core.FileStorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
/**
* <p>created on 2021/7/13</p>
*
* @author zhangliang
*/
@RestController
@Api(value = "通用接口", tags = {"通用接口"})
@Slf4j
public class V2CommonController {
@Autowired
private FileStorageService fileStorageService;
@PostMapping("/v2/common/upload")
@ApiOperation("文件上传")
public AjaxResult uploadFile(MultipartFile file) throws Exception {
try {
FileInfo upload = fileStorageService.of(file).setPath("upload/").upload();
FileUploadRes fileUploadRes = new FileUploadRes();
fileUploadRes.setUrl(upload.getUrl());
fileUploadRes.setFileName(upload.getOriginalFilename());
log.info("sss={}", JSON.toJSONString(upload));
return AjaxResult.success(fileUploadRes);
} catch (Exception e) {
return AjaxResult.error(e.getMessage());
}
}
}