he2802 2 年之前
父节点
当前提交
466e49f90f

+ 99 - 0
zhongzheng-admin-saas/src/main/java/com/zhongzheng/controller/top/TopCostCategoryController.java

@@ -0,0 +1,99 @@
+package com.zhongzheng.controller.top;
+
+import java.util.List;
+import java.util.Arrays;
+
+import com.zhongzheng.modules.top.system.bo.TopCostCategoryAddBo;
+import com.zhongzheng.modules.top.system.bo.TopCostCategoryEditBo;
+import com.zhongzheng.modules.top.system.bo.TopCostCategoryQueryBo;
+import com.zhongzheng.modules.top.system.service.ITopCostCategoryService;
+import com.zhongzheng.modules.top.system.vo.TopCostCategoryVo;
+import lombok.RequiredArgsConstructor;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.zhongzheng.common.annotation.Log;
+import com.zhongzheng.common.core.controller.BaseController;
+import com.zhongzheng.common.core.domain.AjaxResult;
+import com.zhongzheng.common.enums.BusinessType;
+import com.zhongzheng.common.utils.poi.ExcelUtil;
+import com.zhongzheng.common.core.page.TableDataInfo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+/**
+ * 机构成本类别Controller
+ *
+ * @author ruoyi
+ * @date 2023-07-27
+ */
+@Api(value = "机构成本类别控制器", tags = {"机构成本类别管理"})
+@RequiredArgsConstructor(onConstructor_ = @Autowired)
+@RestController
+@RequestMapping("/top/category")
+public class TopCostCategoryController extends BaseController {
+
+    private final ITopCostCategoryService iTopCostCategoryService;
+
+    /**
+     * 查询机构成本类别列表
+     */
+    @ApiOperation("查询机构成本类别列表")
+    @PreAuthorize("@ss.hasPermi('system:category:list')")
+    @GetMapping("/list")
+    public TableDataInfo<TopCostCategoryVo> list(TopCostCategoryQueryBo bo) {
+        startPage();
+        List<TopCostCategoryVo> list = iTopCostCategoryService.queryList(bo);
+        return getDataTable(list);
+    }
+
+
+
+    /**
+     * 获取机构成本类别详细信息
+     */
+    @ApiOperation("获取机构成本类别详细信息")
+    @PreAuthorize("@ss.hasPermi('system:category:query')")
+    @GetMapping("/{categoryId}")
+    public AjaxResult<TopCostCategoryVo> getInfo(@PathVariable("categoryId" ) Long categoryId) {
+        return AjaxResult.success(iTopCostCategoryService.queryById(categoryId));
+    }
+
+    /**
+     * 新增机构成本类别
+     */
+    @ApiOperation("新增机构成本类别")
+    @PreAuthorize("@ss.hasPermi('system:category:add')")
+    @Log(title = "机构成本类别", businessType = BusinessType.INSERT)
+    @PostMapping()
+    public AjaxResult<Void> add(@RequestBody TopCostCategoryAddBo bo) {
+        return toAjax(iTopCostCategoryService.insertByAddBo(bo) ? 1 : 0);
+    }
+
+    /**
+     * 修改机构成本类别
+     */
+    @ApiOperation("修改机构成本类别")
+    @PreAuthorize("@ss.hasPermi('system:category:edit')")
+    @Log(title = "机构成本类别", businessType = BusinessType.UPDATE)
+    @PostMapping("/edit")
+    public AjaxResult<Void> edit(@RequestBody TopCostCategoryEditBo bo) {
+        return toAjax(iTopCostCategoryService.updateByEditBo(bo) ? 1 : 0);
+    }
+
+    @ApiOperation("机构成本类别批量删除")
+    @PreAuthorize("@ss.hasPermi('system:tp:edit')")
+    @Log(title = "机构成本类别批量删除", businessType = BusinessType.UPDATE)
+    @PostMapping("/deleteBatch")
+    public AjaxResult<Void> deleteBatch(@RequestBody TopCostCategoryEditBo bo) {
+        return toAjax(iTopCostCategoryService.deleteBatch(bo) ? 1 : 0);
+    }
+
+}

+ 0 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/vo/GoodsUserVo.java

