From 9e0966deb9d6c6d2b1426bf2afca8fe74d2d5949 Mon Sep 17 00:00:00 2001 From: sxu <602087911@qq.com> Date: Tue, 18 Feb 2025 19:34:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8C=BA=E5=9F=9F=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/SysAllocAreaController.java | 112 ++++++++++++++++++ .../com/bonus/system/domain/SysAllocArea.java | 53 +++++++++ .../system/mapper/SysAllocAreaMapper.java | 60 ++++++++++ .../system/service/ISysAllocAreaService.java | 60 ++++++++++ .../service/impl/SysAllocAreaServiceImpl.java | 98 +++++++++++++++ .../mapper/system/SysAllocAreaMapper.xml | 97 +++++++++++++++ 6 files changed, 480 insertions(+) create mode 100644 bonus-modules/bonus-system/src/main/java/com/bonus/system/controller/SysAllocAreaController.java create mode 100644 bonus-modules/bonus-system/src/main/java/com/bonus/system/domain/SysAllocArea.java create mode 100644 bonus-modules/bonus-system/src/main/java/com/bonus/system/mapper/SysAllocAreaMapper.java create mode 100644 bonus-modules/bonus-system/src/main/java/com/bonus/system/service/ISysAllocAreaService.java create mode 100644 bonus-modules/bonus-system/src/main/java/com/bonus/system/service/impl/SysAllocAreaServiceImpl.java create mode 100644 bonus-modules/bonus-system/src/main/resources/mapper/system/SysAllocAreaMapper.xml diff --git a/bonus-modules/bonus-system/src/main/java/com/bonus/system/controller/SysAllocAreaController.java b/bonus-modules/bonus-system/src/main/java/com/bonus/system/controller/SysAllocAreaController.java new file mode 100644 index 0000000..a8b2d5a --- /dev/null +++ b/bonus-modules/bonus-system/src/main/java/com/bonus/system/controller/SysAllocAreaController.java @@ -0,0 +1,112 @@ +package com.bonus.system.controller; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; +import com.bonus.common.log.enums.OperaType; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +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.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.bonus.common.log.annotation.SysLog; +import com.bonus.common.security.annotation.RequiresPermissions; +import com.bonus.system.domain.SysAllocArea; +import com.bonus.system.service.ISysAllocAreaService; +import com.bonus.common.core.web.controller.BaseController; +import com.bonus.common.core.web.domain.AjaxResult; +import com.bonus.common.core.utils.poi.ExcelUtil; +import com.bonus.common.core.web.page.TableDataInfo; + +/** + * 区域Controller + * + * @author xsheng + * @date 2025-02-18 + */ +@Api(tags = "区域接口") +@RestController +@RequestMapping("/sys_alloc_area") +public class SysAllocAreaController extends BaseController { + @Autowired + private ISysAllocAreaService sysAllocAreaService; + + /** + * 查询区域列表 + */ + @ApiOperation(value = "查询区域列表") + @RequiresPermissions("system:area:list") + @GetMapping("/list") + public TableDataInfo list(SysAllocArea sysAllocArea) { + startPage(); + List list = sysAllocAreaService.selectSysAllocAreaList(sysAllocArea); + return getDataTable(list); + } + + /** + * 导出区域列表 + */ + @ApiOperation(value = "导出区域列表") + @RequiresPermissions("system:area:export") + @SysLog(title = "区域", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出区域") + @PostMapping("/export") + public void export(HttpServletResponse response, SysAllocArea sysAllocArea) { + List list = sysAllocAreaService.selectSysAllocAreaList(sysAllocArea); + ExcelUtil util = new ExcelUtil(SysAllocArea.class); + util.exportExcel(response, list, "区域数据"); + } + + /** + * 获取区域详细信息 + */ + @ApiOperation(value = "获取区域详细信息") + @RequiresPermissions("system:area:query") + @GetMapping(value = "/{areaId}") + public AjaxResult getInfo(@PathVariable("areaId") Long areaId) { + return success(sysAllocAreaService.selectSysAllocAreaByAreaId(areaId)); + } + + /** + * 新增区域 + */ + @ApiOperation(value = "新增区域") + @RequiresPermissions("system:area:add") + @SysLog(title = "区域", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增区域") + @PostMapping + public AjaxResult add(@RequestBody SysAllocArea sysAllocArea) { + try { + return toAjax(sysAllocAreaService.insertSysAllocArea(sysAllocArea)); + } catch (Exception e) { + return error("系统错误, " + e.getMessage()); + } + } + + /** + * 修改区域 + */ + @ApiOperation(value = "修改区域") + @RequiresPermissions("system:area:edit") + @SysLog(title = "区域", businessType = OperaType.UPDATE, logType = 1,module = "仓储管理->修改区域") + @PostMapping("/edit") + public AjaxResult edit(@RequestBody SysAllocArea sysAllocArea) { + try { + return toAjax(sysAllocAreaService.updateSysAllocArea(sysAllocArea)); + } catch (Exception e) { + return error("系统错误, " + e.getMessage()); + } + } + + /** + * 删除区域 + */ + @ApiOperation(value = "删除区域") + @RequiresPermissions("system:area:remove") + @SysLog(title = "区域", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除区域") + @PostMapping("/del/{areaIds}") + public AjaxResult remove(@PathVariable Long[] areaIds) { + return toAjax(sysAllocAreaService.deleteSysAllocAreaByAreaIds(areaIds)); + } +} diff --git a/bonus-modules/bonus-system/src/main/java/com/bonus/system/domain/SysAllocArea.java b/bonus-modules/bonus-system/src/main/java/com/bonus/system/domain/SysAllocArea.java new file mode 100644 index 0000000..da25313 --- /dev/null +++ b/bonus-modules/bonus-system/src/main/java/com/bonus/system/domain/SysAllocArea.java @@ -0,0 +1,53 @@ +package com.bonus.system.domain; + +import com.bonus.common.core.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.ToString; +import com.bonus.common.core.web.domain.BaseEntity; + +/** + * 区域对象 sys_alloc_area + * + * @author xsheng + * @date 2025-02-18 + */ + + +@Data +@ToString +public class SysAllocArea extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** 区域id */ + private Long areaId; + + /** 父区域id */ + @Excel(name = "父区域id") + @ApiModelProperty(value = "父区域id") + private Long parentId; + + /** 祖级列表 */ + @Excel(name = "祖级列表") + @ApiModelProperty(value = "祖级列表") + private String ancestors; + + /** 区域名称 */ + @Excel(name = "区域名称") + @ApiModelProperty(value = "区域名称") + private String areaName; + + /** 显示顺序 */ + @Excel(name = "显示顺序") + @ApiModelProperty(value = "显示顺序") + private Long orderNum; + + /** 区域状态(0正常 1停用) */ + @Excel(name = "区域状态", readConverterExp = "0=正常,1=停用") + private String status; + + /** 删除标志(0代表存在 2代表删除) */ + private String delFlag; + + +} diff --git a/bonus-modules/bonus-system/src/main/java/com/bonus/system/mapper/SysAllocAreaMapper.java b/bonus-modules/bonus-system/src/main/java/com/bonus/system/mapper/SysAllocAreaMapper.java new file mode 100644 index 0000000..805c219 --- /dev/null +++ b/bonus-modules/bonus-system/src/main/java/com/bonus/system/mapper/SysAllocAreaMapper.java @@ -0,0 +1,60 @@ +package com.bonus.system.mapper; + +import java.util.List; +import com.bonus.system.domain.SysAllocArea; + +/** + * 区域Mapper接口 + * + * @author xsheng + * @date 2025-02-18 + */ +public interface SysAllocAreaMapper { + /** + * 查询区域 + * + * @param areaId 区域主键 + * @return 区域 + */ + public SysAllocArea selectSysAllocAreaByAreaId(Long areaId); + + /** + * 查询区域列表 + * + * @param sysAllocArea 区域 + * @return 区域集合 + */ + public List selectSysAllocAreaList(SysAllocArea sysAllocArea); + + /** + * 新增区域 + * + * @param sysAllocArea 区域 + * @return 结果 + */ + public int insertSysAllocArea(SysAllocArea sysAllocArea); + + /** + * 修改区域 + * + * @param sysAllocArea 区域 + * @return 结果 + */ + public int updateSysAllocArea(SysAllocArea sysAllocArea); + + /** + * 删除区域 + * + * @param areaId 区域主键 + * @return 结果 + */ + public int deleteSysAllocAreaByAreaId(Long areaId); + + /** + * 批量删除区域 + * + * @param areaIds 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteSysAllocAreaByAreaIds(Long[] areaIds); +} diff --git a/bonus-modules/bonus-system/src/main/java/com/bonus/system/service/ISysAllocAreaService.java b/bonus-modules/bonus-system/src/main/java/com/bonus/system/service/ISysAllocAreaService.java new file mode 100644 index 0000000..ff39e79 --- /dev/null +++ b/bonus-modules/bonus-system/src/main/java/com/bonus/system/service/ISysAllocAreaService.java @@ -0,0 +1,60 @@ +package com.bonus.system.service; + +import java.util.List; +import com.bonus.system.domain.SysAllocArea; + +/** + * 区域Service接口 + * + * @author xsheng + * @date 2025-02-18 + */ +public interface ISysAllocAreaService { + /** + * 查询区域 + * + * @param areaId 区域主键 + * @return 区域 + */ + public SysAllocArea selectSysAllocAreaByAreaId(Long areaId); + + /** + * 查询区域列表 + * + * @param sysAllocArea 区域 + * @return 区域集合 + */ + public List selectSysAllocAreaList(SysAllocArea sysAllocArea); + + /** + * 新增区域 + * + * @param sysAllocArea 区域 + * @return 结果 + */ + public int insertSysAllocArea(SysAllocArea sysAllocArea); + + /** + * 修改区域 + * + * @param sysAllocArea 区域 + * @return 结果 + */ + public int updateSysAllocArea(SysAllocArea sysAllocArea); + + /** + * 批量删除区域 + * + * @param areaIds 需要删除的区域主键集合 + * @return 结果 + */ + public int deleteSysAllocAreaByAreaIds(Long[] areaIds); + + /** + * 删除区域信息 + * + * @param areaId 区域主键 + * @return 结果 + */ + public int deleteSysAllocAreaByAreaId(Long areaId); +} diff --git a/bonus-modules/bonus-system/src/main/java/com/bonus/system/service/impl/SysAllocAreaServiceImpl.java b/bonus-modules/bonus-system/src/main/java/com/bonus/system/service/impl/SysAllocAreaServiceImpl.java new file mode 100644 index 0000000..2122ca2 --- /dev/null +++ b/bonus-modules/bonus-system/src/main/java/com/bonus/system/service/impl/SysAllocAreaServiceImpl.java @@ -0,0 +1,98 @@ +package com.bonus.system.service.impl; + +import java.util.List; +import com.bonus.common.core.exception.ServiceException; +import com.bonus.common.core.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.bonus.system.mapper.SysAllocAreaMapper; +import com.bonus.system.domain.SysAllocArea; +import com.bonus.system.service.ISysAllocAreaService; + +/** + * 区域Service业务层处理 + * + * @author xsheng + * @date 2025-02-18 + */ +@Service +public class SysAllocAreaServiceImpl implements ISysAllocAreaService { + @Autowired + private SysAllocAreaMapper sysAllocAreaMapper; + + /** + * 查询区域 + * + * @param areaId 区域主键 + * @return 区域 + */ + @Override + public SysAllocArea selectSysAllocAreaByAreaId(Long areaId) { + return sysAllocAreaMapper.selectSysAllocAreaByAreaId(areaId); + } + + /** + * 查询区域列表 + * + * @param sysAllocArea 区域 + * @return 区域 + */ + @Override + public List selectSysAllocAreaList(SysAllocArea sysAllocArea) { + return sysAllocAreaMapper.selectSysAllocAreaList(sysAllocArea); + } + + /** + * 新增区域 + * + * @param sysAllocArea 区域 + * @return 结果 + */ + @Override + public int insertSysAllocArea(SysAllocArea sysAllocArea) { + sysAllocArea.setCreateTime(DateUtils.getNowDate()); + try { + return sysAllocAreaMapper.insertSysAllocArea(sysAllocArea); + } catch (Exception e) { + throw new ServiceException("错误信息描述"); + } + } + + /** + * 修改区域 + * + * @param sysAllocArea 区域 + * @return 结果 + */ + @Override + public int updateSysAllocArea(SysAllocArea sysAllocArea) { + sysAllocArea.setUpdateTime(DateUtils.getNowDate()); + try { + return sysAllocAreaMapper.updateSysAllocArea(sysAllocArea); + } catch (Exception e) { + throw new ServiceException("错误信息描述"); + } + } + + /** + * 批量删除区域 + * + * @param areaIds 需要删除的区域主键 + * @return 结果 + */ + @Override + public int deleteSysAllocAreaByAreaIds(Long[] areaIds) { + return sysAllocAreaMapper.deleteSysAllocAreaByAreaIds(areaIds); + } + + /** + * 删除区域信息 + * + * @param areaId 区域主键 + * @return 结果 + */ + @Override + public int deleteSysAllocAreaByAreaId(Long areaId) { + return sysAllocAreaMapper.deleteSysAllocAreaByAreaId(areaId); + } +} diff --git a/bonus-modules/bonus-system/src/main/resources/mapper/system/SysAllocAreaMapper.xml b/bonus-modules/bonus-system/src/main/resources/mapper/system/SysAllocAreaMapper.xml new file mode 100644 index 0000000..3d61591 --- /dev/null +++ b/bonus-modules/bonus-system/src/main/resources/mapper/system/SysAllocAreaMapper.xml @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + select area_id, parent_id, ancestors, area_name, order_num, status, del_flag, create_by, create_time, update_by, update_time from sys_alloc_area + + + + + + + + insert into sys_alloc_area + + area_id, + parent_id, + ancestors, + area_name, + order_num, + status, + del_flag, + create_by, + create_time, + update_by, + update_time, + + + #{areaId}, + #{parentId}, + #{ancestors}, + #{areaName}, + #{orderNum}, + #{status}, + #{delFlag}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + + + + + update sys_alloc_area + + parent_id = #{parentId}, + ancestors = #{ancestors}, + area_name = #{areaName}, + order_num = #{orderNum}, + status = #{status}, + del_flag = #{delFlag}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + + where area_id = #{areaId} + + + + delete from sys_alloc_area where area_id = #{areaId} + + + + delete from sys_alloc_area where area_id in + + #{areaId} + + + \ No newline at end of file