feat: 债务追踪和部分bug修复
This commit is contained in:
parent
58c53a10f0
commit
38eb0afd92
|
@ -0,0 +1,51 @@
|
|||
package cn.bunny.dao.vo.financial.user;
|
||||
|
||||
import cn.bunny.dao.common.vo.BaseUserVo;
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
|
||||
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 DebtTrackingUserVo extends BaseUserVo {
|
||||
|
||||
@Schema(name = "userId", title = "绑定的用户")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING)
|
||||
@JSONField(serializeUsing = ToStringSerializer.class)
|
||||
private Long userId;
|
||||
|
||||
@Schema(name = "username", title = "用户名")
|
||||
private String username;
|
||||
|
||||
@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 = "还款截止日期")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonSerialize(using = LocalDateTimeSerializer.class)
|
||||
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
|
||||
private LocalDateTime dueDate;
|
||||
|
||||
}
|
|
@ -3,11 +3,14 @@ package cn.bunny.services.controller.financial;
|
|||
import cn.bunny.dao.dto.financial.debtTracking.DebtTrackingDto;
|
||||
import cn.bunny.dao.dto.financial.debtTracking.admin.DebtTrackingAddDto;
|
||||
import cn.bunny.dao.dto.financial.debtTracking.admin.DebtTrackingUpdateDto;
|
||||
import cn.bunny.dao.dto.financial.debtTracking.user.DebtTrackingAddUserDto;
|
||||
import cn.bunny.dao.dto.financial.debtTracking.user.DebtTrackingUpdateUserDto;
|
||||
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.admin.DebtTrackingVo;
|
||||
import cn.bunny.dao.vo.financial.user.DebtTrackingUserVo;
|
||||
import cn.bunny.services.service.financial.DebtTrackingService;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
@ -49,6 +52,19 @@ public class DebtTrackingController {
|
|||
return Mono.just(Result.success(pageResult));
|
||||
}
|
||||
|
||||
@Operation(summary = "用户分页查询债务追踪", description = "用户分页查询债务追踪")
|
||||
@GetMapping("noManage/getUserDebtTrackingList/{page}/{limit}")
|
||||
public Mono<Result<PageResult<DebtTrackingUserVo>>> getUserDebtTrackingList(
|
||||
@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<DebtTrackingUserVo> pageResult = debtTrackingService.getUserDebtTrackingList(pageParams, dto);
|
||||
return Mono.just(Result.success(pageResult));
|
||||
}
|
||||
|
||||
@Operation(summary = "添加债务追踪", description = "添加债务追踪")
|
||||
@PostMapping("addDebtTracking")
|
||||
public Mono<Result<String>> addDebtTracking(@Valid @RequestBody DebtTrackingAddDto dto) {
|
||||
|
@ -56,6 +72,13 @@ public class DebtTrackingController {
|
|||
return Mono.just(Result.success(ResultCodeEnum.ADD_SUCCESS));
|
||||
}
|
||||
|
||||
@Operation(summary = "用户添加债务追踪", description = "用户添加债务追踪")
|
||||
@PostMapping("noManage/addUserDebtTracking")
|
||||
public Mono<Result<String>> addUserDebtTracking(@Valid @RequestBody DebtTrackingAddUserDto dto) {
|
||||
debtTrackingService.addUserDebtTracking(dto);
|
||||
return Mono.just(Result.success(ResultCodeEnum.ADD_SUCCESS));
|
||||
}
|
||||
|
||||
@Operation(summary = "更新债务追踪", description = "更新债务追踪")
|
||||
@PutMapping("updateDebtTracking")
|
||||
public Mono<Result<String>> updateDebtTracking(@Valid @RequestBody DebtTrackingUpdateDto dto) {
|
||||
|
@ -63,10 +86,24 @@ public class DebtTrackingController {
|
|||
return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS));
|
||||
}
|
||||
|
||||
@Operation(summary = "用户更新债务追踪", description = "用户更新债务追踪")
|
||||
@PutMapping("noManage/updateUserDebtTracking")
|
||||
public Mono<Result<String>> updateUserDebtTracking(@Valid @RequestBody DebtTrackingUpdateUserDto dto) {
|
||||
debtTrackingService.updateUserDebtTracking(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));
|
||||
}
|
||||
|
||||
@Operation(summary = "用户删除债务追踪", description = "用户删除债务追踪")
|
||||
@DeleteMapping("noManage/deleteUserDebtTracking")
|
||||
public Mono<Result<String>> deleteUserDebtTracking(@RequestBody List<Long> ids) {
|
||||
debtTrackingService.deleteUserDebtTracking(ids);
|
||||
return Mono.just(Result.success(ResultCodeEnum.DELETE_SUCCESS));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,9 +3,12 @@ package cn.bunny.services.service.financial;
|
|||
import cn.bunny.dao.dto.financial.debtTracking.DebtTrackingDto;
|
||||
import cn.bunny.dao.dto.financial.debtTracking.admin.DebtTrackingAddDto;
|
||||
import cn.bunny.dao.dto.financial.debtTracking.admin.DebtTrackingUpdateDto;
|
||||
import cn.bunny.dao.dto.financial.debtTracking.user.DebtTrackingAddUserDto;
|
||||
import cn.bunny.dao.dto.financial.debtTracking.user.DebtTrackingUpdateUserDto;
|
||||
import cn.bunny.dao.entity.financial.DebtTracking;
|
||||
import cn.bunny.dao.pojo.result.PageResult;
|
||||
import cn.bunny.dao.vo.financial.admin.DebtTrackingVo;
|
||||
import cn.bunny.dao.vo.financial.user.DebtTrackingUserVo;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import jakarta.validation.Valid;
|
||||
|
@ -49,4 +52,34 @@ public interface DebtTrackingService extends IService<DebtTracking> {
|
|||
* @param ids 删除id列表
|
||||
*/
|
||||
void deleteDebtTracking(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 用户分页查询债务追踪
|
||||
*
|
||||
* @param pageParams 分页条件
|
||||
* @param dto 查询表单
|
||||
* @return 查询接到过
|
||||
*/
|
||||
PageResult<DebtTrackingUserVo> getUserDebtTrackingList(Page<DebtTracking> pageParams, DebtTrackingDto dto);
|
||||
|
||||
/**
|
||||
* 用户添加债务追踪
|
||||
*
|
||||
* @param dto 添加表单
|
||||
*/
|
||||
void addUserDebtTracking(DebtTrackingAddUserDto dto);
|
||||
|
||||
/**
|
||||
* 用户更新债务追踪
|
||||
*
|
||||
* @param dto 更新表单
|
||||
*/
|
||||
void updateUserDebtTracking(DebtTrackingUpdateUserDto dto);
|
||||
|
||||
/**
|
||||
* 用户删除债务追踪
|
||||
*
|
||||
* @param ids 删除列表
|
||||
*/
|
||||
void deleteUserDebtTracking(List<Long> ids);
|
||||
}
|
||||
|
|
|
@ -1,14 +1,21 @@
|
|||
package cn.bunny.services.service.financial.impl;
|
||||
|
||||
import cn.bunny.common.service.context.BaseContext;
|
||||
import cn.bunny.common.service.exception.BunnyException;
|
||||
import cn.bunny.dao.dto.financial.debtTracking.DebtTrackingDto;
|
||||
import cn.bunny.dao.dto.financial.debtTracking.admin.DebtTrackingAddDto;
|
||||
import cn.bunny.dao.dto.financial.debtTracking.admin.DebtTrackingUpdateDto;
|
||||
import cn.bunny.dao.dto.financial.debtTracking.user.DebtTrackingAddUserDto;
|
||||
import cn.bunny.dao.dto.financial.debtTracking.user.DebtTrackingUpdateUserDto;
|
||||
import cn.bunny.dao.entity.financial.DebtTracking;
|
||||
import cn.bunny.dao.pojo.result.PageResult;
|
||||
import cn.bunny.dao.pojo.result.ResultCodeEnum;
|
||||
import cn.bunny.dao.vo.financial.admin.DebtTrackingVo;
|
||||
import cn.bunny.dao.vo.financial.user.DebtTrackingUserVo;
|
||||
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.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import jakarta.validation.Valid;
|
||||
|
@ -26,6 +33,7 @@ import java.util.List;
|
|||
* @since 2024-11-11 16:36:31
|
||||
*/
|
||||
@Service
|
||||
|
||||
public class DebtTrackingServiceImpl extends ServiceImpl<DebtTrackingMapper, DebtTracking> implements DebtTrackingService {
|
||||
|
||||
/**
|
||||
|
@ -82,4 +90,77 @@ public class DebtTrackingServiceImpl extends ServiceImpl<DebtTrackingMapper, Deb
|
|||
public void deleteDebtTracking(List<Long> ids) {
|
||||
baseMapper.deleteBatchIdsWithPhysics(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户分页查询债务追踪
|
||||
*
|
||||
* @param pageParams 分页条件
|
||||
* @param dto 查询表单
|
||||
* @return 查询接到过
|
||||
*/
|
||||
@Override
|
||||
public PageResult<DebtTrackingUserVo> getUserDebtTrackingList(Page<DebtTracking> pageParams, DebtTrackingDto dto) {
|
||||
dto.setUserId(BaseContext.getUserId());
|
||||
|
||||
IPage<DebtTrackingVo> page = baseMapper.selectListByPage(pageParams, dto);
|
||||
List<DebtTrackingUserVo> debtTrackingList = page.getRecords().stream().map(debtTrackingVo -> {
|
||||
DebtTrackingUserVo debtTracking = new DebtTrackingUserVo();
|
||||
BeanUtils.copyProperties(debtTrackingVo, debtTracking);
|
||||
return debtTracking;
|
||||
}).toList();
|
||||
|
||||
return PageResult.<DebtTrackingUserVo>builder()
|
||||
.list(debtTrackingList)
|
||||
.pageNo(page.getCurrent())
|
||||
.pageSize(page.getSize())
|
||||
.total(page.getTotal())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户添加债务追踪
|
||||
*
|
||||
* @param dto 添加表单
|
||||
*/
|
||||
@Override
|
||||
public void addUserDebtTracking(DebtTrackingAddUserDto dto) {
|
||||
// 保存数据
|
||||
DebtTracking debtTracking = new DebtTracking();
|
||||
BeanUtils.copyProperties(dto, debtTracking);
|
||||
|
||||
debtTracking.setUserId(BaseContext.getUserId());
|
||||
save(debtTracking);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户更新债务追踪
|
||||
*
|
||||
* @param dto 更新表单
|
||||
*/
|
||||
@Override
|
||||
public void updateUserDebtTracking(DebtTrackingUpdateUserDto dto) {
|
||||
// 更新内容
|
||||
DebtTracking debtTracking = new DebtTracking();
|
||||
BeanUtils.copyProperties(dto, debtTracking);
|
||||
|
||||
debtTracking.setUserId(BaseContext.getUserId());
|
||||
updateById(debtTracking);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户删除债务追踪
|
||||
*
|
||||
* @param ids 删除列表
|
||||
*/
|
||||
@Override
|
||||
public void deleteUserDebtTracking(List<Long> ids) {
|
||||
// 判断删除的是否是自己的账单
|
||||
List<DebtTracking> billList = list(Wrappers.<DebtTracking>lambdaQuery().in(DebtTracking::getId, ids))
|
||||
.stream().filter(bill -> !bill.getUserId().equals(BaseContext.getUserId())).toList();
|
||||
if (!billList.isEmpty()) {
|
||||
throw new BunnyException(ResultCodeEnum.ILLEGAL_DATA_REQUEST);
|
||||
}
|
||||
|
||||
baseMapper.deleteBatchIdsWithPhysics(ids);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
<if test="dto.installmentAmount != null and dto.installmentAmount != ''">
|
||||
and base.installment_amount like CONCAT('%',#{dto.installmentAmount},'%')
|
||||
</if>
|
||||
<if test="dto.dueDate != null and dto.dueDate != ''">
|
||||
<if test="dto.dueDate != null">
|
||||
and base.due_date like CONCAT('%',#{dto.dueDate},'%')
|
||||
</if>
|
||||
<if test="dto.paidAmount != null and dto.paidAmount != ''">
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
<if test="dto.debtStatus != null and dto.debtStatus != ''">
|
||||
and base.debt_status = #{dto.debtStatus}
|
||||
</if>
|
||||
<if test="dto.dueDate != null and dto.dueDate != ''">
|
||||
<if test="dto.dueDate != null">
|
||||
and base.due_date like CONCAT('%',#{dto.dueDate},'%')
|
||||
</if>
|
||||
</where>
|
||||
|
|
Loading…
Reference in New Issue