@@ -403,7 +403,6 @@ public class GoodsUserVo {
 	@ApiModelProperty("学员姓名")
 	private String realName;
 
-
 	/** 学员编码 */
 	@Excel(name = "学员身份证")
 	@ApiModelProperty("学员身份证")

+ 33 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/top/system/bo/TopCostCategoryAddBo.java

@@ -0,0 +1,33 @@
+package com.zhongzheng.modules.top.system.bo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import java.util.Date;
+
+
+
+/**
+ * 机构成本类别添加对象 top_cost_category
+ *
+ * @author ruoyi
+ * @date 2023-07-27
+ */
+@Data
+@ApiModel("机构成本类别添加对象")
+public class TopCostCategoryAddBo {
+
+    /** 类别名 */
+    @ApiModelProperty("类别名")
+    private String categoryName;
+    /** 0 禁用 1启用 */
+    @ApiModelProperty("0 禁用 1启用")
+    private Integer status;
+    /** 添加时间 */
+    @ApiModelProperty("添加时间")
+    private Long createTime;
+    /** 修改时间 */
+    @ApiModelProperty("修改时间")
+    private Long updateTime;
+}

+ 38 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/top/system/bo/TopCostCategoryEditBo.java

@@ -0,0 +1,38 @@
+package com.zhongzheng.modules.top.system.bo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import java.util.Date;
+import java.util.List;
+
+
+/**
+ * 机构成本类别编辑对象 top_cost_category
+ *
+ * @author ruoyi
+ * @date 2023-07-27
+ */
+@Data
+@ApiModel("机构成本类别编辑对象")
+public class TopCostCategoryEditBo {
+
+    /** $column.columnComment */
+    @ApiModelProperty("$column.columnComment")
+    private Long categoryId;
+
+    /** 类别名 */
+    @ApiModelProperty("类别名")
+    private String categoryName;
+
+    /** 0 禁用 1启用 */
+    @ApiModelProperty("0 禁用 1启用")
+    private Integer status;
+
+    /** 修改时间 */
+    @ApiModelProperty("修改时间")
+    private Long updateTime;
+
+    private List<Long> categoryIds;
+}

+ 45 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/top/system/bo/TopCostCategoryQueryBo.java

@@ -0,0 +1,45 @@
+package com.zhongzheng.modules.top.system.bo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.Date;
+import java.util.Map;
+import java.util.HashMap;
+
+import com.zhongzheng.common.core.domain.BaseEntity;
+
+/**
+ * 机构成本类别分页查询对象 top_cost_category
+ *
+ * @author ruoyi
+ * @date 2023-07-27
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ApiModel("机构成本类别分页查询对象")
+public class TopCostCategoryQueryBo extends BaseEntity {
+
+	/** 分页大小 */
+	@ApiModelProperty("分页大小")
+	private Integer pageSize;
+	/** 当前页数 */
+	@ApiModelProperty("当前页数")
+	private Integer pageNum;
+	/** 排序列 */
+	@ApiModelProperty("排序列")
+	private String orderByColumn;
+	/** 排序的方向desc或者asc */
+	@ApiModelProperty(value = "排序的方向", example = "asc,desc")
+	private String isAsc;
+
+
+	/** 类别名 */
+	@ApiModelProperty("类别名")
+	private String categoryName;
+	/** 0 禁用 1启用 */
+	@ApiModelProperty("0 禁用 1启用")
+	private Integer status;
+}

+ 39 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/top/system/domain/TopCostCategory.java

@@ -0,0 +1,39 @@
+package com.zhongzheng.modules.top.system.domain;
+
+import com.baomidou.mybatisplus.annotation.*;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+import java.io.Serializable;
+import java.util.Date;
+import java.math.BigDecimal;
+import com.zhongzheng.common.annotation.Excel;
+
+/**
+ * 机构成本类别对象 top_cost_category
+ *
+ * @author ruoyi
+ * @date 2023-07-27
+ */
+@Data
+@NoArgsConstructor
+@Accessors(chain = true)
+@TableName("top_cost_category")
+public class TopCostCategory implements Serializable {
+
+private static final long serialVersionUID=1L;
+
+    /** $column.columnComment */
+    @TableId(value = "category_id")
+    private Long categoryId;
+    /** 类别名 */
+    private String categoryName;
+    /** 0 禁用 1启用 */
+    private Integer status;
+    /** 添加时间 */
+    @TableField(fill = FieldFill.INSERT)
+    private Long createTime;
+    /** 修改时间 */
+    @TableField(fill = FieldFill.INSERT_UPDATE)
+    private Long updateTime;
+}

