ソースを参照

卡类别管理代码提交

huzhe 1 年間 前
コミット
bcc438edb5

+ 106 - 0
ruoyi-modules/ruoyi-backstage/src/main/java/org/dromara/backstage/basics/controller/PtCardtypeController.java

@@ -0,0 +1,106 @@
+package org.dromara.backstage.basics.controller;
+
+import java.util.List;
+
+import lombok.RequiredArgsConstructor;
+import jakarta.servlet.http.HttpServletResponse;
+import jakarta.validation.constraints.*;
+import cn.dev33.satoken.annotation.SaCheckPermission;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.validation.annotation.Validated;
+import org.dromara.common.idempotent.annotation.RepeatSubmit;
+import org.dromara.common.log.annotation.Log;
+import org.dromara.common.web.core.BaseController;
+import org.dromara.common.mybatis.core.page.PageQuery;
+import org.dromara.common.core.domain.R;
+import org.dromara.common.core.validate.AddGroup;
+import org.dromara.common.core.validate.EditGroup;
+import org.dromara.common.log.enums.BusinessType;
+import org.dromara.common.excel.utils.ExcelUtil;
+import org.dromara.backstage.basics.domain.vo.PtCardtypeVo;
+import org.dromara.backstage.basics.domain.bo.PtCardtypeBo;
+import org.dromara.backstage.basics.service.IPtCardtypeService;
+import org.dromara.common.mybatis.core.page.TableDataInfo;
+
+/**
+ * 卡片类别
+ * 前端访问路由地址为:/basicParameter/ptCardtype
+ *
+ * @author YZ
+ * @date 2024-08-02
+ */
+@Validated
+@RequiredArgsConstructor
+@RestController
+@RequestMapping("/basicParameter/ptCardtype")
+public class PtCardtypeController extends BaseController {
+
+    private final IPtCardtypeService ptCardtypeService;
+
+    /**
+     * 查询卡片类别列表
+     */
+    @SaCheckPermission("basicParameter:ptCardtype:list")
+    @GetMapping("/list")
+    public TableDataInfo<PtCardtypeVo> list(PtCardtypeBo bo, PageQuery pageQuery) {
+        return ptCardtypeService.queryPageList(bo, pageQuery);
+    }
+
+    /**
+     * 导出卡片类别列表
+     */
+    @SaCheckPermission("basicParameter:ptCardtype:export")
+    @Log(title = "卡片类别", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(PtCardtypeBo bo, HttpServletResponse response) {
+        List<PtCardtypeVo> list = ptCardtypeService.queryList(bo);
+        ExcelUtil.exportExcel(list, "卡片类别", PtCardtypeVo.class, response);
+    }
+
+    /**
+     * 获取卡片类别详细信息
+     *
+     * @param typeId 主键
+     */
+    @SaCheckPermission("basicParameter:ptCardtype:query")
+    @GetMapping("/{typeId}")
+    public R<PtCardtypeVo> getInfo(@NotNull(message = "主键不能为空")
+                                     @PathVariable Long typeId) {
+        return R.ok(ptCardtypeService.queryById(typeId));
+    }
+
+    /**
+     * 新增卡片类别
+     */
+    @SaCheckPermission("basicParameter:ptCardtype:add")
+    @Log(title = "卡片类别", businessType = BusinessType.INSERT)
+    @RepeatSubmit()
+    @PostMapping()
+    public R<Void> add(@Validated(AddGroup.class) @RequestBody PtCardtypeBo bo) {
+        return toAjax(ptCardtypeService.insertByBo(bo));
+    }
+
+    /**
+     * 修改卡片类别
+     */
+    @SaCheckPermission("basicParameter:ptCardtype:edit")
+    @Log(title = "卡片类别", businessType = BusinessType.UPDATE)
+    @RepeatSubmit()
+    @PutMapping()
+    public R<Void> edit(@Validated(EditGroup.class) @RequestBody PtCardtypeBo bo) {
+        return toAjax(ptCardtypeService.updateByBo(bo));
+    }
+
+    /**
+     * 删除卡片类别
+     *
+     * @param typeIds 主键串
+     */
+    @SaCheckPermission("basicParameter:ptCardtype:remove")
+    @Log(title = "卡片类别", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{typeIds}")
+    public R<Void> remove(@NotEmpty(message = "主键不能为空")
+                          @PathVariable Long[] typeIds) {
+        return toAjax(ptCardtypeService.deleteWithValidByIds(List.of(typeIds), true));
+    }
+}

+ 72 - 0
ruoyi-modules/ruoyi-backstage/src/main/java/org/dromara/backstage/basics/domain/PtCardtype.java

@@ -0,0 +1,72 @@
+package org.dromara.backstage.basics.domain;
+
+import org.dromara.common.tenant.core.TenantEntity;
+import com.baomidou.mybatisplus.annotation.*;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serial;
+
+/**
+ * 卡片类别对象 t_pt_cardType
+ *
+ * @author YZ
+ * @date 2024-08-02
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@TableName("t_pt_cardType")
+public class PtCardtype extends TenantEntity {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * ID
+     */
+    @TableId(value = "type_id")
+    private Long typeId;
+
+    /**
+     * 卡类别
+     */
+    private String typeName;
+
+    /**
+     * 管理费
+     */
+    private Long commissionCharge;
+
+    /**
+     * 押金
+     */
+    private Long deposit;
+
+    /**
+     * 工本费
+     */
+    private Long productCost;
+
+    /**
+     * 折旧费
+     */
+    private Long depreciation;
+
+    /**
+     * 状态
+     */
+    private String status;
+
+    /**
+     * 类别说明
+     */
+    private String typeNotes;
+
+    /**
+     * 删除标志
+     */
+    @TableLogic
+    private String delFlag;
+
+
+}

+ 70 - 0
ruoyi-modules/ruoyi-backstage/src/main/java/org/dromara/backstage/basics/domain/bo/PtCardtypeBo.java

@@ -0,0 +1,70 @@
+package org.dromara.backstage.basics.domain.bo;
+
+import org.dromara.backstage.basics.domain.PtCardtype;
+import org.dromara.common.mybatis.core.domain.BaseEntity;
+import org.dromara.common.core.validate.AddGroup;
+import org.dromara.common.core.validate.EditGroup;
+import io.github.linpeilie.annotations.AutoMapper;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import jakarta.validation.constraints.*;
+
+/**
+ * 卡片类别业务对象 t_pt_cardType
+ *
+ * @author YZ
+ * @date 2024-08-02
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@AutoMapper(target = PtCardtype.class, reverseConvertGenerate = false)
+public class PtCardtypeBo extends BaseEntity {
+
+    /**
+     * ID
+     */
+    private Long typeId;
+
+    /**
+     * 卡类别
+     */
+    @NotBlank(message = "卡类别不能为空", groups = { AddGroup.class, EditGroup.class })
+    private String typeName;
+
+    /**
+     * 管理费
+     */
+    @NotNull(message = "管理费不能为空", groups = { AddGroup.class, EditGroup.class })
+    private Long commissionCharge;
+
+    /**
+     * 押金
+     */
+    @NotNull(message = "押金不能为空", groups = { AddGroup.class, EditGroup.class })
+    private Long deposit;
+
+    /**
+     * 工本费
+     */
+    @NotNull(message = "工本费不能为空", groups = { AddGroup.class, EditGroup.class })
+    private Long productCost;
+
+    /**
+     * 折旧费
+     */
+    @NotNull(message = "折旧费不能为空", groups = { AddGroup.class, EditGroup.class })
+    private Long depreciation;
+
+    /**
+     * 状态
+     */
+    @NotBlank(message = "状态不能为空", groups = { AddGroup.class, EditGroup.class })
+    private String status;
+
+    /**
+     * 类别说明
+     */
+    private String typeNotes;
+
+
+}

