jtoms 4 년 전
부모
커밋
a6134c3423

+ 47 - 0
src/main/java/com/zhiqiyun/open/core/enmus/ExtendColumnFieldType.java

@@ -0,0 +1,47 @@
+package com.zhiqiyun.open.core.enmus;
+
+
+public enum ExtendColumnFieldType implements IBaseEnum {
+    /**
+     *
+     */
+    string(1, "文本"),
+    number(2, "数字"),
+    bool(3, "布尔"),
+    bstring(4, "多行文本"),
+    radio(5, "单选框"),
+    checkbox(6, "多选框"),
+    select(7, "下拉选择");
+
+    private final int value;
+    private final String text;
+
+    ExtendColumnFieldType(int value, String text) {
+        this.value = value;
+        this.text = text;
+    }
+
+    public static ExtendColumnFieldType valueOf(int value) {
+        ExtendColumnFieldType[] values = ExtendColumnFieldType.values();
+        for (ExtendColumnFieldType type : values) {
+            if (type.value == value) {
+                return type;
+            }
+        }
+        return null;
+    }
+
+
+    public String getText() {
+        return text;
+    }
+
+    public Integer getValue() {
+        return value;
+    }
+
+    @Override
+    public String getName() {
+        return this.name();
+    }
+}

+ 9 - 0
src/main/java/com/zhiqiyun/open/core/mapper/base/CategoryBaseExtendColumnMapper.java

@@ -0,0 +1,9 @@
+package com.zhiqiyun.open.core.mapper.base;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.zhiqiyun.open.core.models.base.CategoryBaseExtendColumn;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface CategoryBaseExtendColumnMapper extends BaseMapper<CategoryBaseExtendColumn> {
+}

+ 9 - 0
src/main/java/com/zhiqiyun/open/core/mapper/base/CategoryBaseMapper.java

@@ -0,0 +1,9 @@
+package com.zhiqiyun.open.core.mapper.base;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.zhiqiyun.open.core.models.base.CategoryBase;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface CategoryBaseMapper extends BaseMapper<CategoryBase> {
+}

+ 24 - 0
src/main/java/com/zhiqiyun/open/core/models/base/CategoryBase.java

@@ -0,0 +1,24 @@
+package com.zhiqiyun.open.core.models.base;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+@Data
+@TableName("category_base")
+public class CategoryBase implements Serializable {
+
+    private static final long serialVersionUID = -3306018969325222999L;
+
+    private Long id;
+    private String name;
+    private Integer sortNumber;
+    private String remark;
+
+    private Date createdTime;
+    private Long createdBy;
+    private Date updatedTime;
+    private Long updatedBy;
+}

+ 22 - 0
src/main/java/com/zhiqiyun/open/core/models/base/CategoryBaseExtendColumn.java

@@ -0,0 +1,22 @@
+package com.zhiqiyun.open.core.models.base;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.zhiqiyun.open.core.enmus.ExtendColumnFieldType;
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+@TableName("category_base_extend_column")
+public class CategoryBaseExtendColumn implements Serializable {
+
+    private static final long serialVersionUID = -3306018969325222999L;
+
+    private Long id;
+    private String categoryId;
+    private String fieldKey;
+    private String fieldLabel;
+    private ExtendColumnFieldType fieldType;
+    private String defaultValue;
+    private Integer sortNumber;
+}

+ 7 - 0
src/main/java/com/zhiqiyun/open/core/service/CategoryBaseExtendColumnService.java

@@ -0,0 +1,7 @@
+package com.zhiqiyun.open.core.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.zhiqiyun.open.core.models.base.CategoryBaseExtendColumn;
+
+public interface CategoryBaseExtendColumnService extends IService<CategoryBaseExtendColumn> {
+}

+ 7 - 0
src/main/java/com/zhiqiyun/open/core/service/CategoryBaseService.java

@@ -0,0 +1,7 @@
+package com.zhiqiyun.open.core.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.zhiqiyun.open.core.models.base.CategoryBase;
+
+public interface CategoryBaseService extends IService<CategoryBase> {
+}

+ 11 - 0
src/main/java/com/zhiqiyun/open/core/service/impl/CategoryBaseExtendColumnServiceImpl.java

@@ -0,0 +1,11 @@
+package com.zhiqiyun.open.core.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.zhiqiyun.open.core.mapper.base.CategoryBaseExtendColumnMapper;
+import com.zhiqiyun.open.core.models.base.CategoryBaseExtendColumn;
+import com.zhiqiyun.open.core.service.CategoryBaseExtendColumnService;
+import org.springframework.stereotype.Service;
+
+@Service
+public class CategoryBaseExtendColumnServiceImpl extends ServiceImpl<CategoryBaseExtendColumnMapper, CategoryBaseExtendColumn> implements CategoryBaseExtendColumnService {
+}