+ 15 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/top/system/mapper/TopCostCategoryMapper.java

@@ -0,0 +1,15 @@
+package com.zhongzheng.modules.top.system.mapper;
+
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.zhongzheng.modules.top.system.domain.TopCostCategory;
+
+/**
+ * 机构成本类别Mapper接口
+ *
+ * @author ruoyi
+ * @date 2023-07-27
+ */
+public interface TopCostCategoryMapper extends BaseMapper<TopCostCategory> {
+
+}

+ 56 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/top/system/service/ITopCostCategoryService.java

@@ -0,0 +1,56 @@
+package com.zhongzheng.modules.top.system.service;
+
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.zhongzheng.modules.top.system.bo.TopCostCategoryAddBo;
+import com.zhongzheng.modules.top.system.bo.TopCostCategoryEditBo;
+import com.zhongzheng.modules.top.system.bo.TopCostCategoryQueryBo;
+import com.zhongzheng.modules.top.system.bo.TopInstCategoryEditBo;
+import com.zhongzheng.modules.top.system.domain.TopCostCategory;
+import com.zhongzheng.modules.top.system.vo.TopCostCategoryVo;
+
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * 机构成本类别Service接口
+ *
+ * @author ruoyi
+ * @date 2023-07-27
+ */
+public interface ITopCostCategoryService extends IService<TopCostCategory> {
+	/**
+	 * 查询单个
+	 * @return
+	 */
+	TopCostCategoryVo queryById(Long categoryId);
+
+	/**
+	 * 查询列表
+	 */
+	List<TopCostCategoryVo> queryList(TopCostCategoryQueryBo bo);
+
+	/**
+	 * 根据新增业务对象插入机构成本类别
+	 * @param bo 机构成本类别新增业务对象
+	 * @return
+	 */
+	Boolean insertByAddBo(TopCostCategoryAddBo bo);
+
+	/**
+	 * 根据编辑业务对象修改机构成本类别
+	 * @param bo 机构成本类别编辑业务对象
+	 * @return
+	 */
+	Boolean updateByEditBo(TopCostCategoryEditBo bo);
+
+	/**
+	 * 校验并删除数据
+	 * @param ids 主键集合
+	 * @param isValid 是否校验,true-删除前校验,false-不校验
+	 * @return
+	 */
+	Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
+
+	Boolean deleteBatch(TopCostCategoryEditBo bo);
+}

+ 153 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/top/system/service/impl/TopCostCategoryServiceImpl.java