+ 81 - 0
ruoyi-modules/ruoyi-backstage/src/main/java/org/dromara/backstage/basics/domain/vo/PtCardtypeVo.java

@@ -0,0 +1,81 @@
+package org.dromara.backstage.basics.domain.vo;
+
+import org.dromara.backstage.basics.domain.PtCardtype;
+import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
+import com.alibaba.excel.annotation.ExcelProperty;
+import org.dromara.common.excel.annotation.ExcelDictFormat;
+import org.dromara.common.excel.convert.ExcelDictConvert;
+import io.github.linpeilie.annotations.AutoMapper;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.util.Date;
+
+
+
+/**
+ * 卡片类别视图对象 t_pt_cardType
+ *
+ * @author YZ
+ * @date 2024-08-02
+ */
+@Data
+@ExcelIgnoreUnannotated
+@AutoMapper(target = PtCardtype.class)
+public class PtCardtypeVo implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * ID
+     */
+    @ExcelProperty(value = "ID")
+    private Long typeId;
+
+    /**
+     * 卡类别
+     */
+    @ExcelProperty(value = "卡类别")
+    private String typeName;
+
+    /**
+     * 管理费
+     */
+    @ExcelProperty(value = "管理费")
+    private Long commissionCharge;
+
+    /**
+     * 押金
+     */
+    @ExcelProperty(value = "押金")
+    private Long deposit;
+
+    /**
+     * 工本费
+     */
+    @ExcelProperty(value = "工本费")
+    private Long productCost;
+
+    /**
+     * 折旧费
+     */
+    @ExcelProperty(value = "折旧费")
+    private Long depreciation;
+
+    /**
+     * 状态
+     */
+    @ExcelProperty(value = "状态", converter = ExcelDictConvert.class)
+    @ExcelDictFormat(dictType = "sys_normal_disable")
+    private String status;
+
+    /**
+     * 类别说明
+     */
+    @ExcelProperty(value = "类别说明")
+    private String typeNotes;
+
+
+}