+ 11 - 0
src/main/java/com/zhiqiyun/open/core/service/impl/CategoryBaseServiceImpl.java

@@ -0,0 +1,11 @@
+package com.zhiqiyun.open.core.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.zhiqiyun.open.core.mapper.base.CategoryBaseMapper;
+import com.zhiqiyun.open.core.models.base.CategoryBase;
+import com.zhiqiyun.open.core.service.CategoryBaseService;
+import org.springframework.stereotype.Service;
+
+@Service
+public class CategoryBaseServiceImpl extends ServiceImpl<CategoryBaseMapper, CategoryBase> implements CategoryBaseService {
+}

+ 115 - 0
src/main/java/com/zhiqiyun/open/mvc/controller/CategoryBaseController.java

@@ -0,0 +1,115 @@
+package com.zhiqiyun.open.mvc.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.OrderItem;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.zhiqiyun.open.annotation.Permission;
+import com.zhiqiyun.open.core.models.base.CategoryBase;
+import com.zhiqiyun.open.core.models.user.OauthInfo;
+import com.zhiqiyun.open.core.service.CategoryBaseExtendColumnService;
+import com.zhiqiyun.open.core.service.CategoryBaseService;
+import com.zhiqiyun.open.core.service.OauthService;
+import com.zhiqiyun.open.core.service.SequenceService;
+import com.zhiqiyun.open.mvc.Result;
+import com.zhiqiyun.open.mvc.params.base.QueryCategoryBaseParam;
+import com.zhiqiyun.open.mvc.params.base.SaveCategoryBaseParam;
+import com.zhiqiyun.open.utils.DateUtil;
+import com.zhiqiyun.open.utils.ServletContext;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.validation.Valid;
+import java.util.List;
+
+@RestController
+@RequestMapping("/category/base")
+public class CategoryBaseController {
+
+    @Autowired
+    private CategoryBaseService categoryBaseService;
+
+    @Autowired
+    private CategoryBaseExtendColumnService categoryBaseExtendColumnService;
+
+    @Autowired
+    private SequenceService sequenceService;
+
+    @Autowired
+    private OauthService oauthService;
+
+    @Permission(value = "category.base.find", tags = "查询基础数据分类")
+    @PostMapping("/findPage")
+    public Result findPage(@RequestBody QueryCategoryBaseParam param) {
+
+        QueryWrapper<CategoryBase> wrapper = new QueryWrapper<>();
+
+        if (StringUtils.isNotBlank(param.getName())) {
+            wrapper.like("name", param.getName());
+        }
+        Page<CategoryBase> page = param.getPage();
+        page.addOrder(OrderItem.asc("sort_number"));
+        page.addOrder(OrderItem.desc("id"));
+
+        Page<CategoryBase> resultData = this.categoryBaseService.page(page, wrapper);
+
+        return Result.instance(Result.Code.SUCCESS).setData(resultData);
+    }
+
+    @Permission(value = "category.base.add", tags = "新建基础数据分类")
+    @PostMapping("/save")
+    public Result save(@Valid @RequestBody SaveCategoryBaseParam param) throws Exception {
+
+        CategoryBase entity = new CategoryBase();
+        BeanUtils.copyProperties(param, entity);
+
+        OauthInfo oauthInfo = this.oauthService.getAuth(ServletContext.getAccessToken());
+
+        if (param.getSortNumber() == null) {
+            entity.setSortNumber(0);
+        }
+
+        entity.setCreatedTime(DateUtil.current());
+        entity.setCreatedBy(oauthInfo.getId());
+
+        entity.setUpdatedTime(DateUtil.current());
+        entity.setUpdatedBy(oauthInfo.getId());
+        entity.setId(this.sequenceService.nextId());
+
+        this.categoryBaseService.save(entity);
+
+        return Result.instance(Result.Code.MESSAGE_SUCCESS);
+    }
+
+    @Permission(value = "category.base.edit", tags = "更新基础数据分类")
+    @PostMapping("/updateById")
+    public Result updateById(Long id, @Valid @RequestBody SaveCategoryBaseParam param) {
+        CategoryBase entity = new CategoryBase();
+        BeanUtils.copyProperties(param, entity);
+
+        OauthInfo oauthInfo = this.oauthService.getAuth(ServletContext.getAccessToken());
+
+        if (param.getSortNumber() == null) {
+            entity.setSortNumber(0);
+        }
+
+        entity.setUpdatedBy(oauthInfo.getId());
+        entity.setUpdatedTime(DateUtil.current());
+        entity.setId(id);
+
+        this.categoryBaseService.updateById(entity);
+
+        return Result.instance(Result.Code.MESSAGE_SUCCESS);
+    }
+
+    @Permission(value = "category.base.delete", tags = "删除基础数据分类")
+    @PostMapping("/deleteByIds")
+    public Result deleteByIds(@RequestBody List<Long> ids) {
+        this.categoryBaseService.removeByIds(ids);
+        return Result.instance(Result.Code.MESSAGE_SUCCESS);
+    }
+}

