diff --git a/yudao-module-bs/yudao-module-bs-api/src/main/java/cn/iocoder/yudao/module/bs/enums/ErrorCodeConstants.java b/yudao-module-bs/yudao-module-bs-api/src/main/java/cn/iocoder/yudao/module/bs/enums/ErrorCodeConstants.java index 69657919..1fb76588 100644 --- a/yudao-module-bs/yudao-module-bs-api/src/main/java/cn/iocoder/yudao/module/bs/enums/ErrorCodeConstants.java +++ b/yudao-module-bs/yudao-module-bs-api/src/main/java/cn/iocoder/yudao/module/bs/enums/ErrorCodeConstants.java @@ -11,4 +11,6 @@ public interface ErrorCodeConstants { ErrorCode INVOICE_NOT_EXISTS = new ErrorCode(200100, "我的发票不存在"); ErrorCode EXPENSE_APPLY_NOT_EXISTS = new ErrorCode(200200, "申请单不存在"); + ErrorCode BUDGET_NOT_EXISTS = new ErrorCode(200400, "预算管理不存在"); + ErrorCode FEE_MANAGE_NOT_EXISTS = new ErrorCode(200500, "费用控制不存在"); } diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/budget/BudgetController.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/budget/BudgetController.java new file mode 100644 index 00000000..049657e8 --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/budget/BudgetController.java @@ -0,0 +1,99 @@ +package cn.iocoder.yudao.module.bs.controller.admin.budget; + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; +import cn.iocoder.yudao.module.bs.controller.admin.budget.vo.*; +import cn.iocoder.yudao.module.bs.convert.budget.BudgetConvert; +import cn.iocoder.yudao.module.bs.dal.dataobject.budget.BudgetDO; +import cn.iocoder.yudao.module.bs.service.budget.BudgetService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; +import java.io.IOException; +import java.util.Collection; +import java.util.List; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; + +@Tag(name = "管理后台 - 预算管理") +@RestController +@RequestMapping("/bs/budget") +@Validated +public class BudgetController { + + @Resource + private BudgetService budgetService; + + @PostMapping("/create") + @Operation(summary = "创建预算管理") + @PreAuthorize("@ss.hasPermission('bs:budget:create')") + public CommonResult createBudget(@Valid @RequestBody BudgetCreateReqVO createReqVO) { + return success(budgetService.createBudget(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新预算管理") + @PreAuthorize("@ss.hasPermission('bs:budget:update')") + public CommonResult updateBudget(@Valid @RequestBody BudgetUpdateReqVO updateReqVO) { + budgetService.updateBudget(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除预算管理") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('bs:budget:delete')") + public CommonResult deleteBudget(@RequestParam("id") Long id) { + budgetService.deleteBudget(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得预算管理") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('bs:budget:query')") + public CommonResult getBudget(@RequestParam("id") Long id) { + BudgetDO budget = budgetService.getBudget(id); + return success(budget); + } + + @GetMapping("/list") + @Operation(summary = "获得预算管理列表") + @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") + @PreAuthorize("@ss.hasPermission('bs:budget:query')") + public CommonResult> getBudgetList(@RequestParam("ids") Collection ids) { + List list = budgetService.getBudgetList(ids); + return success(BudgetConvert.INSTANCE.convertList(list)); + } + + @GetMapping("/page") + @Operation(summary = "获得预算管理分页") + @PreAuthorize("@ss.hasPermission('bs:budget:query')") + public CommonResult> getBudgetPage(@Valid BudgetPageReqVO pageVO) { + PageResult pageResult = budgetService.getBudgetPage(pageVO); + return success(pageResult); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出预算管理 Excel") + @PreAuthorize("@ss.hasPermission('bs:budget:export')") + @OperateLog(type = EXPORT) + public void exportBudgetExcel(@Valid BudgetExportReqVO exportReqVO, + HttpServletResponse response) throws IOException { + List list = budgetService.getBudgetList(exportReqVO); + // 导出 Excel + List datas = BudgetConvert.INSTANCE.convertList02(list); + ExcelUtils.write(response, "预算管理.xls", "数据", BudgetExcelVO.class, datas); + } + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/budget/vo/BudgetBaseVO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/budget/vo/BudgetBaseVO.java new file mode 100644 index 00000000..70bb1553 --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/budget/vo/BudgetBaseVO.java @@ -0,0 +1,42 @@ +package cn.iocoder.yudao.module.bs.controller.admin.budget.vo; + +import cn.iocoder.yudao.framework.common.pojo.ImageVo; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import javax.validation.constraints.NotNull; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.List; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +/** + * 预算管理 Base VO,提供给添加、修改、详细的子 VO 使用 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 + */ +@Data +public class BudgetBaseVO { + + @Schema(description = "预算年度", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "预算年度不能为空") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime budgetYear; + + @Schema(description = "预算金额", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "预算金额不能为空") + private BigDecimal amount; + + + @Schema(description = "部门ID", example = "30450") + @NotNull(message = "部门ID不能为空") + private Long deptId; + + @Schema(description = "备注", example = "你说的对") + private String remark; + + @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED) + private List files; + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/budget/vo/BudgetCreateReqVO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/budget/vo/BudgetCreateReqVO.java new file mode 100644 index 00000000..0595de6c --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/budget/vo/BudgetCreateReqVO.java @@ -0,0 +1,14 @@ +package cn.iocoder.yudao.module.bs.controller.admin.budget.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@Schema(description = "管理后台 - 预算管理创建 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class BudgetCreateReqVO extends BudgetBaseVO { + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/budget/vo/BudgetExcelVO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/budget/vo/BudgetExcelVO.java new file mode 100644 index 00000000..9ded1543 --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/budget/vo/BudgetExcelVO.java @@ -0,0 +1,45 @@ +package cn.iocoder.yudao.module.bs.controller.admin.budget.vo; + +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Data; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +/** + * 预算管理 Excel VO + * + * @author chenqp + */ +@Data +public class BudgetExcelVO { + + @ExcelProperty("id") + private Long id; + + @ExcelProperty("预算年度") + private LocalDateTime budgetYear; + + @ExcelProperty("预算金额") + private BigDecimal amount; + + @ExcelProperty("已使用金额") + private BigDecimal usedAmount; + + @ExcelProperty("占用金额") + private BigDecimal occupyAmount; + + @ExcelProperty("剩余金额") + private BigDecimal remainAmount; + + @ExcelProperty("部门ID") + private Long deptId; + + @ExcelProperty("备注") + private String remark; + + + @ExcelProperty("创建时间") + private LocalDateTime createTime; + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/budget/vo/BudgetExportReqVO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/budget/vo/BudgetExportReqVO.java new file mode 100644 index 00000000..d7ddfe9d --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/budget/vo/BudgetExportReqVO.java @@ -0,0 +1,41 @@ +package cn.iocoder.yudao.module.bs.controller.admin.budget.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 预算管理 Excel 导出 Request VO,参数和 BudgetPageReqVO 是一致的") +@Data +public class BudgetExportReqVO { + + @Schema(description = "预算年度") + private LocalDateTime budgetYear; + + @Schema(description = "预算金额") + private BigDecimal amount; + + @Schema(description = "已使用金额") + private BigDecimal usedAmount; + + @Schema(description = "占用金额") + private BigDecimal occupyAmount; + + @Schema(description = "剩余金额") + private BigDecimal remainAmount; + + @Schema(description = "部门ID", example = "30450") + private Long deptId; + + @Schema(description = "备注", example = "你说的对") + private String remark; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/budget/vo/BudgetPageReqVO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/budget/vo/BudgetPageReqVO.java new file mode 100644 index 00000000..ddad720a --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/budget/vo/BudgetPageReqVO.java @@ -0,0 +1,46 @@ +package cn.iocoder.yudao.module.bs.controller.admin.budget.vo; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; +import org.springframework.format.annotation.DateTimeFormat; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 预算管理分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class BudgetPageReqVO extends PageParam { + + @Schema(description = "预算年度") + private LocalDateTime budgetYear; + + @Schema(description = "预算金额") + private BigDecimal amount; + + @Schema(description = "已使用金额") + private BigDecimal usedAmount; + + @Schema(description = "占用金额") + private BigDecimal occupyAmount; + + @Schema(description = "剩余金额") + private BigDecimal remainAmount; + + @Schema(description = "部门ID", example = "30450") + private Long deptId; + + @Schema(description = "备注", example = "你说的对") + private String remark; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/budget/vo/BudgetRespVO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/budget/vo/BudgetRespVO.java new file mode 100644 index 00000000..8dfee3bd --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/budget/vo/BudgetRespVO.java @@ -0,0 +1,22 @@ +package cn.iocoder.yudao.module.bs.controller.admin.budget.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - 预算管理 Response VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class BudgetRespVO extends BudgetBaseVO { + + @Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "29841") + private Long id; + + @Schema(description = "创建时间") + private LocalDateTime createTime; + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/budget/vo/BudgetUpdateReqVO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/budget/vo/BudgetUpdateReqVO.java new file mode 100644 index 00000000..ee32ea80 --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/budget/vo/BudgetUpdateReqVO.java @@ -0,0 +1,20 @@ +package cn.iocoder.yudao.module.bs.controller.admin.budget.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import javax.validation.constraints.NotNull; + +@Schema(description = "管理后台 - 预算管理更新 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class BudgetUpdateReqVO extends BudgetBaseVO { + + @Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "29841") + @NotNull(message = "id不能为空") + private Long id; + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/feemanage/FeeManageController.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/feemanage/FeeManageController.java new file mode 100644 index 00000000..359a76e4 --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/feemanage/FeeManageController.java @@ -0,0 +1,99 @@ +package cn.iocoder.yudao.module.bs.controller.admin.feemanage; + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; +import cn.iocoder.yudao.module.bs.controller.admin.feemanage.vo.*; +import cn.iocoder.yudao.module.bs.convert.feemanage.FeeManageConvert; +import cn.iocoder.yudao.module.bs.dal.dataobject.feemanage.FeeManageDO; +import cn.iocoder.yudao.module.bs.service.feemanage.FeeManageService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; +import java.io.IOException; +import java.util.Collection; +import java.util.List; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; + +@Tag(name = "管理后台 - 费用控制") +@RestController +@RequestMapping("/bs/fee-manage") +@Validated +public class FeeManageController { + + @Resource + private FeeManageService feeManageService; + + @PostMapping("/create") + @Operation(summary = "创建费用控制") + @PreAuthorize("@ss.hasPermission('bs:fee-manage:create')") + public CommonResult createFeeManage(@Valid @RequestBody FeeManageCreateReqVO createReqVO) { + return success(feeManageService.createFeeManage(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新费用控制") + @PreAuthorize("@ss.hasPermission('bs:fee-manage:update')") + public CommonResult updateFeeManage(@Valid @RequestBody FeeManageUpdateReqVO updateReqVO) { + feeManageService.updateFeeManage(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除费用控制") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('bs:fee-manage:delete')") + public CommonResult deleteFeeManage(@RequestParam("id") Long id) { + feeManageService.deleteFeeManage(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得费用控制") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('bs:fee-manage:query')") + public CommonResult getFeeManage(@RequestParam("id") Long id) { + FeeManageDO feeManage = feeManageService.getFeeManage(id); + return success(feeManage); + } + + @GetMapping("/list") + @Operation(summary = "获得费用控制列表") + @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") + @PreAuthorize("@ss.hasPermission('bs:fee-manage:query')") + public CommonResult> getFeeManageList(@RequestParam("ids") Collection ids) { + List list = feeManageService.getFeeManageList(ids); + return success(FeeManageConvert.INSTANCE.convertList(list)); + } + + @GetMapping("/page") + @Operation(summary = "获得费用控制分页") + @PreAuthorize("@ss.hasPermission('bs:fee-manage:query')") + public CommonResult> getFeeManagePage(@Valid FeeManagePageReqVO pageVO) { + PageResult pageResult = feeManageService.getFeeManagePage(pageVO); + return success(pageResult); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出费用控制 Excel") + @PreAuthorize("@ss.hasPermission('bs:fee-manage:export')") + @OperateLog(type = EXPORT) + public void exportFeeManageExcel(@Valid FeeManageExportReqVO exportReqVO, + HttpServletResponse response) throws IOException { + List list = feeManageService.getFeeManageList(exportReqVO); + // 导出 Excel + List datas = FeeManageConvert.INSTANCE.convertList02(list); + ExcelUtils.write(response, "费用控制.xls", "数据", FeeManageExcelVO.class, datas); + } + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/feemanage/vo/FeeManageBaseVO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/feemanage/vo/FeeManageBaseVO.java new file mode 100644 index 00000000..2385950d --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/feemanage/vo/FeeManageBaseVO.java @@ -0,0 +1,40 @@ +package cn.iocoder.yudao.module.bs.controller.admin.feemanage.vo; + +import cn.iocoder.yudao.framework.common.pojo.ImageVo; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.math.BigDecimal; +import java.util.List; +import java.util.Set; + +/** + * 费用控制 Base VO,提供给添加、修改、详细的子 VO 使用 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 + */ +@Data +public class FeeManageBaseVO { + + @Schema(description = "部门ID", example = "29962") + private Long deptId; + + @Schema(description = "角色", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "角色不能为空") + private Set roleIds; + + @Schema(description = "限定金额", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "限定金额不能为空") + private BigDecimal amount; + + @Schema(description = "出差区域", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "出差区域不能为空") + private List area; + + @Schema(description = "备注", example = "你说的对") + private String remark; + + @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED) + private List files; + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/feemanage/vo/FeeManageCreateReqVO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/feemanage/vo/FeeManageCreateReqVO.java new file mode 100644 index 00000000..a11febba --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/feemanage/vo/FeeManageCreateReqVO.java @@ -0,0 +1,14 @@ +package cn.iocoder.yudao.module.bs.controller.admin.feemanage.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@Schema(description = "管理后台 - 费用控制创建 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class FeeManageCreateReqVO extends FeeManageBaseVO { + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/feemanage/vo/FeeManageExcelVO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/feemanage/vo/FeeManageExcelVO.java new file mode 100644 index 00000000..600343b3 --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/feemanage/vo/FeeManageExcelVO.java @@ -0,0 +1,41 @@ +package cn.iocoder.yudao.module.bs.controller.admin.feemanage.vo; + +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Data; + +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.List; +import java.util.Set; + +/** + * 费用控制 Excel VO + * + * @author chenqp + */ +@Data +public class FeeManageExcelVO { + + @ExcelProperty("id") + private Long id; + + @ExcelProperty("部门ID") + private Long deptId; + + @ExcelProperty("角色") + private Set roleIds; + + @ExcelProperty("限定金额") + private BigDecimal amount; + + @ExcelProperty("出差区域") + private List area; + + @ExcelProperty("备注") + private String remark; + + + @ExcelProperty("创建时间") + private LocalDateTime createTime; + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/feemanage/vo/FeeManageExportReqVO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/feemanage/vo/FeeManageExportReqVO.java new file mode 100644 index 00000000..90d8aaad --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/feemanage/vo/FeeManageExportReqVO.java @@ -0,0 +1,38 @@ +package cn.iocoder.yudao.module.bs.controller.admin.feemanage.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.List; +import java.util.Set; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 费用控制 Excel 导出 Request VO,参数和 FeeManagePageReqVO 是一致的") +@Data +public class FeeManageExportReqVO { + + @Schema(description = "部门ID", example = "29962") + private Long deptId; + + @Schema(description = "角色") + private Set roleIds; + + @Schema(description = "限定金额") + private BigDecimal amount; + + @Schema(description = "出差区域") + private List area; + + @Schema(description = "备注", example = "你说的对") + private String remark; + + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/feemanage/vo/FeeManagePageReqVO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/feemanage/vo/FeeManagePageReqVO.java new file mode 100644 index 00000000..00e1ca11 --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/feemanage/vo/FeeManagePageReqVO.java @@ -0,0 +1,43 @@ +package cn.iocoder.yudao.module.bs.controller.admin.feemanage.vo; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; +import org.springframework.format.annotation.DateTimeFormat; + +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.List; +import java.util.Set; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 费用控制分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class FeeManagePageReqVO extends PageParam { + + @Schema(description = "部门ID", example = "29962") + private Long deptId; + + @Schema(description = "角色") + private Set roleIds; + + @Schema(description = "限定金额") + private BigDecimal amount; + + @Schema(description = "出差区域") + private List area; + + @Schema(description = "备注", example = "你说的对") + private String remark; + + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/feemanage/vo/FeeManageRespVO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/feemanage/vo/FeeManageRespVO.java new file mode 100644 index 00000000..677bf487 --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/feemanage/vo/FeeManageRespVO.java @@ -0,0 +1,22 @@ +package cn.iocoder.yudao.module.bs.controller.admin.feemanage.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - 费用控制 Response VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class FeeManageRespVO extends FeeManageBaseVO { + + @Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1002") + private Long id; + + @Schema(description = "创建时间") + private LocalDateTime createTime; + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/feemanage/vo/FeeManageUpdateReqVO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/feemanage/vo/FeeManageUpdateReqVO.java new file mode 100644 index 00000000..7d01a278 --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/feemanage/vo/FeeManageUpdateReqVO.java @@ -0,0 +1,20 @@ +package cn.iocoder.yudao.module.bs.controller.admin.feemanage.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import javax.validation.constraints.NotNull; + +@Schema(description = "管理后台 - 费用控制更新 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class FeeManageUpdateReqVO extends FeeManageBaseVO { + + @Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1002") + @NotNull(message = "id不能为空") + private Long id; + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/convert/budget/BudgetConvert.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/convert/budget/BudgetConvert.java new file mode 100644 index 00000000..277eb88b --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/convert/budget/BudgetConvert.java @@ -0,0 +1,36 @@ +package cn.iocoder.yudao.module.bs.convert.budget; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.bs.controller.admin.budget.vo.BudgetCreateReqVO; +import cn.iocoder.yudao.module.bs.controller.admin.budget.vo.BudgetExcelVO; +import cn.iocoder.yudao.module.bs.controller.admin.budget.vo.BudgetRespVO; +import cn.iocoder.yudao.module.bs.controller.admin.budget.vo.BudgetUpdateReqVO; +import cn.iocoder.yudao.module.bs.dal.dataobject.budget.BudgetDO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 预算管理 Convert + * + * @author chenqp + */ +@Mapper +public interface BudgetConvert { + + BudgetConvert INSTANCE = Mappers.getMapper(BudgetConvert.class); + + BudgetDO convert(BudgetCreateReqVO bean); + + BudgetDO convert(BudgetUpdateReqVO bean); + + BudgetRespVO convert(BudgetDO bean); + + List convertList(List list); + + PageResult convertPage(PageResult page); + + List convertList02(List list); + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/convert/feemanage/FeeManageConvert.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/convert/feemanage/FeeManageConvert.java new file mode 100644 index 00000000..38366ac5 --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/convert/feemanage/FeeManageConvert.java @@ -0,0 +1,36 @@ +package cn.iocoder.yudao.module.bs.convert.feemanage; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.bs.controller.admin.feemanage.vo.FeeManageCreateReqVO; +import cn.iocoder.yudao.module.bs.controller.admin.feemanage.vo.FeeManageExcelVO; +import cn.iocoder.yudao.module.bs.controller.admin.feemanage.vo.FeeManageRespVO; +import cn.iocoder.yudao.module.bs.controller.admin.feemanage.vo.FeeManageUpdateReqVO; +import cn.iocoder.yudao.module.bs.dal.dataobject.feemanage.FeeManageDO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 费用控制 Convert + * + * @author chenqp + */ +@Mapper +public interface FeeManageConvert { + + FeeManageConvert INSTANCE = Mappers.getMapper(FeeManageConvert.class); + + FeeManageDO convert(FeeManageCreateReqVO bean); + + FeeManageDO convert(FeeManageUpdateReqVO bean); + + FeeManageRespVO convert(FeeManageDO bean); + + List convertList(List list); + + PageResult convertPage(PageResult page); + + List convertList02(List list); + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/budget/BudgetDO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/budget/BudgetDO.java new file mode 100644 index 00000000..ec54413f --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/budget/BudgetDO.java @@ -0,0 +1,70 @@ +package cn.iocoder.yudao.module.bs.dal.dataobject.budget; + +import cn.iocoder.yudao.framework.common.pojo.ImageVo; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import com.baomidou.mybatisplus.annotation.KeySequence; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; +import lombok.*; + +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.List; + +/** + * 预算管理 DO + * + * @author chenqp + */ +@TableName(value = "bs_budget", autoResultMap = true) +@KeySequence("bs_budget_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class BudgetDO extends BaseDO { + + /** + * id + */ + @TableId + private Long id; + /** + * 预算年度 + */ + private LocalDateTime budgetYear; + /** + * 预算金额 + */ + private BigDecimal amount; + /** + * 已使用金额 + */ + private BigDecimal usedAmount; + /** + * 占用金额 + */ + private BigDecimal occupyAmount; + /** + * 剩余金额 + */ + private BigDecimal remainAmount; + /** + * 部门ID + */ + private Long deptId; + /** + * 备注 + */ + private String remark; + /** + * 附件 + */ + @TableField(typeHandler = JacksonTypeHandler.class) + private List files; + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/feemanage/FeeManageDO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/feemanage/FeeManageDO.java new file mode 100644 index 00000000..778fc656 --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/feemanage/FeeManageDO.java @@ -0,0 +1,65 @@ +package cn.iocoder.yudao.module.bs.dal.dataobject.feemanage; + +import cn.iocoder.yudao.framework.common.pojo.ImageVo; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import cn.iocoder.yudao.framework.mybatis.core.type.JsonLongSetTypeHandler; +import com.baomidou.mybatisplus.annotation.KeySequence; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; +import lombok.*; + +import java.math.BigDecimal; +import java.util.List; +import java.util.Set; + +/** + * 费用控制 DO + * + * @author chenqp + */ +@TableName(value = "bs_fee_manage", autoResultMap = true) +@KeySequence("bs_fee_manage_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class FeeManageDO extends BaseDO { + + /** + * id + */ + @TableId + private Long id; + /** + * 部门ID + */ + private Long deptId; + /** + * 角色 + */ + @TableField(typeHandler = JsonLongSetTypeHandler.class) + private Set roleIds; + /** + * 限定金额 + */ + private BigDecimal amount; + /** + * 出差区域 + */ + @TableField(typeHandler = JacksonTypeHandler.class) + private List area; + /** + * 备注 + */ + private String remark; + /** + * 附件 + */ + @TableField(typeHandler = JacksonTypeHandler.class) + private List files; + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/mysql/budget/BudgetMapper.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/mysql/budget/BudgetMapper.java new file mode 100644 index 00000000..5ae46071 --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/mysql/budget/BudgetMapper.java @@ -0,0 +1,47 @@ +package cn.iocoder.yudao.module.bs.dal.mysql.budget; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.module.bs.controller.admin.budget.vo.BudgetExportReqVO; +import cn.iocoder.yudao.module.bs.controller.admin.budget.vo.BudgetPageReqVO; +import cn.iocoder.yudao.module.bs.dal.dataobject.budget.BudgetDO; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 预算管理 Mapper + * + * @author chenqp + */ +@Mapper +public interface BudgetMapper extends BaseMapperX { + + default PageResult selectPage(BudgetPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(BudgetDO::getBudgetYear, reqVO.getBudgetYear()) + .eqIfPresent(BudgetDO::getAmount, reqVO.getAmount()) + .eqIfPresent(BudgetDO::getUsedAmount, reqVO.getUsedAmount()) + .eqIfPresent(BudgetDO::getOccupyAmount, reqVO.getOccupyAmount()) + .eqIfPresent(BudgetDO::getRemainAmount, reqVO.getRemainAmount()) + .eqIfPresent(BudgetDO::getDeptId, reqVO.getDeptId()) + .eqIfPresent(BudgetDO::getRemark, reqVO.getRemark()) + .betweenIfPresent(BudgetDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(BudgetDO::getId)); + } + + default List selectList(BudgetExportReqVO reqVO) { + return selectList(new LambdaQueryWrapperX() + .eqIfPresent(BudgetDO::getBudgetYear, reqVO.getBudgetYear()) + .eqIfPresent(BudgetDO::getAmount, reqVO.getAmount()) + .eqIfPresent(BudgetDO::getUsedAmount, reqVO.getUsedAmount()) + .eqIfPresent(BudgetDO::getOccupyAmount, reqVO.getOccupyAmount()) + .eqIfPresent(BudgetDO::getRemainAmount, reqVO.getRemainAmount()) + .eqIfPresent(BudgetDO::getDeptId, reqVO.getDeptId()) + .eqIfPresent(BudgetDO::getRemark, reqVO.getRemark()) + .betweenIfPresent(BudgetDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(BudgetDO::getId)); + } + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/mysql/feemanage/FeeManageMapper.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/mysql/feemanage/FeeManageMapper.java new file mode 100644 index 00000000..eca7f11f --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/mysql/feemanage/FeeManageMapper.java @@ -0,0 +1,43 @@ +package cn.iocoder.yudao.module.bs.dal.mysql.feemanage; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.module.bs.controller.admin.feemanage.vo.FeeManageExportReqVO; +import cn.iocoder.yudao.module.bs.controller.admin.feemanage.vo.FeeManagePageReqVO; +import cn.iocoder.yudao.module.bs.dal.dataobject.feemanage.FeeManageDO; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 费用控制 Mapper + * + * @author chenqp + */ +@Mapper +public interface FeeManageMapper extends BaseMapperX { + + default PageResult selectPage(FeeManagePageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(FeeManageDO::getDeptId, reqVO.getDeptId()) + .eqIfPresent(FeeManageDO::getRoleIds, reqVO.getRoleIds()) + .eqIfPresent(FeeManageDO::getAmount, reqVO.getAmount()) + .eqIfPresent(FeeManageDO::getArea, reqVO.getArea()) + .eqIfPresent(FeeManageDO::getRemark, reqVO.getRemark()) + .betweenIfPresent(FeeManageDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(FeeManageDO::getId)); + } + + default List selectList(FeeManageExportReqVO reqVO) { + return selectList(new LambdaQueryWrapperX() + .eqIfPresent(FeeManageDO::getDeptId, reqVO.getDeptId()) + .eqIfPresent(FeeManageDO::getRoleIds, reqVO.getRoleIds()) + .eqIfPresent(FeeManageDO::getAmount, reqVO.getAmount()) + .eqIfPresent(FeeManageDO::getArea, reqVO.getArea()) + .eqIfPresent(FeeManageDO::getRemark, reqVO.getRemark()) + .betweenIfPresent(FeeManageDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(FeeManageDO::getId)); + } + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/budget/BudgetService.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/budget/BudgetService.java new file mode 100644 index 00000000..52c14160 --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/budget/BudgetService.java @@ -0,0 +1,76 @@ +package cn.iocoder.yudao.module.bs.service.budget; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.bs.controller.admin.budget.vo.BudgetCreateReqVO; +import cn.iocoder.yudao.module.bs.controller.admin.budget.vo.BudgetExportReqVO; +import cn.iocoder.yudao.module.bs.controller.admin.budget.vo.BudgetPageReqVO; +import cn.iocoder.yudao.module.bs.controller.admin.budget.vo.BudgetUpdateReqVO; +import cn.iocoder.yudao.module.bs.dal.dataobject.budget.BudgetDO; +import com.github.yulichang.base.MPJBaseService; + +import javax.validation.Valid; +import java.util.Collection; +import java.util.List; + +/** + * 预算管理 Service 接口 + * + * @author chenqp + */ +public interface BudgetService extends MPJBaseService { + + /** + * 创建预算管理 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createBudget(@Valid BudgetCreateReqVO createReqVO); + + /** + * 更新预算管理 + * + * @param updateReqVO 更新信息 + */ + void updateBudget(@Valid BudgetUpdateReqVO updateReqVO); + + /** + * 删除预算管理 + * + * @param id 编号 + */ + void deleteBudget(Long id); + + /** + * 获得预算管理 + * + * @param id 编号 + * @return 预算管理 + */ + BudgetDO getBudget(Long id); + + /** + * 获得预算管理列表 + * + * @param ids 编号 + * @return 预算管理列表 + */ + List getBudgetList(Collection ids); + + /** + * 获得预算管理分页 + * + * @param pageReqVO 分页查询 + * @return 预算管理分页 + */ + PageResult getBudgetPage(BudgetPageReqVO pageReqVO); + + /** + * 获得预算管理列表, 用于 Excel 导出 + * + * @param exportReqVO 查询条件 + * @return 预算管理列表 + */ + List getBudgetList(BudgetExportReqVO exportReqVO); + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/budget/BudgetServiceImpl.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/budget/BudgetServiceImpl.java new file mode 100644 index 00000000..7833351e --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/budget/BudgetServiceImpl.java @@ -0,0 +1,95 @@ +package cn.iocoder.yudao.module.bs.service.budget; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.bs.controller.admin.budget.vo.BudgetCreateReqVO; +import cn.iocoder.yudao.module.bs.controller.admin.budget.vo.BudgetExportReqVO; +import cn.iocoder.yudao.module.bs.controller.admin.budget.vo.BudgetPageReqVO; +import cn.iocoder.yudao.module.bs.controller.admin.budget.vo.BudgetUpdateReqVO; +import cn.iocoder.yudao.module.bs.convert.budget.BudgetConvert; +import cn.iocoder.yudao.module.bs.dal.dataobject.budget.BudgetDO; +import cn.iocoder.yudao.module.bs.dal.mysql.budget.BudgetMapper; +import com.github.yulichang.base.MPJBaseServiceImpl; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.Collection; +import java.util.List; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.bs.enums.ErrorCodeConstants.BUDGET_NOT_EXISTS; + +/** + * 预算管理 Service 实现类 + * + * @author chenqp + */ +@Service +@Validated +public class BudgetServiceImpl extends MPJBaseServiceImpl implements BudgetService { + + @Resource + private BudgetMapper budgetMapper; + + @Override + public Long createBudget(BudgetCreateReqVO createReqVO) { + // 插入 + BudgetDO budget = BudgetConvert.INSTANCE.convert(createReqVO); + setBaseField(budget); + budgetMapper.insert(budget); + // 返回 + return budget.getId(); + } + + @Override + public void updateBudget(BudgetUpdateReqVO updateReqVO) { + // 校验存在 + validateBudgetExists(updateReqVO.getId()); + // 更新 + BudgetDO budget = BudgetConvert.INSTANCE.convert(updateReqVO); + setBaseField(budget); + budgetMapper.updateById(budget); + } + + private void setBaseField(BudgetDO budget) { + budget.setOccupyAmount(BigDecimal.ZERO); + budget.setUsedAmount(BigDecimal.ZERO); + budget.setRemainAmount(BigDecimal.ZERO); + } + + @Override + public void deleteBudget(Long id) { + // 校验存在 + validateBudgetExists(id); + // 删除 + budgetMapper.deleteById(id); + } + + private void validateBudgetExists(Long id) { + if (budgetMapper.selectById(id) == null) { + throw exception(BUDGET_NOT_EXISTS); + } + } + + @Override + public BudgetDO getBudget(Long id) { + return budgetMapper.selectById(id); + } + + @Override + public List getBudgetList(Collection ids) { + return budgetMapper.selectBatchIds(ids); + } + + @Override + public PageResult getBudgetPage(BudgetPageReqVO pageReqVO) { + return budgetMapper.selectPage(pageReqVO); + } + + @Override + public List getBudgetList(BudgetExportReqVO exportReqVO) { + return budgetMapper.selectList(exportReqVO); + } + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/feemanage/FeeManageService.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/feemanage/FeeManageService.java new file mode 100644 index 00000000..ff75d2bc --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/feemanage/FeeManageService.java @@ -0,0 +1,76 @@ +package cn.iocoder.yudao.module.bs.service.feemanage; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.bs.controller.admin.feemanage.vo.FeeManageCreateReqVO; +import cn.iocoder.yudao.module.bs.controller.admin.feemanage.vo.FeeManageExportReqVO; +import cn.iocoder.yudao.module.bs.controller.admin.feemanage.vo.FeeManagePageReqVO; +import cn.iocoder.yudao.module.bs.controller.admin.feemanage.vo.FeeManageUpdateReqVO; +import cn.iocoder.yudao.module.bs.dal.dataobject.feemanage.FeeManageDO; +import com.github.yulichang.base.MPJBaseService; + +import javax.validation.Valid; +import java.util.Collection; +import java.util.List; + +/** + * 费用控制 Service 接口 + * + * @author chenqp + */ +public interface FeeManageService extends MPJBaseService { + + /** + * 创建费用控制 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createFeeManage(@Valid FeeManageCreateReqVO createReqVO); + + /** + * 更新费用控制 + * + * @param updateReqVO 更新信息 + */ + void updateFeeManage(@Valid FeeManageUpdateReqVO updateReqVO); + + /** + * 删除费用控制 + * + * @param id 编号 + */ + void deleteFeeManage(Long id); + + /** + * 获得费用控制 + * + * @param id 编号 + * @return 费用控制 + */ + FeeManageDO getFeeManage(Long id); + + /** + * 获得费用控制列表 + * + * @param ids 编号 + * @return 费用控制列表 + */ + List getFeeManageList(Collection ids); + + /** + * 获得费用控制分页 + * + * @param pageReqVO 分页查询 + * @return 费用控制分页 + */ + PageResult getFeeManagePage(FeeManagePageReqVO pageReqVO); + + /** + * 获得费用控制列表, 用于 Excel 导出 + * + * @param exportReqVO 查询条件 + * @return 费用控制列表 + */ + List getFeeManageList(FeeManageExportReqVO exportReqVO); + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/feemanage/FeeManageServiceImpl.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/feemanage/FeeManageServiceImpl.java new file mode 100644 index 00000000..7bfdcb49 --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/feemanage/FeeManageServiceImpl.java @@ -0,0 +1,86 @@ +package cn.iocoder.yudao.module.bs.service.feemanage; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.bs.controller.admin.feemanage.vo.FeeManageCreateReqVO; +import cn.iocoder.yudao.module.bs.controller.admin.feemanage.vo.FeeManageExportReqVO; +import cn.iocoder.yudao.module.bs.controller.admin.feemanage.vo.FeeManagePageReqVO; +import cn.iocoder.yudao.module.bs.controller.admin.feemanage.vo.FeeManageUpdateReqVO; +import cn.iocoder.yudao.module.bs.convert.feemanage.FeeManageConvert; +import cn.iocoder.yudao.module.bs.dal.dataobject.feemanage.FeeManageDO; +import cn.iocoder.yudao.module.bs.dal.mysql.feemanage.FeeManageMapper; +import com.github.yulichang.base.MPJBaseServiceImpl; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.Resource; +import java.util.Collection; +import java.util.List; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.bs.enums.ErrorCodeConstants.FEE_MANAGE_NOT_EXISTS; + +/** + * 费用控制 Service 实现类 + * + * @author chenqp + */ +@Service +@Validated +public class FeeManageServiceImpl extends MPJBaseServiceImpl implements FeeManageService { + + @Resource + private FeeManageMapper feeManageMapper; + + @Override + public Long createFeeManage(FeeManageCreateReqVO createReqVO) { + // 插入 + FeeManageDO feeManage = FeeManageConvert.INSTANCE.convert(createReqVO); + feeManageMapper.insert(feeManage); + // 返回 + return feeManage.getId(); + } + + @Override + public void updateFeeManage(FeeManageUpdateReqVO updateReqVO) { + // 校验存在 + validateFeeManageExists(updateReqVO.getId()); + // 更新 + FeeManageDO updateObj = FeeManageConvert.INSTANCE.convert(updateReqVO); + feeManageMapper.updateById(updateObj); + } + + @Override + public void deleteFeeManage(Long id) { + // 校验存在 + validateFeeManageExists(id); + // 删除 + feeManageMapper.deleteById(id); + } + + private void validateFeeManageExists(Long id) { + if (feeManageMapper.selectById(id) == null) { + throw exception(FEE_MANAGE_NOT_EXISTS); + } + } + + @Override + public FeeManageDO getFeeManage(Long id) { + return feeManageMapper.selectById(id); + } + + @Override + public List getFeeManageList(Collection ids) { + return feeManageMapper.selectBatchIds(ids); + } + + @Override + public PageResult getFeeManagePage(FeeManagePageReqVO pageReqVO) { + return feeManageMapper.selectPage(pageReqVO); + } + + @Override + public List getFeeManageList(FeeManageExportReqVO exportReqVO) { + return feeManageMapper.selectList(exportReqVO); + } + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/resources/mapper/budget/BudgetMapper.xml b/yudao-module-bs/yudao-module-bs-biz/src/main/resources/mapper/budget/BudgetMapper.xml new file mode 100644 index 00000000..aca966bc --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/resources/mapper/budget/BudgetMapper.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/resources/mapper/feemanage/FeeManageMapper.xml b/yudao-module-bs/yudao-module-bs-biz/src/main/resources/mapper/feemanage/FeeManageMapper.xml new file mode 100644 index 00000000..98a2b982 --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/resources/mapper/feemanage/FeeManageMapper.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/yudao-module-bs/yudao-module-bs-biz/src/test/java/cn/iocoder/yudao/module/bs/service/budget/BudgetServiceImplTest.java b/yudao-module-bs/yudao-module-bs-biz/src/test/java/cn/iocoder/yudao/module/bs/service/budget/BudgetServiceImplTest.java new file mode 100644 index 00000000..53d0de9c --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/test/java/cn/iocoder/yudao/module/bs/service/budget/BudgetServiceImplTest.java @@ -0,0 +1,211 @@ +package cn.iocoder.yudao.module.bs.service.budget; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; +import cn.iocoder.yudao.module.bs.controller.admin.budget.vo.BudgetCreateReqVO; +import cn.iocoder.yudao.module.bs.controller.admin.budget.vo.BudgetExportReqVO; +import cn.iocoder.yudao.module.bs.controller.admin.budget.vo.BudgetPageReqVO; +import cn.iocoder.yudao.module.bs.controller.admin.budget.vo.BudgetUpdateReqVO; +import cn.iocoder.yudao.module.bs.dal.dataobject.budget.BudgetDO; +import cn.iocoder.yudao.module.bs.dal.mysql.budget.BudgetMapper; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.context.annotation.Import; + +import javax.annotation.Resource; +import java.util.List; + +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; +import static cn.iocoder.yudao.module.bs.enums.ErrorCodeConstants.BUDGET_NOT_EXISTS; +import static org.junit.jupiter.api.Assertions.*; + +/** + * {@link BudgetServiceImpl} 的单元测试类 + * + * @author chenqp + */ +@Import(BudgetServiceImpl.class) +public class BudgetServiceImplTest extends BaseDbUnitTest { + + @Resource + private BudgetServiceImpl budgetService; + + @Resource + private BudgetMapper budgetMapper; + + @Test + public void testCreateBudget_success() { + // 准备参数 + BudgetCreateReqVO reqVO = randomPojo(BudgetCreateReqVO.class); + + // 调用 + Long budgetId = budgetService.createBudget(reqVO); + // 断言 + assertNotNull(budgetId); + // 校验记录的属性是否正确 + BudgetDO budget = budgetMapper.selectById(budgetId); + assertPojoEquals(reqVO, budget); + } + + @Test + public void testUpdateBudget_success() { + // mock 数据 + BudgetDO dbBudget = randomPojo(BudgetDO.class); + budgetMapper.insert(dbBudget);// @Sql: 先插入出一条存在的数据 + // 准备参数 + BudgetUpdateReqVO reqVO = randomPojo(BudgetUpdateReqVO.class, o -> { + o.setId(dbBudget.getId()); // 设置更新的 ID + }); + + // 调用 + budgetService.updateBudget(reqVO); + // 校验是否更新正确 + BudgetDO budget = budgetMapper.selectById(reqVO.getId()); // 获取最新的 + assertPojoEquals(reqVO, budget); + } + + @Test + public void testUpdateBudget_notExists() { + // 准备参数 + BudgetUpdateReqVO reqVO = randomPojo(BudgetUpdateReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> budgetService.updateBudget(reqVO), BUDGET_NOT_EXISTS); + } + + @Test + public void testDeleteBudget_success() { + // mock 数据 + BudgetDO dbBudget = randomPojo(BudgetDO.class); + budgetMapper.insert(dbBudget);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbBudget.getId(); + + // 调用 + budgetService.deleteBudget(id); + // 校验数据不存在了 + assertNull(budgetMapper.selectById(id)); + } + + @Test + public void testDeleteBudget_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> budgetService.deleteBudget(id), BUDGET_NOT_EXISTS); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetBudgetPage() { + // mock 数据 + BudgetDO dbBudget = randomPojo(BudgetDO.class, o -> { // 等会查询到 + o.setBudgetYear(null); + o.setAmount(null); + o.setUsedAmount(null); + o.setOccupyAmount(null); + o.setRemainAmount(null); + o.setDeptId(null); + o.setRemark(null); + o.setFiles(null); + o.setCreateTime(null); + }); + budgetMapper.insert(dbBudget); + // 测试 budgetYear 不匹配 + budgetMapper.insert(cloneIgnoreId(dbBudget, o -> o.setBudgetYear(null))); + // 测试 amount 不匹配 + budgetMapper.insert(cloneIgnoreId(dbBudget, o -> o.setAmount(null))); + // 测试 usedAmount 不匹配 + budgetMapper.insert(cloneIgnoreId(dbBudget, o -> o.setUsedAmount(null))); + // 测试 occupyAmount 不匹配 + budgetMapper.insert(cloneIgnoreId(dbBudget, o -> o.setOccupyAmount(null))); + // 测试 remainAmount 不匹配 + budgetMapper.insert(cloneIgnoreId(dbBudget, o -> o.setRemainAmount(null))); + // 测试 deptId 不匹配 + budgetMapper.insert(cloneIgnoreId(dbBudget, o -> o.setDeptId(null))); + // 测试 remark 不匹配 + budgetMapper.insert(cloneIgnoreId(dbBudget, o -> o.setRemark(null))); + // 测试 files 不匹配 + budgetMapper.insert(cloneIgnoreId(dbBudget, o -> o.setFiles(null))); + // 测试 createTime 不匹配 + budgetMapper.insert(cloneIgnoreId(dbBudget, o -> o.setCreateTime(null))); + // 准备参数 + BudgetPageReqVO reqVO = new BudgetPageReqVO(); + reqVO.setBudgetYear(null); + reqVO.setAmount(null); + reqVO.setUsedAmount(null); + reqVO.setOccupyAmount(null); + reqVO.setRemainAmount(null); + reqVO.setDeptId(null); + reqVO.setRemark(null); + reqVO.setFiles(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + + // 调用 + PageResult pageResult = budgetService.getBudgetPage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbBudget, pageResult.getList().get(0)); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetBudgetList() { + // mock 数据 + BudgetDO dbBudget = randomPojo(BudgetDO.class, o -> { // 等会查询到 + o.setBudgetYear(null); + o.setAmount(null); + o.setUsedAmount(null); + o.setOccupyAmount(null); + o.setRemainAmount(null); + o.setDeptId(null); + o.setRemark(null); + o.setFiles(null); + o.setCreateTime(null); + }); + budgetMapper.insert(dbBudget); + // 测试 budgetYear 不匹配 + budgetMapper.insert(cloneIgnoreId(dbBudget, o -> o.setBudgetYear(null))); + // 测试 amount 不匹配 + budgetMapper.insert(cloneIgnoreId(dbBudget, o -> o.setAmount(null))); + // 测试 usedAmount 不匹配 + budgetMapper.insert(cloneIgnoreId(dbBudget, o -> o.setUsedAmount(null))); + // 测试 occupyAmount 不匹配 + budgetMapper.insert(cloneIgnoreId(dbBudget, o -> o.setOccupyAmount(null))); + // 测试 remainAmount 不匹配 + budgetMapper.insert(cloneIgnoreId(dbBudget, o -> o.setRemainAmount(null))); + // 测试 deptId 不匹配 + budgetMapper.insert(cloneIgnoreId(dbBudget, o -> o.setDeptId(null))); + // 测试 remark 不匹配 + budgetMapper.insert(cloneIgnoreId(dbBudget, o -> o.setRemark(null))); + // 测试 files 不匹配 + budgetMapper.insert(cloneIgnoreId(dbBudget, o -> o.setFiles(null))); + // 测试 createTime 不匹配 + budgetMapper.insert(cloneIgnoreId(dbBudget, o -> o.setCreateTime(null))); + // 准备参数 + BudgetExportReqVO reqVO = new BudgetExportReqVO(); + reqVO.setBudgetYear(null); + reqVO.setAmount(null); + reqVO.setUsedAmount(null); + reqVO.setOccupyAmount(null); + reqVO.setRemainAmount(null); + reqVO.setDeptId(null); + reqVO.setRemark(null); + reqVO.setFiles(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + + // 调用 + List list = budgetService.getBudgetList(reqVO); + // 断言 + assertEquals(1, list.size()); + assertPojoEquals(dbBudget, list.get(0)); + } + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/test/java/cn/iocoder/yudao/module/bs/service/feemanage/FeeManageServiceImplTest.java b/yudao-module-bs/yudao-module-bs-biz/src/test/java/cn/iocoder/yudao/module/bs/service/feemanage/FeeManageServiceImplTest.java new file mode 100644 index 00000000..87f2f528 --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/test/java/cn/iocoder/yudao/module/bs/service/feemanage/FeeManageServiceImplTest.java @@ -0,0 +1,195 @@ +package cn.iocoder.yudao.module.bs.service.feemanage; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; +import cn.iocoder.yudao.module.bs.controller.admin.feemanage.vo.FeeManageCreateReqVO; +import cn.iocoder.yudao.module.bs.controller.admin.feemanage.vo.FeeManageExportReqVO; +import cn.iocoder.yudao.module.bs.controller.admin.feemanage.vo.FeeManagePageReqVO; +import cn.iocoder.yudao.module.bs.controller.admin.feemanage.vo.FeeManageUpdateReqVO; +import cn.iocoder.yudao.module.bs.dal.dataobject.feemanage.FeeManageDO; +import cn.iocoder.yudao.module.bs.dal.mysql.feemanage.FeeManageMapper; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.context.annotation.Import; + +import javax.annotation.Resource; +import java.util.List; + +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; +import static cn.iocoder.yudao.module.bs.enums.ErrorCodeConstants.FEE_MANAGE_NOT_EXISTS; +import static org.junit.jupiter.api.Assertions.*; + +/** + * {@link FeeManageServiceImpl} 的单元测试类 + * + * @author chenqp + */ +@Import(FeeManageServiceImpl.class) +public class FeeManageServiceImplTest extends BaseDbUnitTest { + + @Resource + private FeeManageServiceImpl feeManageService; + + @Resource + private FeeManageMapper feeManageMapper; + + @Test + public void testCreateFeeManage_success() { + // 准备参数 + FeeManageCreateReqVO reqVO = randomPojo(FeeManageCreateReqVO.class); + + // 调用 + Long feeManageId = feeManageService.createFeeManage(reqVO); + // 断言 + assertNotNull(feeManageId); + // 校验记录的属性是否正确 + FeeManageDO feeManage = feeManageMapper.selectById(feeManageId); + assertPojoEquals(reqVO, feeManage); + } + + @Test + public void testUpdateFeeManage_success() { + // mock 数据 + FeeManageDO dbFeeManage = randomPojo(FeeManageDO.class); + feeManageMapper.insert(dbFeeManage);// @Sql: 先插入出一条存在的数据 + // 准备参数 + FeeManageUpdateReqVO reqVO = randomPojo(FeeManageUpdateReqVO.class, o -> { + o.setId(dbFeeManage.getId()); // 设置更新的 ID + }); + + // 调用 + feeManageService.updateFeeManage(reqVO); + // 校验是否更新正确 + FeeManageDO feeManage = feeManageMapper.selectById(reqVO.getId()); // 获取最新的 + assertPojoEquals(reqVO, feeManage); + } + + @Test + public void testUpdateFeeManage_notExists() { + // 准备参数 + FeeManageUpdateReqVO reqVO = randomPojo(FeeManageUpdateReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> feeManageService.updateFeeManage(reqVO), FEE_MANAGE_NOT_EXISTS); + } + + @Test + public void testDeleteFeeManage_success() { + // mock 数据 + FeeManageDO dbFeeManage = randomPojo(FeeManageDO.class); + feeManageMapper.insert(dbFeeManage);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbFeeManage.getId(); + + // 调用 + feeManageService.deleteFeeManage(id); + // 校验数据不存在了 + assertNull(feeManageMapper.selectById(id)); + } + + @Test + public void testDeleteFeeManage_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> feeManageService.deleteFeeManage(id), FEE_MANAGE_NOT_EXISTS); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetFeeManagePage() { + // mock 数据 + FeeManageDO dbFeeManage = randomPojo(FeeManageDO.class, o -> { // 等会查询到 + o.setDeptId(null); + o.setRoleIds(null); + o.setAmount(null); + o.setArea(null); + o.setRemark(null); + o.setFiles(null); + o.setCreateTime(null); + }); + feeManageMapper.insert(dbFeeManage); + // 测试 deptId 不匹配 + feeManageMapper.insert(cloneIgnoreId(dbFeeManage, o -> o.setDeptId(null))); + // 测试 roleIds 不匹配 + feeManageMapper.insert(cloneIgnoreId(dbFeeManage, o -> o.setRoleIds(null))); + // 测试 amount 不匹配 + feeManageMapper.insert(cloneIgnoreId(dbFeeManage, o -> o.setAmount(null))); + // 测试 area 不匹配 + feeManageMapper.insert(cloneIgnoreId(dbFeeManage, o -> o.setArea(null))); + // 测试 remark 不匹配 + feeManageMapper.insert(cloneIgnoreId(dbFeeManage, o -> o.setRemark(null))); + // 测试 files 不匹配 + feeManageMapper.insert(cloneIgnoreId(dbFeeManage, o -> o.setFiles(null))); + // 测试 createTime 不匹配 + feeManageMapper.insert(cloneIgnoreId(dbFeeManage, o -> o.setCreateTime(null))); + // 准备参数 + FeeManagePageReqVO reqVO = new FeeManagePageReqVO(); + reqVO.setDeptId(null); + reqVO.setRoleIds(null); + reqVO.setAmount(null); + reqVO.setArea(null); + reqVO.setRemark(null); + reqVO.setFiles(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + + // 调用 + PageResult pageResult = feeManageService.getFeeManagePage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbFeeManage, pageResult.getList().get(0)); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetFeeManageList() { + // mock 数据 + FeeManageDO dbFeeManage = randomPojo(FeeManageDO.class, o -> { // 等会查询到 + o.setDeptId(null); + o.setRoleIds(null); + o.setAmount(null); + o.setArea(null); + o.setRemark(null); + o.setFiles(null); + o.setCreateTime(null); + }); + feeManageMapper.insert(dbFeeManage); + // 测试 deptId 不匹配 + feeManageMapper.insert(cloneIgnoreId(dbFeeManage, o -> o.setDeptId(null))); + // 测试 roleIds 不匹配 + feeManageMapper.insert(cloneIgnoreId(dbFeeManage, o -> o.setRoleIds(null))); + // 测试 amount 不匹配 + feeManageMapper.insert(cloneIgnoreId(dbFeeManage, o -> o.setAmount(null))); + // 测试 area 不匹配 + feeManageMapper.insert(cloneIgnoreId(dbFeeManage, o -> o.setArea(null))); + // 测试 remark 不匹配 + feeManageMapper.insert(cloneIgnoreId(dbFeeManage, o -> o.setRemark(null))); + // 测试 files 不匹配 + feeManageMapper.insert(cloneIgnoreId(dbFeeManage, o -> o.setFiles(null))); + // 测试 createTime 不匹配 + feeManageMapper.insert(cloneIgnoreId(dbFeeManage, o -> o.setCreateTime(null))); + // 准备参数 + FeeManageExportReqVO reqVO = new FeeManageExportReqVO(); + reqVO.setDeptId(null); + reqVO.setRoleIds(null); + reqVO.setAmount(null); + reqVO.setArea(null); + reqVO.setRemark(null); + reqVO.setFiles(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + + // 调用 + List list = feeManageService.getFeeManageList(reqVO); + // 断言 + assertEquals(1, list.size()); + assertPojoEquals(dbFeeManage, list.get(0)); + } + +}