From b885f71589a895279ce9d7e38502f80c8f49215b Mon Sep 17 00:00:00 2001 From: bunny <1319900154@qq.com> Date: Mon, 11 Nov 2024 15:41:39 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=A2=84=E7=AE=97=E5=88=86=E7=B1=BB?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../generator/generator/WebGeneratorCode.java | 25 +++---- .../budgetCategory/BudgetCategoryAddDto.java | 53 +++++++++++++ .../budgetCategory/BudgetCategoryDto.java | 40 ++++++++++ .../BudgetCategoryUpdateDto.java | 57 ++++++++++++++ .../DebtRepaymentPlanUpdateDto.java | 4 +- .../dao/entity/financial/BudgetCategory.java | 26 +++---- .../dao/vo/financial/BudgetCategoryVo.java | 38 ++++++++++ .../financial/BudgetCategoryController.java | 66 ++++++++++++++-- .../financial/BudgetCategoryMapper.java | 26 ++++++- .../financial/BudgetCategoryService.java | 40 +++++++++- .../impl/BudgetCategoryServiceImpl.java | 73 +++++++++++++++++- .../mapper/financial/BudgetCategoryMapper.xml | 75 +++++++++++++++---- 12 files changed, 463 insertions(+), 60 deletions(-) create mode 100644 dao/src/main/java/cn/bunny/dao/dto/financial/budgetCategory/BudgetCategoryAddDto.java create mode 100644 dao/src/main/java/cn/bunny/dao/dto/financial/budgetCategory/BudgetCategoryDto.java create mode 100644 dao/src/main/java/cn/bunny/dao/dto/financial/budgetCategory/BudgetCategoryUpdateDto.java create mode 100644 dao/src/main/java/cn/bunny/dao/vo/financial/BudgetCategoryVo.java diff --git a/common/common-generator/src/main/java/cn/bunny/common/generator/generator/WebGeneratorCode.java b/common/common-generator/src/main/java/cn/bunny/common/generator/generator/WebGeneratorCode.java index 03ddebc..556abd7 100644 --- a/common/common-generator/src/main/java/cn/bunny/common/generator/generator/WebGeneratorCode.java +++ b/common/common-generator/src/main/java/cn/bunny/common/generator/generator/WebGeneratorCode.java @@ -3,16 +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.debtRepaymentPlan.DebtRepaymentPlanAddDto; -import cn.bunny.dao.dto.financial.debtRepaymentPlan.DebtRepaymentPlanDto; -import cn.bunny.dao.dto.financial.debtRepaymentPlan.DebtRepaymentPlanUpdateDto; -import cn.bunny.dao.dto.system.configuration.category.CategoryAddDto; -import cn.bunny.dao.dto.system.configuration.category.CategoryDto; -import cn.bunny.dao.dto.system.configuration.category.CategoryUpdateDto; -import cn.bunny.dao.entity.financial.Category; -import cn.bunny.dao.entity.financial.DebtRepaymentPlan; -import cn.bunny.dao.vo.configuration.CategoryVo; -import cn.bunny.dao.vo.financial.DebtRepaymentPlanVo; +import cn.bunny.dao.dto.financial.budgetCategory.BudgetCategoryAddDto; +import cn.bunny.dao.dto.financial.budgetCategory.BudgetCategoryDto; +import cn.bunny.dao.dto.financial.budgetCategory.BudgetCategoryUpdateDto; +import cn.bunny.dao.entity.financial.BudgetCategory; +import cn.bunny.dao.vo.financial.BudgetCategoryVo; import com.baomidou.mybatisplus.annotation.TableName; import com.google.common.base.CaseFormat; import io.swagger.v3.oas.annotations.media.Schema; @@ -57,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 = DebtRepaymentPlan.class; - Class dtoClass = DebtRepaymentPlanDto.class; - Class addDtoClass = DebtRepaymentPlanAddDto.class; - Class updateDtoClass = DebtRepaymentPlanUpdateDto.class; - Class voClass = DebtRepaymentPlanVo.class; + Class originalClass = BudgetCategory.class; + Class dtoClass = BudgetCategoryDto.class; + Class addDtoClass = BudgetCategoryAddDto.class; + Class updateDtoClass = BudgetCategoryUpdateDto.class; + Class voClass = BudgetCategoryVo.class; // 设置velocity资源加载器 Properties prop = new Properties(); diff --git a/dao/src/main/java/cn/bunny/dao/dto/financial/budgetCategory/BudgetCategoryAddDto.java b/dao/src/main/java/cn/bunny/dao/dto/financial/budgetCategory/BudgetCategoryAddDto.java new file mode 100644 index 0000000..fa2f580 --- /dev/null +++ b/dao/src/main/java/cn/bunny/dao/dto/financial/budgetCategory/BudgetCategoryAddDto.java @@ -0,0 +1,53 @@ +package cn.bunny.dao.dto.financial.budgetCategory; + +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; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +@Schema(name = "BudgetCategoryAddDto对象", title = "预算分类添加", description = "预算分类添加") +public class BudgetCategoryAddDto { + + @Schema(name = "parentId", title = "父级id") + @NotNull(message = "父级id不能为空") + private Long parentId; + + @Schema(name = "userId", title = "绑定的用户id") + @NotNull(message = "债绑定的用户不能为空") + private Long userId; + + @Schema(name = "categoryName", title = "分类名称") + @NotNull(message = "分类名称不能为空") + @NotBlank(message = "分类名称不能为空") + private String categoryName; + + @Schema(name = "budgetName", title = "预算名称") + @NotNull(message = "预算名称不能为空") + @NotBlank(message = "预算名称不能为空") + private String budgetName; + + @Schema(name = "statusType", title = "完成状态") + @NotNull(message = "完成状态不能为空") + @NotBlank(message = "完成状态不能为空") + private String statusType; + + @Schema(name = "amount", title = "预算金额") + @NotNull(message = "预算金额不能为空") + private BigDecimal amount; + + @Schema(name = "period", title = "预算周期") + @NotNull(message = "预算周期不能为空") + @NotBlank(message = "预算周期不能为空") + private String period; + +} + diff --git a/dao/src/main/java/cn/bunny/dao/dto/financial/budgetCategory/BudgetCategoryDto.java b/dao/src/main/java/cn/bunny/dao/dto/financial/budgetCategory/BudgetCategoryDto.java new file mode 100644 index 0000000..fa36766 --- /dev/null +++ b/dao/src/main/java/cn/bunny/dao/dto/financial/budgetCategory/BudgetCategoryDto.java @@ -0,0 +1,40 @@ +package cn.bunny.dao.dto.financial.budgetCategory; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +@Schema(name = "BudgetCategoryDto对象", title = "预算分类查询", description = "预算分类查询") +public class BudgetCategoryDto { + + @Schema(name = "parentId", title = "父级id") + private Long parentId; + + @Schema(name = "userId", title = "绑定的用户id") + private Long userId; + + @Schema(name = "categoryName", title = "分类名称") + private String categoryName; + + @Schema(name = "budgetName", title = "预算名称") + private String budgetName; + + @Schema(name = "statusType", title = "完成状态") + private String statusType; + + @Schema(name = "amount", title = "预算金额") + private BigDecimal amount; + + @Schema(name = "period", title = "预算周期") + private String period; + +} + diff --git a/dao/src/main/java/cn/bunny/dao/dto/financial/budgetCategory/BudgetCategoryUpdateDto.java b/dao/src/main/java/cn/bunny/dao/dto/financial/budgetCategory/BudgetCategoryUpdateDto.java new file mode 100644 index 0000000..b5e7884 --- /dev/null +++ b/dao/src/main/java/cn/bunny/dao/dto/financial/budgetCategory/BudgetCategoryUpdateDto.java @@ -0,0 +1,57 @@ +package cn.bunny.dao.dto.financial.budgetCategory; + +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; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +@Schema(name = "BudgetCategoryUpdateDto对象", title = "预算分类更新", description = "预算分类更新") +public class BudgetCategoryUpdateDto { + + @Schema(name = "id", title = "主键") + @NotNull(message = "id不能为空") + private Long id; + + @Schema(name = "parentId", title = "父级id") + @NotNull(message = "父级id不能为空") + private Long parentId; + + @Schema(name = "userId", title = "绑定的用户id") + @NotNull(message = "债绑定的用户不能为空") + private Long userId; + + @Schema(name = "categoryName", title = "分类名称") + @NotNull(message = "分类名称不能为空") + @NotBlank(message = "分类名称不能为空") + private String categoryName; + + @Schema(name = "budgetName", title = "预算名称") + @NotNull(message = "预算名称不能为空") + @NotBlank(message = "预算名称不能为空") + private String budgetName; + + @Schema(name = "statusType", title = "完成状态") + @NotNull(message = "完成状态不能为空") + @NotBlank(message = "完成状态不能为空") + private String statusType; + + @Schema(name = "amount", title = "预算金额") + @NotNull(message = "预算金额不能为空") + private BigDecimal amount; + + @Schema(name = "period", title = "预算周期") + @NotNull(message = "预算周期不能为空") + @NotBlank(message = "预算周期不能为空") + private String period; + +} + diff --git a/dao/src/main/java/cn/bunny/dao/dto/financial/debtRepaymentPlan/DebtRepaymentPlanUpdateDto.java b/dao/src/main/java/cn/bunny/dao/dto/financial/debtRepaymentPlan/DebtRepaymentPlanUpdateDto.java index e52933a..c6bc92e 100644 --- a/dao/src/main/java/cn/bunny/dao/dto/financial/debtRepaymentPlan/DebtRepaymentPlanUpdateDto.java +++ b/dao/src/main/java/cn/bunny/dao/dto/financial/debtRepaymentPlan/DebtRepaymentPlanUpdateDto.java @@ -1,6 +1,7 @@ package cn.bunny.dao.dto.financial.debtRepaymentPlan; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Builder; @@ -20,7 +21,7 @@ public class DebtRepaymentPlanUpdateDto { @Schema(name = "id", title = "主键") @NotNull(message = "id不能为空") private Long id; - + @Schema(name = "debtId", title = "债务ID") @NotNull(message = "债务不能为空") private Long debtId; @@ -43,6 +44,7 @@ public class DebtRepaymentPlanUpdateDto { @Schema(name = "paymentStatus", title = "还款状态") @NotNull(message = "还款状态不能为空") + @NotBlank(message = "还款状态不能为空") private String paymentStatus; } \ No newline at end of file diff --git a/dao/src/main/java/cn/bunny/dao/entity/financial/BudgetCategory.java b/dao/src/main/java/cn/bunny/dao/entity/financial/BudgetCategory.java index bf13973..1acdd10 100644 --- a/dao/src/main/java/cn/bunny/dao/entity/financial/BudgetCategory.java +++ b/dao/src/main/java/cn/bunny/dao/entity/financial/BudgetCategory.java @@ -1,18 +1,14 @@ 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; + /** *