+ 15 - 0
ruoyi-modules/ruoyi-backstage/src/main/java/org/dromara/backstage/basics/mapper/PtCardtypeMapper.java

@@ -0,0 +1,15 @@
+package org.dromara.backstage.basics.mapper;
+
+import org.dromara.backstage.basics.domain.PtCardtype;
+import org.dromara.backstage.basics.domain.vo.PtCardtypeVo;
+import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
+
+/**
+ * 卡片类别Mapper接口
+ *
+ * @author YZ
+ * @date 2024-08-02
+ */
+public interface PtCardtypeMapper extends BaseMapperPlus<PtCardtype, PtCardtypeVo> {
+
+}

+ 69 - 0
ruoyi-modules/ruoyi-backstage/src/main/java/org/dromara/backstage/basics/service/IPtCardtypeService.java

@@ -0,0 +1,69 @@
+package org.dromara.backstage.basics.service;
+
+import org.dromara.backstage.basics.domain.PtCardtype;
+import org.dromara.backstage.basics.domain.vo.PtCardtypeVo;
+import org.dromara.backstage.basics.domain.bo.PtCardtypeBo;
+import org.dromara.common.mybatis.core.page.TableDataInfo;
+import org.dromara.common.mybatis.core.page.PageQuery;
+
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * 卡片类别Service接口
+ *
+ * @author YZ
+ * @date 2024-08-02
+ */
+public interface IPtCardtypeService {
+
+    /**
+     * 查询卡片类别
+     *
+     * @param typeId 主键
+     * @return 卡片类别
+     */
+    PtCardtypeVo queryById(Long typeId);
+
+    /**
+     * 分页查询卡片类别列表
+     *
+     * @param bo        查询条件
+     * @param pageQuery 分页参数
+     * @return 卡片类别分页列表
+     */
+    TableDataInfo<PtCardtypeVo> queryPageList(PtCardtypeBo bo, PageQuery pageQuery);
+
+    /**
+     * 查询符合条件的卡片类别列表
+     *
+     * @param bo 查询条件
+     * @return 卡片类别列表
+     */
+    List<PtCardtypeVo> queryList(PtCardtypeBo bo);
+
+    /**
+     * 新增卡片类别
+     *
+     * @param bo 卡片类别
+     * @return 是否新增成功
+     */
+    Boolean insertByBo(PtCardtypeBo bo);
+
+    /**
+     * 修改卡片类别
+     *
+     * @param bo 卡片类别
+     * @return 是否修改成功
+     */
+    Boolean updateByBo(PtCardtypeBo bo);
+
+    /**
+     * 校验并批量删除卡片类别信息
+     *
+     * @param ids     待删除的主键集合
+     * @param isValid 是否进行有效性校验
+     * @return 是否删除成功
+     */
+    Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
+}

+ 130 - 0
ruoyi-modules/ruoyi-backstage/src/main/java/org/dromara/backstage/basics/service/impl/PtCardtypeServiceImpl.java

