瀏覽代碼

fix 新增网格下拉接口

tjf 3 年之前
父節點
當前提交
8b356693dc

+ 99 - 0
boman-web-core/src/main/java/com/boman/web/core/controller/GridInfoController.java

@@ -0,0 +1,99 @@
+package com.boman.web.core.controller;
+
+import java.util.List;
+import javax.servlet.http.HttpServletResponse;
+
+import com.boman.common.core.utils.StringUtils;
+import com.boman.common.core.utils.poi.ExcelUtil;
+import com.boman.common.core.web.controller.BaseController;
+import com.boman.common.log.enums.BusinessType;
+import com.boman.common.security.annotation.PreAuthorize;
+import com.boman.domain.TableDataInfo;
+import com.boman.domain.dto.AjaxResult;
+import com.boman.web.core.domain.GridInfo;
+import com.boman.web.core.service.grid.IGridInfoService;
+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;
+/**
+ * 网格信息Controller
+ * 
+ * @author boman
+ * @date 2022-01-19
+ */
+@RestController
+@RequestMapping("/gridInfo")
+public class GridInfoController extends BaseController
+{
+    @Autowired
+    private IGridInfoService gridInfoService;
+
+    /**
+     * 查询网格信息列表
+     */
+    @GetMapping("/list")
+    public TableDataInfo list(GridInfo gridInfo)
+    {
+        startPage();
+        List<GridInfo> list = gridInfoService.selectGridInfoList(gridInfo);
+        return getDataTable(list);
+    }
+
+
+    /**
+     * 获取网格信息详细信息
+     */
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") Long id)
+    {
+        return AjaxResult.success(gridInfoService.selectGridInfoById(id));
+    }
+
+    /**
+     * 新增网格信息
+     */
+    @PostMapping
+    public AjaxResult add(@RequestBody GridInfo gridInfo)
+    {
+        return toAjax(gridInfoService.insertGridInfo(gridInfo));
+    }
+
+    /**
+     * 修改网格信息
+     */
+    @PutMapping
+    public AjaxResult edit(@RequestBody GridInfo gridInfo)
+    {
+        return toAjax(gridInfoService.updateGridInfo(gridInfo));
+    }
+
+    /**
+     * 删除网格信息
+     */
+	@DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids)
+    {
+        return toAjax(gridInfoService.deleteGridInfoByIds(ids));
+    }
+
+
+    /**
+     * 网格信息下拉菜单
+     */
+    @PostMapping("/treeSelect")
+    public AjaxResult treeSelect(@RequestBody GridInfo gridInfo)
+    {
+        String areaName = gridInfo.getAreaName();
+        if (StringUtils.isNotBlank(areaName)){
+            gridInfo.setType("1");
+        }
+        AjaxResult ajaxResult = gridInfoService.treeSelect(gridInfo);
+        return AjaxResult.success(ajaxResult);
+    }
+}

+ 111 - 0
boman-web-core/src/main/java/com/boman/web/core/domain/GridInfo.java

@@ -0,0 +1,111 @@
+package com.boman.web.core.domain;
+
+import com.boman.domain.BaseEntity;
+import com.boman.domain.annotation.Excel;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+/**
+ * 网格信息对象 grid_info
+ * 
+ * @author boman
+ * @date 2022-01-19
+ */
+public class GridInfo extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 网格id */
+    private Long id;
+
+    /** 区域名称 */
+    @Excel(name = "区域名称")
+    private String areaName;
+
+    /** 网格名称 */
+    @Excel(name = "网格名称")
+    private String gridName;
+
+    /** 排序 */
+    @Excel(name = "排序")
+    private String sort;
+
+    /** 0:区域 1:网格 */
+    @Excel(name = "0:区域 1:网格")
+    private String type;
+
+    /** 是否删除 */
+    @Excel(name = "是否删除")
+    private String isDel;
+
+    public void setId(Long id) 
+    {
+        this.id = id;
+    }
+
+    public Long getId() 
+    {
+        return id;
+    }
+    public void setAreaName(String areaName) 
+    {
+        this.areaName = areaName;
+    }
+
+    public String getAreaName() 
+    {
+        return areaName;
+    }
+    public void setGridName(String gridName) 
+    {
+        this.gridName = gridName;
+    }
+
+    public String getGridName() 
+    {
+        return gridName;
+    }
+    public void setSort(String sort) 
+    {
+        this.sort = sort;
+    }
+
+    public String getSort() 
+    {
+        return sort;
+    }
+    public void setType(String type) 
+    {
+        this.type = type;
+    }
+
+    public String getType() 
+    {
+        return type;
+    }
+    public void setIsDel(String isDel) 
+    {
+        this.isDel = isDel;
+    }
+
+    public String getIsDel() 
+    {
+        return isDel;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("id", getId())
+            .append("areaName", getAreaName())
+            .append("gridName", getGridName())
+            .append("sort", getSort())
+            .append("type", getType())
+            .append("createBy", getCreateBy())
+            .append("createTime", getCreateTime())
+            .append("updateBy", getUpdateBy())
+            .append("updateTime", getUpdateTime())
+            .append("isDel", getIsDel())
+            .toString();
+    }
+}

