diff --git a/zfipc-server/zfipc-admin/src/main/java/com/inspur/web/controller/system/SysRegionController.java b/zfipc-server/zfipc-admin/src/main/java/com/inspur/web/controller/system/SysRegionController.java new file mode 100644 index 0000000..4efd06e --- /dev/null +++ b/zfipc-server/zfipc-admin/src/main/java/com/inspur/web/controller/system/SysRegionController.java @@ -0,0 +1,114 @@ +package com.inspur.web.controller.system; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; +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.inspur.common.annotation.Log; +import com.inspur.common.core.controller.BaseController; +import com.inspur.common.core.domain.AjaxResult; +import com.inspur.common.enums.BusinessType; +import com.inspur.system.domain.SysRegion; +import com.inspur.system.service.ISysRegionService; +import com.inspur.common.utils.poi.ExcelUtil; +import com.inspur.common.core.page.TableDataInfo; + +/** + * 行政区划Controller + * + * @author zhanghan11 + * @date 2024-07-04 + */ +@RestController +@RequestMapping("/system/region") +public class SysRegionController extends BaseController +{ + @Autowired + private ISysRegionService sysRegionService; + + /** + * 查询行政区划列表 + */ + @PreAuthorize("@ss.hasPermi('system:region:list')") + @GetMapping("/list") + public TableDataInfo list(SysRegion sysRegion) + { + startPage(); + List list = sysRegionService.selectSysRegionList(sysRegion); + return getDataTable(list); + } + + /** + * 查询行政区划列表 + */ + @PreAuthorize("@ss.hasPermi('system:region:list')") + @GetMapping("/listAll") + public AjaxResult listAll(SysRegion sysRegion) + { + return AjaxResult.success(sysRegionService.selectSysRegionList(sysRegion)); + } + + /** + * 导出行政区划列表 + */ + @PreAuthorize("@ss.hasPermi('system:region:export')") + @Log(title = "行政区划", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, SysRegion sysRegion) + { + List list = sysRegionService.selectSysRegionList(sysRegion); + ExcelUtil util = new ExcelUtil(SysRegion.class); + util.exportExcel(response, list, "行政区划数据"); + } + + /** + * 获取行政区划详细信息 + */ + @PreAuthorize("@ss.hasPermi('system:region:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(sysRegionService.selectSysRegionById(id)); + } + + /** + * 新增行政区划 + */ + @PreAuthorize("@ss.hasPermi('system:region:add')") + @Log(title = "行政区划", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody SysRegion sysRegion) + { + return toAjax(sysRegionService.insertSysRegion(sysRegion)); + } + + /** + * 修改行政区划 + */ + @PreAuthorize("@ss.hasPermi('system:region:edit')") + @Log(title = "行政区划", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody SysRegion sysRegion) + { + return toAjax(sysRegionService.updateSysRegion(sysRegion)); + } + + /** + * 删除行政区划 + */ + @PreAuthorize("@ss.hasPermi('system:region:remove')") + @Log(title = "行政区划", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(sysRegionService.deleteSysRegionByIds(ids)); + } +} diff --git a/zfipc-server/zfipc-common/src/main/java/com/inspur/common/core/domain/entity/SysDept.java b/zfipc-server/zfipc-common/src/main/java/com/inspur/common/core/domain/entity/SysDept.java index 1922250..b7d499a 100644 --- a/zfipc-server/zfipc-common/src/main/java/com/inspur/common/core/domain/entity/SysDept.java +++ b/zfipc-server/zfipc-common/src/main/java/com/inspur/common/core/domain/entity/SysDept.java @@ -12,7 +12,7 @@ import com.inspur.common.core.domain.BaseEntity; /** * 部门表 sys_dept - * + * * @author inspur */ public class SysDept extends BaseEntity @@ -51,7 +51,10 @@ public class SysDept extends BaseEntity /** 父部门名称 */ private String parentName; - + + /** 行政区划ID */ + private String regionId; + /** 子部门 */ private List children = new ArrayList(); @@ -181,6 +184,14 @@ public class SysDept extends BaseEntity this.children = children; } + public String getRegionId() { + return regionId; + } + + public void setRegionId(String regionId) { + this.regionId = regionId; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/zfipc-server/zfipc-system/src/main/java/com/inspur/system/domain/SysRegion.java b/zfipc-server/zfipc-system/src/main/java/com/inspur/system/domain/SysRegion.java new file mode 100644 index 0000000..56f2496 --- /dev/null +++ b/zfipc-server/zfipc-system/src/main/java/com/inspur/system/domain/SysRegion.java @@ -0,0 +1,107 @@ +package com.inspur.system.domain; + +import com.inspur.common.annotation.Excel; +import com.inspur.common.core.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +/** + * 行政区划对象 sys_region + * + * @author zhanghan11 + * @date 2024-07-04 + */ +public class SysRegion extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键 */ + private Long id; + + /** 名称 */ + @Excel(name = "名称") + private String name; + + /** 父级ID */ + @Excel(name = "父级ID") + private Long parentId; + + /** 祖级列表 */ + @Excel(name = "祖级列表") + private String ancestors; + + /** 显示顺序 */ + @Excel(name = "显示顺序") + private Integer orderNum; + + /** 层级,1:省级,2:市级 */ + @Excel(name = "层级,1:省级,2:市级") + private Integer level; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + public void setName(String name) + { + this.name = name; + } + + public String getName() + { + return name; + } + public void setParentId(Long parentId) + { + this.parentId = parentId; + } + + public Long getParentId() + { + return parentId; + } + public void setAncestors(String ancestors) + { + this.ancestors = ancestors; + } + + public String getAncestors() + { + return ancestors; + } + public void setOrderNum(Integer orderNum) + { + this.orderNum = orderNum; + } + + public Integer getOrderNum() + { + return orderNum; + } + public void setLevel(Integer level) + { + this.level = level; + } + + public Integer getLevel() + { + return level; + } + + @Override + public String toString() { + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("name", getName()) + .append("parentId", getParentId()) + .append("ancestors", getAncestors()) + .append("orderNum", getOrderNum()) + .append("level", getLevel()) + .toString(); + } +} diff --git a/zfipc-server/zfipc-system/src/main/java/com/inspur/system/mapper/SysRegionMapper.java b/zfipc-server/zfipc-system/src/main/java/com/inspur/system/mapper/SysRegionMapper.java new file mode 100644 index 0000000..4884f5f --- /dev/null +++ b/zfipc-server/zfipc-system/src/main/java/com/inspur/system/mapper/SysRegionMapper.java @@ -0,0 +1,61 @@ +package com.inspur.system.mapper; + +import java.util.List; +import com.inspur.system.domain.SysRegion; + +/** + * 行政区划Mapper接口 + * + * @author zhanghan11 + * @date 2024-07-04 + */ +public interface SysRegionMapper +{ + /** + * 查询行政区划 + * + * @param id 行政区划主键 + * @return 行政区划 + */ + public SysRegion selectSysRegionById(Long id); + + /** + * 查询行政区划列表 + * + * @param sysRegion 行政区划 + * @return 行政区划集合 + */ + public List selectSysRegionList(SysRegion sysRegion); + + /** + * 新增行政区划 + * + * @param sysRegion 行政区划 + * @return 结果 + */ + public int insertSysRegion(SysRegion sysRegion); + + /** + * 修改行政区划 + * + * @param sysRegion 行政区划 + * @return 结果 + */ + public int updateSysRegion(SysRegion sysRegion); + + /** + * 删除行政区划 + * + * @param id 行政区划主键 + * @return 结果 + */ + public int deleteSysRegionById(Long id); + + /** + * 批量删除行政区划 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteSysRegionByIds(Long[] ids); +} diff --git a/zfipc-server/zfipc-system/src/main/java/com/inspur/system/service/ISysRegionService.java b/zfipc-server/zfipc-system/src/main/java/com/inspur/system/service/ISysRegionService.java new file mode 100644 index 0000000..2ce4bfe --- /dev/null +++ b/zfipc-server/zfipc-system/src/main/java/com/inspur/system/service/ISysRegionService.java @@ -0,0 +1,61 @@ +package com.inspur.system.service; + +import java.util.List; +import com.inspur.system.domain.SysRegion; + +/** + * 行政区划Service接口 + * + * @author zhanghan11 + * @date 2024-07-04 + */ +public interface ISysRegionService +{ + /** + * 查询行政区划 + * + * @param id 行政区划主键 + * @return 行政区划 + */ + public SysRegion selectSysRegionById(Long id); + + /** + * 查询行政区划列表 + * + * @param sysRegion 行政区划 + * @return 行政区划集合 + */ + public List selectSysRegionList(SysRegion sysRegion); + + /** + * 新增行政区划 + * + * @param sysRegion 行政区划 + * @return 结果 + */ + public int insertSysRegion(SysRegion sysRegion); + + /** + * 修改行政区划 + * + * @param sysRegion 行政区划 + * @return 结果 + */ + public int updateSysRegion(SysRegion sysRegion); + + /** + * 批量删除行政区划 + * + * @param ids 需要删除的行政区划主键集合 + * @return 结果 + */ + public int deleteSysRegionByIds(Long[] ids); + + /** + * 删除行政区划信息 + * + * @param id 行政区划主键 + * @return 结果 + */ + public int deleteSysRegionById(Long id); +} diff --git a/zfipc-server/zfipc-system/src/main/java/com/inspur/system/service/impl/SysRegionServiceImpl.java b/zfipc-server/zfipc-system/src/main/java/com/inspur/system/service/impl/SysRegionServiceImpl.java new file mode 100644 index 0000000..a8ba5d4 --- /dev/null +++ b/zfipc-server/zfipc-system/src/main/java/com/inspur/system/service/impl/SysRegionServiceImpl.java @@ -0,0 +1,93 @@ +package com.inspur.system.service.impl; + +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.inspur.system.mapper.SysRegionMapper; +import com.inspur.system.domain.SysRegion; +import com.inspur.system.service.ISysRegionService; + +/** + * 行政区划Service业务层处理 + * + * @author zhanghan11 + * @date 2024-07-04 + */ +@Service +public class SysRegionServiceImpl implements ISysRegionService +{ + @Autowired + private SysRegionMapper sysRegionMapper; + + /** + * 查询行政区划 + * + * @param id 行政区划主键 + * @return 行政区划 + */ + @Override + public SysRegion selectSysRegionById(Long id) + { + return sysRegionMapper.selectSysRegionById(id); + } + + /** + * 查询行政区划列表 + * + * @param sysRegion 行政区划 + * @return 行政区划 + */ + @Override + public List selectSysRegionList(SysRegion sysRegion) + { + return sysRegionMapper.selectSysRegionList(sysRegion); + } + + /** + * 新增行政区划 + * + * @param sysRegion 行政区划 + * @return 结果 + */ + @Override + public int insertSysRegion(SysRegion sysRegion) + { + return sysRegionMapper.insertSysRegion(sysRegion); + } + + /** + * 修改行政区划 + * + * @param sysRegion 行政区划 + * @return 结果 + */ + @Override + public int updateSysRegion(SysRegion sysRegion) + { + return sysRegionMapper.updateSysRegion(sysRegion); + } + + /** + * 批量删除行政区划 + * + * @param ids 需要删除的行政区划主键 + * @return 结果 + */ + @Override + public int deleteSysRegionByIds(Long[] ids) + { + return sysRegionMapper.deleteSysRegionByIds(ids); + } + + /** + * 删除行政区划信息 + * + * @param id 行政区划主键 + * @return 结果 + */ + @Override + public int deleteSysRegionById(Long id) + { + return sysRegionMapper.deleteSysRegionById(id); + } +} diff --git a/zfipc-server/zfipc-system/src/main/resources/mapper/system/SysDeptMapper.xml b/zfipc-server/zfipc-system/src/main/resources/mapper/system/SysDeptMapper.xml index ae710a4..0110ee2 100644 --- a/zfipc-server/zfipc-system/src/main/resources/mapper/system/SysDeptMapper.xml +++ b/zfipc-server/zfipc-system/src/main/resources/mapper/system/SysDeptMapper.xml @@ -20,13 +20,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + - + - select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time + select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time,d.region_id from sys_dept d - + - + - + - + - + select * from sys_dept where find_in_set(#{deptId}, ancestors) - + - + - + insert into sys_dept( dept_id, @@ -107,6 +108,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" phone, email, status, + region_id, create_by, create_time )values( @@ -119,11 +121,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{phone}, #{email}, #{status}, + #{regionId}, #{createBy}, sysdate() ) - + update sys_dept @@ -135,12 +138,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" phone = #{phone}, email = #{email}, status = #{status}, + region_id = #{regionId}, update_by = #{updateBy}, update_time = sysdate() where dept_id = #{deptId} - + update sys_dept set ancestors = - + - update sys_dept set status = '0' where dept_id in + update sys_dept set status = '0' where dept_id in #{deptId} - + update sys_dept set del_flag = '2' where dept_id = #{deptId} - \ No newline at end of file + diff --git a/zfipc-server/zfipc-system/src/main/resources/mapper/system/SysRegionMapper.xml b/zfipc-server/zfipc-system/src/main/resources/mapper/system/SysRegionMapper.xml new file mode 100644 index 0000000..836e83b --- /dev/null +++ b/zfipc-server/zfipc-system/src/main/resources/mapper/system/SysRegionMapper.xml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + select id, name, parent_id, ancestors, order_num, level from sys_region + + + + + + + + insert into sys_region + + id, + name, + parent_id, + ancestors, + order_num, + level, + + + #{id}, + #{name}, + #{parentId}, + #{ancestors}, + #{orderNum}, + #{level}, + + + + + update sys_region + + name = #{name}, + parent_id = #{parentId}, + ancestors = #{ancestors}, + order_num = #{orderNum}, + level = #{level}, + + where id = #{id} + + + + delete from sys_region where id = #{id} + + + + delete from sys_region where id in + + #{id} + + + \ No newline at end of file diff --git a/zfipc-ui/src/api/system/region.js b/zfipc-ui/src/api/system/region.js new file mode 100644 index 0000000..307c579 --- /dev/null +++ b/zfipc-ui/src/api/system/region.js @@ -0,0 +1,53 @@ +import request from "@/utils/request"; + +// 查询行政区划列表 +export function listRegion(query) { + return request({ + url: "/system/region/list", + method: "get", + params: query, + }); +} + +// 查询行政区划树数据 +export function listRegionAll(query) { + return request({ + url: "/system/region/listAll", + method: "get", + params: query, + }); +} + +// 查询行政区划详细 +export function getRegion(id) { + return request({ + url: "/system/region/" + id, + method: "get", + }); +} + +// 新增行政区划 +export function addRegion(data) { + return request({ + url: "/system/region", + method: "post", + data: data, + }); +} + +// 修改行政区划 +export function updateRegion(data) { + return request({ + url: "/system/region", + method: "put", + data: data, + }); +} + +// 删除行政区划 +export function delRegion(id) { + return request({ + url: "/system/region/" + id, + method: "delete", + }); +} diff --git a/zfipc-ui/src/views/system/dept/index.vue b/zfipc-ui/src/views/system/dept/index.vue index e502b4e..e7927eb 100644 --- a/zfipc-ui/src/views/system/dept/index.vue +++ b/zfipc-ui/src/views/system/dept/index.vue @@ -1,7 +1,16 @@