@@ -0,0 +1,153 @@
+package com.zhongzheng.modules.top.system.service.impl;
+
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.lang.Validator;
+import cn.hutool.core.util.StrUtil;
+import com.zhongzheng.common.exception.CustomException;
+import com.zhongzheng.common.utils.DateUtils;
+import com.zhongzheng.modules.top.financial.domain.TopCostInstTpItem;
+import com.zhongzheng.modules.top.financial.domain.TopCostTpItem;
+import com.zhongzheng.modules.top.financial.service.ITopCostInstTpItemService;
+import com.zhongzheng.modules.top.financial.service.ITopCostTpItemService;
+import com.zhongzheng.modules.top.system.bo.TopCostCategoryAddBo;
+import com.zhongzheng.modules.top.system.bo.TopCostCategoryEditBo;
+import com.zhongzheng.modules.top.system.bo.TopCostCategoryQueryBo;
+import com.zhongzheng.modules.top.system.domain.TopCostCategory;
+import com.zhongzheng.modules.top.system.domain.TopInstCategory;
+import com.zhongzheng.modules.top.system.mapper.TopCostCategoryMapper;
+import com.zhongzheng.modules.top.system.service.ITopCostCategoryService;
+import com.zhongzheng.modules.top.system.vo.TopCostCategoryVo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.github.pagehelper.Page;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * 机构成本类别Service业务层处理
+ *
+ * @author ruoyi
+ * @date 2023-07-27
+ */
+@Service
+public class TopCostCategoryServiceImpl extends ServiceImpl<TopCostCategoryMapper, TopCostCategory> implements ITopCostCategoryService {
+
+    @Autowired
+    private ITopCostTpItemService iTopCostTpItemService;
+
+    @Override
+    public TopCostCategoryVo queryById(Long categoryId){
+        TopCostCategory db = this.baseMapper.selectById(categoryId);
+        return BeanUtil.toBean(db, TopCostCategoryVo.class);
+    }
+
+    @Override
+    public List<TopCostCategoryVo> queryList(TopCostCategoryQueryBo bo) {
+        LambdaQueryWrapper<TopCostCategory> lqw = Wrappers.lambdaQuery();
+        lqw.like(StrUtil.isNotBlank(bo.getCategoryName()), TopCostCategory::getCategoryName, bo.getCategoryName());
+        lqw.eq(bo.getStatus() != null, TopCostCategory::getStatus, bo.getStatus());
+        return entity2Vo(this.list(lqw));
+    }
+
+    /**
+    * 实体类转化成视图对象
+    *
+    * @param collection 实体类集合
+    * @return
+    */
+    private List<TopCostCategoryVo> entity2Vo(Collection<TopCostCategory> collection) {
+        List<TopCostCategoryVo> voList = collection.stream()
+                .map(any -> BeanUtil.toBean(any, TopCostCategoryVo.class))
+                .collect(Collectors.toList());
+        if (collection instanceof Page) {
+            Page<TopCostCategory> page = (Page<TopCostCategory>)collection;
+            Page<TopCostCategoryVo> pageVo = new Page<>();
+            BeanUtil.copyProperties(page,pageVo);
+            pageVo.addAll(voList);
+            voList = pageVo;
+        }
+        return voList;
+    }
+
+    @Override
+    public Boolean insertByAddBo(TopCostCategoryAddBo bo) {
+        TopCostCategory add = BeanUtil.toBean(bo, TopCostCategory.class);
+        validEntityBeforeSave(add);
+        add.setCreateTime(DateUtils.getNowTime());
+        add.setUpdateTime(DateUtils.getNowTime());
+        return this.save(add);
+    }
+
+    @Override
+    public Boolean updateByEditBo(TopCostCategoryEditBo bo) {
+        TopCostCategory update = BeanUtil.toBean(bo, TopCostCategory.class);
+        validEntityBeforeSave(update);
+        update.setUpdateTime(DateUtils.getNowTime());
+        return this.updateById(update);
+    }
+
+    /**
+     * 保存前的数据校验
+     *
+     * @param entity 实体类数据
+     */
+    private void validEntityBeforeSave(TopCostCategory entity){
+        //TODO 做一些数据校验,如唯一约束
+        if(Validator.isNotEmpty(entity.getStatus())&&entity.getStatus()==-1){
+            if(iTopCostTpItemService.count(new LambdaQueryWrapper<TopCostTpItem>()
+                    .eq(TopCostTpItem::getItemCategory, entity.getCategoryId())
+                    .ne(TopCostTpItem::getStatus, -1))>0){
+                throw new CustomException("该分类已被使用,无法编辑和删除");
+            }
+        }else{
+            if(checkNameUnique(entity)){
+                throw new CustomException("名称重复");
+            }
+        }
+
+    }
+
+    @Override
+    public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
+        if(isValid){
+            //TODO 做一些业务上的校验,判断是否需要校验
+        }
+        return this.removeByIds(ids);
+    }
+
+    @Override
+    public Boolean deleteBatch(TopCostCategoryEditBo bo) {
+        for(Long id : bo.getCategoryIds()){
+            TopCostCategoryEditBo update = new TopCostCategoryEditBo();
+            update.setCategoryId(id);
+            update.setStatus(-1);
+            this.updateByEditBo(update);
+        }
+        return true;
+    }
+
+    private boolean checkNameUnique(TopCostCategory entity) {
+        if(Validator.isEmpty(entity.getCategoryName())){
+            return true;
+        }
+        TopCostCategory info = getOne(new LambdaQueryWrapper<TopCostCategory>()
+                .eq(TopCostCategory::getCategoryName,entity.getCategoryName()).ne(TopCostCategory::getStatus,-1)
+                .last("limit 1"));
+        if (Validator.isNotNull(info)) {
+            if(Validator.isNotEmpty(entity.getCategoryId())){
+                if(entity.getCategoryId().longValue() != info.getCategoryId().longValue()){
+                    return true;
+                }
+            }else{
+                return true;
+            }
+        }
+        return false;
+    }
+}

