区域管理
This commit is contained in:
parent
35cdcdcbab
commit
9e0966deb9
|
|
@ -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<SysAllocArea> 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<SysAllocArea> list = sysAllocAreaService.selectSysAllocAreaList(sysAllocArea);
|
||||||
|
ExcelUtil<SysAllocArea> util = new ExcelUtil<SysAllocArea>(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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -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<SysAllocArea> 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);
|
||||||
|
}
|
||||||
|
|
@ -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<SysAllocArea> 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);
|
||||||
|
}
|
||||||
|
|
@ -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<SysAllocArea> 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,97 @@
|
||||||
|
<?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="com.bonus.system.mapper.SysAllocAreaMapper">
|
||||||
|
<resultMap type="com.bonus.system.domain.SysAllocArea" id="SysAllocAreaResult">
|
||||||
|
<result property="areaId" column="area_id" />
|
||||||
|
<result property="parentId" column="parent_id" />
|
||||||
|
<result property="ancestors" column="ancestors" />
|
||||||
|
<result property="areaName" column="area_name" />
|
||||||
|
<result property="orderNum" column="order_num" />
|
||||||
|
<result property="status" column="status" />
|
||||||
|
<result property="delFlag" column="del_flag" />
|
||||||
|
<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>
|
||||||
|
|
||||||
|
<sql id="selectSysAllocAreaVo">
|
||||||
|
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
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectSysAllocAreaList" parameterType="com.bonus.system.domain.SysAllocArea" resultMap="SysAllocAreaResult">
|
||||||
|
<include refid="selectSysAllocAreaVo"/>
|
||||||
|
<where>
|
||||||
|
<if test="parentId != null "> and parent_id = #{parentId}</if>
|
||||||
|
<if test="ancestors != null and ancestors != ''"> and ancestors = #{ancestors}</if>
|
||||||
|
<if test="areaName != null and areaName != ''"> and area_name like concat('%', #{areaName}, '%')</if>
|
||||||
|
<if test="orderNum != null "> and order_num = #{orderNum}</if>
|
||||||
|
<if test="status != null and status != ''"> and status = #{status}</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectSysAllocAreaByAreaId" parameterType="Long" resultMap="SysAllocAreaResult">
|
||||||
|
<include refid="selectSysAllocAreaVo"/>
|
||||||
|
where area_id = #{areaId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertSysAllocArea" parameterType="com.bonus.system.domain.SysAllocArea">
|
||||||
|
insert into sys_alloc_area
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="areaId != null">area_id,</if>
|
||||||
|
<if test="parentId != null">parent_id,</if>
|
||||||
|
<if test="ancestors != null">ancestors,</if>
|
||||||
|
<if test="areaName != null">area_name,</if>
|
||||||
|
<if test="orderNum != null">order_num,</if>
|
||||||
|
<if test="status != null">status,</if>
|
||||||
|
<if test="delFlag != null">del_flag,</if>
|
||||||
|
<if test="createBy != null">create_by,</if>
|
||||||
|
<if test="createTime != null">create_time,</if>
|
||||||
|
<if test="updateBy != null">update_by,</if>
|
||||||
|
<if test="updateTime != null">update_time,</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="areaId != null">#{areaId},</if>
|
||||||
|
<if test="parentId != null">#{parentId},</if>
|
||||||
|
<if test="ancestors != null">#{ancestors},</if>
|
||||||
|
<if test="areaName != null">#{areaName},</if>
|
||||||
|
<if test="orderNum != null">#{orderNum},</if>
|
||||||
|
<if test="status != null">#{status},</if>
|
||||||
|
<if test="delFlag != null">#{delFlag},</if>
|
||||||
|
<if test="createBy != null">#{createBy},</if>
|
||||||
|
<if test="createTime != null">#{createTime},</if>
|
||||||
|
<if test="updateBy != null">#{updateBy},</if>
|
||||||
|
<if test="updateTime != null">#{updateTime},</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateSysAllocArea" parameterType="com.bonus.system.domain.SysAllocArea">
|
||||||
|
update sys_alloc_area
|
||||||
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
<if test="parentId != null">parent_id = #{parentId},</if>
|
||||||
|
<if test="ancestors != null">ancestors = #{ancestors},</if>
|
||||||
|
<if test="areaName != null">area_name = #{areaName},</if>
|
||||||
|
<if test="orderNum != null">order_num = #{orderNum},</if>
|
||||||
|
<if test="status != null">status = #{status},</if>
|
||||||
|
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||||||
|
<if test="createBy != null">create_by = #{createBy},</if>
|
||||||
|
<if test="createTime != null">create_time = #{createTime},</if>
|
||||||
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||||
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||||
|
</trim>
|
||||||
|
where area_id = #{areaId}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<delete id="deleteSysAllocAreaByAreaId" parameterType="Long">
|
||||||
|
delete from sys_alloc_area where area_id = #{areaId}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deleteSysAllocAreaByAreaIds" parameterType="String">
|
||||||
|
delete from sys_alloc_area where area_id in
|
||||||
|
<foreach item="areaId" collection="array" open="(" separator="," close=")">
|
||||||
|
#{areaId}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
</mapper>
|
||||||
Loading…
Reference in New Issue