+ 96 - 0
src/main/java/com/zhiqiyun/open/mvc/controller/CategoryBaseExtendColumnController.java

@@ -0,0 +1,96 @@
+package com.zhiqiyun.open.mvc.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.OrderItem;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.zhiqiyun.open.annotation.Permission;
+import com.zhiqiyun.open.core.models.base.CategoryBaseExtendColumn;
+import com.zhiqiyun.open.core.service.CategoryBaseExtendColumnService;
+import com.zhiqiyun.open.core.service.SequenceService;
+import com.zhiqiyun.open.mvc.Result;
+import com.zhiqiyun.open.mvc.params.base.QueryCategoryBaseExtendColumnParam;
+import com.zhiqiyun.open.mvc.params.base.SaveCategoryBaseExtendColumnParam;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.validation.Valid;
+import java.util.List;
+
+@RestController
+@RequestMapping("/category/base/extend/column")
+public class CategoryBaseExtendColumnController {
+
+    @Autowired
+    private CategoryBaseExtendColumnService categoryBaseExtendColumnService;
+
+    @Autowired
+    private SequenceService sequenceService;
+
+    @Permission(value = "category.base.extend.column", tags = "查询基础数据分类扩展字段")
+    @PostMapping("/findPage")
+    public Result findPage(@RequestBody QueryCategoryBaseExtendColumnParam param) {
+
+        QueryWrapper<CategoryBaseExtendColumn> wrapper = new QueryWrapper<>();
+
+        if (StringUtils.isNotBlank(param.getFieldKey())) {
+            wrapper.eq("field_key", param.getFieldKey());
+        }
+        if (StringUtils.isNotBlank(param.getFieldLabel())) {
+            wrapper.like("field_label", param.getFieldLabel());
+        }
+        Page<CategoryBaseExtendColumn> page = param.getPage();
+        page.addOrder(OrderItem.asc("sort_number"));
+        page.addOrder(OrderItem.desc("id"));
+
+        Page<CategoryBaseExtendColumn> resultData = this.categoryBaseExtendColumnService.page(page, wrapper);
+
+        return Result.instance(Result.Code.SUCCESS).setData(resultData);
+    }
+
+    @Permission(value = "category.base.extend.column", tags = "新建基础数据分类扩展字段")
+    @PostMapping("/save")
+    public Result save(@Valid @RequestBody SaveCategoryBaseExtendColumnParam param) throws Exception {
+
+        CategoryBaseExtendColumn entity = new CategoryBaseExtendColumn();
+        BeanUtils.copyProperties(param, entity);
+
+        if (param.getSortNumber() == null) {
+            entity.setSortNumber(0);
+        }
+
+        entity.setId(this.sequenceService.nextId());
+
+        this.categoryBaseExtendColumnService.save(entity);
+
+        return Result.instance(Result.Code.MESSAGE_SUCCESS);
+    }
+
+    @Permission(value = "category.base.extend.column", tags = "更新基础数据分类扩展字段")
+    @PostMapping("/updateById")
+    public Result updateById(Long id, @Valid @RequestBody SaveCategoryBaseExtendColumnParam param) {
+        CategoryBaseExtendColumn entity = new CategoryBaseExtendColumn();
+        BeanUtils.copyProperties(param, entity);
+
+        if (param.getSortNumber() == null) {
+            entity.setSortNumber(0);
+        }
+
+        entity.setId(id);
+
+        this.categoryBaseExtendColumnService.updateById(entity);
+
+        return Result.instance(Result.Code.MESSAGE_SUCCESS);
+    }
+
+    @Permission(value = "category.base.extend.column", tags = "删除基础数据分类扩展字段")
+    @PostMapping("/deleteByIds")
+    public Result deleteByIds(@RequestBody List<Long> ids) {
+        this.categoryBaseExtendColumnService.removeByIds(ids);
+        return Result.instance(Result.Code.MESSAGE_SUCCESS);
+    }
+}