@@ -0,0 +1,130 @@
+package org.dromara.backstage.basics.service.impl;
+
+import org.dromara.common.core.utils.MapstructUtils;
+import org.dromara.common.core.utils.StringUtils;
+import org.dromara.common.mybatis.core.page.TableDataInfo;
+import org.dromara.common.mybatis.core.page.PageQuery;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Service;
+import org.dromara.backstage.basics.domain.bo.PtCardtypeBo;
+import org.dromara.backstage.basics.domain.vo.PtCardtypeVo;
+import org.dromara.backstage.basics.domain.PtCardtype;
+import org.dromara.backstage.basics.mapper.PtCardtypeMapper;
+import org.dromara.backstage.basics.service.IPtCardtypeService;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Collection;
+
+/**
+ * 卡片类别Service业务层处理
+ *
+ * @author YZ
+ * @date 2024-08-02
+ */
+@RequiredArgsConstructor
+@Service
+public class PtCardtypeServiceImpl implements IPtCardtypeService {
+
+    private final PtCardtypeMapper baseMapper;
+
+    /**
+     * 查询卡片类别
+     *
+     * @param typeId 主键
+     * @return 卡片类别
+     */
+    @Override
+    public PtCardtypeVo queryById(Long typeId){
+        return baseMapper.selectVoById(typeId);
+    }
+
+    /**
+     * 分页查询卡片类别列表
+     *
+     * @param bo        查询条件
+     * @param pageQuery 分页参数
+     * @return 卡片类别分页列表
+     */
+    @Override
+    public TableDataInfo<PtCardtypeVo> queryPageList(PtCardtypeBo bo, PageQuery pageQuery) {
+        LambdaQueryWrapper<PtCardtype> lqw = buildQueryWrapper(bo);
+        Page<PtCardtypeVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
+        return TableDataInfo.build(result);
+    }
+
+    /**
+     * 查询符合条件的卡片类别列表
+     *
+     * @param bo 查询条件
+     * @return 卡片类别列表
+     */
+    @Override
+    public List<PtCardtypeVo> queryList(PtCardtypeBo bo) {
+        LambdaQueryWrapper<PtCardtype> lqw = buildQueryWrapper(bo);
+        return baseMapper.selectVoList(lqw);
+    }
+
+    private LambdaQueryWrapper<PtCardtype> buildQueryWrapper(PtCardtypeBo bo) {
+        Map<String, Object> params = bo.getParams();
+        LambdaQueryWrapper<PtCardtype> lqw = Wrappers.lambdaQuery();
+        lqw.like(StringUtils.isNotBlank(bo.getTypeName()), PtCardtype::getTypeName, bo.getTypeName());
+        lqw.eq(StringUtils.isNotBlank(bo.getStatus()), PtCardtype::getStatus, bo.getStatus());
+        return lqw;
+    }
+
+    /**
+     * 新增卡片类别
+     *
+     * @param bo 卡片类别
+     * @return 是否新增成功
+     */
+    @Override
+    public Boolean insertByBo(PtCardtypeBo bo) {
+        PtCardtype add = MapstructUtils.convert(bo, PtCardtype.class);
+        validEntityBeforeSave(add);
+        boolean flag = baseMapper.insert(add) > 0;
+        if (flag) {
+            bo.setTypeId(add.getTypeId());
+        }
+        return flag;
+    }
+
+    /**
+     * 修改卡片类别
+     *
+     * @param bo 卡片类别
+     * @return 是否修改成功
+     */
+    @Override
+    public Boolean updateByBo(PtCardtypeBo bo) {
+        PtCardtype update = MapstructUtils.convert(bo, PtCardtype.class);
+        validEntityBeforeSave(update);
+        return baseMapper.updateById(update) > 0;
+    }
+
+    /**
+     * 保存前的数据校验
+     */
+    private void validEntityBeforeSave(PtCardtype entity){
+        //TODO 做一些数据校验,如唯一约束
+    }
+
+    /**
+     * 校验并批量删除卡片类别信息
+     *
+     * @param ids     待删除的主键集合
+     * @param isValid 是否进行有效性校验
+     * @return 是否删除成功
+     */
+    @Override
+    public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
+        if(isValid){
+            //TODO 做一些业务上的校验,判断是否需要校验
+        }
+        return baseMapper.deleteByIds(ids) > 0;
+    }
+}

+ 24 - 0
ruoyi-modules/ruoyi-backstage/src/main/resources/mapper/basicParameter/PtCardtypeMapper.xml

@@ -0,0 +1,24 @@
+<?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="org.dromara.backstage.basics.mapper.PtCardtypeMapper">
+
+    <resultMap type="org.dromara.backstage.basics.domain.PtCardtype" id="PtCardtypeResult">
+            <result property="typeId"    column="type_id"    />
+            <result property="tenantId"    column="tenant_id"    />
+            <result property="typeName"    column="type_name"    />
+            <result property="commissionCharge"    column="commission_Charge"    />
+            <result property="deposit"    column="deposit"    />
+            <result property="productCost"    column="product_cost"    />
+            <result property="depreciation"    column="depreciation"    />
+            <result property="status"    column="status"    />
+            <result property="typeNotes"    column="type_Notes"    />
+            <result property="delFlag"    column="del_flag"    />
+            <result property="createDept"    column="create_dept"    />
+            <result property="createBy"    column="create_by"    />
+            <result property="createTime"    column="create_time"    />
+            <result property="updateBy"    column="update_by"    />
+            <result property="updateTime"    column="update_time"    />
+    </resultMap>
+</mapper>