+ 68 - 0
boman-web-core/src/main/java/com/boman/web/core/mapper/GridInfoMapper.java

@@ -0,0 +1,68 @@
+package com.boman.web.core.mapper;
+
+import com.boman.web.core.domain.GridInfo;
+import java.util.List;
+
+/**
+ * 网格信息Mapper接口
+ * 
+ * @author boman
+ * @date 2022-01-19
+ */
+public interface GridInfoMapper 
+{
+    /**
+     * 查询网格信息
+     * 
+     * @param id 网格信息主键
+     * @return 网格信息
+     */
+    public GridInfo selectGridInfoById(Long id);
+
+    /**
+     * 查询网格信息列表
+     * 
+     * @param gridInfo 网格信息
+     * @return 网格信息集合
+     */
+    public List<GridInfo> selectGridInfoList(GridInfo gridInfo);
+
+    /**
+     * 新增网格信息
+     * 
+     * @param gridInfo 网格信息
+     * @return 结果
+     */
+    public int insertGridInfo(GridInfo gridInfo);
+
+    /**
+     * 修改网格信息
+     * 
+     * @param gridInfo 网格信息
+     * @return 结果
+     */
+    public int updateGridInfo(GridInfo gridInfo);
+
+    /**
+     * 删除网格信息
+     * 
+     * @param id 网格信息主键
+     * @return 结果
+     */
+    public int deleteGridInfoById(Long id);
+
+    /**
+     * 批量删除网格信息
+     * 
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteGridInfoByIds(Long[] ids);
+
+    /**
+     * 网格信息下拉菜单
+     * @param gridInfo
+     * @return
+     */
+    List<GridInfo>treeSelect(GridInfo gridInfo);
+}

+ 71 - 0
boman-web-core/src/main/java/com/boman/web/core/service/grid/IGridInfoService.java

@@ -0,0 +1,71 @@
+package com.boman.web.core.service.grid;
+
+
+import com.boman.domain.dto.AjaxResult;
+import com.boman.web.core.domain.GridInfo;
+
+import java.util.List;
+
+/**
+ * 网格信息Service接口
+ * 
+ * @author boman
+ * @date 2022-01-19
+ */
+public interface IGridInfoService 
+{
+    /**
+     * 查询网格信息
+     * 
+     * @param id 网格信息主键
+     * @return 网格信息
+     */
+    public GridInfo selectGridInfoById(Long id);
+
+    /**
+     * 查询网格信息列表
+     * 
+     * @param gridInfo 网格信息
+     * @return 网格信息集合
+     */
+    public List<GridInfo> selectGridInfoList(GridInfo gridInfo);
+
+    /**
+     * 新增网格信息
+     * 
+     * @param gridInfo 网格信息
+     * @return 结果
+     */
+    public int insertGridInfo(GridInfo gridInfo);
+
+    /**
+     * 修改网格信息
+     * 
+     * @param gridInfo 网格信息
+     * @return 结果
+     */
+    public int updateGridInfo(GridInfo gridInfo);
+
+    /**
+     * 批量删除网格信息
+     * 
+     * @param ids 需要删除的网格信息主键集合
+     * @return 结果
+     */
+    public int deleteGridInfoByIds(Long[] ids);
+
+    /**
+     * 删除网格信息信息
+     * 
+     * @param id 网格信息主键
+     * @return 结果
+     */
+    public int deleteGridInfoById(Long id);
+
+    /**
+     * 网格信息下拉菜单
+     * @param gridInfo
+     * @return
+     */
+    AjaxResult treeSelect(GridInfo gridInfo);
+}

+ 110 - 0
boman-web-core/src/main/java/com/boman/web/core/service/grid/impl/GridInfoServiceImpl.java