+ 12 - 0
src/main/java/com/zhiqiyun/open/mvc/params/base/QueryCategoryBaseExtendColumnParam.java

@@ -0,0 +1,12 @@
+package com.zhiqiyun.open.mvc.params.base;
+
+import com.zhiqiyun.open.mvc.params.QueryPageParams;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class QueryCategoryBaseExtendColumnParam extends QueryPageParams {
+    private String fieldKey;
+    private String fieldLabel;
+}

+ 11 - 0
src/main/java/com/zhiqiyun/open/mvc/params/base/QueryCategoryBaseParam.java

@@ -0,0 +1,11 @@
+package com.zhiqiyun.open.mvc.params.base;
+
+import com.zhiqiyun.open.mvc.params.QueryPageParams;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class QueryCategoryBaseParam extends QueryPageParams {
+    private String name;
+}

+ 14 - 0
src/main/java/com/zhiqiyun/open/mvc/params/base/SaveCategoryBaseExtendColumnParam.java

@@ -0,0 +1,14 @@
+package com.zhiqiyun.open.mvc.params.base;
+
+import com.zhiqiyun.open.core.enmus.ExtendColumnFieldType;
+import lombok.Data;
+
+@Data
+public class SaveCategoryBaseExtendColumnParam {
+    private String categoryId;
+    private String fieldKey;
+    private String fieldLabel;
+    private Integer sortNumber;
+    private ExtendColumnFieldType fieldType;
+    private String defaultValue;
+}

+ 10 - 0
src/main/java/com/zhiqiyun/open/mvc/params/base/SaveCategoryBaseParam.java

@@ -0,0 +1,10 @@
+package com.zhiqiyun.open.mvc.params.base;
+
+import lombok.Data;
+
+@Data
+public class SaveCategoryBaseParam {
+    private String name;
+    private String remark;
+    private Integer sortNumber;
+}

+ 36 - 0
src/main/resources/db/migration/V1.0.7__base.sql

@@ -0,0 +1,36 @@
+DROP TABLE IF EXISTS `category_base`;
+CREATE TABLE `category_base`
+(
+    `id`           BIGINT(20) NOT NULL COMMENT 'ID',
+    `name`         VARCHAR(50) NOT NULL COMMENT '分类名称',
+    `sort_number`  INT(11) NOT NULL DEFAULT 0 COMMENT '排序ID',
+    `remark`       TEXT NULL DEFAULT NULL COMMENT '备注说明',
+    `created_time` DATETIME NULL DEFAULT NULL COMMENT '创建时间',
+    `created_by`   BIGINT(20) NULL DEFAULT NULL COMMENT '创建人',
+    `updated_time` DATETIME NULL DEFAULT NULL COMMENT '修改时间',
+    `updated_by`   BIGINT(20) NULL DEFAULT NULL COMMENT '修改人',
+    PRIMARY KEY (`id`)
+) COMMENT ='基础数据分类管理' ENGINE = InnoDB;
+
+DROP TABLE IF EXISTS `category_base_extend_column`;
+CREATE TABLE `category_base_extend_column`
+(
+    `id`            BIGINT(20) NOT NULL COMMENT 'ID',
+    `category_id`   VARCHAR(50)  NOT NULL COMMENT '分类ID',
+    `field_key`     VARCHAR(50)  NOT NULL COMMENT '字段Key',
+    `field_label`   VARCHAR(100) NOT NULL COMMENT '字段名称',
+    `sort_number`   INT(11) NOT NULL DEFAULT 0 COMMENT '排序ID',
+    `field_type`    INT(11) NULL DEFAULT NULL COMMENT '字段类型',
+    `default_value` TEXT NULL DEFAULT NULL COMMENT '默认值',
+    PRIMARY KEY (`id`)
+) COMMENT ='基础数据分类管理' ENGINE = InnoDB;
+
+
+REPLACE
+INTO `authority_info` (`id`, `parent_id`, `name`, `remark`)
+VALUES (2500, 0, 'category.base', '基础数据分类管理'),
+       (2501, 2500, 'category.base.find', '查询'),
+       (2502, 2500, 'category.base.add', '添加'),
+       (2503, 2500, 'category.base.edit', '修改'),
+       (2504, 2500, 'category.base.delete', '删除'),
+       (2505, 2500, 'category.base.extend.column', '扩展字段管理');