* 预算分类表 @@ -25,28 +21,28 @@ import lombok.experimental.Accessors; @Setter @Accessors(chain = true) @TableName("t_budget_category") -@ApiModel(value = "BudgetCategory对象", description = "预算分类表") +@Schema(name = "BudgetCategory对象", title = "预算分类表", description = "预算分类表") public class BudgetCategory extends BaseEntity { - @ApiModelProperty("父级id") + @Schema(name = "parentId", title = "父级id") private Long parentId; - @ApiModelProperty("绑定的用户id") + @Schema(name = "userId", title = "绑定的用户id") private Long userId; - @ApiModelProperty("分类名称") + @Schema(name = "categoryName", title = "分类名称") private String categoryName; - @ApiModelProperty("预算名称") + @Schema(name = "budgetName", title = "预算名称") private String budgetName; - @ApiModelProperty("完成状态") + @Schema(name = "statusType", title = "完成状态") private String statusType; - @ApiModelProperty("预算金额") + @Schema(name = "amount", title = "预算金额") private BigDecimal amount; - @ApiModelProperty("预算周期") + @Schema(name = "period", title = "预算周期") private String period; } diff --git a/dao/src/main/java/cn/bunny/dao/vo/financial/BudgetCategoryVo.java b/dao/src/main/java/cn/bunny/dao/vo/financial/BudgetCategoryVo.java new file mode 100644 index 0000000..859f5ac --- /dev/null +++ b/dao/src/main/java/cn/bunny/dao/vo/financial/BudgetCategoryVo.java @@ -0,0 +1,38 @@ +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; + +@EqualsAndHashCode(callSuper = true) +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +@Schema(name = "BudgetCategoryVo对象", title = "预算分类查询返回对象", description = "预算分类查询返回对象") +public class BudgetCategoryVo extends BaseVo { + + @Schema(name = "parentId", title = "父级id") + private Long parentId; + + @Schema(name = "userId", title = "绑定的用户id") + private Long userId; + + @Schema(name = "categoryName", title = "分类名称") + private String categoryName; + + @Schema(name = "budgetName", title = "预算名称") + private String budgetName; + + @Schema(name = "statusType", title = "完成状态") + private String statusType; + + @Schema(name = "amount", title = "预算金额") + private BigDecimal amount; + + @Schema(name = "period", title = "预算周期") + private String period; + +} \ No newline at end of file diff --git a/service/src/main/java/cn/bunny/services/controller/financial/BudgetCategoryController.java b/service/src/main/java/cn/bunny/services/controller/financial/BudgetCategoryController.java index 4e60b6b..a2505d1 100644 --- a/service/src/main/java/cn/bunny/services/controller/financial/BudgetCategoryController.java +++ b/service/src/main/java/cn/bunny/services/controller/financial/BudgetCategoryController.java @@ -1,18 +1,72 @@ -package cn.bunny.services.controller.financial; +package cn.bunny.services.controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import cn.bunny.dao.dto.financial.budgetCategory.BudgetCategoryAddDto; +import cn.bunny.dao.dto.financial.budgetCategory.BudgetCategoryDto; +import cn.bunny.dao.dto.financial.budgetCategory.BudgetCategoryUpdateDto; +import cn.bunny.dao.entity.financial.BudgetCategory; +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.BudgetCategoryVo; +import cn.bunny.services.service.BudgetCategoryService; +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; /** *

- * 预算分类表 前端控制器 + * 预算分类表表 前端控制器 *

* * @author Bunny - * @since 2024-11-11 + * @since 2024-11-11 15:36:57 */ +@Tag(name = "预算分类表", description = "预算分类表相关接口") @RestController -@RequestMapping("/budgetCategory") +@RequestMapping("admin/budgetCategory") public class BudgetCategoryController { + @Autowired + private BudgetCategoryService budgetCategoryService; + + @Operation(summary = "分页查询预算分类表", description = "分页查询预算分类表") + @GetMapping("getBudgetCategoryList/{page}/{limit}") + public Mono>> getBudgetCategoryList( + @Parameter(name = "page", description = "当前页", required = true) + @PathVariable("page") Integer page, + @Parameter(name = "limit", description = "每页记录数", required = true) + @PathVariable("limit") Integer limit, + BudgetCategoryDto dto) { + Page pageParams = new Page<>(page, limit); + PageResult pageResult = budgetCategoryService.getBudgetCategoryList(pageParams, dto); + return Mono.just(Result.success(pageResult)); + } + + @Operation(summary = "添加预算分类表", description = "添加预算分类表") + @PostMapping("addBudgetCategory") + public Mono> addBudgetCategory(@Valid @RequestBody BudgetCategoryAddDto dto) { + budgetCategoryService.addBudgetCategory(dto); + return Mono.just(Result.success(ResultCodeEnum.ADD_SUCCESS)); + } + + @Operation(summary = "更新预算分类表", description = "更新预算分类表") + @PutMapping("updateBudgetCategory") + public Mono> updateBudgetCategory(@Valid @RequestBody BudgetCategoryUpdateDto dto) { + budgetCategoryService.updateBudgetCategory(dto); + return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS)); + } + + @Operation(summary = "删除预算分类表", description = "删除预算分类表") + @DeleteMapping("deleteBudgetCategory") + public Mono> deleteBudgetCategory(@RequestBody List ids) { + budgetCategoryService.deleteBudgetCategory(ids); + return Mono.just(Result.success(ResultCodeEnum.DELETE_SUCCESS)); + } } diff --git a/service/src/main/java/cn/bunny/services/mapper/financial/BudgetCategoryMapper.java b/service/src/main/java/cn/bunny/services/mapper/financial/BudgetCategoryMapper.java index 47e54a3..4048ebd 100644 --- a/service/src/main/java/cn/bunny/services/mapper/financial/BudgetCategoryMapper.java +++ b/service/src/main/java/cn/bunny/services/mapper/financial/BudgetCategoryMapper.java @@ -1,8 +1,15 @@ -package cn.bunny.services.mapper.financial; +package cn.bunny.services.mapper; +import cn.bunny.dao.dto.financial.budgetCategory.BudgetCategoryDto; import cn.bunny.dao.entity.financial.BudgetCategory; +import cn.bunny.dao.vo.financial.BudgetCategoryVo; 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; /** *

@@ -10,9 +17,24 @@ import org.apache.ibatis.annotations.Mapper; *

* * @author Bunny - * @since 2024-11-11 + * @since 2024-11-11 15:36:57 */ @Mapper public interface BudgetCategoryMapper extends BaseMapper { + /** + * * 分页查询预算分类表内容 + * + * @param pageParams 预算分类表分页参数 + * @param dto 预算分类表查询表单 + * @return 预算分类表分页结果 + */ + IPage selectListByPage(@Param("page") Page pageParams, @Param("dto") BudgetCategoryDto dto); + + /** + * 物理删除预算分类表 + * + * @param ids 删除 id 列表 + */ + void deleteBatchIdsWithPhysics(List ids); } diff --git a/service/src/main/java/cn/bunny/services/service/financial/BudgetCategoryService.java b/service/src/main/java/cn/bunny/services/service/financial/BudgetCategoryService.java index 4674cd6..a7e91a4 100644 --- a/service/src/main/java/cn/bunny/services/service/financial/BudgetCategoryService.java +++ b/service/src/main/java/cn/bunny/services/service/financial/BudgetCategoryService.java @@ -1,7 +1,16 @@ -package cn.bunny.services.service.financial; +package cn.bunny.services.service; +import cn.bunny.dao.dto.financial.budgetCategory.BudgetCategoryAddDto; +import cn.bunny.dao.dto.financial.budgetCategory.BudgetCategoryDto; +import cn.bunny.dao.dto.financial.budgetCategory.BudgetCategoryUpdateDto; import cn.bunny.dao.entity.financial.BudgetCategory; +import cn.bunny.dao.pojo.result.PageResult; +import cn.bunny.dao.vo.financial.BudgetCategoryVo; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; +import jakarta.validation.Valid; + +import java.util.List; /** *

@@ -9,8 +18,35 @@ import com.baomidou.mybatisplus.extension.service.IService; *

* * @author Bunny - * @since 2024-11-11 + * @since 2024-11-11 15:36:57 */ public interface BudgetCategoryService extends IService { + /** + * * 获取预算分类表列表 + * + * @return 预算分类表返回列表 + */ + PageResult getBudgetCategoryList(Page pageParams, BudgetCategoryDto dto); + + /** + * * 添加预算分类表 + * + * @param dto 添加表单 + */ + void addBudgetCategory(@Valid BudgetCategoryAddDto dto); + + /** + * * 更新预算分类表 + * + * @param dto 更新表单 + */ + void updateBudgetCategory(@Valid BudgetCategoryUpdateDto dto); + + /** + * * 删除|批量删除预算分类表类型 + * + * @param ids 删除id列表 + */ + void deleteBudgetCategory(List ids); } diff --git a/service/src/main/java/cn/bunny/services/service/financial/impl/BudgetCategoryServiceImpl.java b/service/src/main/java/cn/bunny/services/service/financial/impl/BudgetCategoryServiceImpl.java index b2b3260..2a67cd8 100644 --- a/service/src/main/java/cn/bunny/services/service/financial/impl/BudgetCategoryServiceImpl.java +++ b/service/src/main/java/cn/bunny/services/service/financial/impl/BudgetCategoryServiceImpl.java @@ -1,20 +1,85 @@ -package cn.bunny.services.service.financial.impl; +package cn.bunny.services.service.impl; +import cn.bunny.dao.dto.financial.budgetCategory.BudgetCategoryAddDto; +import cn.bunny.dao.dto.financial.budgetCategory.BudgetCategoryDto; +import cn.bunny.dao.dto.financial.budgetCategory.BudgetCategoryUpdateDto; import cn.bunny.dao.entity.financial.BudgetCategory; -import cn.bunny.services.mapper.financial.BudgetCategoryMapper; -import cn.bunny.services.service.financial.BudgetCategoryService; +import cn.bunny.dao.pojo.result.PageResult; +import cn.bunny.dao.vo.financial.BudgetCategoryVo; +import cn.bunny.services.mapper.BudgetCategoryMapper; +import cn.bunny.services.service.BudgetCategoryService; +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; + /** *

* 预算分类表 服务实现类 *

* * @author Bunny - * @since 2024-11-11 + * @since 2024-11-11 15:36:57 */ @Service public class BudgetCategoryServiceImpl extends ServiceImpl implements BudgetCategoryService { + /** + * * 预算分类表 服务实现类 + * + * @param pageParams 预算分类表分页查询page对象 + * @param dto 预算分类表分页查询对象 + * @return 查询分页预算分类表返回对象 + */ + @Override + public PageResult getBudgetCategoryList(Page pageParams, BudgetCategoryDto dto) { + IPage page = baseMapper.selectListByPage(pageParams, dto); + + return PageResult.builder() + .list(page.getRecords()) + .pageNo(page.getCurrent()) + .pageSize(page.getSize()) + .total(page.getTotal()) + .build(); + } + + /** + * 添加预算分类表 + * + * @param dto 预算分类表添加 + */ + @Override + public void addBudgetCategory(@Valid BudgetCategoryAddDto dto) { + // 保存数据 + BudgetCategory budgetCategory = new BudgetCategory(); + BeanUtils.copyProperties(dto, budgetCategory); + save(budgetCategory); + } + + /** + * 更新预算分类表 + * + * @param dto 预算分类表更新 + */ + @Override + public void updateBudgetCategory(@Valid BudgetCategoryUpdateDto dto) { + // 更新内容 + BudgetCategory budgetCategory = new BudgetCategory(); + BeanUtils.copyProperties(dto, budgetCategory); + updateById(budgetCategory); + } + + /** + * 删除|批量删除预算分类表 + * + * @param ids 删除id列表 + */ + @Override + public void deleteBudgetCategory(List ids) { + baseMapper.deleteBatchIdsWithPhysics(ids); + } } diff --git a/service/src/main/resources/mapper/financial/BudgetCategoryMapper.xml b/service/src/main/resources/mapper/financial/BudgetCategoryMapper.xml index 4680f81..876a0b7 100644 --- a/service/src/main/resources/mapper/financial/BudgetCategoryMapper.xml +++ b/service/src/main/resources/mapper/financial/BudgetCategoryMapper.xml @@ -1,27 +1,72 @@ - + - - - - - - - - - - - - - + + + + + + + + + + + + + - id, parent_id, user_id, category_name, budget_name, status_type, amount, period, create_user, create_time, update_user, update_time, is_deleted + id, create_time, update_time, create_user, update_user, is_deleted, parent_id, user_id, category_name, budget_name, status_type, amount, period + + + + + + delete + from t_budget_category + where id in + + #{id} + + +