@@ -0,0 +1,110 @@
+package com.boman.web.core.service.grid.impl;
+
+
+import com.boman.common.core.utils.DateUtils;
+import com.boman.domain.dto.AjaxResult;
+import com.boman.web.core.domain.GridInfo;
+import com.boman.web.core.mapper.GridInfoMapper;
+import com.boman.web.core.service.grid.IGridInfoService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 网格信息Service业务层处理
+ * 
+ * @author boman
+ * @date 2022-01-19
+ */
+@Service
+public class GridInfoServiceImpl implements IGridInfoService
+{
+    @Autowired
+    private GridInfoMapper gridInfoMapper;
+
+    /**
+     * 查询网格信息
+     * 
+     * @param id 网格信息主键
+     * @return 网格信息
+     */
+    @Override
+    public GridInfo selectGridInfoById(Long id)
+    {
+        return gridInfoMapper.selectGridInfoById(id);
+    }
+
+    /**
+     * 查询网格信息列表
+     * 
+     * @param gridInfo 网格信息
+     * @return 网格信息
+     */
+    @Override
+    public List<GridInfo> selectGridInfoList(GridInfo gridInfo)
+    {
+        return gridInfoMapper.selectGridInfoList(gridInfo);
+    }
+
+    /**
+     * 新增网格信息
+     * 
+     * @param gridInfo 网格信息
+     * @return 结果
+     */
+    @Override
+    public int insertGridInfo(GridInfo gridInfo)
+    {
+        gridInfo.setCreateTime(DateUtils.getNowDate());
+        return gridInfoMapper.insertGridInfo(gridInfo);
+    }
+
+    /**
+     * 修改网格信息
+     * 
+     * @param gridInfo 网格信息
+     * @return 结果
+     */
+    @Override
+    public int updateGridInfo(GridInfo gridInfo)
+    {
+        gridInfo.setUpdateTime(DateUtils.getNowDate());
+        return gridInfoMapper.updateGridInfo(gridInfo);
+    }
+
+    /**
+     * 批量删除网格信息
+     * 
+     * @param ids 需要删除的网格信息主键
+     * @return 结果
+     */
+    @Override
+    public int deleteGridInfoByIds(Long[] ids)
+    {
+        return gridInfoMapper.deleteGridInfoByIds(ids);
+    }
+
+    /**
+     * 删除网格信息信息
+     * 
+     * @param id 网格信息主键
+     * @return 结果
+     */
+    @Override
+    public int deleteGridInfoById(Long id)
+    {
+        return gridInfoMapper.deleteGridInfoById(id);
+    }
+
+    /**
+     * 网格信息下拉菜单
+     * @param gridInfo
+     * @return
+     */
+    @Override
+    public AjaxResult treeSelect(GridInfo gridInfo) {
+        List<GridInfo> gridInfos = gridInfoMapper.treeSelect(gridInfo);
+        return AjaxResult.success(gridInfos);
+    }
+}

+ 102 - 0
boman-web-core/src/main/resources/mapper/GridInfoMapper.xml

@@ -0,0 +1,102 @@
+<?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.boman.web.core.mapper.GridInfoMapper">
+    
+    <resultMap type="GridInfo" id="GridInfoResult">
+        <result property="id"    column="id"    />
+        <result property="areaName"    column="area_name"    />
+        <result property="gridName"    column="grid_name"    />
+        <result property="sort"    column="sort"    />
+        <result property="type"    column="type"    />
+        <result property="createBy"    column="create_by"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateBy"    column="update_by"    />
+        <result property="updateTime"    column="update_time"    />
+        <result property="isDel"    column="is_del"    />
+    </resultMap>
+
+    <sql id="selectGridInfoVo">
+        select id, area_name, grid_name, sort, type, create_by, create_time, update_by, update_time, is_del from grid_info
+    </sql>
+
+    <select id="selectGridInfoList" parameterType="GridInfo" resultMap="GridInfoResult">
+        <include refid="selectGridInfoVo"/>
+        <where>  
+            <if test="areaName != null  and areaName != ''"> and area_name like concat('%', #{areaName}, '%')</if>
+            <if test="gridName != null  and gridName != ''"> and grid_name like concat('%', #{gridName}, '%')</if>
+            <if test="sort != null  and sort != ''"> and sort = #{sort}</if>
+            <if test="type != null  and type != ''"> and type = #{type}</if>
+            <if test="isDel != null  and isDel != ''"> and is_del = #{isDel}</if>
+        </where>
+    </select>
+    
+    <select id="selectGridInfoById" parameterType="Long" resultMap="GridInfoResult">
+        <include refid="selectGridInfoVo"/>
+        where id = #{id}
+    </select>
+        
+    <insert id="insertGridInfo" parameterType="GridInfo" useGeneratedKeys="true" keyProperty="id">
+        insert into grid_info
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="areaName != null and areaName != ''">area_name,</if>
+            <if test="gridName != null and gridName != ''">grid_name,</if>
+            <if test="sort != null and sort != ''">sort,</if>
+            <if test="type != null">type,</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>
+            <if test="isDel != null">is_del,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="areaName != null and areaName != ''">#{areaName},</if>
+            <if test="gridName != null and gridName != ''">#{gridName},</if>
+            <if test="sort != null and sort != ''">#{sort},</if>
+            <if test="type != null">#{type},</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>
+            <if test="isDel != null">#{isDel},</if>
+         </trim>
+    </insert>
+
+    <update id="updateGridInfo" parameterType="GridInfo">
+        update grid_info
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="areaName != null and areaName != ''">area_name = #{areaName},</if>
+            <if test="gridName != null and gridName != ''">grid_name = #{gridName},</if>
+            <if test="sort != null and sort != ''">sort = #{sort},</if>
+            <if test="type != null">type = #{type},</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>
+            <if test="isDel != null">is_del = #{isDel},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <delete id="deleteGridInfoById" parameterType="Long">
+        delete from grid_info where id = #{id}
+    </delete>
+
+    <delete id="deleteGridInfoByIds" parameterType="String">
+        delete from grid_info where id in 
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+
+    <select id="treeSelect" parameterType="GridInfo" resultMap="GridInfoResult">
+        select area_name, grid_name, sort, type, from grid_info
+        <where>
+            is_del = 'N'
+            <if test="areaName != null  and areaName != ''"> and area_name like concat('%', #{areaName}, '%')</if>
+            <if test="type != null  and type != ''"> and type = #{type}</if>
+        </where>
+        order by sort
+    </select>
+</mapper>