feat(credit): 新增小程序端客户管理功能

- 修改Redis数据库配置从database 0切换到database 3
- 添加代码生成工具YsbGenerator用于自动生成CRUD代码
- 生成CreditMpCustomer实体类包含客户基本信息和状态字段
- 创建CreditMpCustomerController提供RESTful API接口
- 实现CreditMpCustomerService业务逻辑层
- 添加CreditMpCustomerMapper数据访问层及XML映射文件
- 生成CreditMpCustomerParam查询参数类支持条件筛选
- 实现服务层接口及具体业务逻辑方法
- 集成权限控制和操作日志记录功能
- 支持分页查询、批量操作和关联查询功能
This commit is contained in:
2026-03-16 21:14:36 +08:00
parent 7fe347d7bc
commit 044d87cfde
9 changed files with 907 additions and 1 deletions

View File

@@ -0,0 +1,129 @@
package com.gxwebsoft.credit.controller;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.credit.service.CreditMpCustomerService;
import com.gxwebsoft.credit.entity.CreditMpCustomer;
import com.gxwebsoft.credit.param.CreditMpCustomerParam;
import com.gxwebsoft.common.core.web.ApiResult;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.BatchParam;
import com.gxwebsoft.common.core.annotation.OperationLog;
import com.gxwebsoft.common.system.entity.User;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* 小程序端客户控制器
*
* @author 科技小王子
* @since 2026-03-16 20:59:17
*/
@Tag(name = "小程序端客户管理")
@RestController
@RequestMapping("/api/credit/credit-mp-customer")
public class CreditMpCustomerController extends BaseController {
@Resource
private CreditMpCustomerService creditMpCustomerService;
@PreAuthorize("hasAuthority('credit:creditMpCustomer:list')")
@Operation(summary = "分页查询小程序端客户")
@GetMapping("/page")
public ApiResult<PageResult<CreditMpCustomer>> page(CreditMpCustomerParam param) {
// 使用关联查询
return success(creditMpCustomerService.pageRel(param));
}
@PreAuthorize("hasAuthority('credit:creditMpCustomer:list')")
@Operation(summary = "查询全部小程序端客户")
@GetMapping()
public ApiResult<List<CreditMpCustomer>> list(CreditMpCustomerParam param) {
// 使用关联查询
return success(creditMpCustomerService.listRel(param));
}
@PreAuthorize("hasAuthority('credit:creditMpCustomer:list')")
@Operation(summary = "根据id查询小程序端客户")
@GetMapping("/{id}")
public ApiResult<CreditMpCustomer> get(@PathVariable("id") Integer id) {
// 使用关联查询
return success(creditMpCustomerService.getByIdRel(id));
}
@PreAuthorize("hasAuthority('credit:creditMpCustomer:save')")
@OperationLog
@Operation(summary = "添加小程序端客户")
@PostMapping()
public ApiResult<?> save(@RequestBody CreditMpCustomer creditMpCustomer) {
// 记录当前登录用户id
User loginUser = getLoginUser();
if (loginUser != null) {
creditMpCustomer.setUserId(loginUser.getUserId());
}
if (creditMpCustomerService.save(creditMpCustomer)) {
return success("添加成功");
}
return fail("添加失败");
}
@PreAuthorize("hasAuthority('credit:creditMpCustomer:update')")
@OperationLog
@Operation(summary = "修改小程序端客户")
@PutMapping()
public ApiResult<?> update(@RequestBody CreditMpCustomer creditMpCustomer) {
if (creditMpCustomerService.updateById(creditMpCustomer)) {
return success("修改成功");
}
return fail("修改失败");
}
@PreAuthorize("hasAuthority('credit:creditMpCustomer:remove')")
@OperationLog
@Operation(summary = "删除小程序端客户")
@DeleteMapping("/{id}")
public ApiResult<?> remove(@PathVariable("id") Integer id) {
if (creditMpCustomerService.removeById(id)) {
return success("删除成功");
}
return fail("删除失败");
}
@PreAuthorize("hasAuthority('credit:creditMpCustomer:save')")
@OperationLog
@Operation(summary = "批量添加小程序端客户")
@PostMapping("/batch")
public ApiResult<?> saveBatch(@RequestBody List<CreditMpCustomer> list) {
if (creditMpCustomerService.saveBatch(list)) {
return success("添加成功");
}
return fail("添加失败");
}
@PreAuthorize("hasAuthority('credit:creditMpCustomer:update')")
@OperationLog
@Operation(summary = "批量修改小程序端客户")
@PutMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody BatchParam<CreditMpCustomer> batchParam) {
if (batchParam.update(creditMpCustomerService, "id")) {
return success("修改成功");
}
return fail("修改失败");
}
@PreAuthorize("hasAuthority('credit:creditMpCustomer:remove')")
@OperationLog
@Operation(summary = "批量删除小程序端客户")
@DeleteMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
if (creditMpCustomerService.removeByIds(ids)) {
return success("删除成功");
}
return fail("删除失败");
}
}

