refactor: 财务管理删除不需要的代码
This commit is contained in:
parent
d835d962fc
commit
2d6bf3daab
|
@ -4,7 +4,7 @@ target/
|
||||||
!**/src/main/**/target/
|
!**/src/main/**/target/
|
||||||
!**/src/test/**/target/
|
!**/src/test/**/target/
|
||||||
logs/
|
logs/
|
||||||
!**/src/main/resources/application-prod.yml
|
application-prod.yml
|
||||||
|
|
||||||
### STS ###
|
### STS ###
|
||||||
.apt_generated
|
.apt_generated
|
||||||
|
|
|
@ -3,9 +3,9 @@ package cn.bunny.common.generator.generator;
|
||||||
import cn.bunny.common.generator.entity.BaseField;
|
import cn.bunny.common.generator.entity.BaseField;
|
||||||
import cn.bunny.common.generator.entity.BaseResultMap;
|
import cn.bunny.common.generator.entity.BaseResultMap;
|
||||||
import cn.bunny.common.generator.utils.GeneratorCodeUtils;
|
import cn.bunny.common.generator.utils.GeneratorCodeUtils;
|
||||||
import cn.bunny.dao.dto.financial.bill.admin.BillAddDto;
|
import cn.bunny.dao.dto.financial.bill.BillAddDto;
|
||||||
import cn.bunny.dao.dto.financial.bill.admin.BillDto;
|
import cn.bunny.dao.dto.financial.bill.BillDto;
|
||||||
import cn.bunny.dao.dto.financial.bill.admin.BillUpdateDto;
|
import cn.bunny.dao.dto.financial.bill.BillUpdateDto;
|
||||||
import cn.bunny.dao.entity.financial.Bill;
|
import cn.bunny.dao.entity.financial.Bill;
|
||||||
import cn.bunny.dao.vo.financial.admin.BillVo;
|
import cn.bunny.dao.vo.financial.admin.BillVo;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
|
|
@ -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 com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
|
@ -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 com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
|
@ -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 com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
|
@ -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;
|
|
||||||
|
|
||||||
}
|
|
|
@ -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;
|
|
||||||
|
|
||||||
}
|
|
|
@ -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;
|
|
||||||
|
|
||||||
}
|
|
|
@ -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;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
package cn.bunny.services.controller.financial;
|
package cn.bunny.services.controller.financial;
|
||||||
|
|
||||||
import cn.bunny.dao.dto.financial.bill.admin.BillAddDto;
|
import cn.bunny.common.service.context.BaseContext;
|
||||||
import cn.bunny.dao.dto.financial.bill.admin.BillDto;
|
import cn.bunny.dao.dto.financial.bill.BillAddDto;
|
||||||
import cn.bunny.dao.dto.financial.bill.admin.BillUpdateDto;
|
import cn.bunny.dao.dto.financial.bill.BillDto;
|
||||||
import cn.bunny.dao.dto.financial.bill.user.BillUserAddDto;
|
import cn.bunny.dao.dto.financial.bill.BillUpdateDto;
|
||||||
import cn.bunny.dao.dto.financial.bill.user.BillUserDto;
|
|
||||||
import cn.bunny.dao.dto.financial.bill.user.BillUserUpdateDto;
|
|
||||||
import cn.bunny.dao.entity.financial.Bill;
|
import cn.bunny.dao.entity.financial.Bill;
|
||||||
import cn.bunny.dao.pojo.result.PageResult;
|
import cn.bunny.dao.pojo.result.PageResult;
|
||||||
import cn.bunny.dao.pojo.result.Result;
|
import cn.bunny.dao.pojo.result.Result;
|
||||||
|
@ -40,40 +38,6 @@ public class BillController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private BillService billService;
|
private BillService billService;
|
||||||
|
|
||||||
@Operation(summary = "用户分页查询账单信息", description = "用户分页查询账单信息")
|
|
||||||
@GetMapping("noManage/getUserBillList/{page}/{limit}")
|
|
||||||
public Mono<Result<PageResult<BillUserVo>>> getUserBillList(
|
|
||||||
@Parameter(name = "page", description = "当前页", required = true)
|
|
||||||
@PathVariable("page") Integer page,
|
|
||||||
@Parameter(name = "limit", description = "每页记录数", required = true)
|
|
||||||
@PathVariable("limit") Integer limit,
|
|
||||||
BillUserDto dto) {
|
|
||||||
Page<Bill> pageParams = new Page<>(page, limit);
|
|
||||||
PageResult<BillUserVo> pageResult = billService.getUserBillList(pageParams, dto);
|
|
||||||
return Mono.just(Result.success(pageResult));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "用户添加账单信息", description = "用户添加账单信息")
|
|
||||||
@PostMapping("noManage/addUserBill")
|
|
||||||
public Mono<Result<String>> addUserBill(@Valid @RequestBody BillUserAddDto dto) {
|
|
||||||
billService.addUserBill(dto);
|
|
||||||
return Mono.just(Result.success(ResultCodeEnum.ADD_SUCCESS));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "用户更新账单信息", description = "用户更新账单信息")
|
|
||||||
@PutMapping("noManage/updateUserBill")
|
|
||||||
public Mono<Result<String>> updateUserBill(@Valid @RequestBody BillUserUpdateDto dto) {
|
|
||||||
billService.updateUserBill(dto);
|
|
||||||
return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "用户删除账单信息", description = "用户删除账单信息")
|
|
||||||
@DeleteMapping("noManage/deleteUserBill")
|
|
||||||
public Mono<Result<String>> deleteUserBill(@RequestBody List<Long> ids) {
|
|
||||||
billService.deleteUserBill(ids);
|
|
||||||
return Mono.just(Result.success(ResultCodeEnum.DELETE_SUCCESS));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "分页查询账单信息", description = "分页查询账单信息")
|
@Operation(summary = "分页查询账单信息", description = "分页查询账单信息")
|
||||||
@GetMapping("getBillList/{page}/{limit}")
|
@GetMapping("getBillList/{page}/{limit}")
|
||||||
public Mono<Result<PageResult<BillVo>>> getBillList(
|
public Mono<Result<PageResult<BillVo>>> getBillList(
|
||||||
|
@ -87,6 +51,19 @@ public class BillController {
|
||||||
return Mono.just(Result.success(pageResult));
|
return Mono.just(Result.success(pageResult));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "用户分页查询账单信息", description = "用户分页查询账单信息")
|
||||||
|
@GetMapping("noManage/getUserBillList/{page}/{limit}")
|
||||||
|
public Mono<Result<PageResult<BillUserVo>>> getUserBillList(
|
||||||
|
@Parameter(name = "page", description = "当前页", required = true)
|
||||||
|
@PathVariable("page") Integer page,
|
||||||
|
@Parameter(name = "limit", description = "每页记录数", required = true)
|
||||||
|
@PathVariable("limit") Integer limit,
|
||||||
|
BillDto dto) {
|
||||||
|
Page<Bill> pageParams = new Page<>(page, limit);
|
||||||
|
PageResult<BillUserVo> pageResult = billService.getUserBillList(pageParams, dto);
|
||||||
|
return Mono.just(Result.success(pageResult));
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "添加账单信息", description = "添加账单信息")
|
@Operation(summary = "添加账单信息", description = "添加账单信息")
|
||||||
@PostMapping("addBill")
|
@PostMapping("addBill")
|
||||||
public Mono<Result<String>> addBill(@Valid @RequestBody BillAddDto dto) {
|
public Mono<Result<String>> addBill(@Valid @RequestBody BillAddDto dto) {
|
||||||
|
@ -94,6 +71,14 @@ public class BillController {
|
||||||
return Mono.just(Result.success(ResultCodeEnum.ADD_SUCCESS));
|
return Mono.just(Result.success(ResultCodeEnum.ADD_SUCCESS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "用户添加账单信息", description = "用户添加账单信息")
|
||||||
|
@PostMapping("noManage/addUserBill")
|
||||||
|
public Mono<Result<String>> addUserBill(@Valid @RequestBody BillAddDto dto) {
|
||||||
|
dto.setUserId(BaseContext.getUserId());
|
||||||
|
billService.addBill(dto);
|
||||||
|
return Mono.just(Result.success(ResultCodeEnum.ADD_SUCCESS));
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "更新账单信息", description = "更新账单信息")
|
@Operation(summary = "更新账单信息", description = "更新账单信息")
|
||||||
@PutMapping("updateBill")
|
@PutMapping("updateBill")
|
||||||
public Mono<Result<String>> updateBill(@Valid @RequestBody BillUpdateDto dto) {
|
public Mono<Result<String>> updateBill(@Valid @RequestBody BillUpdateDto dto) {
|
||||||
|
@ -101,10 +86,25 @@ public class BillController {
|
||||||
return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS));
|
return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "用户更新账单信息", description = "用户更新账单信息")
|
||||||
|
@PutMapping("noManage/updateUserBill")
|
||||||
|
public Mono<Result<String>> updateUserBill(@Valid @RequestBody BillUpdateDto dto) {
|
||||||
|
dto.setUserId(BaseContext.getUserId());
|
||||||
|
billService.updateBill(dto);
|
||||||
|
return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS));
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "删除账单信息", description = "删除账单信息")
|
@Operation(summary = "删除账单信息", description = "删除账单信息")
|
||||||
@DeleteMapping("deleteBill")
|
@DeleteMapping("deleteBill")
|
||||||
public Mono<Result<String>> deleteBill(@RequestBody List<Long> ids) {
|
public Mono<Result<String>> deleteBill(@RequestBody List<Long> ids) {
|
||||||
billService.deleteBill(ids);
|
billService.deleteBill(ids);
|
||||||
return Mono.just(Result.success(ResultCodeEnum.DELETE_SUCCESS));
|
return Mono.just(Result.success(ResultCodeEnum.DELETE_SUCCESS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "用户删除账单信息", description = "用户删除账单信息")
|
||||||
|
@DeleteMapping("noManage/deleteUserBill")
|
||||||
|
public Mono<Result<String>> deleteUserBill(@RequestBody List<Long> ids) {
|
||||||
|
billService.deleteUserBill(ids);
|
||||||
|
return Mono.just(Result.success(ResultCodeEnum.DELETE_SUCCESS));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.CategoryDto;
|
||||||
import cn.bunny.dao.dto.financial.category.admin.CategoryUpdateDto;
|
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.CategoryUserAddDto;
|
||||||
import cn.bunny.dao.dto.financial.category.user.CategoryUserDto;
|
|
||||||
import cn.bunny.dao.dto.financial.category.user.CategoryUserUpdateDto;
|
import cn.bunny.dao.dto.financial.category.user.CategoryUserUpdateDto;
|
||||||
import cn.bunny.dao.entity.financial.Category;
|
import cn.bunny.dao.entity.financial.Category;
|
||||||
import cn.bunny.dao.pojo.result.PageResult;
|
import cn.bunny.dao.pojo.result.PageResult;
|
||||||
|
@ -40,6 +39,19 @@ public class CategoryController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private CategoryService categoryService;
|
private CategoryService categoryService;
|
||||||
|
|
||||||
|
@Operation(summary = "分页查询分类信息", description = "分页查询分类信息")
|
||||||
|
@GetMapping("getCategoryList/{page}/{limit}")
|
||||||
|
public Mono<Result<PageResult<CategoryVo>>> getCategoryList(
|
||||||
|
@Parameter(name = "page", description = "当前页", required = true)
|
||||||
|
@PathVariable("page") Integer page,
|
||||||
|
@Parameter(name = "limit", description = "每页记录数", required = true)
|
||||||
|
@PathVariable("limit") Integer limit,
|
||||||
|
CategoryDto dto) {
|
||||||
|
Page<Category> pageParams = new Page<>(page, limit);
|
||||||
|
PageResult<CategoryVo> pageResult = categoryService.getCategoryList(pageParams, dto);
|
||||||
|
return Mono.just(Result.success(pageResult));
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "用户分类分页查询分类信息", description = "用户分类分页查询分类信息")
|
@Operation(summary = "用户分类分页查询分类信息", description = "用户分类分页查询分类信息")
|
||||||
@GetMapping("noManage/getCategoryUserList/{page}/{limit}")
|
@GetMapping("noManage/getCategoryUserList/{page}/{limit}")
|
||||||
public Mono<Result<PageResult<CategoryUserVo>>> getCategoryUserList(
|
public Mono<Result<PageResult<CategoryUserVo>>> getCategoryUserList(
|
||||||
|
@ -47,7 +59,7 @@ public class CategoryController {
|
||||||
@PathVariable("page") Integer page,
|
@PathVariable("page") Integer page,
|
||||||
@Parameter(name = "limit", description = "每页记录数", required = true)
|
@Parameter(name = "limit", description = "每页记录数", required = true)
|
||||||
@PathVariable("limit") Integer limit,
|
@PathVariable("limit") Integer limit,
|
||||||
CategoryUserDto dto) {
|
CategoryDto dto) {
|
||||||
Page<Category> pageParams = new Page<>(page, limit);
|
Page<Category> pageParams = new Page<>(page, limit);
|
||||||
PageResult<CategoryUserVo> pageResult = categoryService.getCategoryUserList(pageParams, dto);
|
PageResult<CategoryUserVo> pageResult = categoryService.getCategoryUserList(pageParams, dto);
|
||||||
return Mono.just(Result.success(pageResult));
|
return Mono.just(Result.success(pageResult));
|
||||||
|
@ -60,6 +72,13 @@ public class CategoryController {
|
||||||
return Mono.just(Result.success(voList));
|
return Mono.just(Result.success(voList));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "添加分类信息", description = "添加分类信息")
|
||||||
|
@PostMapping("addCategory")
|
||||||
|
public Mono<Result<String>> addCategory(@Valid @RequestBody CategoryAddDto dto) {
|
||||||
|
categoryService.addCategory(dto);
|
||||||
|
return Mono.just(Result.success(ResultCodeEnum.ADD_SUCCESS));
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "用戶分类添加分类信息", description = "用戶分类添加分类信息")
|
@Operation(summary = "用戶分类添加分类信息", description = "用戶分类添加分类信息")
|
||||||
@PostMapping("noManage/addCategoryUser")
|
@PostMapping("noManage/addCategoryUser")
|
||||||
public Mono<Result<String>> addCategoryUser(@Valid @RequestBody CategoryUserAddDto dto) {
|
public Mono<Result<String>> addCategoryUser(@Valid @RequestBody CategoryUserAddDto dto) {
|
||||||
|
@ -67,6 +86,13 @@ public class CategoryController {
|
||||||
return Mono.just(Result.success(ResultCodeEnum.ADD_SUCCESS));
|
return Mono.just(Result.success(ResultCodeEnum.ADD_SUCCESS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "更新分类信息", description = "更新分类信息")
|
||||||
|
@PutMapping("updateCategory")
|
||||||
|
public Mono<Result<String>> updateCategory(@Valid @RequestBody CategoryUpdateDto dto) {
|
||||||
|
categoryService.updateCategory(dto);
|
||||||
|
return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS));
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "用户分类更新分类信息", description = "用户分类更新分类信息")
|
@Operation(summary = "用户分类更新分类信息", description = "用户分类更新分类信息")
|
||||||
@PutMapping("noManage/updateCategoryUser")
|
@PutMapping("noManage/updateCategoryUser")
|
||||||
public Mono<Result<String>> updateCategoryUser(@Valid @RequestBody CategoryUserUpdateDto dto) {
|
public Mono<Result<String>> updateCategoryUser(@Valid @RequestBody CategoryUserUpdateDto dto) {
|
||||||
|
@ -81,33 +107,6 @@ public class CategoryController {
|
||||||
return Mono.just(Result.success(ResultCodeEnum.DELETE_SUCCESS));
|
return Mono.just(Result.success(ResultCodeEnum.DELETE_SUCCESS));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "分页查询分类信息", description = "分页查询分类信息")
|
|
||||||
@GetMapping("getCategoryList/{page}/{limit}")
|
|
||||||
public Mono<Result<PageResult<CategoryVo>>> getCategoryList(
|
|
||||||
@Parameter(name = "page", description = "当前页", required = true)
|
|
||||||
@PathVariable("page") Integer page,
|
|
||||||
@Parameter(name = "limit", description = "每页记录数", required = true)
|
|
||||||
@PathVariable("limit") Integer limit,
|
|
||||||
CategoryDto dto) {
|
|
||||||
Page<Category> pageParams = new Page<>(page, limit);
|
|
||||||
PageResult<CategoryVo> pageResult = categoryService.getCategoryList(pageParams, dto);
|
|
||||||
return Mono.just(Result.success(pageResult));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "添加分类信息", description = "添加分类信息")
|
|
||||||
@PostMapping("addCategory")
|
|
||||||
public Mono<Result<String>> addCategory(@Valid @RequestBody CategoryAddDto dto) {
|
|
||||||
categoryService.addCategory(dto);
|
|
||||||
return Mono.just(Result.success(ResultCodeEnum.ADD_SUCCESS));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "更新分类信息", description = "更新分类信息")
|
|
||||||
@PutMapping("updateCategory")
|
|
||||||
public Mono<Result<String>> updateCategory(@Valid @RequestBody CategoryUpdateDto dto) {
|
|
||||||
categoryService.updateCategory(dto);
|
|
||||||
return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "删除分类信息", description = "删除分类信息")
|
@Operation(summary = "删除分类信息", description = "删除分类信息")
|
||||||
@DeleteMapping("deleteCategory")
|
@DeleteMapping("deleteCategory")
|
||||||
public Mono<Result<String>> deleteCategory(@RequestBody List<Long> ids) {
|
public Mono<Result<String>> deleteCategory(@RequestBody List<Long> ids) {
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
package cn.bunny.services.mapper.financial;
|
package cn.bunny.services.mapper.financial;
|
||||||
|
|
||||||
import cn.bunny.dao.dto.financial.bill.admin.BillDto;
|
import cn.bunny.dao.dto.financial.bill.BillDto;
|
||||||
import cn.bunny.dao.dto.financial.bill.user.BillUserDto;
|
|
||||||
import cn.bunny.dao.entity.financial.Bill;
|
import cn.bunny.dao.entity.financial.Bill;
|
||||||
import cn.bunny.dao.vo.financial.admin.BillVo;
|
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.mapper.BaseMapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
@ -24,15 +22,6 @@ import java.util.List;
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface BillMapper extends BaseMapper<Bill> {
|
public interface BillMapper extends BaseMapper<Bill> {
|
||||||
|
|
||||||
/**
|
|
||||||
* * 分页查询用户账单信息内容
|
|
||||||
*
|
|
||||||
* @param pageParams 账单信息分页参数
|
|
||||||
* @param dto 账单信息查询表单
|
|
||||||
* @return 账单信息分页结果
|
|
||||||
*/
|
|
||||||
IPage<BillUserVo> selectUserListByPage(@Param("page") Page<Bill> pageParams, @Param("dto") BillUserDto dto, @Param("userId") Long userId);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 物理删除账单信息
|
* 物理删除账单信息
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
package cn.bunny.services.mapper.financial;
|
package cn.bunny.services.mapper.financial;
|
||||||
|
|
||||||
import cn.bunny.dao.dto.financial.category.admin.CategoryDto;
|
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.entity.financial.Category;
|
||||||
import cn.bunny.dao.vo.financial.admin.CategoryVo;
|
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.mapper.BaseMapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
@ -23,21 +21,6 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface CategoryMapper extends BaseMapper<Category> {
|
public interface CategoryMapper extends BaseMapper<Category> {
|
||||||
/**
|
|
||||||
* * 分页查询分类信息内容
|
|
||||||
*
|
|
||||||
* @param pageParams 分类信息分页参数
|
|
||||||
* @param dto 分类信息查询表单
|
|
||||||
* @return 分类信息分页结果
|
|
||||||
*/
|
|
||||||
IPage<CategoryUserVo> selectUserListByPage(@Param("page") Page<Category> pageParams, @Param("dto") CategoryUserDto dto, @Param("userId") Long userId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 物理删除分类信息
|
|
||||||
*
|
|
||||||
* @param ids 删除 id 列表
|
|
||||||
*/
|
|
||||||
void deleteBatchIdsWithUserPhysics(List<Long> ids);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * 分页查询分类信息内容
|
* * 分页查询分类信息内容
|
||||||
|
|
|
@ -1,18 +1,14 @@
|
||||||
package cn.bunny.services.service.financial;
|
package cn.bunny.services.service.financial;
|
||||||
|
|
||||||
import cn.bunny.dao.dto.financial.bill.admin.BillAddDto;
|
import cn.bunny.dao.dto.financial.bill.BillAddDto;
|
||||||
import cn.bunny.dao.dto.financial.bill.admin.BillDto;
|
import cn.bunny.dao.dto.financial.bill.BillDto;
|
||||||
import cn.bunny.dao.dto.financial.bill.admin.BillUpdateDto;
|
import cn.bunny.dao.dto.financial.bill.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.entity.financial.Bill;
|
import cn.bunny.dao.entity.financial.Bill;
|
||||||
import cn.bunny.dao.pojo.result.PageResult;
|
import cn.bunny.dao.pojo.result.PageResult;
|
||||||
import cn.bunny.dao.vo.financial.admin.BillVo;
|
import cn.bunny.dao.vo.financial.admin.BillVo;
|
||||||
import cn.bunny.dao.vo.financial.user.BillUserVo;
|
import cn.bunny.dao.vo.financial.user.BillUserVo;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import jakarta.validation.Valid;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -31,21 +27,7 @@ public interface BillService extends IService<Bill> {
|
||||||
*
|
*
|
||||||
* @return 账单信息返回列表
|
* @return 账单信息返回列表
|
||||||
*/
|
*/
|
||||||
PageResult<BillUserVo> getUserBillList(Page<Bill> pageParams, BillUserDto dto);
|
PageResult<BillUserVo> getUserBillList(Page<Bill> pageParams, BillDto dto);
|
||||||
|
|
||||||
/**
|
|
||||||
* * 添加账单信息
|
|
||||||
*
|
|
||||||
* @param dto 添加表单
|
|
||||||
*/
|
|
||||||
void addUserBill(@Valid BillUserAddDto dto);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* * 更新账单信息
|
|
||||||
*
|
|
||||||
* @param dto 更新表单
|
|
||||||
*/
|
|
||||||
void updateUserBill(@Valid BillUserUpdateDto dto);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * 删除|批量删除账单信息类型
|
* * 删除|批量删除账单信息类型
|
||||||
|
|
|
@ -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.CategoryDto;
|
||||||
import cn.bunny.dao.dto.financial.category.admin.CategoryUpdateDto;
|
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.CategoryUserAddDto;
|
||||||
import cn.bunny.dao.dto.financial.category.user.CategoryUserDto;
|
|
||||||
import cn.bunny.dao.dto.financial.category.user.CategoryUserUpdateDto;
|
import cn.bunny.dao.dto.financial.category.user.CategoryUserUpdateDto;
|
||||||
import cn.bunny.dao.entity.financial.Category;
|
import cn.bunny.dao.entity.financial.Category;
|
||||||
import cn.bunny.dao.pojo.result.PageResult;
|
import cn.bunny.dao.pojo.result.PageResult;
|
||||||
|
@ -26,12 +25,33 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public interface CategoryService extends IService<Category> {
|
public interface CategoryService extends IService<Category> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 获取分类信息列表
|
||||||
|
*
|
||||||
|
* @return 分类信息返回列表
|
||||||
|
*/
|
||||||
|
PageResult<CategoryVo> getCategoryList(Page<Category> pageParams, CategoryDto dto);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * 用户分类分页查询分类信息
|
* * 用户分类分页查询分类信息
|
||||||
*
|
*
|
||||||
* @return 分类信息返回列表
|
* @return 分类信息返回列表
|
||||||
*/
|
*/
|
||||||
PageResult<CategoryUserVo> getCategoryUserList(Page<Category> pageParams, CategoryUserDto dto);
|
PageResult<CategoryUserVo> getCategoryUserList(Page<Category> pageParams, CategoryDto dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询当前用户下所有的分类
|
||||||
|
*
|
||||||
|
* @return 当前用户分类返回列表
|
||||||
|
*/
|
||||||
|
List<CategoryUserVo> getCategoryUserAllList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 添加分类信息
|
||||||
|
*
|
||||||
|
* @param dto 添加表单
|
||||||
|
*/
|
||||||
|
void addCategory(@Valid CategoryAddDto dto);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * 用戶分类添加分类信息
|
* * 用戶分类添加分类信息
|
||||||
|
@ -40,6 +60,13 @@ public interface CategoryService extends IService<Category> {
|
||||||
*/
|
*/
|
||||||
void addCategoryUser(@Valid CategoryUserAddDto dto);
|
void addCategoryUser(@Valid CategoryUserAddDto dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 更新分类信息
|
||||||
|
*
|
||||||
|
* @param dto 更新表单
|
||||||
|
*/
|
||||||
|
void updateCategory(@Valid CategoryUpdateDto dto);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * 用户分类更新分类信息
|
* * 用户分类更新分类信息
|
||||||
*
|
*
|
||||||
|
@ -54,34 +81,6 @@ public interface CategoryService extends IService<Category> {
|
||||||
*/
|
*/
|
||||||
void deleteCategoryUser(List<Long> ids);
|
void deleteCategoryUser(List<Long> ids);
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询当前用户下所有的分类
|
|
||||||
*
|
|
||||||
* @return 当前用户分类返回列表
|
|
||||||
*/
|
|
||||||
List<CategoryUserVo> getCategoryUserAllList();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* * 获取分类信息列表
|
|
||||||
*
|
|
||||||
* @return 分类信息返回列表
|
|
||||||
*/
|
|
||||||
PageResult<CategoryVo> getCategoryList(Page<Category> pageParams, CategoryDto dto);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* * 添加分类信息
|
|
||||||
*
|
|
||||||
* @param dto 添加表单
|
|
||||||
*/
|
|
||||||
void addCategory(@Valid CategoryAddDto dto);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* * 更新分类信息
|
|
||||||
*
|
|
||||||
* @param dto 更新表单
|
|
||||||
*/
|
|
||||||
void updateCategory(@Valid CategoryUpdateDto dto);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * 删除|批量删除分类信息类型
|
* * 删除|批量删除分类信息类型
|
||||||
*
|
*
|
||||||
|
|
|
@ -2,12 +2,9 @@ package cn.bunny.services.service.financial.impl;
|
||||||
|
|
||||||
import cn.bunny.common.service.context.BaseContext;
|
import cn.bunny.common.service.context.BaseContext;
|
||||||
import cn.bunny.common.service.exception.BunnyException;
|
import cn.bunny.common.service.exception.BunnyException;
|
||||||
import cn.bunny.dao.dto.financial.bill.admin.BillAddDto;
|
import cn.bunny.dao.dto.financial.bill.BillAddDto;
|
||||||
import cn.bunny.dao.dto.financial.bill.admin.BillDto;
|
import cn.bunny.dao.dto.financial.bill.BillDto;
|
||||||
import cn.bunny.dao.dto.financial.bill.admin.BillUpdateDto;
|
import cn.bunny.dao.dto.financial.bill.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.entity.financial.Bill;
|
import cn.bunny.dao.entity.financial.Bill;
|
||||||
import cn.bunny.dao.pojo.result.PageResult;
|
import cn.bunny.dao.pojo.result.PageResult;
|
||||||
import cn.bunny.dao.pojo.result.ResultCodeEnum;
|
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.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import jakarta.validation.Valid;
|
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@ -44,72 +40,27 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements Bi
|
||||||
* @return 查询分页账单信息返回对象
|
* @return 查询分页账单信息返回对象
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PageResult<BillUserVo> getUserBillList(Page<Bill> pageParams, BillUserDto dto) {
|
public PageResult<BillUserVo> getUserBillList(Page<Bill> pageParams, BillDto dto) {
|
||||||
// 需要根据当前用户去查询
|
// 需要根据当前用户去查询
|
||||||
Long userId = BaseContext.getUserId();
|
Long userId = BaseContext.getUserId();
|
||||||
|
dto.setUserId(userId);
|
||||||
|
|
||||||
// 判断创建用户的Id是否和当前请求的用户id是否相同
|
// 判断创建用户的Id是否和当前请求的用户id是否相同
|
||||||
IPage<BillUserVo> page = baseMapper.selectUserListByPage(pageParams, dto, userId);
|
IPage<BillVo> page = baseMapper.selectListByPage(pageParams, dto);
|
||||||
|
List<BillUserVo> userVoList = page.getRecords().stream().map(billVo -> {
|
||||||
|
BillUserVo billUserVo = new BillUserVo();
|
||||||
|
BeanUtils.copyProperties(billVo, billUserVo);
|
||||||
|
return billUserVo;
|
||||||
|
}).toList();
|
||||||
|
|
||||||
return PageResult.<BillUserVo>builder()
|
return PageResult.<BillUserVo>builder()
|
||||||
.list(page.getRecords())
|
.list(userVoList)
|
||||||
.pageNo(page.getCurrent())
|
.pageNo(page.getCurrent())
|
||||||
.pageSize(page.getSize())
|
.pageSize(page.getSize())
|
||||||
.total(page.getTotal())
|
.total(page.getTotal())
|
||||||
.build();
|
.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.<Bill>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<Long> ids) {
|
|
||||||
// 判断删除的是否是自己的账单
|
|
||||||
List<Bill> billList = list(Wrappers.<Bill>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<BillMapper, Bill> implements Bi
|
||||||
public void deleteBill(List<Long> ids) {
|
public void deleteBill(List<Long> ids) {
|
||||||
baseMapper.deleteBatchIdsWithPhysics(ids);
|
baseMapper.deleteBatchIdsWithPhysics(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除|批量删除账单信息
|
||||||
|
*
|
||||||
|
* @param ids 删除id列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void deleteUserBill(List<Long> ids) {
|
||||||
|
// 判断删除的是否是自己的账单
|
||||||
|
List<Bill> billList = list(Wrappers.<Bill>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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.CategoryDto;
|
||||||
import cn.bunny.dao.dto.financial.category.admin.CategoryUpdateDto;
|
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.CategoryUserAddDto;
|
||||||
import cn.bunny.dao.dto.financial.category.user.CategoryUserDto;
|
|
||||||
import cn.bunny.dao.dto.financial.category.user.CategoryUserUpdateDto;
|
import cn.bunny.dao.dto.financial.category.user.CategoryUserUpdateDto;
|
||||||
import cn.bunny.dao.entity.financial.Category;
|
import cn.bunny.dao.entity.financial.Category;
|
||||||
import cn.bunny.dao.pojo.constant.UserConstant;
|
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.dao.vo.financial.user.CategoryUserVo;
|
||||||
import cn.bunny.services.mapper.financial.CategoryMapper;
|
import cn.bunny.services.mapper.financial.CategoryMapper;
|
||||||
import cn.bunny.services.service.financial.CategoryService;
|
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.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
@ -38,17 +38,17 @@ import java.util.List;
|
||||||
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> implements CategoryService {
|
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> implements CategoryService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * 用户分类分页查询分类信息 服务实现类
|
* 分类信息 服务实现类
|
||||||
*
|
*
|
||||||
* @param pageParams 分类信息分页查询page对象
|
* @param pageParams 分类信息分页查询page对象
|
||||||
* @param dto 分类信息分页查询对象
|
* @param dto 分类信息分页查询对象
|
||||||
* @return 查询分页分类信息返回对象
|
* @return 查询分页分类信息返回对象
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PageResult<CategoryUserVo> getCategoryUserList(Page<Category> pageParams, CategoryUserDto dto) {
|
public PageResult<CategoryVo> getCategoryList(Page<Category> pageParams, CategoryDto dto) {
|
||||||
IPage<CategoryUserVo> page = baseMapper.selectUserListByPage(pageParams, dto, BaseContext.getUserId());
|
IPage<CategoryVo> page = baseMapper.selectListByPage(pageParams, dto);
|
||||||
|
|
||||||
return PageResult.<CategoryUserVo>builder()
|
return PageResult.<CategoryVo>builder()
|
||||||
.list(page.getRecords())
|
.list(page.getRecords())
|
||||||
.pageNo(page.getCurrent())
|
.pageNo(page.getCurrent())
|
||||||
.pageSize(page.getSize())
|
.pageSize(page.getSize())
|
||||||
|
@ -56,6 +56,69 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> i
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户分类分页查询分类信息
|
||||||
|
*
|
||||||
|
* @param pageParams 分类信息分页查询page对象
|
||||||
|
* @param dto 分类信息分页查询对象
|
||||||
|
* @return 查询分页分类信息返回对象
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public PageResult<CategoryUserVo> getCategoryUserList(Page<Category> pageParams, CategoryDto dto) {
|
||||||
|
// 为当前用户查询信息
|
||||||
|
dto.setUserId(BaseContext.getUserId());
|
||||||
|
|
||||||
|
IPage<CategoryVo> page = baseMapper.selectListByPage(pageParams, dto);
|
||||||
|
|
||||||
|
List<CategoryUserVo> categoryUserVoList = page.getRecords().stream().map(categoryVo -> {
|
||||||
|
CategoryUserVo categoryUserVo = new CategoryUserVo();
|
||||||
|
BeanUtils.copyProperties(categoryVo, categoryUserVo);
|
||||||
|
return categoryUserVo;
|
||||||
|
}).toList();
|
||||||
|
|
||||||
|
return PageResult.<CategoryUserVo>builder()
|
||||||
|
.list(categoryUserVoList)
|
||||||
|
.pageNo(page.getCurrent())
|
||||||
|
.pageSize(page.getSize())
|
||||||
|
.total(page.getTotal())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询当前用户下所有的分类
|
||||||
|
*
|
||||||
|
* @return 当前用户分类返回列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<CategoryUserVo> getCategoryUserAllList() {
|
||||||
|
LambdaQueryWrapper<Category> 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<CategoryMapper, Category> i
|
||||||
save(categoryUser);
|
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<CategoryMapper, Category> i
|
||||||
@Override
|
@Override
|
||||||
public void updateCategoryUser(@Valid CategoryUserUpdateDto dto) {
|
public void updateCategoryUser(@Valid CategoryUserUpdateDto dto) {
|
||||||
Long userId = BaseContext.getUserId();
|
Long userId = BaseContext.getUserId();
|
||||||
String categoryName = dto.getCategoryName();
|
|
||||||
|
|
||||||
// 判断用户修改的当前内容是否和系统内置的信息一致
|
// 判断用户修改的当前内容是否和系统内置的信息一致
|
||||||
Category category = getOne(Wrappers.<Category>lambdaQuery().eq(Category::getId, dto.getId()));
|
Category category = getOne(Wrappers.<Category>lambdaQuery().eq(Category::getId, dto.getId()));
|
||||||
Long categoryUserId = category.getUserId();
|
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);
|
throw new BunnyException(ResultCodeEnum.ILLEGAL_DATA_REQUEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,69 +186,6 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> i
|
||||||
baseMapper.deleteBatchIdsWithPhysics(ids);
|
baseMapper.deleteBatchIdsWithPhysics(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询当前用户下所有的分类
|
|
||||||
*
|
|
||||||
* @return 当前用户分类返回列表
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<CategoryUserVo> getCategoryUserAllList() {
|
|
||||||
return list(Wrappers.<Category>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<CategoryVo> getCategoryList(Page<Category> pageParams, CategoryDto dto) {
|
|
||||||
IPage<CategoryVo> page = baseMapper.selectListByPage(pageParams, dto);
|
|
||||||
|
|
||||||
return PageResult.<CategoryVo>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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除|批量删除分类信息
|
* 删除|批量删除分类信息
|
||||||
*
|
*
|
||||||
|
|
|
@ -22,32 +22,6 @@
|
||||||
id, create_time, update_time, create_user, update_user, is_deleted, type, amount, description, transaction_date, category_id
|
id, create_time, update_time, create_user, update_user, is_deleted, type, amount, description, transaction_date, category_id
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<!-- 分页查询用户账单信息内容 -->
|
|
||||||
<select id="selectUserListByPage" resultType="cn.bunny.dao.vo.financial.user.BillUserVo">
|
|
||||||
select
|
|
||||||
base.*,
|
|
||||||
category.category_name,
|
|
||||||
category.id as category_id,
|
|
||||||
create_user.username as create_username,
|
|
||||||
update_user.username as update_username
|
|
||||||
from t_bill base
|
|
||||||
left join t_category category on category.id = base.category_id
|
|
||||||
left join sys_user create_user on create_user.id = base.create_user
|
|
||||||
left join sys_user update_user on update_user.id = base.update_user
|
|
||||||
<where>
|
|
||||||
base.is_deleted = 0 and base.user_id = #{userId}
|
|
||||||
<if test="dto.type != null and dto.type != ''">
|
|
||||||
and base.type = #{dto.type}
|
|
||||||
</if>
|
|
||||||
<if test="dto.description != null and dto.description != ''">
|
|
||||||
and base.description like CONCAT('%',#{dto.description},'%')
|
|
||||||
</if>
|
|
||||||
<if test="dto.startDate != null and dto.endDate != null">
|
|
||||||
and base.transaction_date between #{dto.startDate} and #{dto.endDate}
|
|
||||||
</if>
|
|
||||||
</where>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<!-- 分页查询账单信息内容 -->
|
<!-- 分页查询账单信息内容 -->
|
||||||
<select id="selectListByPage" resultType="cn.bunny.dao.vo.financial.admin.BillVo">
|
<select id="selectListByPage" resultType="cn.bunny.dao.vo.financial.admin.BillVo">
|
||||||
select
|
select
|
||||||
|
|
|
@ -20,37 +20,6 @@
|
||||||
id, create_time, update_time, create_user, update_user, is_deleted, user_id, category_name, is_builtin
|
id, create_time, update_time, create_user, update_user, is_deleted, user_id, category_name, is_builtin
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<!-- 分页查询分类信息内容 -->
|
|
||||||
<select id="selectUserListByPage" resultType="cn.bunny.dao.vo.financial.user.CategoryUserVo">
|
|
||||||
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
|
|
||||||
<where>
|
|
||||||
base.is_deleted = 0 and (base.user_id = #{userId} or base.is_builtin = 1)
|
|
||||||
<if test="dto.categoryName != null and dto.categoryName != ''">
|
|
||||||
and base.category_name like CONCAT('%',#{dto.categoryName},'%')
|
|
||||||
</if>
|
|
||||||
<if test="dto.isBuiltin != null and dto.isBuiltin != ''">
|
|
||||||
and base.is_builtin = #{dto.isBuiltin}
|
|
||||||
</if>
|
|
||||||
</where>
|
|
||||||
order by base.is_builtin desc
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<!-- 物理删除分类信息 -->
|
|
||||||
<delete id="deleteBatchIdsWithUserPhysics">
|
|
||||||
delete
|
|
||||||
from t_category
|
|
||||||
where id in
|
|
||||||
<foreach collection="ids" item="id" open="(" close=")" separator=",">
|
|
||||||
#{id}
|
|
||||||
</foreach>
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
<!-- 分页查询分类信息内容 -->
|
<!-- 分页查询分类信息内容 -->
|
||||||
<select id="selectListByPage" resultType="cn.bunny.dao.vo.financial.admin.CategoryVo">
|
<select id="selectListByPage" resultType="cn.bunny.dao.vo.financial.admin.CategoryVo">
|
||||||
select
|
select
|
||||||
|
@ -65,7 +34,7 @@
|
||||||
<where>
|
<where>
|
||||||
base.is_deleted = 0
|
base.is_deleted = 0
|
||||||
<if test="dto.userId != null and dto.userId != ''">
|
<if test="dto.userId != null and dto.userId != ''">
|
||||||
and base.user_id = #{dto.userId}
|
and (base.user_id = #{dto.userId} or base.is_builtin = 1)
|
||||||
</if>
|
</if>
|
||||||
<if test="dto.categoryName != null and dto.categoryName != ''">
|
<if test="dto.categoryName != null and dto.categoryName != ''">
|
||||||
and base.category_name like CONCAT('%',#{dto.categoryName},'%')
|
and base.category_name like CONCAT('%',#{dto.categoryName},'%')
|
||||||
|
|
Loading…
Reference in New Issue