diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/gss/ProductCategoryController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/gss/ProductCategoryController.java new file mode 100644 index 0000000..7c9e18b --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/gss/ProductCategoryController.java @@ -0,0 +1,100 @@ +package com.ruoyi.web.controller.gss; + +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.entity.SysDept; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.gss.domain.ProductCategory; +import com.ruoyi.gss.service.IProductCategoryService; + +@RestController +@RequestMapping("/gss/category") +public class ProductCategoryController extends BaseController +{ + @Autowired + private IProductCategoryService productCategoryService; + + @PreAuthorize("@ss.hasPermi('gss:category:list')") + @GetMapping("/list") + public AjaxResult list(ProductCategory productCategory) + { + List list = productCategoryService.selectProductCategoryList(productCategory); + return success(productCategoryService.buildProductCategoryTree(list)); + } + + @PreAuthorize("@ss.hasPermi('gss:category:query')") + @GetMapping(value = "/{categoryId}") + public AjaxResult getInfo(@PathVariable Long categoryId) + { + return success(productCategoryService.selectProductCategoryById(categoryId)); + } + + @PreAuthorize("@ss.hasPermi('gss:category:query')") + @GetMapping(value = "/children/{categoryId}") + public AjaxResult getChildren(@PathVariable Long categoryId) + { + List list = productCategoryService.selectChildrenProductCategoryById(categoryId); + return success(productCategoryService.buildProductCategoryTree(list)); + } + + @PreAuthorize("@ss.hasPermi('gss:category:query')") + @GetMapping(value = "/parent/{categoryId}") + public AjaxResult getParent(@PathVariable Long categoryId) + { + return success(productCategoryService.selectParentProductCategoryById(categoryId)); + } + +// @PreAuthorize("@ss.hasPermi('gss:category:add')") +// @Log(title = "产品分类管理", businessType = BusinessType.INSERT) +// @PostMapping +// public AjaxResult add(@Validated @RequestBody ProductCategory productCategory) +// { +// if (StringUtils.isNotEmpty(productCategory.getCategoryCode()) +// && UserConstants.NOT_UNIQUE.equals(productCategoryService.checkProductCategoryCodeUnique(productCategory))) +// { +// return error("新增产品分类'" + productCategory.getCategoryName() + "'失败,分类编码已存在"); +// } +// return toAjax(productCategoryService.insertProductCategory(productCategory)); +// } + + @PreAuthorize("@ss.hasPermi('gss:category:edit')") + @Log(title = "产品分类管理", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@Validated @RequestBody ProductCategory productCategory) + { + // todo相关类型验证 目前没有新新增方法 +// if (StringUtils.isNotEmpty(productCategory.getCategoryCode()) +// && UserConstants.NOT_UNIQUE.equals(productCategoryService.checkProductCategoryCodeUnique(productCategory))) +// { +// return error("修改产品分类'" + productCategory.getCategoryName() + "'失败,分类编码已存在"); +// } +// else if (productCategory.getParentId().equals(productCategory.getCategoryId())) +// { +// return error("修改产品分类'" + productCategory.getCategoryName() + "'失败,上级分类不能是自己"); +// } + return toAjax(productCategoryService.updateProductCategory(productCategory)); + } + + @PreAuthorize("@ss.hasPermi('gss:category:remove')") + @Log(title = "产品分类管理", businessType = BusinessType.DELETE) + @DeleteMapping("/{categoryIds}") + public AjaxResult remove(@PathVariable Long[] categoryIds) + { + return toAjax(productCategoryService.deleteProductCategoryByIds(categoryIds)); + } +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/gss/domain/ProductCategory.java b/ruoyi-system/src/main/java/com/ruoyi/gss/domain/ProductCategory.java new file mode 100644 index 0000000..1b0975b --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/gss/domain/ProductCategory.java @@ -0,0 +1,114 @@ +package com.ruoyi.gss.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.TreeEntity; + +public class ProductCategory extends TreeEntity +{ + private static final long serialVersionUID = 1L; + + /** 分类ID */ + private Long categoryId; + + /** 分类编码 */ + @Excel(name = "分类编码") + private String categoryCode; + + /** 分类名称 */ + @Excel(name = "分类名称") + private String categoryName; + + /** 分类英文名称 */ + @Excel(name = "分类英文名称") + private String categoryNameEn; + + /** 分类级别(1大类 2中类 3小类) */ + @Excel(name = "分类级别", readConverterExp = "1=大类,2=中类,3=小类") + private String categoryLevel; + + /** 状态(0正常 1停用) */ + @Excel(name = "状态", readConverterExp = "0=正常,1=停用") + private String status; + + /** 删除标志(0代表存在 2代表删除) */ + private String delFlag; + + public Long getCategoryId() { + return categoryId; + } + + public void setCategoryId(Long categoryId) { + this.categoryId = categoryId; + } + + public String getCategoryCode() { + return categoryCode; + } + + public void setCategoryCode(String categoryCode) { + this.categoryCode = categoryCode; + } + + public String getCategoryName() { + return categoryName; + } + + public void setCategoryName(String categoryName) { + this.categoryName = categoryName; + } + + public String getCategoryNameEn() { + return categoryNameEn; + } + + public void setCategoryNameEn(String categoryNameEn) { + this.categoryNameEn = categoryNameEn; + } + + public String getCategoryLevel() { + return categoryLevel; + } + + public void setCategoryLevel(String categoryLevel) { + this.categoryLevel = categoryLevel; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getDelFlag() { + return delFlag; + } + + public void setDelFlag(String delFlag) { + this.delFlag = delFlag; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("categoryId", getCategoryId()) + .append("categoryCode", getCategoryCode()) + .append("categoryName", getCategoryName()) + .append("categoryNameEn", getCategoryNameEn()) + .append("parentId", getParentId()) + .append("ancestors", getAncestors()) + .append("categoryLevel", getCategoryLevel()) + .append("orderNum", getOrderNum()) + .append("status", getStatus()) + .append("delFlag", getDelFlag()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); + } +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/gss/mapper/ProductCategoryMapper.java b/ruoyi-system/src/main/java/com/ruoyi/gss/mapper/ProductCategoryMapper.java new file mode 100644 index 0000000..8d5f6f7 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/gss/mapper/ProductCategoryMapper.java @@ -0,0 +1,70 @@ +package com.ruoyi.gss.mapper; + +import java.util.List; +import com.ruoyi.gss.domain.ProductCategory; + +public interface ProductCategoryMapper +{ + /** + * 查询产品分类 + */ + public ProductCategory selectProductCategoryById(Long categoryId); + + /** + * 查询产品分类列表 + */ + public List selectProductCategoryList(ProductCategory productCategory); + + /** + * 查询产品分类树列表 + */ + public List selectProductCategoryTreeList(ProductCategory productCategory); + + /** + * 根据ID查询所有子产品分类 + */ + public List selectChildrenProductCategoryById(Long categoryId); + + /** + * 根据ID查询所有父产品分类 + */ + public List selectParentProductCategoryById(Long categoryId); + + /** + * 是否存在子节点 + */ + public int hasChildByProductCategoryId(Long categoryId); + + /** + * 新增产品分类 + */ + public int insertProductCategory(ProductCategory productCategory); + + /** + * 修改产品分类 + */ + public int updateProductCategory(ProductCategory productCategory); + + /** + * 修改子元素关系 + */ + public int updateProductCategoryChildren(List children); + + /** + * 删除产品分类 + */ + public int deleteProductCategoryById(Long categoryId); + + /** + * 批量删除产品分类 + */ + public int deleteProductCategoryByIds(Long[] categoryIds); + + /** + * 校验分类编码是否唯一 + * + * @param categoryCode 分类编码 + * @return 结果 + */ + public ProductCategory checkProductCategoryCodeUnique(String categoryCode); +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/gss/service/IProductCategoryService.java b/ruoyi-system/src/main/java/com/ruoyi/gss/service/IProductCategoryService.java new file mode 100644 index 0000000..f735128 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/gss/service/IProductCategoryService.java @@ -0,0 +1,60 @@ +package com.ruoyi.gss.service; + +import java.util.List; +import com.ruoyi.gss.domain.ProductCategory; + +public interface IProductCategoryService +{ + /** + * 查询产品分类 + */ + public ProductCategory selectProductCategoryById(Long categoryId); + + /** + * 查询产品分类列表 + */ + public List selectProductCategoryList(ProductCategory productCategory); + + /** + * 构建前端所需要树结构 + */ + public List buildProductCategoryTree(List categories); + + /** + * 根据ID查询所有子产品分类 + */ + public List selectChildrenProductCategoryById(Long categoryId); + + /** + * 根据ID查询所有父产品分类 + */ + public List selectParentProductCategoryById(Long categoryId); + + /** + * 新增产品分类 + */ + public int insertProductCategory(ProductCategory productCategory); + + /** + * 修改产品分类 + */ + public int updateProductCategory(ProductCategory productCategory); + + /** + * 删除产品分类信息 + */ + public int deleteProductCategoryById(Long categoryId); + + /** + * 批量删除产品分类信息 + */ + public int deleteProductCategoryByIds(Long[] categoryIds); + + /** + * 校验分类编码是否唯一 + * + * @param productCategory 产品分类信息 + * @return 结果 + */ + public String checkProductCategoryCodeUnique(ProductCategory productCategory); +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/gss/service/impl/ProductCategoryServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/gss/service/impl/ProductCategoryServiceImpl.java new file mode 100644 index 0000000..97b29fe --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/gss/service/impl/ProductCategoryServiceImpl.java @@ -0,0 +1,215 @@ +package com.ruoyi.gss.service.impl; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.stream.Collectors; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.common.core.domain.TreeSelect; +import com.ruoyi.common.core.text.Convert; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.gss.mapper.ProductCategoryMapper; +import com.ruoyi.gss.domain.ProductCategory; +import com.ruoyi.gss.service.IProductCategoryService; +import com.ruoyi.common.constant.UserConstants; + +@Service +public class ProductCategoryServiceImpl implements IProductCategoryService +{ + @Autowired + private ProductCategoryMapper productCategoryMapper; + + @Override + public ProductCategory selectProductCategoryById(Long categoryId) + { + return productCategoryMapper.selectProductCategoryById(categoryId); + } + + @Override + public List selectProductCategoryList(ProductCategory productCategory) + { + return productCategoryMapper.selectProductCategoryList(productCategory); + } + + @Override + public List buildProductCategoryTree(List categories) + { + List returnList = new ArrayList(); + List tempList = new ArrayList(); + for (ProductCategory category : categories) + { + tempList.add(category.getCategoryId()); + } + for (Iterator iterator = categories.iterator(); iterator.hasNext();) + { + ProductCategory category = (ProductCategory) iterator.next(); + // 如果是顶级节点, 遍历该父节点的所有子节点 + if (!tempList.contains(category.getParentId())) + { + recursionFn(categories, category); + returnList.add(category); + } + } + if (returnList.isEmpty()) + { + returnList = categories; + } + return returnList; + } + + @Override + public List selectChildrenProductCategoryById(Long categoryId) + { + return productCategoryMapper.selectChildrenProductCategoryById(categoryId); + } + + @Override + public List selectParentProductCategoryById(Long categoryId) + { + return productCategoryMapper.selectParentProductCategoryById(categoryId); + } + + @Override + public int insertProductCategory(ProductCategory productCategory) + { + ProductCategory info = productCategoryMapper.selectProductCategoryById(productCategory.getParentId()); + // 如果父节点不为正常状态,则不允许新增子节点 + if (StringUtils.isNotNull(info) && !info.getStatus().equals("0")) + { + throw new RuntimeException("父分类停用,不允许新增"); + } + productCategory.setAncestors(info.getAncestors() + "," + productCategory.getParentId()); + return productCategoryMapper.insertProductCategory(productCategory); + } + + @Override + public int updateProductCategory(ProductCategory productCategory) + { + ProductCategory newParentCategory = productCategoryMapper.selectProductCategoryById(productCategory.getParentId()); + ProductCategory oldCategory = productCategoryMapper.selectProductCategoryById(productCategory.getCategoryId()); + if (StringUtils.isNotNull(newParentCategory) && StringUtils.isNotNull(oldCategory)) + { + String newAncestors = newParentCategory.getAncestors() + "," + newParentCategory.getCategoryId(); + String oldAncestors = oldCategory.getAncestors(); + productCategory.setAncestors(newAncestors); + updateProductCategoryChildren(productCategory.getCategoryId(), newAncestors, oldAncestors); + } + int result = productCategoryMapper.updateProductCategory(productCategory); + if (StringUtils.isNotNull(oldCategory) && "1".equals(productCategory.getStatus()) + && StringUtils.equals(oldCategory.getStatus(), "0")) + { + // 如果当前节点被停用,则将所有子节点停用 + updateProductCategoryStatus(productCategory); + } + return result; + } + + @Override + public int deleteProductCategoryById(Long categoryId) + { + return productCategoryMapper.deleteProductCategoryById(categoryId); + } + + @Override + public int deleteProductCategoryByIds(Long[] categoryIds) + { + return productCategoryMapper.deleteProductCategoryByIds(categoryIds); + } + + /** + * 递归列表 + */ + private void recursionFn(List list, ProductCategory t) + { + // 得到子节点列表 + List childList = getChildList(list, t); + t.setChildren(childList); + for (ProductCategory tChild : childList) + { + if (hasChild(list, tChild)) + { + recursionFn(list, tChild); + } + } + } + + /** + * 得到子节点列表 + */ + private List getChildList(List list, ProductCategory t) + { + List tlist = new ArrayList(); + Iterator it = list.iterator(); + while (it.hasNext()) + { + ProductCategory n = (ProductCategory) it.next(); + if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getCategoryId().longValue()) + { + tlist.add(n); + } + } + return tlist; + } + + /** + * 判断是否有子节点 + */ + private boolean hasChild(List list, ProductCategory t) + { + return getChildList(list, t).size() > 0; + } + + /** + * 修改子元素关系 + */ + private void updateProductCategoryChildren(Long categoryId, String newAncestors, String oldAncestors) + { + List children = productCategoryMapper.selectChildrenProductCategoryById(categoryId); + for (ProductCategory child : children) + { + child.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors)); + } + if (children.size() > 0) + { + productCategoryMapper.updateProductCategoryChildren(children); + } + } + + /** + * 修改子元素状态 + */ + private void updateProductCategoryStatus(ProductCategory category) + { + List children = productCategoryMapper.selectChildrenProductCategoryById(category.getCategoryId()); + for (ProductCategory child : children) + { + child.setStatus(category.getStatus()); + productCategoryMapper.updateProductCategory(child); + } + } + + // todo相关类型验证 目前没有新新增方法 + // /** + // * 校验产品分类编码是否唯一 + // * + // * @param productCategory 产品分类信息 + // * @return 结果 + // */ + // @Override + public String checkProductCategoryCodeUnique(ProductCategory productCategory) + { + // 如果分类ID为空则设置为-1 + Long categoryId = StringUtils.isNull(productCategory.getCategoryId()) ? -1L : productCategory.getCategoryId(); + // 根据分类编码查询数据库中是否存在相同编码的分类 + ProductCategory info = productCategoryMapper.checkProductCategoryCodeUnique(productCategory.getCategoryCode()); + // 如果存在相同编码且不是当前编辑的分类,则返回不唯一标识 + // if (StringUtils.isNotNull(info) && info.getCategoryId().longValue() != categoryId.longValue()) + // { + // return UserConstants.NOT_UNIQUE; + // } + // // 返回唯一标识 + // return UserConstants.UNIQUE; + return null; + } +} \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/gss/ProductCategoryMapper.xml b/ruoyi-system/src/main/resources/mapper/gss/ProductCategoryMapper.xml new file mode 100644 index 0000000..896dbbe --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/gss/ProductCategoryMapper.xml @@ -0,0 +1,154 @@ + + + + + + + + + + + + + + + + + + + + + + + + + select category_id, category_name, category_code, parent_id, ancestors, + category_level, order_num, status, del_flag, create_by, create_time, update_by, update_time, remark + from dhc_product_category + + + + + + + + + + + + + + insert into dhc_product_category( + category_id, + category_code, + category_name, + category_name_en, + parent_id, + ancestors, + category_level, + order_num, + status, + create_by, + create_time + )values( + #{categoryId}, + #{categoryCode}, + #{categoryName}, + #{categoryNameEn}, + #{parentId}, + #{ancestors}, + #{categoryLevel}, + #{orderNum}, + #{status}, + #{createBy}, + sysdate() + ) + + + + update dhc_product_category + + category_code = #{categoryCode}, + category_name = #{categoryName}, + category_name_en = #{categoryNameEn}, + parent_id = #{parentId}, + ancestors = #{ancestors}, + category_level = #{categoryLevel}, + order_num = #{orderNum}, + status = #{status}, + update_by = #{updateBy}, + update_time = sysdate() + + where category_id = #{categoryId} + + + + update dhc_product_category set ancestors = + + when #{item.categoryId} then #{item.ancestors} + + where category_id in + + #{item.categoryId} + + + + + update dhc_product_category set del_flag = '2' where category_id = #{categoryId} + + + + update dhc_product_category set del_flag = '2' where category_id in + + #{categoryId} + + + + + + \ No newline at end of file diff --git a/sql/gss/产品分类表.sql b/sql/gss/产品分类表.sql index e69de29..76cd265 100644 --- a/sql/gss/产品分类表.sql +++ b/sql/gss/产品分类表.sql @@ -0,0 +1,41 @@ +CREATE TABLE `dhc_product_category` ( + `category_id` bigint NOT NULL AUTO_INCREMENT COMMENT '分类ID', + `category_code` varchar(10) COLLATE utf8mb4_general_ci NOT NULL COMMENT '分类编码', + `category_name` varchar(100) COLLATE utf8mb4_general_ci NOT NULL COMMENT '分类名称', + `category_name_en` varchar(200) COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '分类英文名称', + `parent_id` bigint DEFAULT '0' COMMENT '父分类ID', + `ancestors` varchar(500) COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '祖级列表', + `category_level` char(1) COLLATE utf8mb4_general_ci NOT NULL COMMENT '分类级别(1大类 2中类 3小类)', + `order_num` int DEFAULT '0' COMMENT '显示顺序', + `status` char(1) COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '状态(0正常 1停用)', + `del_flag` char(1) COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标志(0代表存在 2代表删除)', + `create_by` varchar(64) COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '创建者', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `update_by` varchar(64) COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '更新者', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `remark` varchar(500) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '备注', + PRIMARY KEY (`category_id`) +) ENGINE=InnoDB AUTO_INCREMENT=211 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='产品分类表'; + + +--------------------------------------------------------------------------------------------------------- +-- 菜单与权限 +-- 菜单 SQL +insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) +values('产品分类管理', '3', '1', 'category', 'gss/category/index', 1, 0, 'C', '0', '0', 'gss:category:list', 'tree', 'admin', sysdate(), '', null, '产品分类管理菜单'); + +-- 按钮父菜单ID +SELECT @parentId := LAST_INSERT_ID(); + +-- 按钮 SQL +insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) +values('产品分类查询', @parentId, '1', '#', '', 1, 0, 'F', '0', '0', 'gss:category:query', '#', 'admin', sysdate(), '', null, ''); + +insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) +values('产品分类新增', @parentId, '2', '#', '', 1, 0, 'F', '0', '0', 'gss:category:add', '#', 'admin', sysdate(), '', null, ''); + +insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) +values('产品分类修改', @parentId, '3', '#', '', 1, 0, 'F', '0', '0', 'gss:category:edit', '#', 'admin', sysdate(), '', null, ''); + +insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) +values('产品分类删除', @parentId, '4', '#', '', 1, 0, 'F', '0', '0', 'gss:category:remove', '#', 'admin', sysdate(), '', null, ''); \ No newline at end of file diff --git a/sql/采购订单.sql b/sql/采购订单.sql new file mode 100644 index 0000000..e69de29 diff --git a/sql/销售区域表.sql b/sql/销售区域表.sql new file mode 100644 index 0000000..ddd8d3f --- /dev/null +++ b/sql/销售区域表.sql @@ -0,0 +1,23 @@ +-- ---------------------------- +-- by AI +-- ---------------------------- + +-- 创建销售区域表 +CREATE TABLE `sales_region` ( + `region_id` bigint NOT NULL AUTO_INCREMENT COMMENT '销售区域ID', + `region_name` varchar(100) NOT NULL COMMENT '销售区域名称', + `country_id` int NOT NULL COMMENT '国家ID', + `user_id` bigint NOT NULL COMMENT '负责用户ID', + `status` char(1) DEFAULT '0' COMMENT '状态(0正常 1停用)', + `del_flag` char(1) DEFAULT '0' COMMENT '删除标志(0代表存在 2代表删除)', + `create_by` varchar(64) DEFAULT '' COMMENT '创建者', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `update_by` varchar(64) DEFAULT '' COMMENT '更新者', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `remark` varchar(500) DEFAULT NULL COMMENT '备注', + PRIMARY KEY (`region_id`), + KEY `idx_country_id` (`country_id`), + KEY `idx_user_id` (`user_id`), + CONSTRAINT `fk_sales_region_country` FOREIGN KEY (`country_id`) REFERENCES `iso3166_country` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT, + CONSTRAINT `fk_sales_region_user` FOREIGN KEY (`user_id`) REFERENCES `sys_user` (`user_id`) ON DELETE RESTRICT ON UPDATE RESTRICT +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='销售区域表'; \ No newline at end of file