View File

@@ -0,0 +1,93 @@
package com.gxwebsoft.credit.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableLogic;
import java.io.Serializable;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 小程序端客户
*
* @author 科技小王子
* @since 2026-03-16 20:59:17
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Schema(name = "CreditMpCustomer对象", description = "小程序端客户")
public class CreditMpCustomer implements Serializable {
private static final long serialVersionUID = 1L;
@Schema(description = "ID")
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@Schema(description = "拖欠方")
private String toUser;
@Schema(description = "拖欠金额")
private String price;
@Schema(description = "拖欠年数")
private String years;
@Schema(description = "链接")
private String url;
@Schema(description = "状态")
private String statusTxt;
@Schema(description = "企业ID")
private Integer companyId;
@Schema(description = "所在省份")
private String province;
@Schema(description = "所在城市")
private String city;
@Schema(description = "所在辖区")
private String region;
@Schema(description = "文件路径")
private String files;
@Schema(description = "是否有数据")
private Boolean hasData;
@Schema(description = "备注")
private String comments;
@Schema(description = "是否推荐")
private Integer recommend;
@Schema(description = "排序(数字越小越靠前)")
private Integer sortNumber;
@Schema(description = "状态, 0正常, 1冻结")
private Integer status;
@Schema(description = "是否删除, 0否, 1是")
@TableLogic
private Integer deleted;
@Schema(description = "用户ID")
private Integer userId;
@Schema(description = "租户id")
private Integer tenantId;
@Schema(description = "创建时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime;
@Schema(description = "修改时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime;
}

View File

@@ -0,0 +1,37 @@
package com.gxwebsoft.credit.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gxwebsoft.credit.entity.CreditMpCustomer;
import com.gxwebsoft.credit.param.CreditMpCustomerParam;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 小程序端客户Mapper
*
* @author 科技小王子
* @since 2026-03-16 20:59:17
*/
public interface CreditMpCustomerMapper extends BaseMapper<CreditMpCustomer> {
/**
* 分页查询
*
* @param page 分页对象
* @param param 查询参数
* @return List<CreditMpCustomer>
*/
List<CreditMpCustomer> selectPageRel(@Param("page") IPage<CreditMpCustomer> page,
@Param("param") CreditMpCustomerParam param);
/**
* 查询全部
*
* @param param 查询参数
* @return List<User>
*/
List<CreditMpCustomer> selectListRel(@Param("param") CreditMpCustomerParam param);
}

View File

@@ -0,0 +1,90 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gxwebsoft.credit.mapper.CreditMpCustomerMapper">
<!-- 关联查询sql -->
<sql id="selectSql">
SELECT a.*
FROM credit_mp_customer a
<where>
<if test="param.id != null">
AND a.id = #{param.id}
</if>
<if test="param.toUser != null">
AND a.to_user LIKE CONCAT('%', #{param.toUser}, '%')
</if>
<if test="param.price != null">
AND a.price LIKE CONCAT('%', #{param.price}, '%')
</if>
<if test="param.years != null">
AND a.years LIKE CONCAT('%', #{param.years}, '%')
</if>
<if test="param.url != null">
AND a.url LIKE CONCAT('%', #{param.url}, '%')
</if>
<if test="param.statusTxt != null">
AND a.status_txt LIKE CONCAT('%', #{param.statusTxt}, '%')
</if>
<if test="param.companyId != null">
AND a.company_id = #{param.companyId}
</if>
<if test="param.province != null">
AND a.province LIKE CONCAT('%', #{param.province}, '%')
</if>
<if test="param.city != null">
AND a.city LIKE CONCAT('%', #{param.city}, '%')
</if>
<if test="param.region != null">
AND a.region LIKE CONCAT('%', #{param.region}, '%')
</if>
<if test="param.files != null">
AND a.files LIKE CONCAT('%', #{param.files}, '%')
</if>
<if test="param.hasData != null">
AND a.has_data = #{param.hasData}
</if>
<if test="param.comments != null">
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
</if>
<if test="param.recommend != null">
AND a.recommend = #{param.recommend}
</if>
<if test="param.sortNumber != null">
AND a.sort_number = #{param.sortNumber}
</if>
<if test="param.status != null">
AND a.status = #{param.status}
</if>
<if test="param.deleted != null">
AND a.deleted = #{param.deleted}
</if>
<if test="param.deleted == null">
AND a.deleted = 0
</if>
<if test="param.userId != null">
AND a.user_id = #{param.userId}
</if>
<if test="param.createTimeStart != null">
AND a.create_time &gt;= #{param.createTimeStart}
</if>
<if test="param.createTimeEnd != null">
AND a.create_time &lt;= #{param.createTimeEnd}
</if>
<if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
)
</if>
</where>
</sql>
<!-- 分页查询 -->
<select id="selectPageRel" resultType="com.gxwebsoft.credit.entity.CreditMpCustomer">
<include refid="selectSql"></include>
</select>
<!-- 查询全部 -->
<select id="selectListRel" resultType="com.gxwebsoft.credit.entity.CreditMpCustomer">
<include refid="selectSql"></include>
</select>
</mapper>

View File

@@ -0,0 +1,87 @@
package com.gxwebsoft.credit.param;
import java.math.BigDecimal;
import com.gxwebsoft.common.core.annotation.QueryField;
import com.gxwebsoft.common.core.annotation.QueryType;
import com.gxwebsoft.common.core.web.BaseParam;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 小程序端客户查询参数
*
* @author 科技小王子
* @since 2026-03-16 20:59:17
*/
@Data
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
@Schema(name = "CreditMpCustomerParam对象", description = "小程序端客户查询参数")
public class CreditMpCustomerParam extends BaseParam {
private static final long serialVersionUID = 1L;
@Schema(description = "ID")
@QueryField(type = QueryType.EQ)
private Integer id;
@Schema(description = "拖欠方")
private String toUser;
@Schema(description = "拖欠金额")
private String price;
@Schema(description = "拖欠年数")
private String years;
@Schema(description = "链接")
private String url;
@Schema(description = "状态")
private String statusTxt;
@Schema(description = "企业ID")
@QueryField(type = QueryType.EQ)
private Integer companyId;
@Schema(description = "所在省份")
private String province;
@Schema(description = "所在城市")
private String city;
@Schema(description = "所在辖区")
private String region;
@Schema(description = "文件路径")
private String files;
@Schema(description = "是否有数据")
@QueryField(type = QueryType.EQ)
private Boolean hasData;
@Schema(description = "备注")
private String comments;
@Schema(description = "是否推荐")
@QueryField(type = QueryType.EQ)
private Integer recommend;
@Schema(description = "排序(数字越小越靠前)")
@QueryField(type = QueryType.EQ)
private Integer sortNumber;
@Schema(description = "状态, 0正常, 1冻结")
@QueryField(type = QueryType.EQ)
private Integer status;
@Schema(description = "是否删除, 0否, 1是")
@QueryField(type = QueryType.EQ)
private Integer deleted;
@Schema(description = "用户ID")
@QueryField(type = QueryType.EQ)
private Integer userId;
}

View File

@@ -0,0 +1,42 @@
package com.gxwebsoft.credit.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.credit.entity.CreditMpCustomer;
import com.gxwebsoft.credit.param.CreditMpCustomerParam;
import java.util.List;
/**
* 小程序端客户Service
*
* @author 科技小王子
* @since 2026-03-16 20:59:17
*/
public interface CreditMpCustomerService extends IService<CreditMpCustomer> {
/**
* 分页关联查询
*
* @param param 查询参数
* @return PageResult<CreditMpCustomer>
*/
PageResult<CreditMpCustomer> pageRel(CreditMpCustomerParam param);
/**
* 关联查询全部
*
* @param param 查询参数
* @return List<CreditMpCustomer>
*/
List<CreditMpCustomer> listRel(CreditMpCustomerParam param);
/**
* 根据id查询
*
* @param id ID
* @return CreditMpCustomer
*/
CreditMpCustomer getByIdRel(Integer id);
}

View File

@@ -0,0 +1,47 @@
package com.gxwebsoft.credit.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.credit.mapper.CreditMpCustomerMapper;
import com.gxwebsoft.credit.service.CreditMpCustomerService;
import com.gxwebsoft.credit.entity.CreditMpCustomer;
import com.gxwebsoft.credit.param.CreditMpCustomerParam;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 小程序端客户Service实现
*
* @author 科技小王子
* @since 2026-03-16 20:59:17
*/
@Service
public class CreditMpCustomerServiceImpl extends ServiceImpl<CreditMpCustomerMapper, CreditMpCustomer> implements CreditMpCustomerService {
@Override
public PageResult<CreditMpCustomer> pageRel(CreditMpCustomerParam param) {
PageParam<CreditMpCustomer, CreditMpCustomerParam> page = new PageParam<>(param);
page.setDefaultOrder("sort_number asc, create_time desc");
List<CreditMpCustomer> list = baseMapper.selectPageRel(page, param);
return new PageResult<>(list, page.getTotal());
}
@Override
public List<CreditMpCustomer> listRel(CreditMpCustomerParam param) {
List<CreditMpCustomer> list = baseMapper.selectListRel(param);
// 排序
PageParam<CreditMpCustomer, CreditMpCustomerParam> page = new PageParam<>();
page.setDefaultOrder("sort_number asc, create_time desc");
return page.sortRecords(list);
}
@Override
public CreditMpCustomer getByIdRel(Integer id) {
CreditMpCustomerParam param = new CreditMpCustomerParam();
param.setId(id);
return param.getOne(baseMapper.selectListRel(param));
}
}

View File

@@ -14,7 +14,7 @@ spring:
# redis
redis:
database: 0
database: 3
host: 1Panel-redis-GmNr
port: 6379
password: redis_t74P8C