+ 13 - 9
zhongzheng-system/src/main/java/com/zhongzheng/modules/top/system/service/impl/TopInstCategoryServiceImpl.java

@@ -99,14 +99,18 @@ public class TopInstCategoryServiceImpl extends ServiceImpl<TopInstCategoryMappe
      */
     private void validEntityBeforeSave(TopInstCategory entity){
         //TODO 做一些数据校验,如唯一约束
-        if(iTopCostInstTpItemService.count(new LambdaQueryWrapper<TopCostInstTpItem>()
-                .eq(TopCostInstTpItem::getCostCatId, entity.getCostCatId())
-                .ne(TopCostInstTpItem::getStatus, -1))>0){
-            throw new CustomException("该分类已被使用,无法编辑和删除");
-        }
-        if(checkNameUnique(entity)){
-            throw new CustomException("名称重复");
+        if(Validator.isNotEmpty(entity.getStatus())&&entity.getStatus()==-1){
+            if(iTopCostInstTpItemService.count(new LambdaQueryWrapper<TopCostInstTpItem>()
+                    .eq(TopCostInstTpItem::getCostCatId, entity.getCostCatId())
+                    .ne(TopCostInstTpItem::getStatus, -1))>0){
+                throw new CustomException("该分类已被使用,无法编辑和删除");
+            }
+        }else{
+            if(checkNameUnique(entity)){
+                throw new CustomException("名称重复");
+            }
         }
+
     }
 
     @Override
@@ -120,10 +124,10 @@ public class TopInstCategoryServiceImpl extends ServiceImpl<TopInstCategoryMappe
     @Override
     public Boolean deleteBatch(TopInstCategoryEditBo bo) {
         for(Long id : bo.getCostCatIds()){
-            TopInstCategory update = new TopInstCategory();
+            TopInstCategoryEditBo update = new TopInstCategoryEditBo();
             update.setCostCatId(id);
             update.setStatus(-1);
-            this.updateById(update);
+            this.updateByEditBo(update);
         }
         return true;
     }

+ 35 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/top/system/vo/TopCostCategoryVo.java

@@ -0,0 +1,35 @@
+package com.zhongzheng.modules.top.system.vo;
+
+import com.zhongzheng.common.annotation.Excel;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import java.util.Date;
+
+
+
+/**
+ * 机构成本类别视图对象 mall_package
+ *
+ * @author ruoyi
+ * @date 2023-07-27
+ */
+@Data
+@ApiModel("机构成本类别视图对象")
+public class TopCostCategoryVo {
+	private static final long serialVersionUID = 1L;
+
+	/** $pkColumn.columnComment */
+	@ApiModelProperty("$pkColumn.columnComment")
+	private Long categoryId;
+
+	/** 类别名 */
+	@Excel(name = "类别名")
+	@ApiModelProperty("类别名")
+	private String categoryName;
+	/** 0 禁用 1启用 */
+	@Excel(name = "0 禁用 1启用")
+	@ApiModelProperty("0 禁用 1启用")
+	private Integer status;
+}

+ 16 - 0
zhongzheng-system/src/main/resources/mapper/modules/top/TopCostCategoryMapper.xml

@@ -0,0 +1,16 @@
+<?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="com.zhongzheng.modules.top.system.mapper.TopCostCategoryMapper">
+
+    <resultMap type="com.zhongzheng.modules.top.system.domain.TopCostCategory" id="TopCostCategoryResult">
+        <result property="categoryId" column="category_id"/>
+        <result property="categoryName" column="category_name"/>
+        <result property="status" column="status"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateTime" column="update_time"/>
+    </resultMap>
+
+
+</mapper>