diff --git a/.gitignore b/.gitignore index a593848..83635dc 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,7 @@ target/ !**/src/main/**/target/ !**/src/test/**/target/ logs/ -!**/src/main/resources/application-prod.yml +application-prod.yml ### STS ### .apt_generated 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 3702b26..4f100ad 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,9 +3,9 @@ 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.bill.admin.BillAddDto; -import cn.bunny.dao.dto.financial.bill.admin.BillDto; -import cn.bunny.dao.dto.financial.bill.admin.BillUpdateDto; +import cn.bunny.dao.dto.financial.bill.BillAddDto; +import cn.bunny.dao.dto.financial.bill.BillDto; +import cn.bunny.dao.dto.financial.bill.BillUpdateDto; import cn.bunny.dao.entity.financial.Bill; import cn.bunny.dao.vo.financial.admin.BillVo; import com.baomidou.mybatisplus.annotation.TableName; diff --git a/dao/src/main/java/cn/bunny/dao/dto/financial/bill/admin/BillAddDto.java b/dao/src/main/java/cn/bunny/dao/dto/financial/bill/BillAddDto.java similarity index 97% rename from dao/src/main/java/cn/bunny/dao/dto/financial/bill/admin/BillAddDto.java rename to dao/src/main/java/cn/bunny/dao/dto/financial/bill/BillAddDto.java index 1097f52..fd0a5ef 100644 --- a/dao/src/main/java/cn/bunny/dao/dto/financial/bill/admin/BillAddDto.java +++ b/dao/src/main/java/cn/bunny/dao/dto/financial/bill/BillAddDto.java @@ -1,4 +1,4 @@ -package cn.bunny.dao.dto.financial.bill.admin; +package cn.bunny.dao.dto.financial.bill; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; diff --git a/dao/src/main/java/cn/bunny/dao/dto/financial/bill/admin/BillDto.java b/dao/src/main/java/cn/bunny/dao/dto/financial/bill/BillDto.java similarity index 95% rename from dao/src/main/java/cn/bunny/dao/dto/financial/bill/admin/BillDto.java rename to dao/src/main/java/cn/bunny/dao/dto/financial/bill/BillDto.java index c62015a..ce1c5f4 100644 --- a/dao/src/main/java/cn/bunny/dao/dto/financial/bill/admin/BillDto.java +++ b/dao/src/main/java/cn/bunny/dao/dto/financial/bill/BillDto.java @@ -1,4 +1,4 @@ -package cn.bunny.dao.dto.financial.bill.admin; +package cn.bunny.dao.dto.financial.bill; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; diff --git a/dao/src/main/java/cn/bunny/dao/dto/financial/bill/admin/BillUpdateDto.java b/dao/src/main/java/cn/bunny/dao/dto/financial/bill/BillUpdateDto.java similarity index 97% rename from dao/src/main/java/cn/bunny/dao/dto/financial/bill/admin/BillUpdateDto.java rename to dao/src/main/java/cn/bunny/dao/dto/financial/bill/BillUpdateDto.java index 593e88f..bc650c0 100644 --- a/dao/src/main/java/cn/bunny/dao/dto/financial/bill/admin/BillUpdateDto.java +++ b/dao/src/main/java/cn/bunny/dao/dto/financial/bill/BillUpdateDto.java @@ -1,4 +1,4 @@ -package cn.bunny.dao.dto.financial.bill.admin; +package cn.bunny.dao.dto.financial.bill; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; diff --git a/dao/src/main/java/cn/bunny/dao/dto/financial/bill/user/BillUserAddDto.java b/dao/src/main/java/cn/bunny/dao/dto/financial/bill/user/BillUserAddDto.java deleted file mode 100644 index 06a20a3..0000000 --- a/dao/src/main/java/cn/bunny/dao/dto/financial/bill/user/BillUserAddDto.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.bunny.dao.dto.financial.bill.user; - -import com.fasterxml.jackson.annotation.JsonFormat; -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.Max; -import jakarta.validation.constraints.Min; -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 = "BillUserAddDto对象", title = "用户账单信息添加内容", description = "用户账单信息添加内容") -public class BillUserAddDto { - - @Schema(name = "username", title = "类型:1 - 收入,-1 - 支出") - @NotNull(message = "类型不能为空") - @Min(value = -1, message = "类型格式不正确") - @Max(value = 1, message = "类型格式不正确") - private Byte type; - - @Schema(name = "amount", title = "金额") - @NotNull(message = "金额不能为空") - @Min(value = 0, message = "金额格式不正确") - private BigDecimal amount; - - @Schema(name = "description", title = "描述") - private String description; - - @Schema(name = "transactionDate", title = "交易日期") - @NotNull(message = "交易日期不能为空") - @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime transactionDate; - - @Schema(name = "categoryId", title = "类别id") - @NotNull(message = "类别id不能为空") - private Long categoryId; - -} \ No newline at end of file diff --git a/dao/src/main/java/cn/bunny/dao/dto/financial/bill/user/BillUserDto.java b/dao/src/main/java/cn/bunny/dao/dto/financial/bill/user/BillUserDto.java deleted file mode 100644 index 8db7af6..0000000 --- a/dao/src/main/java/cn/bunny/dao/dto/financial/bill/user/BillUserDto.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.bunny.dao.dto.financial.bill.user; - -import com.fasterxml.jackson.annotation.JsonFormat; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.time.LocalDate; - -@Data -@AllArgsConstructor -@NoArgsConstructor -@Builder -@Schema(name = "BillUserDto对象", title = "用户账单信息查询内容", description = "用户账单信息查询内容") -public class BillUserDto { - - @Schema(name = "username", title = "类型:1 - 收入,-1 - 支出") - private Byte type; - - @Schema(name = "description", title = "描述") - private String description; - - @Schema(name = "startDate", title = "开始交易日期") - @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd") - private LocalDate startDate; - - @Schema(name = "endDate", title = "结束交易日期") - @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd") - private LocalDate endDate; - -} \ No newline at end of file diff --git a/dao/src/main/java/cn/bunny/dao/dto/financial/bill/user/BillUserUpdateDto.java b/dao/src/main/java/cn/bunny/dao/dto/financial/bill/user/BillUserUpdateDto.java deleted file mode 100644 index 55da532..0000000 --- a/dao/src/main/java/cn/bunny/dao/dto/financial/bill/user/BillUserUpdateDto.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.bunny.dao.dto.financial.bill.user; - -import com.fasterxml.jackson.annotation.JsonFormat; -import io.swagger.v3.oas.annotations.media.Schema; -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 = "BillUserUpdateDto对象", title = "用户账单信息更新内容", description = "用户账单信息更新内容") -public class BillUserUpdateDto { - - @Schema(name = "id", title = "主键") - @NotNull(message = "id不能为空") - private Long id; - - @Schema(name = "username", title = "类型:1 - 收入,-1 - 支出") - private Byte type; - - @Schema(name = "amount", title = "金额") - private BigDecimal amount; - - @Schema(name = "description", title = "描述") - private String description; - - @Schema(name = "transactionDate", title = "交易日期") - @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime transactionDate; - - @Schema(name = "categoryId", title = "类别id") - private Long categoryId; - -} \ No newline at end of file diff --git a/dao/src/main/java/cn/bunny/dao/dto/financial/category/user/CategoryUserDto.java b/dao/src/main/java/cn/bunny/dao/dto/financial/category/user/CategoryUserDto.java deleted file mode 100644 index 2d19729..0000000 --- a/dao/src/main/java/cn/bunny/dao/dto/financial/category/user/CategoryUserDto.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.bunny.dao.dto.financial.category.user; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@AllArgsConstructor -@NoArgsConstructor -@Builder -@Schema(name = "CategoryDto对象", title = "分类信息查询", description = "分类信息查询") -public class CategoryUserDto { - - @Schema(name = "categoryName", title = "分类名称") - private String categoryName; - - @Schema(name = "isBuiltin", title = "是否内置字段") - private Boolean isBuiltin; - -} - - - - - - - - diff --git a/service/src/main/java/cn/bunny/services/controller/financial/BillController.java b/service/src/main/java/cn/bunny/services/controller/financial/BillController.java index 5ce0518..182e2d9 100644 --- a/service/src/main/java/cn/bunny/services/controller/financial/BillController.java +++ b/service/src/main/java/cn/bunny/services/controller/financial/BillController.java @@ -1,11 +1,9 @@ package cn.bunny.services.controller.financial; -import cn.bunny.dao.dto.financial.bill.admin.BillAddDto; -import cn.bunny.dao.dto.financial.bill.admin.BillDto; -import cn.bunny.dao.dto.financial.bill.admin.BillUpdateDto; -import cn.bunny.dao.dto.financial.bill.user.BillUserAddDto; -import cn.bunny.dao.dto.financial.bill.user.BillUserDto; -import cn.bunny.dao.dto.financial.bill.user.BillUserUpdateDto; +import cn.bunny.common.service.context.BaseContext; +import cn.bunny.dao.dto.financial.bill.BillAddDto; +import cn.bunny.dao.dto.financial.bill.BillDto; +import cn.bunny.dao.dto.financial.bill.BillUpdateDto; import cn.bunny.dao.entity.financial.Bill; import cn.bunny.dao.pojo.result.PageResult; import cn.bunny.dao.pojo.result.Result; @@ -40,40 +38,6 @@ public class BillController { @Autowired private BillService billService; - @Operation(summary = "用户分页查询账单信息", description = "用户分页查询账单信息") - @GetMapping("noManage/getUserBillList/{page}/{limit}") - public Mono>> getUserBillList( - @Parameter(name = "page", description = "当前页", required = true) - @PathVariable("page") Integer page, - @Parameter(name = "limit", description = "每页记录数", required = true) - @PathVariable("limit") Integer limit, - BillUserDto dto) { - Page pageParams = new Page<>(page, limit); - PageResult pageResult = billService.getUserBillList(pageParams, dto); - return Mono.just(Result.success(pageResult)); - } - - @Operation(summary = "用户添加账单信息", description = "用户添加账单信息") - @PostMapping("noManage/addUserBill") - public Mono> addUserBill(@Valid @RequestBody BillUserAddDto dto) { - billService.addUserBill(dto); - return Mono.just(Result.success(ResultCodeEnum.ADD_SUCCESS)); - } - - @Operation(summary = "用户更新账单信息", description = "用户更新账单信息") - @PutMapping("noManage/updateUserBill") - public Mono> updateUserBill(@Valid @RequestBody BillUserUpdateDto dto) { - billService.updateUserBill(dto); - return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS)); - } - - @Operation(summary = "用户删除账单信息", description = "用户删除账单信息") - @DeleteMapping("noManage/deleteUserBill") - public Mono> deleteUserBill(@RequestBody List ids) { - billService.deleteUserBill(ids); - return Mono.just(Result.success(ResultCodeEnum.DELETE_SUCCESS)); - } - @Operation(summary = "分页查询账单信息", description = "分页查询账单信息") @GetMapping("getBillList/{page}/{limit}") public Mono>> getBillList( @@ -87,6 +51,19 @@ public class BillController { return Mono.just(Result.success(pageResult)); } + @Operation(summary = "用户分页查询账单信息", description = "用户分页查询账单信息") + @GetMapping("noManage/getUserBillList/{page}/{limit}") + public Mono>> getUserBillList( + @Parameter(name = "page", description = "当前页", required = true) + @PathVariable("page") Integer page, + @Parameter(name = "limit", description = "每页记录数", required = true) + @PathVariable("limit") Integer limit, + BillDto dto) { + Page pageParams = new Page<>(page, limit); + PageResult pageResult = billService.getUserBillList(pageParams, dto); + return Mono.just(Result.success(pageResult)); + } + @Operation(summary = "添加账单信息", description = "添加账单信息") @PostMapping("addBill") public Mono> addBill(@Valid @RequestBody BillAddDto dto) { @@ -94,6 +71,14 @@ public class BillController { return Mono.just(Result.success(ResultCodeEnum.ADD_SUCCESS)); } + @Operation(summary = "用户添加账单信息", description = "用户添加账单信息") + @PostMapping("noManage/addUserBill") + public Mono> addUserBill(@Valid @RequestBody BillAddDto dto) { + dto.setUserId(BaseContext.getUserId()); + billService.addBill(dto); + return Mono.just(Result.success(ResultCodeEnum.ADD_SUCCESS)); + } + @Operation(summary = "更新账单信息", description = "更新账单信息") @PutMapping("updateBill") public Mono> updateBill(@Valid @RequestBody BillUpdateDto dto) { @@ -101,10 +86,25 @@ public class BillController { return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS)); } + @Operation(summary = "用户更新账单信息", description = "用户更新账单信息") + @PutMapping("noManage/updateUserBill") + public Mono> updateUserBill(@Valid @RequestBody BillUpdateDto dto) { + dto.setUserId(BaseContext.getUserId()); + billService.updateBill(dto); + return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS)); + } + @Operation(summary = "删除账单信息", description = "删除账单信息") @DeleteMapping("deleteBill") public Mono> deleteBill(@RequestBody List ids) { billService.deleteBill(ids); return Mono.just(Result.success(ResultCodeEnum.DELETE_SUCCESS)); } + + @Operation(summary = "用户删除账单信息", description = "用户删除账单信息") + @DeleteMapping("noManage/deleteUserBill") + public Mono> deleteUserBill(@RequestBody List ids) { + billService.deleteUserBill(ids); + return Mono.just(Result.success(ResultCodeEnum.DELETE_SUCCESS)); + } } diff --git a/service/src/main/java/cn/bunny/services/controller/financial/CategoryController.java b/service/src/main/java/cn/bunny/services/controller/financial/CategoryController.java index bf75406..9337d1d 100644 --- a/service/src/main/java/cn/bunny/services/controller/financial/CategoryController.java +++ b/service/src/main/java/cn/bunny/services/controller/financial/CategoryController.java @@ -4,7 +4,6 @@ import cn.bunny.dao.dto.financial.category.admin.CategoryAddDto; import cn.bunny.dao.dto.financial.category.admin.CategoryDto; import cn.bunny.dao.dto.financial.category.admin.CategoryUpdateDto; import cn.bunny.dao.dto.financial.category.user.CategoryUserAddDto; -import cn.bunny.dao.dto.financial.category.user.CategoryUserDto; import cn.bunny.dao.dto.financial.category.user.CategoryUserUpdateDto; import cn.bunny.dao.entity.financial.Category; import cn.bunny.dao.pojo.result.PageResult; @@ -40,6 +39,19 @@ public class CategoryController { @Autowired private CategoryService categoryService; + @Operation(summary = "分页查询分类信息", description = "分页查询分类信息") + @GetMapping("getCategoryList/{page}/{limit}") + public Mono>> getCategoryList( + @Parameter(name = "page", description = "当前页", required = true) + @PathVariable("page") Integer page, + @Parameter(name = "limit", description = "每页记录数", required = true) + @PathVariable("limit") Integer limit, + CategoryDto dto) { + Page pageParams = new Page<>(page, limit); + PageResult pageResult = categoryService.getCategoryList(pageParams, dto); + return Mono.just(Result.success(pageResult)); + } + @Operation(summary = "用户分类分页查询分类信息", description = "用户分类分页查询分类信息") @GetMapping("noManage/getCategoryUserList/{page}/{limit}") public Mono>> getCategoryUserList( @@ -47,7 +59,7 @@ public class CategoryController { @PathVariable("page") Integer page, @Parameter(name = "limit", description = "每页记录数", required = true) @PathVariable("limit") Integer limit, - CategoryUserDto dto) { + CategoryDto dto) { Page pageParams = new Page<>(page, limit); PageResult pageResult = categoryService.getCategoryUserList(pageParams, dto); return Mono.just(Result.success(pageResult)); @@ -60,6 +72,13 @@ public class CategoryController { return Mono.just(Result.success(voList)); } + @Operation(summary = "添加分类信息", description = "添加分类信息") + @PostMapping("addCategory") + public Mono> addCategory(@Valid @RequestBody CategoryAddDto dto) { + categoryService.addCategory(dto); + return Mono.just(Result.success(ResultCodeEnum.ADD_SUCCESS)); + } + @Operation(summary = "用戶分类添加分类信息", description = "用戶分类添加分类信息") @PostMapping("noManage/addCategoryUser") public Mono> addCategoryUser(@Valid @RequestBody CategoryUserAddDto dto) { @@ -67,6 +86,13 @@ public class CategoryController { return Mono.just(Result.success(ResultCodeEnum.ADD_SUCCESS)); } + @Operation(summary = "更新分类信息", description = "更新分类信息") + @PutMapping("updateCategory") + public Mono> updateCategory(@Valid @RequestBody CategoryUpdateDto dto) { + categoryService.updateCategory(dto); + return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS)); + } + @Operation(summary = "用户分类更新分类信息", description = "用户分类更新分类信息") @PutMapping("noManage/updateCategoryUser") public Mono> updateCategoryUser(@Valid @RequestBody CategoryUserUpdateDto dto) { @@ -81,33 +107,6 @@ public class CategoryController { return Mono.just(Result.success(ResultCodeEnum.DELETE_SUCCESS)); } - @Operation(summary = "分页查询分类信息", description = "分页查询分类信息") - @GetMapping("getCategoryList/{page}/{limit}") - public Mono>> getCategoryList( - @Parameter(name = "page", description = "当前页", required = true) - @PathVariable("page") Integer page, - @Parameter(name = "limit", description = "每页记录数", required = true) - @PathVariable("limit") Integer limit, - CategoryDto dto) { - Page pageParams = new Page<>(page, limit); - PageResult pageResult = categoryService.getCategoryList(pageParams, dto); - return Mono.just(Result.success(pageResult)); - } - - @Operation(summary = "添加分类信息", description = "添加分类信息") - @PostMapping("addCategory") - public Mono> addCategory(@Valid @RequestBody CategoryAddDto dto) { - categoryService.addCategory(dto); - return Mono.just(Result.success(ResultCodeEnum.ADD_SUCCESS)); - } - - @Operation(summary = "更新分类信息", description = "更新分类信息") - @PutMapping("updateCategory") - public Mono> updateCategory(@Valid @RequestBody CategoryUpdateDto dto) { - categoryService.updateCategory(dto); - return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS)); - } - @Operation(summary = "删除分类信息", description = "删除分类信息") @DeleteMapping("deleteCategory") public Mono> deleteCategory(@RequestBody List ids) { diff --git a/service/src/main/java/cn/bunny/services/mapper/financial/BillMapper.java b/service/src/main/java/cn/bunny/services/mapper/financial/BillMapper.java index 8b4b263..be9f9b5 100644 --- a/service/src/main/java/cn/bunny/services/mapper/financial/BillMapper.java +++ b/service/src/main/java/cn/bunny/services/mapper/financial/BillMapper.java @@ -1,10 +1,8 @@ package cn.bunny.services.mapper.financial; -import cn.bunny.dao.dto.financial.bill.admin.BillDto; -import cn.bunny.dao.dto.financial.bill.user.BillUserDto; +import cn.bunny.dao.dto.financial.bill.BillDto; import cn.bunny.dao.entity.financial.Bill; import cn.bunny.dao.vo.financial.admin.BillVo; -import cn.bunny.dao.vo.financial.user.BillUserVo; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -24,15 +22,6 @@ import java.util.List; @Mapper public interface BillMapper extends BaseMapper { - /** - * * 分页查询用户账单信息内容 - * - * @param pageParams 账单信息分页参数 - * @param dto 账单信息查询表单 - * @return 账单信息分页结果 - */ - IPage selectUserListByPage(@Param("page") Page pageParams, @Param("dto") BillUserDto dto, @Param("userId") Long userId); - /** * 物理删除账单信息 * diff --git a/service/src/main/java/cn/bunny/services/mapper/financial/CategoryMapper.java b/service/src/main/java/cn/bunny/services/mapper/financial/CategoryMapper.java index 8cce449..3428beb 100644 --- a/service/src/main/java/cn/bunny/services/mapper/financial/CategoryMapper.java +++ b/service/src/main/java/cn/bunny/services/mapper/financial/CategoryMapper.java @@ -1,10 +1,8 @@ package cn.bunny.services.mapper.financial; import cn.bunny.dao.dto.financial.category.admin.CategoryDto; -import cn.bunny.dao.dto.financial.category.user.CategoryUserDto; import cn.bunny.dao.entity.financial.Category; import cn.bunny.dao.vo.financial.admin.CategoryVo; -import cn.bunny.dao.vo.financial.user.CategoryUserVo; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -23,21 +21,6 @@ import java.util.List; */ @Mapper public interface CategoryMapper extends BaseMapper { - /** - * * 分页查询分类信息内容 - * - * @param pageParams 分类信息分页参数 - * @param dto 分类信息查询表单 - * @return 分类信息分页结果 - */ - IPage selectUserListByPage(@Param("page") Page pageParams, @Param("dto") CategoryUserDto dto, @Param("userId") Long userId); - - /** - * 物理删除分类信息 - * - * @param ids 删除 id 列表 - */ - void deleteBatchIdsWithUserPhysics(List ids); /** * * 分页查询分类信息内容 diff --git a/service/src/main/java/cn/bunny/services/service/financial/BillService.java b/service/src/main/java/cn/bunny/services/service/financial/BillService.java index 320beff..83c1191 100644 --- a/service/src/main/java/cn/bunny/services/service/financial/BillService.java +++ b/service/src/main/java/cn/bunny/services/service/financial/BillService.java @@ -1,18 +1,14 @@ package cn.bunny.services.service.financial; -import cn.bunny.dao.dto.financial.bill.admin.BillAddDto; -import cn.bunny.dao.dto.financial.bill.admin.BillDto; -import cn.bunny.dao.dto.financial.bill.admin.BillUpdateDto; -import cn.bunny.dao.dto.financial.bill.user.BillUserAddDto; -import cn.bunny.dao.dto.financial.bill.user.BillUserDto; -import cn.bunny.dao.dto.financial.bill.user.BillUserUpdateDto; +import cn.bunny.dao.dto.financial.bill.BillAddDto; +import cn.bunny.dao.dto.financial.bill.BillDto; +import cn.bunny.dao.dto.financial.bill.BillUpdateDto; import cn.bunny.dao.entity.financial.Bill; import cn.bunny.dao.pojo.result.PageResult; import cn.bunny.dao.vo.financial.admin.BillVo; import cn.bunny.dao.vo.financial.user.BillUserVo; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; -import jakarta.validation.Valid; import java.util.List; @@ -31,21 +27,7 @@ public interface BillService extends IService { * * @return 账单信息返回列表 */ - PageResult getUserBillList(Page pageParams, BillUserDto dto); - - /** - * * 添加账单信息 - * - * @param dto 添加表单 - */ - void addUserBill(@Valid BillUserAddDto dto); - - /** - * * 更新账单信息 - * - * @param dto 更新表单 - */ - void updateUserBill(@Valid BillUserUpdateDto dto); + PageResult getUserBillList(Page pageParams, BillDto dto); /** * * 删除|批量删除账单信息类型 diff --git a/service/src/main/java/cn/bunny/services/service/financial/CategoryService.java b/service/src/main/java/cn/bunny/services/service/financial/CategoryService.java index e06f4f5..6ec910c 100644 --- a/service/src/main/java/cn/bunny/services/service/financial/CategoryService.java +++ b/service/src/main/java/cn/bunny/services/service/financial/CategoryService.java @@ -4,7 +4,6 @@ import cn.bunny.dao.dto.financial.category.admin.CategoryAddDto; import cn.bunny.dao.dto.financial.category.admin.CategoryDto; import cn.bunny.dao.dto.financial.category.admin.CategoryUpdateDto; import cn.bunny.dao.dto.financial.category.user.CategoryUserAddDto; -import cn.bunny.dao.dto.financial.category.user.CategoryUserDto; import cn.bunny.dao.dto.financial.category.user.CategoryUserUpdateDto; import cn.bunny.dao.entity.financial.Category; import cn.bunny.dao.pojo.result.PageResult; @@ -26,12 +25,33 @@ import java.util.List; */ public interface CategoryService extends IService { + /** + * * 获取分类信息列表 + * + * @return 分类信息返回列表 + */ + PageResult getCategoryList(Page pageParams, CategoryDto dto); + /** * * 用户分类分页查询分类信息 * * @return 分类信息返回列表 */ - PageResult getCategoryUserList(Page pageParams, CategoryUserDto dto); + PageResult getCategoryUserList(Page pageParams, CategoryDto dto); + + /** + * 查询当前用户下所有的分类 + * + * @return 当前用户分类返回列表 + */ + List getCategoryUserAllList(); + + /** + * * 添加分类信息 + * + * @param dto 添加表单 + */ + void addCategory(@Valid CategoryAddDto dto); /** * * 用戶分类添加分类信息 @@ -40,6 +60,13 @@ public interface CategoryService extends IService { */ void addCategoryUser(@Valid CategoryUserAddDto dto); + /** + * * 更新分类信息 + * + * @param dto 更新表单 + */ + void updateCategory(@Valid CategoryUpdateDto dto); + /** * * 用户分类更新分类信息 * @@ -54,34 +81,6 @@ public interface CategoryService extends IService { */ void deleteCategoryUser(List ids); - /** - * 查询当前用户下所有的分类 - * - * @return 当前用户分类返回列表 - */ - List getCategoryUserAllList(); - - /** - * * 获取分类信息列表 - * - * @return 分类信息返回列表 - */ - PageResult getCategoryList(Page pageParams, CategoryDto dto); - - /** - * * 添加分类信息 - * - * @param dto 添加表单 - */ - void addCategory(@Valid CategoryAddDto dto); - - /** - * * 更新分类信息 - * - * @param dto 更新表单 - */ - void updateCategory(@Valid CategoryUpdateDto dto); - /** * * 删除|批量删除分类信息类型 * diff --git a/service/src/main/java/cn/bunny/services/service/financial/impl/BillServiceImpl.java b/service/src/main/java/cn/bunny/services/service/financial/impl/BillServiceImpl.java index 8503a31..37bbc7a 100644 --- a/service/src/main/java/cn/bunny/services/service/financial/impl/BillServiceImpl.java +++ b/service/src/main/java/cn/bunny/services/service/financial/impl/BillServiceImpl.java @@ -2,12 +2,9 @@ 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.bill.admin.BillAddDto; -import cn.bunny.dao.dto.financial.bill.admin.BillDto; -import cn.bunny.dao.dto.financial.bill.admin.BillUpdateDto; -import cn.bunny.dao.dto.financial.bill.user.BillUserAddDto; -import cn.bunny.dao.dto.financial.bill.user.BillUserDto; -import cn.bunny.dao.dto.financial.bill.user.BillUserUpdateDto; +import cn.bunny.dao.dto.financial.bill.BillAddDto; +import cn.bunny.dao.dto.financial.bill.BillDto; +import cn.bunny.dao.dto.financial.bill.BillUpdateDto; import cn.bunny.dao.entity.financial.Bill; import cn.bunny.dao.pojo.result.PageResult; import cn.bunny.dao.pojo.result.ResultCodeEnum; @@ -19,7 +16,6 @@ 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; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; @@ -44,72 +40,27 @@ public class BillServiceImpl extends ServiceImpl implements Bi * @return 查询分页账单信息返回对象 */ @Override - public PageResult getUserBillList(Page pageParams, BillUserDto dto) { + public PageResult getUserBillList(Page pageParams, BillDto dto) { // 需要根据当前用户去查询 Long userId = BaseContext.getUserId(); + dto.setUserId(userId); // 判断创建用户的Id是否和当前请求的用户id是否相同 - IPage page = baseMapper.selectUserListByPage(pageParams, dto, userId); + IPage page = baseMapper.selectListByPage(pageParams, dto); + List userVoList = page.getRecords().stream().map(billVo -> { + BillUserVo billUserVo = new BillUserVo(); + BeanUtils.copyProperties(billVo, billUserVo); + return billUserVo; + }).toList(); return PageResult.builder() - .list(page.getRecords()) + .list(userVoList) .pageNo(page.getCurrent()) .pageSize(page.getSize()) .total(page.getTotal()) .build(); } - /** - * 添加账单信息 - * - * @param dto 账单信息添加 - */ - @Override - public void addUserBill(@Valid BillUserAddDto dto) { - // 保存数据 - Bill bill = new Bill(); - BeanUtils.copyProperties(dto, bill); - - // 设置当前的用户Id - bill.setUserId(BaseContext.getUserId()); - save(bill); - } - - /** - * 更新账单信息 - * - * @param dto 账单信息更新 - */ - @Override - public void updateUserBill(@Valid BillUserUpdateDto dto) { - // 判断当前用户修改的内容是否是自己的内容 - Bill bill = getOne(Wrappers.lambdaQuery().eq(Bill::getId, dto.getId())); - if (!bill.getUserId().equals(BaseContext.getUserId())) { - throw new BunnyException(ResultCodeEnum.ILLEGAL_DATA_REQUEST); - } - - // 更新内容 - bill = new Bill(); - BeanUtils.copyProperties(dto, bill); - updateById(bill); - } - - /** - * 删除|批量删除账单信息 - * - * @param ids 删除id列表 - */ - @Override - public void deleteUserBill(List ids) { - // 判断删除的是否是自己的账单 - List billList = list(Wrappers.lambdaQuery().in(Bill::getId, ids)) - .stream().filter(bill -> !bill.getUserId().equals(BaseContext.getUserId())).toList(); - if (!billList.isEmpty()) { - throw new BunnyException(ResultCodeEnum.ILLEGAL_DATA_REQUEST); - } - baseMapper.deleteBatchIdsWithPhysics(ids); - } - /** * 分页查询账单信息 * @@ -163,4 +114,20 @@ public class BillServiceImpl extends ServiceImpl implements Bi public void deleteBill(List ids) { baseMapper.deleteBatchIdsWithPhysics(ids); } + + /** + * 删除|批量删除账单信息 + * + * @param ids 删除id列表 + */ + @Override + public void deleteUserBill(List ids) { + // 判断删除的是否是自己的账单 + List billList = list(Wrappers.lambdaQuery().in(Bill::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/CategoryServiceImpl.java b/service/src/main/java/cn/bunny/services/service/financial/impl/CategoryServiceImpl.java index 9755745..4138a17 100644 --- a/service/src/main/java/cn/bunny/services/service/financial/impl/CategoryServiceImpl.java +++ b/service/src/main/java/cn/bunny/services/service/financial/impl/CategoryServiceImpl.java @@ -6,7 +6,6 @@ import cn.bunny.dao.dto.financial.category.admin.CategoryAddDto; import cn.bunny.dao.dto.financial.category.admin.CategoryDto; import cn.bunny.dao.dto.financial.category.admin.CategoryUpdateDto; import cn.bunny.dao.dto.financial.category.user.CategoryUserAddDto; -import cn.bunny.dao.dto.financial.category.user.CategoryUserDto; import cn.bunny.dao.dto.financial.category.user.CategoryUserUpdateDto; import cn.bunny.dao.entity.financial.Category; import cn.bunny.dao.pojo.constant.UserConstant; @@ -16,6 +15,7 @@ import cn.bunny.dao.vo.financial.admin.CategoryVo; import cn.bunny.dao.vo.financial.user.CategoryUserVo; import cn.bunny.services.mapper.financial.CategoryMapper; import cn.bunny.services.service.financial.CategoryService; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -38,17 +38,17 @@ import java.util.List; public class CategoryServiceImpl extends ServiceImpl implements CategoryService { /** - * * 用户分类分页查询分类信息 服务实现类 + * 分类信息 服务实现类 * * @param pageParams 分类信息分页查询page对象 * @param dto 分类信息分页查询对象 * @return 查询分页分类信息返回对象 */ @Override - public PageResult getCategoryUserList(Page pageParams, CategoryUserDto dto) { - IPage page = baseMapper.selectUserListByPage(pageParams, dto, BaseContext.getUserId()); + public PageResult getCategoryList(Page pageParams, CategoryDto dto) { + IPage page = baseMapper.selectListByPage(pageParams, dto); - return PageResult.builder() + return PageResult.builder() .list(page.getRecords()) .pageNo(page.getCurrent()) .pageSize(page.getSize()) @@ -56,6 +56,69 @@ public class CategoryServiceImpl extends ServiceImpl i .build(); } + /** + * 用户分类分页查询分类信息 + * + * @param pageParams 分类信息分页查询page对象 + * @param dto 分类信息分页查询对象 + * @return 查询分页分类信息返回对象 + */ + @Override + public PageResult getCategoryUserList(Page pageParams, CategoryDto dto) { + // 为当前用户查询信息 + dto.setUserId(BaseContext.getUserId()); + + IPage page = baseMapper.selectListByPage(pageParams, dto); + + List categoryUserVoList = page.getRecords().stream().map(categoryVo -> { + CategoryUserVo categoryUserVo = new CategoryUserVo(); + BeanUtils.copyProperties(categoryVo, categoryUserVo); + return categoryUserVo; + }).toList(); + + return PageResult.builder() + .list(categoryUserVoList) + .pageNo(page.getCurrent()) + .pageSize(page.getSize()) + .total(page.getTotal()) + .build(); + } + + /** + * 查询当前用户下所有的分类 + * + * @return 当前用户分类返回列表 + */ + @Override + public List getCategoryUserAllList() { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(Category::getUserId, BaseContext.getUserId()) + .or() + .eq(Category::getIsBuiltin, true); + return list(wrapper) + .stream().map(category -> { + CategoryUserVo categoryUserVo = new CategoryUserVo(); + BeanUtils.copyProperties(category, categoryUserVo); + return categoryUserVo; + }).toList(); + } + + /** + * 添加分类信息 + * + * @param dto 分类信息添加 + */ + @Override + public void addCategory(@Valid CategoryAddDto dto) { + // 保存数据 + Category category = new Category(); + BeanUtils.copyProperties(dto, category); + + // 如果内置的id为空设置为当前用户的id + category.setUserId(category.getUserId() == null ? BaseContext.getUserId() : dto.getUserId()); + save(category); + } + /** * 用戶分类添加分类信息 * @@ -77,6 +140,19 @@ public class CategoryServiceImpl extends ServiceImpl i save(categoryUser); } + /** + * 更新分类信息 + * + * @param dto 分类信息更新 + */ + @Override + public void updateCategory(@Valid CategoryUpdateDto dto) { + // 更新内容 + Category category = new Category(); + BeanUtils.copyProperties(dto, category); + updateById(category); + } + /** * 用户分类更新分类信息 * @@ -85,14 +161,12 @@ public class CategoryServiceImpl extends ServiceImpl i @Override public void updateCategoryUser(@Valid CategoryUserUpdateDto dto) { Long userId = BaseContext.getUserId(); - String categoryName = dto.getCategoryName(); // 判断用户修改的当前内容是否和系统内置的信息一致 Category category = getOne(Wrappers.lambdaQuery().eq(Category::getId, dto.getId())); Long categoryUserId = category.getUserId(); - String categoryCategoryName = category.getCategoryName(); - if (!categoryUserId.equals(userId) || !categoryCategoryName.equals(categoryName)) { + if (!categoryUserId.equals(userId)) { throw new BunnyException(ResultCodeEnum.ILLEGAL_DATA_REQUEST); } @@ -112,69 +186,6 @@ public class CategoryServiceImpl extends ServiceImpl i baseMapper.deleteBatchIdsWithPhysics(ids); } - /** - * 查询当前用户下所有的分类 - * - * @return 当前用户分类返回列表 - */ - @Override - public List getCategoryUserAllList() { - return list(Wrappers.lambdaQuery().eq(Category::getUserId, BaseContext.getUserId())) - .stream().map(category -> { - CategoryUserVo categoryUserVo = new CategoryUserVo(); - BeanUtils.copyProperties(category, categoryUserVo); - return categoryUserVo; - }).toList(); - } - - /** - * * 分类信息 服务实现类 - * - * @param pageParams 分类信息分页查询page对象 - * @param dto 分类信息分页查询对象 - * @return 查询分页分类信息返回对象 - */ - @Override - public PageResult getCategoryList(Page pageParams, CategoryDto 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 addCategory(@Valid CategoryAddDto dto) { - // 保存数据 - Category category = new Category(); - BeanUtils.copyProperties(dto, category); - - // 如果内置的id为空设置为当前用户的id - category.setUserId(category.getUserId() == null ? BaseContext.getUserId() : dto.getUserId()); - save(category); - } - - /** - * 更新分类信息 - * - * @param dto 分类信息更新 - */ - @Override - public void updateCategory(@Valid CategoryUpdateDto dto) { - // 更新内容 - Category category = new Category(); - BeanUtils.copyProperties(dto, category); - updateById(category); - } - /** * 删除|批量删除分类信息 * diff --git a/service/src/main/resources/mapper/financial/BillMapper.xml b/service/src/main/resources/mapper/financial/BillMapper.xml index 717bb98..53ca0b5 100644 --- a/service/src/main/resources/mapper/financial/BillMapper.xml +++ b/service/src/main/resources/mapper/financial/BillMapper.xml @@ -22,32 +22,6 @@ id, create_time, update_time, create_user, update_user, is_deleted, type, amount, description, transaction_date, category_id - - - - select - base.*, - create_user.username as create_username, - update_user.username as update_username - from t_category 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 - - base.is_deleted = 0 and (base.user_id = #{userId} or base.is_builtin = 1) - - and base.category_name like CONCAT('%',#{dto.categoryName},'%') - - - and base.is_builtin = #{dto.isBuiltin} - - - order by base.is_builtin desc - - - - - delete - from t_category - where id in - - #{id} - - -