diff --git a/dao/src/main/java/cn/bunny/dao/vo/financial/user/BudgetCategoryUserVo.java b/dao/src/main/java/cn/bunny/dao/vo/financial/user/BudgetCategoryUserVo.java index a493ad1..c0762db 100644 --- a/dao/src/main/java/cn/bunny/dao/vo/financial/user/BudgetCategoryUserVo.java +++ b/dao/src/main/java/cn/bunny/dao/vo/financial/user/BudgetCategoryUserVo.java @@ -1,6 +1,6 @@ package cn.bunny.dao.vo.financial.user; -import cn.bunny.dao.common.vo.BaseUserVo; +import cn.bunny.dao.common.vo.BaseVo; import com.alibaba.fastjson2.annotation.JSONField; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; @@ -20,7 +20,7 @@ import java.time.LocalDateTime; @NoArgsConstructor @Builder @Schema(name = "BudgetCategoryVo对象", title = "预算分类查询返回对象", description = "预算分类查询返回对象") -public class BudgetCategoryUserVo extends BaseUserVo { +public class BudgetCategoryUserVo extends BaseVo { @Schema(name = "parentId", title = "父级id") @JsonFormat(shape = JsonFormat.Shape.STRING) diff --git a/dao/src/main/java/cn/bunny/dao/vo/financial/user/DebtRepaymentPlanUserVo.java b/dao/src/main/java/cn/bunny/dao/vo/financial/user/DebtRepaymentPlanUserVo.java new file mode 100644 index 0000000..cb24244 --- /dev/null +++ b/dao/src/main/java/cn/bunny/dao/vo/financial/user/DebtRepaymentPlanUserVo.java @@ -0,0 +1,41 @@ +package cn.bunny.dao.vo.financial.user; + +import cn.bunny.dao.common.vo.BaseVo; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +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 = "DebtRepaymentPlanVo对象", title = "债务还款计划返回对象", description = "债务还款计划返回对象") +public class DebtRepaymentPlanUserVo extends BaseVo { + + @Schema(name = "installmentNumber", title = "债务金额") + private BigDecimal installmentNumber; + + @Schema(name = "installmentAmount", title = "每期应还金额") + private BigDecimal installmentAmount; + + @Schema(name = "dueDate", title = "还款截止日期") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonSerialize(using = LocalDateTimeSerializer.class) + @JsonDeserialize(using = LocalDateTimeDeserializer.class) + private LocalDateTime dueDate; + + @Schema(name = "paidAmount", title = "已还金额") + private BigDecimal paidAmount; + + @Schema(name = "paymentStatus", title = "还款状态") + private String paymentStatus; + +} \ No newline at end of file diff --git a/dao/src/main/java/cn/bunny/dao/vo/financial/user/DebtTrackingUserVo.java b/dao/src/main/java/cn/bunny/dao/vo/financial/user/DebtTrackingUserVo.java index df2490d..9916f65 100644 --- a/dao/src/main/java/cn/bunny/dao/vo/financial/user/DebtTrackingUserVo.java +++ b/dao/src/main/java/cn/bunny/dao/vo/financial/user/DebtTrackingUserVo.java @@ -1,6 +1,6 @@ package cn.bunny.dao.vo.financial.user; -import cn.bunny.dao.common.vo.BaseUserVo; +import cn.bunny.dao.common.vo.BaseVo; import com.alibaba.fastjson2.annotation.JSONField; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; @@ -20,7 +20,7 @@ import java.time.LocalDateTime; @NoArgsConstructor @Builder @Schema(name = "DebtTrackingVo对象", title = "债务追踪返回内容", description = "债务追踪返回内容") -public class DebtTrackingUserVo extends BaseUserVo { +public class DebtTrackingUserVo extends BaseVo { @Schema(name = "userId", title = "绑定的用户") @JsonFormat(shape = JsonFormat.Shape.STRING) diff --git a/dao/src/main/java/cn/bunny/dao/vo/financial/user/SavingGoalUserVo.java b/dao/src/main/java/cn/bunny/dao/vo/financial/user/SavingGoalUserVo.java new file mode 100644 index 0000000..5036306 --- /dev/null +++ b/dao/src/main/java/cn/bunny/dao/vo/financial/user/SavingGoalUserVo.java @@ -0,0 +1,44 @@ +package cn.bunny.dao.vo.financial.user; + +import cn.bunny.dao.common.vo.BaseVo; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +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 = "SavingGoalVo对象", title = "用户储值返回内容", description = "用户储值返回内容") +public class SavingGoalUserVo extends BaseVo { + + @Schema(name = "statusType", title = "完成状态") + private String statusType; + + @Schema(name = "savingGoalName", title = "储值目标名称") + private String savingGoalName; + + @Schema(name = "amount", title = "目标金额") + private BigDecimal amount; + + @Schema(name = "startDuration", title = "开始目标时长") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonSerialize(using = LocalDateTimeSerializer.class) + @JsonDeserialize(using = LocalDateTimeDeserializer.class) + private LocalDateTime startDuration; + + @Schema(name = "endDuration", title = "结束目标时长") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonSerialize(using = LocalDateTimeSerializer.class) + @JsonDeserialize(using = LocalDateTimeDeserializer.class) + private LocalDateTime endDuration; + +} \ No newline at end of file diff --git a/service/src/main/java/cn/bunny/services/controller/financial/DebtRepaymentPlanController.java b/service/src/main/java/cn/bunny/services/controller/financial/DebtRepaymentPlanController.java index 25cc19f..05b5388 100644 --- a/service/src/main/java/cn/bunny/services/controller/financial/DebtRepaymentPlanController.java +++ b/service/src/main/java/cn/bunny/services/controller/financial/DebtRepaymentPlanController.java @@ -3,11 +3,14 @@ package cn.bunny.services.controller.financial; import cn.bunny.dao.dto.financial.debtRepaymentPlan.DebtRepaymentPlanDto; import cn.bunny.dao.dto.financial.debtRepaymentPlan.admin.DebtRepaymentPlanAddDto; import cn.bunny.dao.dto.financial.debtRepaymentPlan.admin.DebtRepaymentPlanUpdateDto; +import cn.bunny.dao.dto.financial.debtRepaymentPlan.user.DebtRepaymentPlanAddUserDto; +import cn.bunny.dao.dto.financial.debtRepaymentPlan.user.DebtRepaymentPlanUpdateUserDto; import cn.bunny.dao.entity.financial.DebtRepaymentPlan; 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.DebtRepaymentPlanVo; +import cn.bunny.dao.vo.financial.user.DebtRepaymentPlanUserVo; import cn.bunny.services.service.financial.DebtRepaymentPlanService; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.v3.oas.annotations.Operation; @@ -49,6 +52,19 @@ public class DebtRepaymentPlanController { return Mono.just(Result.success(pageResult)); } + @Operation(summary = "用户分页查询债务还款计划表", description = "用户分页查询债务还款计划表") + @GetMapping("noManage/getUserDebtRepaymentPlanList/{page}/{limit}") + public Mono>> getUserDebtRepaymentPlanList( + @Parameter(name = "page", description = "当前页", required = true) + @PathVariable("page") Integer page, + @Parameter(name = "limit", description = "每页记录数", required = true) + @PathVariable("limit") Integer limit, + DebtRepaymentPlanDto dto) { + Page pageParams = new Page<>(page, limit); + PageResult pageResult = debtRepaymentPlanService.getUserDebtRepaymentPlanList(pageParams, dto); + return Mono.just(Result.success(pageResult)); + } + @Operation(summary = "添加债务还款计划表", description = "添加债务还款计划表") @PostMapping("addDebtRepaymentPlan") public Mono> addDebtRepaymentPlan(@Valid @RequestBody DebtRepaymentPlanAddDto dto) { @@ -56,6 +72,13 @@ public class DebtRepaymentPlanController { return Mono.just(Result.success(ResultCodeEnum.ADD_SUCCESS)); } + @Operation(summary = "用户添加债务还款计划表", description = "用户添加债务还款计划表") + @PostMapping("noManage/addUserDebtRepaymentPlan") + public Mono> addUserDebtRepaymentPlan(@Valid @RequestBody DebtRepaymentPlanAddUserDto dto) { + debtRepaymentPlanService.addUserDebtRepaymentPlan(dto); + return Mono.just(Result.success(ResultCodeEnum.ADD_SUCCESS)); + } + @Operation(summary = "更新债务还款计划表", description = "更新债务还款计划表") @PutMapping("updateDebtRepaymentPlan") public Mono> updateDebtRepaymentPlan(@Valid @RequestBody DebtRepaymentPlanUpdateDto dto) { @@ -63,10 +86,25 @@ public class DebtRepaymentPlanController { return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS)); } + @Operation(summary = "用户更新债务还款计划表", description = "用户更新债务还款计划表") + @PutMapping("noManage/updateUserDebtRepaymentPlan") + public Mono> updateUserDebtRepaymentPlan(@Valid @RequestBody DebtRepaymentPlanUpdateUserDto dto) { + debtRepaymentPlanService.updateUserDebtRepaymentPlan(dto); + return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS)); + } + @Operation(summary = "删除债务还款计划表", description = "删除债务还款计划表") @DeleteMapping("deleteDebtRepaymentPlan") public Mono> deleteDebtRepaymentPlan(@RequestBody List ids) { debtRepaymentPlanService.deleteDebtRepaymentPlan(ids); return Mono.just(Result.success(ResultCodeEnum.DELETE_SUCCESS)); } + + @Operation(summary = "用户删除债务还款计划表", description = "用户删除债务还款计划表") + @DeleteMapping("noManage/deleteUserDebtRepaymentPlan") + public Mono> deleteUserDebtRepaymentPlan(@RequestBody List ids) { + debtRepaymentPlanService.deleteUserDebtRepaymentPlan(ids); + return Mono.just(Result.success(ResultCodeEnum.DELETE_SUCCESS)); + } + } diff --git a/service/src/main/java/cn/bunny/services/controller/financial/SavingGoalController.java b/service/src/main/java/cn/bunny/services/controller/financial/SavingGoalController.java index 66750a1..720cb94 100644 --- a/service/src/main/java/cn/bunny/services/controller/financial/SavingGoalController.java +++ b/service/src/main/java/cn/bunny/services/controller/financial/SavingGoalController.java @@ -9,6 +9,7 @@ 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.SavingGoalVo; +import cn.bunny.dao.vo.financial.user.SavingGoalUserVo; import cn.bunny.services.service.financial.SavingGoalService; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.v3.oas.annotations.Operation; @@ -52,14 +53,14 @@ public class SavingGoalController { @Operation(summary = "用户分页查询用户储值", description = "用户分页查询用户储值") @GetMapping("noManage/getUserSavingGoalList/{page}/{limit}") - public Mono>> getUserSavingGoalList( + public Mono>> getUserSavingGoalList( @Parameter(name = "page", description = "当前页", required = true) @PathVariable("page") Integer page, @Parameter(name = "limit", description = "每页记录数", required = true) @PathVariable("limit") Integer limit, SavingGoalDto dto) { Page pageParams = new Page<>(page, limit); - PageResult pageResult = savingGoalService.getUserSavingGoalList(pageParams, dto); + PageResult pageResult = savingGoalService.getUserSavingGoalList(pageParams, dto); return Mono.just(Result.success(pageResult)); } diff --git a/service/src/main/java/cn/bunny/services/service/financial/DebtRepaymentPlanService.java b/service/src/main/java/cn/bunny/services/service/financial/DebtRepaymentPlanService.java index 6a6e157..5cdb846 100644 --- a/service/src/main/java/cn/bunny/services/service/financial/DebtRepaymentPlanService.java +++ b/service/src/main/java/cn/bunny/services/service/financial/DebtRepaymentPlanService.java @@ -3,9 +3,12 @@ package cn.bunny.services.service.financial; import cn.bunny.dao.dto.financial.debtRepaymentPlan.DebtRepaymentPlanDto; import cn.bunny.dao.dto.financial.debtRepaymentPlan.admin.DebtRepaymentPlanAddDto; import cn.bunny.dao.dto.financial.debtRepaymentPlan.admin.DebtRepaymentPlanUpdateDto; +import cn.bunny.dao.dto.financial.debtRepaymentPlan.user.DebtRepaymentPlanAddUserDto; +import cn.bunny.dao.dto.financial.debtRepaymentPlan.user.DebtRepaymentPlanUpdateUserDto; import cn.bunny.dao.entity.financial.DebtRepaymentPlan; import cn.bunny.dao.pojo.result.PageResult; import cn.bunny.dao.vo.financial.admin.DebtRepaymentPlanVo; +import cn.bunny.dao.vo.financial.user.DebtRepaymentPlanUserVo; 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 DebtRepaymentPlanService extends IService { * @param ids 删除id列表 */ void deleteDebtRepaymentPlan(List ids); + + /** + * 用户分页查询债务还款计划表 + * + * @param pageParams 分页参数 + * @param dto 查询表单 + * @return 分页返回结果 + */ + PageResult getUserDebtRepaymentPlanList(Page pageParams, DebtRepaymentPlanDto dto); + + /** + * 用户添加债务还款计划表 + * + * @param dto 添加表单 + */ + void addUserDebtRepaymentPlan(@Valid DebtRepaymentPlanAddUserDto dto); + + /** + * 用户更新债务还款计划表 + * + * @param dto 更新表单 + */ + void updateUserDebtRepaymentPlan(@Valid DebtRepaymentPlanUpdateUserDto dto); + + /** + * 用户删除债务还款计划表 + * + * @param ids 删除id列表 + */ + void deleteUserDebtRepaymentPlan(List ids); } diff --git a/service/src/main/java/cn/bunny/services/service/financial/SavingGoalService.java b/service/src/main/java/cn/bunny/services/service/financial/SavingGoalService.java index f0cd2d4..aa19b5b 100644 --- a/service/src/main/java/cn/bunny/services/service/financial/SavingGoalService.java +++ b/service/src/main/java/cn/bunny/services/service/financial/SavingGoalService.java @@ -7,6 +7,7 @@ import cn.bunny.dao.dto.financial.savingGoal.user.SavingGoalAddUserDto; import cn.bunny.dao.entity.financial.SavingGoal; import cn.bunny.dao.pojo.result.PageResult; import cn.bunny.dao.vo.financial.admin.SavingGoalVo; +import cn.bunny.dao.vo.financial.user.SavingGoalUserVo; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import jakarta.validation.Valid; @@ -58,7 +59,7 @@ public interface SavingGoalService extends IService { * @param dto 分页查询表单 * @return 分页返回结果 */ - PageResult getUserSavingGoalList(Page pageParams, SavingGoalDto dto); + PageResult getUserSavingGoalList(Page pageParams, SavingGoalDto dto); /** * 用户添加储值 diff --git a/service/src/main/java/cn/bunny/services/service/financial/impl/DebtRepaymentPlanServiceImpl.java b/service/src/main/java/cn/bunny/services/service/financial/impl/DebtRepaymentPlanServiceImpl.java index 774f505..f159b1c 100644 --- a/service/src/main/java/cn/bunny/services/service/financial/impl/DebtRepaymentPlanServiceImpl.java +++ b/service/src/main/java/cn/bunny/services/service/financial/impl/DebtRepaymentPlanServiceImpl.java @@ -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.debtRepaymentPlan.DebtRepaymentPlanDto; import cn.bunny.dao.dto.financial.debtRepaymentPlan.admin.DebtRepaymentPlanAddDto; import cn.bunny.dao.dto.financial.debtRepaymentPlan.admin.DebtRepaymentPlanUpdateDto; +import cn.bunny.dao.dto.financial.debtRepaymentPlan.user.DebtRepaymentPlanAddUserDto; +import cn.bunny.dao.dto.financial.debtRepaymentPlan.user.DebtRepaymentPlanUpdateUserDto; import cn.bunny.dao.entity.financial.DebtRepaymentPlan; import cn.bunny.dao.pojo.result.PageResult; +import cn.bunny.dao.pojo.result.ResultCodeEnum; import cn.bunny.dao.vo.financial.admin.DebtRepaymentPlanVo; +import cn.bunny.dao.vo.financial.user.DebtRepaymentPlanUserVo; import cn.bunny.services.mapper.financial.DebtRepaymentPlanMapper; import cn.bunny.services.service.financial.DebtRepaymentPlanService; 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; @@ -82,4 +89,77 @@ public class DebtRepaymentPlanServiceImpl extends ServiceImpl ids) { baseMapper.deleteBatchIdsWithPhysics(ids); } + + /** + * 用户分页查询债务还款计划表 + * + * @param pageParams 分页参数 + * @param dto 查询表单 + * @return 分页返回结果 + */ + @Override + public PageResult getUserDebtRepaymentPlanList(Page pageParams, DebtRepaymentPlanDto dto) { + dto.setUserId(BaseContext.getUserId()); + + IPage page = baseMapper.selectListByPage(pageParams, dto); + List planUserVoList = page.getRecords().stream().map(debtRepaymentPlanVo -> { + DebtRepaymentPlanUserVo debtRepaymentPlanUserVo = new DebtRepaymentPlanUserVo(); + BeanUtils.copyProperties(debtRepaymentPlanVo, debtRepaymentPlanUserVo); + return debtRepaymentPlanUserVo; + }).toList(); + + return PageResult.builder() + .list(planUserVoList) + .pageNo(page.getCurrent()) + .pageSize(page.getSize()) + .total(page.getTotal()) + .build(); + } + + /** + * 用户添加债务还款计划表 + * + * @param dto 添加表单 + */ + @Override + public void addUserDebtRepaymentPlan(@Valid DebtRepaymentPlanAddUserDto dto) { + // 保存数据 + DebtRepaymentPlan debtRepaymentPlan = new DebtRepaymentPlan(); + BeanUtils.copyProperties(dto, debtRepaymentPlan); + + debtRepaymentPlan.setUserId(BaseContext.getUserId()); + save(debtRepaymentPlan); + } + + /** + * 用户更新债务还款计划表 + * + * @param dto 更新表单 + */ + @Override + public void updateUserDebtRepaymentPlan(@Valid DebtRepaymentPlanUpdateUserDto dto) { + // 更新内容 + DebtRepaymentPlan debtRepaymentPlan = new DebtRepaymentPlan(); + BeanUtils.copyProperties(dto, debtRepaymentPlan); + + debtRepaymentPlan.setUserId(BaseContext.getUserId()); + updateById(debtRepaymentPlan); + } + + /** + * 用户删除债务还款计划表 + * + * @param ids 删除id列表 + */ + @Override + public void deleteUserDebtRepaymentPlan(List ids) { + // 判断删除的是否是自己的账单 + List billList = list(Wrappers.lambdaQuery().in(DebtRepaymentPlan::getId, ids)) + .stream().filter(bill -> !bill.getUserId().equals(BaseContext.getUserId())).toList(); + if (!billList.isEmpty()) { + throw new BunnyException(ResultCodeEnum.ILLEGAL_DATA_REQUEST); + } + + baseMapper.deleteBatchIdsWithPhysics(ids); + } } diff --git a/service/src/main/java/cn/bunny/services/service/financial/impl/SavingGoalServiceImpl.java b/service/src/main/java/cn/bunny/services/service/financial/impl/SavingGoalServiceImpl.java index a6896e3..128e837 100644 --- a/service/src/main/java/cn/bunny/services/service/financial/impl/SavingGoalServiceImpl.java +++ b/service/src/main/java/cn/bunny/services/service/financial/impl/SavingGoalServiceImpl.java @@ -10,6 +10,7 @@ import cn.bunny.dao.entity.financial.SavingGoal; import cn.bunny.dao.pojo.result.PageResult; import cn.bunny.dao.pojo.result.ResultCodeEnum; import cn.bunny.dao.vo.financial.admin.SavingGoalVo; +import cn.bunny.dao.vo.financial.user.SavingGoalUserVo; import cn.bunny.services.mapper.financial.SavingGoalMapper; import cn.bunny.services.service.financial.SavingGoalService; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -96,12 +97,18 @@ public class SavingGoalServiceImpl extends ServiceImpl getUserSavingGoalList(Page pageParams, SavingGoalDto dto) { + public PageResult getUserSavingGoalList(Page pageParams, SavingGoalDto dto) { dto.setUserId(BaseContext.getUserId()); - IPage page = baseMapper.selectListByPage(pageParams, dto); - return PageResult.builder() - .list(page.getRecords()) + IPage page = baseMapper.selectListByPage(pageParams, dto); + List goalUserVoList = page.getRecords().stream().map(savingGoalVo -> { + SavingGoalUserVo savingGoalUserVo = new SavingGoalUserVo(); + BeanUtils.copyProperties(savingGoalVo, savingGoalUserVo); + return savingGoalUserVo; + }).toList(); + + return PageResult.builder() + .list(goalUserVoList) .pageNo(page.getCurrent()) .pageSize(page.getSize()) .total(page.getTotal()) diff --git a/service/src/main/resources/mapper/financial/DebtRepaymentPlanMapper.xml b/service/src/main/resources/mapper/financial/DebtRepaymentPlanMapper.xml index 9e2fa56..188639a 100644 --- a/service/src/main/resources/mapper/financial/DebtRepaymentPlanMapper.xml +++ b/service/src/main/resources/mapper/financial/DebtRepaymentPlanMapper.xml @@ -36,6 +36,9 @@ left join sys_user update_user on update_user.id = base.update_user base.is_deleted = 0 + + and base.user_id = #{dto.userId} + and base.installment_number like CONCAT('%',#{dto.installmentNumber},'%')