feat: 债务追踪代码生产

This commit is contained in:
bunny 2024-11-11 16:42:20 +08:00
parent 15525d4827
commit c30ceeb719
11 changed files with 444 additions and 48 deletions

View File

@ -3,11 +3,11 @@ package cn.bunny.common.generator.generator;
import cn.bunny.common.generator.entity.BaseField;
import cn.bunny.common.generator.entity.BaseResultMap;
import cn.bunny.common.generator.utils.GeneratorCodeUtils;
import cn.bunny.dao.dto.financial.debtCollectionManagement.DebtCollectionManagementAddDto;
import cn.bunny.dao.dto.financial.debtCollectionManagement.DebtCollectionManagementDto;
import cn.bunny.dao.dto.financial.debtCollectionManagement.DebtCollectionManagementUpdateDto;
import cn.bunny.dao.entity.financial.DebtCollectionManagement;
import cn.bunny.dao.vo.financial.DebtCollectionManagementVo;
import cn.bunny.dao.dto.financial.debtTracking.DebtTrackingAddDto;
import cn.bunny.dao.dto.financial.debtTracking.DebtTrackingDto;
import cn.bunny.dao.dto.financial.debtTracking.DebtTrackingUpdateDto;
import cn.bunny.dao.entity.financial.DebtTracking;
import cn.bunny.dao.vo.financial.DebtTrackingVo;
import com.baomidou.mybatisplus.annotation.TableName;
import com.google.common.base.CaseFormat;
import io.swagger.v3.oas.annotations.media.Schema;
@ -52,11 +52,11 @@ public class WebGeneratorCode {
public static String resourceMapperPath = "D:\\MyFolder\\auth\\financial-web-server\\service\\src\\main\\resources\\mapper\\financial\\";
public static void main(String[] args) throws Exception {
Class<?> originalClass = DebtCollectionManagement.class;
Class<?> dtoClass = DebtCollectionManagementDto.class;
Class<?> addDtoClass = DebtCollectionManagementAddDto.class;
Class<?> updateDtoClass = DebtCollectionManagementUpdateDto.class;
Class<?> voClass = DebtCollectionManagementVo.class;
Class<?> originalClass = DebtTracking.class;
Class<?> dtoClass = DebtTrackingDto.class;
Class<?> addDtoClass = DebtTrackingAddDto.class;
Class<?> updateDtoClass = DebtTrackingUpdateDto.class;
Class<?> voClass = DebtTrackingVo.class;
// 设置velocity资源加载器
Properties prop = new Properties();

View File

@ -0,0 +1,49 @@
package cn.bunny.dao.dto.financial.debtTracking;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Schema(name = "DebtTrackingAddDto对象", title = "债务追踪添加", description = "债务追踪")
public class DebtTrackingAddDto {
@Schema(name = "userId", title = "绑定的用户")
@NotNull(message = "债务不能为空")
private Long userId;
@Schema(name = "debtorName", title = "债务人姓名")
@NotNull(message = "债务人姓名不能为空")
@NotBlank(message = "债务人姓名不能为空")
private String debtorName;
@Schema(name = "debtAmount", title = "债务金额")
@NotNull(message = "债务不能为空")
private BigDecimal debtAmount;
@Schema(name = "debtType", title = "债务类型")
@NotNull(message = "债务类型不能为空")
@NotBlank(message = "债务类型不能为空")
private String debtType;
@Schema(name = "debtStatus", title = "债务状态")
@NotNull(message = "债务状态不能为空")
@NotBlank(message = "债务状态不能为空")
private String debtStatus;
@Schema(name = "dueDate", title = "还款截止日期")
@NotNull(message = "债务不能为空")
private LocalDateTime dueDate;
}

View File

@ -0,0 +1,38 @@
package cn.bunny.dao.dto.financial.debtTracking;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Schema(name = "DebtTrackingDto对象", title = "债务追踪查询", description = "债务追踪查询")
public class DebtTrackingDto {
@Schema(name = "userId", title = "绑定的用户")
private Long userId;
@Schema(name = "debtorName", title = "债务人姓名")
private String debtorName;
@Schema(name = "debtAmount", title = "债务金额")
private BigDecimal debtAmount;
@Schema(name = "debtType", title = "债务类型")
private String debtType;
@Schema(name = "debtStatus", title = "债务状态")
private String debtStatus;
@Schema(name = "dueDate", title = "还款截止日期")
private LocalDateTime dueDate;
}

View File

@ -0,0 +1,52 @@
package cn.bunny.dao.dto.financial.debtTracking;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Schema(name = "DebtTrackingUpdateDto对象", title = "债务追踪更新", description = "债务追踪更新")
public class DebtTrackingUpdateDto {
@Schema(name = "id", title = "主键")
@NotNull(message = "id不能为空")
private Long id;
@Schema(name = "userId", title = "绑定的用户")
@NotNull(message = "债务不能为空")
private Long userId;
@Schema(name = "debtorName", title = "债务人姓名")
@NotNull(message = "债务人姓名不能为空")
@NotBlank(message = "债务人姓名不能为空")
private String debtorName;
@Schema(name = "debtAmount", title = "债务金额")
@NotNull(message = "债务不能为空")
private BigDecimal debtAmount;
@Schema(name = "debtType", title = "债务类型")
@NotNull(message = "债务类型不能为空")
@NotBlank(message = "债务类型不能为空")
private String debtType;
@Schema(name = "debtStatus", title = "债务状态")
@NotNull(message = "债务状态不能为空")
@NotBlank(message = "债务状态不能为空")
private String debtStatus;
@Schema(name = "dueDate", title = "还款截止日期")
@NotNull(message = "债务不能为空")
private LocalDateTime dueDate;
}

View File

@ -1,18 +1,15 @@
package cn.bunny.dao.entity.financial;
import cn.bunny.dao.common.entity.BaseEntity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* <p>
* 债务追踪表
@ -25,25 +22,30 @@ import lombok.experimental.Accessors;
@Setter
@Accessors(chain = true)
@TableName("t_debt_tracking")
@ApiModel(value = "DebtTracking对象", description = "债务追踪")
public class DebtTracking extends BaseEntity {
@Schema(name = "DebtTracking对象", title = "债务追踪", description = "债务追踪")
public class DebtTracking extends BaseEntity {
@ApiModelProperty("绑定的用户id")
@Schema(name = "userId", title = "绑定的用户")
private Long userId;
@ApiModelProperty("债务人姓名")
@Schema(name = "debtorName", title = "债务人姓名")
private String debtorName;
@ApiModelProperty("债务金额")
@Schema(name = "debtAmount", title = "债务金额")
private BigDecimal debtAmount;
@ApiModelProperty("债务类型,如信用卡债务、贷款债务")
@Schema(name = "debtType", title = "债务类型")
private String debtType;
@ApiModelProperty("债务状态,如未还、部分还款、已还清等")
@Schema(name = "debtStatus", title = "债务状态")
private String debtStatus;
@ApiModelProperty("还款截止日期")
@Schema(name = "dueDate", title = "还款截止日期")
private LocalDateTime dueDate;
}

View File

@ -0,0 +1,36 @@
package cn.bunny.dao.vo.financial;
import cn.bunny.dao.common.vo.BaseVo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@EqualsAndHashCode(callSuper = true)
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Schema(name = "DebtTrackingVo对象", title = "债务追踪返回内容", description = "债务追踪返回内容")
public class DebtTrackingVo extends BaseVo {
@Schema(name = "userId", title = "绑定的用户")
private Long userId;
@Schema(name = "debtorName", title = "债务人姓名")
private String debtorName;
@Schema(name = "debtAmount", title = "债务金额")
private BigDecimal debtAmount;
@Schema(name = "debtType", title = "债务类型")
private String debtType;
@Schema(name = "debtStatus", title = "债务状态")
private String debtStatus;
@Schema(name = "dueDate", title = "还款截止日期")
private LocalDateTime dueDate;
}

View File

@ -1,7 +1,24 @@
package cn.bunny.services.controller.financial;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.bunny.dao.dto.financial.debtTracking.DebtTrackingAddDto;
import cn.bunny.dao.dto.financial.debtTracking.DebtTrackingDto;
import cn.bunny.dao.dto.financial.debtTracking.DebtTrackingUpdateDto;
import cn.bunny.dao.entity.financial.DebtTracking;
import cn.bunny.dao.pojo.result.PageResult;
import cn.bunny.dao.pojo.result.Result;
import cn.bunny.dao.pojo.result.ResultCodeEnum;
import cn.bunny.dao.vo.financial.DebtTrackingVo;
import cn.bunny.services.service.financial.DebtTrackingService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Mono;
import java.util.List;
/**
* <p>
@ -9,10 +26,47 @@ import org.springframework.web.bind.annotation.RestController;
* </p>
*
* @author Bunny
* @since 2024-11-11
* @since 2024-11-11 16:36:31
*/
@Tag(name = "债务追踪", description = "债务追踪相关接口")
@RestController
@RequestMapping("/debtTracking")
@RequestMapping("admin/debtTracking")
public class DebtTrackingController {
@Autowired
private DebtTrackingService debtTrackingService;
@Operation(summary = "分页查询债务追踪", description = "分页查询债务追踪")
@GetMapping("getDebtTrackingList/{page}/{limit}")
public Mono<Result<PageResult<DebtTrackingVo>>> getDebtTrackingList(
@Parameter(name = "page", description = "当前页", required = true)
@PathVariable("page") Integer page,
@Parameter(name = "limit", description = "每页记录数", required = true)
@PathVariable("limit") Integer limit,
DebtTrackingDto dto) {
Page<DebtTracking> pageParams = new Page<>(page, limit);
PageResult<DebtTrackingVo> pageResult = debtTrackingService.getDebtTrackingList(pageParams, dto);
return Mono.just(Result.success(pageResult));
}
@Operation(summary = "添加债务追踪", description = "添加债务追踪")
@PostMapping("addDebtTracking")
public Mono<Result<String>> addDebtTracking(@Valid @RequestBody DebtTrackingAddDto dto) {
debtTrackingService.addDebtTracking(dto);
return Mono.just(Result.success(ResultCodeEnum.ADD_SUCCESS));
}
@Operation(summary = "更新债务追踪", description = "更新债务追踪")
@PutMapping("updateDebtTracking")
public Mono<Result<String>> updateDebtTracking(@Valid @RequestBody DebtTrackingUpdateDto dto) {
debtTrackingService.updateDebtTracking(dto);
return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS));
}
@Operation(summary = "删除债务追踪", description = "删除债务追踪")
@DeleteMapping("deleteDebtTracking")
public Mono<Result<String>> deleteDebtTracking(@RequestBody List<Long> ids) {
debtTrackingService.deleteDebtTracking(ids);
return Mono.just(Result.success(ResultCodeEnum.DELETE_SUCCESS));
}
}

View File

@ -1,18 +1,40 @@
package cn.bunny.services.mapper.financial;
import cn.bunny.dao.dto.financial.debtTracking.DebtTrackingDto;
import cn.bunny.dao.entity.financial.DebtTracking;
import cn.bunny.dao.vo.financial.DebtTrackingVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>
* 债务追踪 Mapper 接口
* 债务追踪 Mapper 接口
* </p>
*
* @author Bunny
* @since 2024-11-11
* @since 2024-11-11 16:36:31
*/
@Mapper
public interface DebtTrackingMapper extends BaseMapper<DebtTracking> {
/**
* * 分页查询债务追踪内容
*
* @param pageParams 债务追踪分页参数
* @param dto 债务追踪查询表单
* @return 债务追踪分页结果
*/
IPage<DebtTrackingVo> selectListByPage(@Param("page") Page<DebtTracking> pageParams, @Param("dto") DebtTrackingDto dto);
/**
* 物理删除债务追踪
*
* @param ids 删除 id 列表
*/
void deleteBatchIdsWithPhysics(List<Long> ids);
}

View File

@ -1,16 +1,52 @@
package cn.bunny.services.service.financial;
import cn.bunny.dao.dto.financial.debtTracking.DebtTrackingAddDto;
import cn.bunny.dao.dto.financial.debtTracking.DebtTrackingDto;
import cn.bunny.dao.dto.financial.debtTracking.DebtTrackingUpdateDto;
import cn.bunny.dao.entity.financial.DebtTracking;
import cn.bunny.dao.pojo.result.PageResult;
import cn.bunny.dao.vo.financial.DebtTrackingVo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import jakarta.validation.Valid;
import java.util.List;
/**
* <p>
* 债务追踪 服务类
* 债务追踪 服务类
* </p>
*
* @author Bunny
* @since 2024-11-11
* @since 2024-11-11 16:36:31
*/
public interface DebtTrackingService extends IService<DebtTracking> {
/**
* * 获取债务追踪列表
*
* @return 债务追踪返回列表
*/
PageResult<DebtTrackingVo> getDebtTrackingList(Page<DebtTracking> pageParams, DebtTrackingDto dto);
/**
* * 添加债务追踪
*
* @param dto 添加表单
*/
void addDebtTracking(@Valid DebtTrackingAddDto dto);
/**
* * 更新债务追踪
*
* @param dto 更新表单
*/
void updateDebtTracking(@Valid DebtTrackingUpdateDto dto);
/**
* * 删除|批量删除债务追踪类型
*
* @param ids 删除id列表
*/
void deleteDebtTracking(List<Long> ids);
}

View File

@ -1,20 +1,85 @@
package cn.bunny.services.service.financial.impl;
import cn.bunny.dao.dto.financial.debtTracking.DebtTrackingAddDto;
import cn.bunny.dao.dto.financial.debtTracking.DebtTrackingDto;
import cn.bunny.dao.dto.financial.debtTracking.DebtTrackingUpdateDto;
import cn.bunny.dao.entity.financial.DebtTracking;
import cn.bunny.dao.pojo.result.PageResult;
import cn.bunny.dao.vo.financial.DebtTrackingVo;
import cn.bunny.services.mapper.financial.DebtTrackingMapper;
import cn.bunny.services.service.financial.DebtTrackingService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.validation.Valid;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 债务追踪 服务实现类
* 债务追踪 服务实现类
* </p>
*
* @author Bunny
* @since 2024-11-11
* @since 2024-11-11 16:36:31
*/
@Service
public class DebtTrackingServiceImpl extends ServiceImpl<DebtTrackingMapper, DebtTracking> implements DebtTrackingService {
/**
* * 债务追踪 服务实现类
*
* @param pageParams 债务追踪分页查询page对象
* @param dto 债务追踪分页查询对象
* @return 查询分页债务追踪返回对象
*/
@Override
public PageResult<DebtTrackingVo> getDebtTrackingList(Page<DebtTracking> pageParams, DebtTrackingDto dto) {
IPage<DebtTrackingVo> page = baseMapper.selectListByPage(pageParams, dto);
return PageResult.<DebtTrackingVo>builder()
.list(page.getRecords())
.pageNo(page.getCurrent())
.pageSize(page.getSize())
.total(page.getTotal())
.build();
}
/**
* 添加债务追踪
*
* @param dto 债务追踪添加
*/
@Override
public void addDebtTracking(@Valid DebtTrackingAddDto dto) {
// 保存数据
DebtTracking debtTracking = new DebtTracking();
BeanUtils.copyProperties(dto, debtTracking);
save(debtTracking);
}
/**
* 更新债务追踪
*
* @param dto 债务追踪更新
*/
@Override
public void updateDebtTracking(@Valid DebtTrackingUpdateDto dto) {
// 更新内容
DebtTracking debtTracking = new DebtTracking();
BeanUtils.copyProperties(dto, debtTracking);
updateById(debtTracking);
}
/**
* 删除|批量删除债务追踪
*
* @param ids 删除id列表
*/
@Override
public void deleteDebtTracking(List<Long> ids) {
baseMapper.deleteBatchIdsWithPhysics(ids);
}
}

View File

@ -4,23 +4,65 @@
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="cn.bunny.dao.entity.financial.DebtTracking">
<id column="id" property="id" />
<result column="user_id" property="userId" />
<result column="debtor_name" property="debtorName" />
<result column="debt_amount" property="debtAmount" />
<result column="debt_type" property="debtType" />
<result column="debt_status" property="debtStatus" />
<result column="due_date" property="dueDate" />
<result column="create_user" property="createUser" />
<result column="create_time" property="createTime" />
<result column="update_user" property="updateUser" />
<result column="update_time" property="updateTime" />
<result column="is_deleted" property="isDeleted" />
<id column="id" property="id"/>
<id column="create_time" property="createTime"/>
<id column="update_time" property="updateTime"/>
<id column="create_user" property="createUser"/>
<id column="update_user" property="updateUser"/>
<id column="is_deleted" property="isDeleted"/>
<id column="user_id" property="userId"/>
<id column="debtor_name" property="debtorName"/>
<id column="debt_amount" property="debtAmount"/>
<id column="debt_type" property="debtType"/>
<id column="debt_status" property="debtStatus"/>
<id column="due_date" property="dueDate"/>
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, user_id, debtor_name, debt_amount, debt_type, debt_status, due_date, create_user, create_time, update_user, update_time, is_deleted
id, create_time, update_time, create_user, update_user, is_deleted, user_id, debtor_name, debt_amount, debt_type, debt_status, due_date
</sql>
<!-- 分页查询债务追踪内容 -->
<select id="selectListByPage" resultType="cn.bunny.dao.vo.financial.DebtTrackingVo">
select
base.*,
create_user.username as create_username,
update_user.username as update_username
from t_debt_tracking base
left join sys_user create_user on create_user.id = base.create_user
left join sys_user update_user on update_user.id = base.update_user
<where>
base.is_deleted = 0
<if test="dto.userId != null and dto.userId != ''">
and base.user_id like CONCAT('%',#{dto.userId},'%')
</if>
<if test="dto.debtorName != null and dto.debtorName != ''">
and base.debtor_name like CONCAT('%',#{dto.debtorName},'%')
</if>
<if test="dto.debtAmount != null and dto.debtAmount != ''">
and base.debt_amount like CONCAT('%',#{dto.debtAmount},'%')
</if>
<if test="dto.debtType != null and dto.debtType != ''">
and base.debt_type like CONCAT('%',#{dto.debtType},'%')
</if>
<if test="dto.debtStatus != null and dto.debtStatus != ''">
and base.debt_status like CONCAT('%',#{dto.debtStatus},'%')
</if>
<if test="dto.dueDate != null and dto.dueDate != ''">
and base.due_date like CONCAT('%',#{dto.dueDate},'%')
</if>
</where>
</select>
<!-- 物理删除债务追踪 -->
<delete id="deleteBatchIdsWithPhysics">
delete
from t_debt_tracking
where id in
<foreach collection="ids" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</delete>
</mapper>