feat: 预算分类代码生成
This commit is contained in:
parent
fbd385883b
commit
b885f71589
|
@ -3,16 +3,11 @@ package cn.bunny.common.generator.generator;
|
|||
import cn.bunny.common.generator.entity.BaseField;
|
||||
import cn.bunny.common.generator.entity.BaseResultMap;
|
||||
import cn.bunny.common.generator.utils.GeneratorCodeUtils;
|
||||
import cn.bunny.dao.dto.financial.debtRepaymentPlan.DebtRepaymentPlanAddDto;
|
||||
import cn.bunny.dao.dto.financial.debtRepaymentPlan.DebtRepaymentPlanDto;
|
||||
import cn.bunny.dao.dto.financial.debtRepaymentPlan.DebtRepaymentPlanUpdateDto;
|
||||
import cn.bunny.dao.dto.system.configuration.category.CategoryAddDto;
|
||||
import cn.bunny.dao.dto.system.configuration.category.CategoryDto;
|
||||
import cn.bunny.dao.dto.system.configuration.category.CategoryUpdateDto;
|
||||
import cn.bunny.dao.entity.financial.Category;
|
||||
import cn.bunny.dao.entity.financial.DebtRepaymentPlan;
|
||||
import cn.bunny.dao.vo.configuration.CategoryVo;
|
||||
import cn.bunny.dao.vo.financial.DebtRepaymentPlanVo;
|
||||
import cn.bunny.dao.dto.financial.budgetCategory.BudgetCategoryAddDto;
|
||||
import cn.bunny.dao.dto.financial.budgetCategory.BudgetCategoryDto;
|
||||
import cn.bunny.dao.dto.financial.budgetCategory.BudgetCategoryUpdateDto;
|
||||
import cn.bunny.dao.entity.financial.BudgetCategory;
|
||||
import cn.bunny.dao.vo.financial.BudgetCategoryVo;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.google.common.base.CaseFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
@ -57,11 +52,11 @@ public class WebGeneratorCode {
|
|||
public static String resourceMapperPath = "D:\\MyFolder\\auth\\financial-web-server\\service\\src\\main\\resources\\mapper\\financial\\";
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Class<?> originalClass = DebtRepaymentPlan.class;
|
||||
Class<?> dtoClass = DebtRepaymentPlanDto.class;
|
||||
Class<?> addDtoClass = DebtRepaymentPlanAddDto.class;
|
||||
Class<?> updateDtoClass = DebtRepaymentPlanUpdateDto.class;
|
||||
Class<?> voClass = DebtRepaymentPlanVo.class;
|
||||
Class<?> originalClass = BudgetCategory.class;
|
||||
Class<?> dtoClass = BudgetCategoryDto.class;
|
||||
Class<?> addDtoClass = BudgetCategoryAddDto.class;
|
||||
Class<?> updateDtoClass = BudgetCategoryUpdateDto.class;
|
||||
Class<?> voClass = BudgetCategoryVo.class;
|
||||
|
||||
// 设置velocity资源加载器
|
||||
Properties prop = new Properties();
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
package cn.bunny.dao.dto.financial.budgetCategory;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@Schema(name = "BudgetCategoryAddDto对象", title = "预算分类添加", description = "预算分类添加")
|
||||
public class BudgetCategoryAddDto {
|
||||
|
||||
@Schema(name = "parentId", title = "父级id")
|
||||
@NotNull(message = "父级id不能为空")
|
||||
private Long parentId;
|
||||
|
||||
@Schema(name = "userId", title = "绑定的用户id")
|
||||
@NotNull(message = "债绑定的用户不能为空")
|
||||
private Long userId;
|
||||
|
||||
@Schema(name = "categoryName", title = "分类名称")
|
||||
@NotNull(message = "分类名称不能为空")
|
||||
@NotBlank(message = "分类名称不能为空")
|
||||
private String categoryName;
|
||||
|
||||
@Schema(name = "budgetName", title = "预算名称")
|
||||
@NotNull(message = "预算名称不能为空")
|
||||
@NotBlank(message = "预算名称不能为空")
|
||||
private String budgetName;
|
||||
|
||||
@Schema(name = "statusType", title = "完成状态")
|
||||
@NotNull(message = "完成状态不能为空")
|
||||
@NotBlank(message = "完成状态不能为空")
|
||||
private String statusType;
|
||||
|
||||
@Schema(name = "amount", title = "预算金额")
|
||||
@NotNull(message = "预算金额不能为空")
|
||||
private BigDecimal amount;
|
||||
|
||||
@Schema(name = "period", title = "预算周期")
|
||||
@NotNull(message = "预算周期不能为空")
|
||||
@NotBlank(message = "预算周期不能为空")
|
||||
private String period;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
package cn.bunny.dao.dto.financial.budgetCategory;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@Schema(name = "BudgetCategoryDto对象", title = "预算分类查询", description = "预算分类查询")
|
||||
public class BudgetCategoryDto {
|
||||
|
||||
@Schema(name = "parentId", title = "父级id")
|
||||
private Long parentId;
|
||||
|
||||
@Schema(name = "userId", title = "绑定的用户id")
|
||||
private Long userId;
|
||||
|
||||
@Schema(name = "categoryName", title = "分类名称")
|
||||
private String categoryName;
|
||||
|
||||
@Schema(name = "budgetName", title = "预算名称")
|
||||
private String budgetName;
|
||||
|
||||
@Schema(name = "statusType", title = "完成状态")
|
||||
private String statusType;
|
||||
|
||||
@Schema(name = "amount", title = "预算金额")
|
||||
private BigDecimal amount;
|
||||
|
||||
@Schema(name = "period", title = "预算周期")
|
||||
private String period;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
package cn.bunny.dao.dto.financial.budgetCategory;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@Schema(name = "BudgetCategoryUpdateDto对象", title = "预算分类更新", description = "预算分类更新")
|
||||
public class BudgetCategoryUpdateDto {
|
||||
|
||||
@Schema(name = "id", title = "主键")
|
||||
@NotNull(message = "id不能为空")
|
||||
private Long id;
|
||||
|
||||
@Schema(name = "parentId", title = "父级id")
|
||||
@NotNull(message = "父级id不能为空")
|
||||
private Long parentId;
|
||||
|
||||
@Schema(name = "userId", title = "绑定的用户id")
|
||||
@NotNull(message = "债绑定的用户不能为空")
|
||||
private Long userId;
|
||||
|
||||
@Schema(name = "categoryName", title = "分类名称")
|
||||
@NotNull(message = "分类名称不能为空")
|
||||
@NotBlank(message = "分类名称不能为空")
|
||||
private String categoryName;
|
||||
|
||||
@Schema(name = "budgetName", title = "预算名称")
|
||||
@NotNull(message = "预算名称不能为空")
|
||||
@NotBlank(message = "预算名称不能为空")
|
||||
private String budgetName;
|
||||
|
||||
@Schema(name = "statusType", title = "完成状态")
|
||||
@NotNull(message = "完成状态不能为空")
|
||||
@NotBlank(message = "完成状态不能为空")
|
||||
private String statusType;
|
||||
|
||||
@Schema(name = "amount", title = "预算金额")
|
||||
@NotNull(message = "预算金额不能为空")
|
||||
private BigDecimal amount;
|
||||
|
||||
@Schema(name = "period", title = "预算周期")
|
||||
@NotNull(message = "预算周期不能为空")
|
||||
@NotBlank(message = "预算周期不能为空")
|
||||
private String period;
|
||||
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package cn.bunny.dao.dto.financial.debtRepaymentPlan;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
|
@ -20,7 +21,7 @@ public class DebtRepaymentPlanUpdateDto {
|
|||
@Schema(name = "id", title = "主键")
|
||||
@NotNull(message = "id不能为空")
|
||||
private Long id;
|
||||
|
||||
|
||||
@Schema(name = "debtId", title = "债务ID")
|
||||
@NotNull(message = "债务不能为空")
|
||||
private Long debtId;
|
||||
|
@ -43,6 +44,7 @@ public class DebtRepaymentPlanUpdateDto {
|
|||
|
||||
@Schema(name = "paymentStatus", title = "还款状态")
|
||||
@NotNull(message = "还款状态不能为空")
|
||||
@NotBlank(message = "还款状态不能为空")
|
||||
private String paymentStatus;
|
||||
|
||||
}
|
|
@ -1,18 +1,14 @@
|
|||
package cn.bunny.dao.entity.financial;
|
||||
|
||||
import cn.bunny.dao.common.entity.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 预算分类表
|
||||
|
@ -25,28 +21,28 @@ import lombok.experimental.Accessors;
|
|||
@Setter
|
||||
@Accessors(chain = true)
|
||||
@TableName("t_budget_category")
|
||||
@ApiModel(value = "BudgetCategory对象", description = "预算分类表")
|
||||
@Schema(name = "BudgetCategory对象", title = "预算分类表", description = "预算分类表")
|
||||
public class BudgetCategory extends BaseEntity {
|
||||
|
||||
@ApiModelProperty("父级id")
|
||||
@Schema(name = "parentId", title = "父级id")
|
||||
private Long parentId;
|
||||
|
||||
@ApiModelProperty("绑定的用户id")
|
||||
@Schema(name = "userId", title = "绑定的用户id")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty("分类名称")
|
||||
@Schema(name = "categoryName", title = "分类名称")
|
||||
private String categoryName;
|
||||
|
||||
@ApiModelProperty("预算名称")
|
||||
@Schema(name = "budgetName", title = "预算名称")
|
||||
private String budgetName;
|
||||
|
||||
@ApiModelProperty("完成状态")
|
||||
@Schema(name = "statusType", title = "完成状态")
|
||||
private String statusType;
|
||||
|
||||
@ApiModelProperty("预算金额")
|
||||
@Schema(name = "amount", title = "预算金额")
|
||||
private BigDecimal amount;
|
||||
|
||||
@ApiModelProperty("预算周期")
|
||||
@Schema(name = "period", title = "预算周期")
|
||||
private String period;
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
package cn.bunny.dao.vo.financial;
|
||||
|
||||
import cn.bunny.dao.common.vo.BaseVo;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@Schema(name = "BudgetCategoryVo对象", title = "预算分类查询返回对象", description = "预算分类查询返回对象")
|
||||
public class BudgetCategoryVo extends BaseVo {
|
||||
|
||||
@Schema(name = "parentId", title = "父级id")
|
||||
private Long parentId;
|
||||
|
||||
@Schema(name = "userId", title = "绑定的用户id")
|
||||
private Long userId;
|
||||
|
||||
@Schema(name = "categoryName", title = "分类名称")
|
||||
private String categoryName;
|
||||
|
||||
@Schema(name = "budgetName", title = "预算名称")
|
||||
private String budgetName;
|
||||
|
||||
@Schema(name = "statusType", title = "完成状态")
|
||||
private String statusType;
|
||||
|
||||
@Schema(name = "amount", title = "预算金额")
|
||||
private BigDecimal amount;
|
||||
|
||||
@Schema(name = "period", title = "预算周期")
|
||||
private String period;
|
||||
|
||||
}
|
|
@ -1,18 +1,72 @@
|
|||
package cn.bunny.services.controller.financial;
|
||||
package cn.bunny.services.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import cn.bunny.dao.dto.financial.budgetCategory.BudgetCategoryAddDto;
|
||||
import cn.bunny.dao.dto.financial.budgetCategory.BudgetCategoryDto;
|
||||
import cn.bunny.dao.dto.financial.budgetCategory.BudgetCategoryUpdateDto;
|
||||
import cn.bunny.dao.entity.financial.BudgetCategory;
|
||||
import cn.bunny.dao.pojo.result.PageResult;
|
||||
import cn.bunny.dao.pojo.result.Result;
|
||||
import cn.bunny.dao.pojo.result.ResultCodeEnum;
|
||||
import cn.bunny.dao.vo.financial.BudgetCategoryVo;
|
||||
import cn.bunny.services.service.BudgetCategoryService;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 预算分类表 前端控制器
|
||||
* 预算分类表表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2024-11-11
|
||||
* @since 2024-11-11 15:36:57
|
||||
*/
|
||||
@Tag(name = "预算分类表", description = "预算分类表相关接口")
|
||||
@RestController
|
||||
@RequestMapping("/budgetCategory")
|
||||
@RequestMapping("admin/budgetCategory")
|
||||
public class BudgetCategoryController {
|
||||
|
||||
@Autowired
|
||||
private BudgetCategoryService budgetCategoryService;
|
||||
|
||||
@Operation(summary = "分页查询预算分类表", description = "分页查询预算分类表")
|
||||
@GetMapping("getBudgetCategoryList/{page}/{limit}")
|
||||
public Mono<Result<PageResult<BudgetCategoryVo>>> getBudgetCategoryList(
|
||||
@Parameter(name = "page", description = "当前页", required = true)
|
||||
@PathVariable("page") Integer page,
|
||||
@Parameter(name = "limit", description = "每页记录数", required = true)
|
||||
@PathVariable("limit") Integer limit,
|
||||
BudgetCategoryDto dto) {
|
||||
Page<BudgetCategory> pageParams = new Page<>(page, limit);
|
||||
PageResult<BudgetCategoryVo> pageResult = budgetCategoryService.getBudgetCategoryList(pageParams, dto);
|
||||
return Mono.just(Result.success(pageResult));
|
||||
}
|
||||
|
||||
@Operation(summary = "添加预算分类表", description = "添加预算分类表")
|
||||
@PostMapping("addBudgetCategory")
|
||||
public Mono<Result<String>> addBudgetCategory(@Valid @RequestBody BudgetCategoryAddDto dto) {
|
||||
budgetCategoryService.addBudgetCategory(dto);
|
||||
return Mono.just(Result.success(ResultCodeEnum.ADD_SUCCESS));
|
||||
}
|
||||
|
||||
@Operation(summary = "更新预算分类表", description = "更新预算分类表")
|
||||
@PutMapping("updateBudgetCategory")
|
||||
public Mono<Result<String>> updateBudgetCategory(@Valid @RequestBody BudgetCategoryUpdateDto dto) {
|
||||
budgetCategoryService.updateBudgetCategory(dto);
|
||||
return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS));
|
||||
}
|
||||
|
||||
@Operation(summary = "删除预算分类表", description = "删除预算分类表")
|
||||
@DeleteMapping("deleteBudgetCategory")
|
||||
public Mono<Result<String>> deleteBudgetCategory(@RequestBody List<Long> ids) {
|
||||
budgetCategoryService.deleteBudgetCategory(ids);
|
||||
return Mono.just(Result.success(ResultCodeEnum.DELETE_SUCCESS));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,15 @@
|
|||
package cn.bunny.services.mapper.financial;
|
||||
package cn.bunny.services.mapper;
|
||||
|
||||
import cn.bunny.dao.dto.financial.budgetCategory.BudgetCategoryDto;
|
||||
import cn.bunny.dao.entity.financial.BudgetCategory;
|
||||
import cn.bunny.dao.vo.financial.BudgetCategoryVo;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
@ -10,9 +17,24 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2024-11-11
|
||||
* @since 2024-11-11 15:36:57
|
||||
*/
|
||||
@Mapper
|
||||
public interface BudgetCategoryMapper extends BaseMapper<BudgetCategory> {
|
||||
|
||||
/**
|
||||
* * 分页查询预算分类表内容
|
||||
*
|
||||
* @param pageParams 预算分类表分页参数
|
||||
* @param dto 预算分类表查询表单
|
||||
* @return 预算分类表分页结果
|
||||
*/
|
||||
IPage<BudgetCategoryVo> selectListByPage(@Param("page") Page<BudgetCategory> pageParams, @Param("dto") BudgetCategoryDto dto);
|
||||
|
||||
/**
|
||||
* 物理删除预算分类表
|
||||
*
|
||||
* @param ids 删除 id 列表
|
||||
*/
|
||||
void deleteBatchIdsWithPhysics(List<Long> ids);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,16 @@
|
|||
package cn.bunny.services.service.financial;
|
||||
package cn.bunny.services.service;
|
||||
|
||||
import cn.bunny.dao.dto.financial.budgetCategory.BudgetCategoryAddDto;
|
||||
import cn.bunny.dao.dto.financial.budgetCategory.BudgetCategoryDto;
|
||||
import cn.bunny.dao.dto.financial.budgetCategory.BudgetCategoryUpdateDto;
|
||||
import cn.bunny.dao.entity.financial.BudgetCategory;
|
||||
import cn.bunny.dao.pojo.result.PageResult;
|
||||
import cn.bunny.dao.vo.financial.BudgetCategoryVo;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
@ -9,8 +18,35 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2024-11-11
|
||||
* @since 2024-11-11 15:36:57
|
||||
*/
|
||||
public interface BudgetCategoryService extends IService<BudgetCategory> {
|
||||
|
||||
/**
|
||||
* * 获取预算分类表列表
|
||||
*
|
||||
* @return 预算分类表返回列表
|
||||
*/
|
||||
PageResult<BudgetCategoryVo> getBudgetCategoryList(Page<BudgetCategory> pageParams, BudgetCategoryDto dto);
|
||||
|
||||
/**
|
||||
* * 添加预算分类表
|
||||
*
|
||||
* @param dto 添加表单
|
||||
*/
|
||||
void addBudgetCategory(@Valid BudgetCategoryAddDto dto);
|
||||
|
||||
/**
|
||||
* * 更新预算分类表
|
||||
*
|
||||
* @param dto 更新表单
|
||||
*/
|
||||
void updateBudgetCategory(@Valid BudgetCategoryUpdateDto dto);
|
||||
|
||||
/**
|
||||
* * 删除|批量删除预算分类表类型
|
||||
*
|
||||
* @param ids 删除id列表
|
||||
*/
|
||||
void deleteBudgetCategory(List<Long> ids);
|
||||
}
|
||||
|
|
|
@ -1,20 +1,85 @@
|
|||
package cn.bunny.services.service.financial.impl;
|
||||
package cn.bunny.services.service.impl;
|
||||
|
||||
import cn.bunny.dao.dto.financial.budgetCategory.BudgetCategoryAddDto;
|
||||
import cn.bunny.dao.dto.financial.budgetCategory.BudgetCategoryDto;
|
||||
import cn.bunny.dao.dto.financial.budgetCategory.BudgetCategoryUpdateDto;
|
||||
import cn.bunny.dao.entity.financial.BudgetCategory;
|
||||
import cn.bunny.services.mapper.financial.BudgetCategoryMapper;
|
||||
import cn.bunny.services.service.financial.BudgetCategoryService;
|
||||
import cn.bunny.dao.pojo.result.PageResult;
|
||||
import cn.bunny.dao.vo.financial.BudgetCategoryVo;
|
||||
import cn.bunny.services.mapper.BudgetCategoryMapper;
|
||||
import cn.bunny.services.service.BudgetCategoryService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 预算分类表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2024-11-11
|
||||
* @since 2024-11-11 15:36:57
|
||||
*/
|
||||
@Service
|
||||
public class BudgetCategoryServiceImpl extends ServiceImpl<BudgetCategoryMapper, BudgetCategory> implements BudgetCategoryService {
|
||||
|
||||
/**
|
||||
* * 预算分类表 服务实现类
|
||||
*
|
||||
* @param pageParams 预算分类表分页查询page对象
|
||||
* @param dto 预算分类表分页查询对象
|
||||
* @return 查询分页预算分类表返回对象
|
||||
*/
|
||||
@Override
|
||||
public PageResult<BudgetCategoryVo> getBudgetCategoryList(Page<BudgetCategory> pageParams, BudgetCategoryDto dto) {
|
||||
IPage<BudgetCategoryVo> page = baseMapper.selectListByPage(pageParams, dto);
|
||||
|
||||
return PageResult.<BudgetCategoryVo>builder()
|
||||
.list(page.getRecords())
|
||||
.pageNo(page.getCurrent())
|
||||
.pageSize(page.getSize())
|
||||
.total(page.getTotal())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加预算分类表
|
||||
*
|
||||
* @param dto 预算分类表添加
|
||||
*/
|
||||
@Override
|
||||
public void addBudgetCategory(@Valid BudgetCategoryAddDto dto) {
|
||||
// 保存数据
|
||||
BudgetCategory budgetCategory = new BudgetCategory();
|
||||
BeanUtils.copyProperties(dto, budgetCategory);
|
||||
save(budgetCategory);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新预算分类表
|
||||
*
|
||||
* @param dto 预算分类表更新
|
||||
*/
|
||||
@Override
|
||||
public void updateBudgetCategory(@Valid BudgetCategoryUpdateDto dto) {
|
||||
// 更新内容
|
||||
BudgetCategory budgetCategory = new BudgetCategory();
|
||||
BeanUtils.copyProperties(dto, budgetCategory);
|
||||
updateById(budgetCategory);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除|批量删除预算分类表
|
||||
*
|
||||
* @param ids 删除id列表
|
||||
*/
|
||||
@Override
|
||||
public void deleteBudgetCategory(List<Long> ids) {
|
||||
baseMapper.deleteBatchIdsWithPhysics(ids);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,27 +1,72 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.bunny.services.mapper.financial.BudgetCategoryMapper">
|
||||
<mapper namespace="cn.bunny.services.mapper.BudgetCategoryMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="cn.bunny.dao.entity.financial.BudgetCategory">
|
||||
<id column="id" property="id" />
|
||||
<result column="parent_id" property="parentId" />
|
||||
<result column="user_id" property="userId" />
|
||||
<result column="category_name" property="categoryName" />
|
||||
<result column="budget_name" property="budgetName" />
|
||||
<result column="status_type" property="statusType" />
|
||||
<result column="amount" property="amount" />
|
||||
<result column="period" property="period" />
|
||||
<result column="create_user" property="createUser" />
|
||||
<result column="create_time" property="createTime" />
|
||||
<result column="update_user" property="updateUser" />
|
||||
<result column="update_time" property="updateTime" />
|
||||
<result column="is_deleted" property="isDeleted" />
|
||||
<id column="id" property="id"/>
|
||||
<id column="create_time" property="createTime"/>
|
||||
<id column="update_time" property="updateTime"/>
|
||||
<id column="create_user" property="createUser"/>
|
||||
<id column="update_user" property="updateUser"/>
|
||||
<id column="is_deleted" property="isDeleted"/>
|
||||
<id column="parent_id" property="parentId"/>
|
||||
<id column="user_id" property="userId"/>
|
||||
<id column="category_name" property="categoryName"/>
|
||||
<id column="budget_name" property="budgetName"/>
|
||||
<id column="status_type" property="statusType"/>
|
||||
<id column="amount" property="amount"/>
|
||||
<id column="period" property="period"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, parent_id, user_id, category_name, budget_name, status_type, amount, period, create_user, create_time, update_user, update_time, is_deleted
|
||||
id, create_time, update_time, create_user, update_user, is_deleted, parent_id, user_id, category_name, budget_name, status_type, amount, period
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询预算分类表内容 -->
|
||||
<select id="selectListByPage" resultType="cn.bunny.dao.vo.financial.BudgetCategoryVo">
|
||||
select
|
||||
base.*,
|
||||
create_user.username as create_username,
|
||||
update_user.username as update_username
|
||||
from t_budget_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
|
||||
<if test="dto.parentId != null and dto.parentId != ''">
|
||||
and base.parent_id like CONCAT('%',#{dto.parentId},'%')
|
||||
</if>
|
||||
<if test="dto.userId != null and dto.userId != ''">
|
||||
and base.user_id like CONCAT('%',#{dto.userId},'%')
|
||||
</if>
|
||||
<if test="dto.categoryName != null and dto.categoryName != ''">
|
||||
and base.category_name like CONCAT('%',#{dto.categoryName},'%')
|
||||
</if>
|
||||
<if test="dto.budgetName != null and dto.budgetName != ''">
|
||||
and base.budget_name like CONCAT('%',#{dto.budgetName},'%')
|
||||
</if>
|
||||
<if test="dto.statusType != null and dto.statusType != ''">
|
||||
and base.status_type like CONCAT('%',#{dto.statusType},'%')
|
||||
</if>
|
||||
<if test="dto.amount != null and dto.amount != ''">
|
||||
and base.amount like CONCAT('%',#{dto.amount},'%')
|
||||
</if>
|
||||
<if test="dto.period != null and dto.period != ''">
|
||||
and base.period like CONCAT('%',#{dto.period},'%')
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!-- 物理删除预算分类表 -->
|
||||
<delete id="deleteBatchIdsWithPhysics">
|
||||
delete
|
||||
from t_budget_category
|
||||
where id in
|
||||
<foreach collection="ids" item="id" open="(" close=")" separator=",">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue