管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2023-03-07 11a649a1c1c48546be1394c0437d0cf284010db7
1
已添加5个文件
已修改2个文件
669 ■■■■■ 文件已修改
data/db_cx.sql 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/controller/show/ModelController.java 253 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/entity/bs/SsurveyinformationEntity.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/entity/show/ModelEntity.java 155 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/mapper/show/ModelMapper.java 96 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/service/show/ModelService.java 69 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/show/ModelMapper.xml 74 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
data/db_cx.sql
@@ -9,10 +9,16 @@
select * from lf.sys_attach where tab='lf.sys_style';
select * from lf.sys_attach order by tab,tab_guid;
select * from bs.s_survey_information --勘察信息表,汉江穿越
select * from bs.s_surveyworksite --勘察工点
select * from bs.s_survey_information; --勘察信息表,汉江穿越
alter table bs.s_survey_information add column workname varchar(50);
update bs.s_survey_information set workname='汉江穿越' where gid=1;
select * from bs.s_surveyworksite; --勘察工点
select * from lf.sys_download order by id desc;
select * from lf.sys_layer where en_name is not null;
select * from lf.sys_layer where url is not null and serve_type='WMS' and data_type in ('工程项目','工程项目-地灾类','工程项目-测量类','工程项目-洞库类','工程项目-勘察类') order by id;
src/main/java/com/lf/server/controller/show/ModelController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,253 @@
package com.lf.server.controller.show;
import com.lf.server.annotation.SysLog;
import com.lf.server.controller.all.BaseController;
import com.lf.server.entity.all.ResponseMsg;
import com.lf.server.entity.show.ModelEntity;
import com.lf.server.entity.sys.UserEntity;
import com.lf.server.service.show.ModelService;
import com.lf.server.service.sys.TokenService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
 * æ¨¡åž‹
 * @author WWW
 */
@Api(tags = "综合展示\\模型")
@RestController
@RequestMapping("/model")
public class ModelController extends BaseController {
    @Autowired
    ModelService modelService;
    @Autowired
    TokenService tokenService;
    @SysLog()
    @ApiOperation(value = "查询记录数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "layerid", value = "图层ID", dataType = "Integer", paramType = "query", required = false, example = "")
    })
    @GetMapping({"/selectCount"})
    public ResponseMsg<Integer> selectCount(Integer layerid) {
        try {
            int count = modelService.selectCount(layerid);
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
        }
    }
    @SysLog()
    @ApiOperation(value = "分页查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "layerid", value = "图层ID", dataType = "Integer", paramType = "query", example = ""),
            @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "Integer", paramType = "query", example = "10"),
            @ApiImplicitParam(name = "pageIndex", value = "分页数(从1开始)", dataType = "Integer", paramType = "query", example = "1")
    })
    @GetMapping(value = "/selectByPage")
    public ResponseMsg<List<ModelEntity>> selectByPage(Integer layerid, Integer pageSize, Integer pageIndex) {
        try {
            if (pageSize < 1 || pageIndex < 1) {
                return fail("每页页数或分页数小于1", null);
            }
            List<ModelEntity> rs = modelService.selectByPage(layerid, pageSize, pageSize * (pageIndex - 1));
            return success(rs);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
        }
    }
    @SysLog()
    @ApiOperation(value = "分页查询并返回记录数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "layerid", value = "图层ID", dataType = "Integer", paramType = "query", example = ""),
            @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "Integer", paramType = "query", example = "10"),
            @ApiImplicitParam(name = "pageIndex", value = "分页数(从1开始)", dataType = "Integer", paramType = "query", example = "1")
    })
    @GetMapping(value = "/selectByPageAndCount")
    public ResponseMsg<List<ModelEntity>> selectByPageAndCount(Integer layerid, Integer pageSize, Integer pageIndex) {
        try {
            if (pageSize < 1 || pageIndex < 1) {
                return fail("每页页数或分页数小于1", null);
            }
            int count = modelService.selectCount(layerid);
            if (count == 0) {
                return success(0, null);
            }
            List<ModelEntity> rs = modelService.selectByPage(layerid, pageSize, pageSize * (pageIndex - 1));
            return success(count, rs);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
        }
    }
    @SysLog()
    @ApiOperation(value = "查询所有")
    @GetMapping(value = "/selectAll")
    public ResponseMsg<List<ModelEntity>> selectAll() {
        try {
            List<ModelEntity> list = modelService.selectAll();
            return success(list);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
        }
    }
    @SysLog()
    @ApiOperation(value = "根据ID查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", dataType = "int", paramType = "query", example = "1")
    })
    @GetMapping(value = "/selectById")
    public ResponseMsg<ModelEntity> selectById(int id) {
        try {
            ModelEntity entity = modelService.selectById(id);
            return success(entity);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
        }
    }
    @SysLog()
    @ApiOperation(value = "插入一条")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "entity", value = "实体类", dataType = "ModelEntity", paramType = "body")
    })
    @PostMapping(value = "/insert", produces = "application/json; charset=UTF-8")
    public ResponseMsg<Integer> insert(@RequestBody ModelEntity entity, HttpServletRequest req) {
        try {
            UserEntity ue = tokenService.getCurrentUser(req);
            if (ue != null) {
                entity.setCreateUser(ue.getId());
            }
            int count = modelService.insert(entity);
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
        }
    }
    @SysLog()
    @ApiOperation(value = "插入多条")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "list", value = "实体类集合", dataType = "ModelEntity", paramType = "body")
    })
    @PostMapping(value = "/inserts", produces = "application/json; charset=UTF-8")
    public ResponseMsg<Integer> inserts(@RequestBody List<ModelEntity> list, HttpServletRequest req) {
        try {
            UserEntity ue = tokenService.getCurrentUser(req);
            if (ue != null) {
                for (ModelEntity entity : list) {
                    entity.setCreateUser(ue.getId());
                }
            }
            int count = modelService.inserts(list);
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
        }
    }
    @SysLog()
    @ApiOperation(value = "删除一条")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", dataType = "Integer", paramType = "query", example = "1")
    })
    @GetMapping(value = "/delete")
    public ResponseMsg<Integer> delete(int id) {
        try {
            int count = modelService.delete(id);
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
        }
    }
    @SysLog()
    @ApiOperation(value = "删除多条")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ids", value = "ID数组", dataType = "Integer", paramType = "query", example = "1,2")
    })
    @GetMapping(value = "/deletes")
    public ResponseMsg<Integer> deletes(@RequestParam List<Integer> ids) {
        try {
            if (ids == null || ids.isEmpty()) {
                return fail("id数组不能为空", -1);
            }
            int count = modelService.deletes(ids);
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
        }
    }
    @SysLog()
    @ApiOperation(value = "更新一条")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "entity", value = "实体类", dataType = "ModelEntity", paramType = "body")
    })
    @ResponseBody
    @PostMapping(value = "/update", produces = "application/json; charset=UTF-8")
    public ResponseMsg<Integer> update(@RequestBody ModelEntity entity, HttpServletRequest req) {
        try {
            UserEntity ue = tokenService.getCurrentUser(req);
            if (ue != null) {
                entity.setUpdateUser(ue.getId());
            }
            int count = modelService.update(entity);
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
        }
    }
    @SysLog()
    @ApiOperation(value = "更新多条")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "list", value = "实体类集合", dataType = "ModelEntity", paramType = "body")
    })
    @ResponseBody
    @PostMapping(value = "/updates", produces = "application/json; charset=UTF-8")
    public ResponseMsg<Integer> updates(@RequestBody List<ModelEntity> list, HttpServletRequest req) {
        try {
            UserEntity ue = tokenService.getCurrentUser(req);
            if (ue != null) {
                for (ModelEntity entity : list) {
                    entity.setUpdateUser(ue.getId());
                }
            }
            int count = modelService.updates(list);
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
        }
    }
}
src/main/java/com/lf/server/entity/bs/SsurveyinformationEntity.java
@@ -150,6 +150,8 @@
    private String remarks;
    private String workname;
    public SsurveyinformationEntity() {
    }
@@ -672,4 +674,12 @@
    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }
    public String getWorkname() {
        return workname;
    }
    public void setWorkname(String workname) {
        this.workname = workname;
    }
}
src/main/java/com/lf/server/entity/show/ModelEntity.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,155 @@
package com.lf.server.entity.show;
import java.io.Serializable;
import java.sql.Timestamp;
/**
 * æ¨¡åž‹
 * @author WWW
 */
public class ModelEntity implements Serializable {
    private static final long serialVersionUID = -41778639909708240L;
    private int id;
    private int layerid;
    private String modelid;
    private String guid;
    private String name;
    private int type;
    private String info;
    private String url;
    private String icon;
    private int createUser;
    private Timestamp createTime;
    private int updateUser;
    private Timestamp updateTime;
    private String bak;
    public ModelEntity() {
    }
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public int getLayerid() {
        return layerid;
    }
    public void setLayerid(int layerid) {
        this.layerid = layerid;
    }
    public String getModelid() {
        return modelid;
    }
    public void setModelid(String modelid) {
        this.modelid = modelid;
    }
    public String getGuid() {
        return guid;
    }
    public void setGuid(String guid) {
        this.guid = guid;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getType() {
        return type;
    }
    public void setType(int type) {
        this.type = type;
    }
    public String getInfo() {
        return info;
    }
    public void setInfo(String info) {
        this.info = info;
    }
    public String getUrl() {
        return url;
    }
    public void setUrl(String url) {
        this.url = url;
    }
    public String getIcon() {
        return icon;
    }
    public void setIcon(String icon) {
        this.icon = icon;
    }
    public int getCreateUser() {
        return createUser;
    }
    public void setCreateUser(int createUser) {
        this.createUser = createUser;
    }
    public Timestamp getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }
    public int getUpdateUser() {
        return updateUser;
    }
    public void setUpdateUser(int updateUser) {
        this.updateUser = updateUser;
    }
    public Timestamp getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Timestamp updateTime) {
        this.updateTime = updateTime;
    }
    public String getBak() {
        return bak;
    }
    public void setBak(String bak) {
        this.bak = bak;
    }
}
src/main/java/com/lf/server/mapper/show/ModelMapper.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,96 @@
package com.lf.server.mapper.show;
import com.lf.server.entity.show.ModelEntity;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
 * æ¨¡åž‹
 * @author WWW
 */
@Mapper
@Repository
public interface ModelMapper {
    /**
     * æŸ¥è¯¢è®°å½•æ•°
     *
     * @param layerid å›¾å±‚ID
     * @return è®°å½•æ•°
     */
    public Integer selectCount(Integer layerid);
    /**
     * åˆ†é¡µæŸ¥è¯¢
     *
     * @param layerid   å›¾å±‚ID
     * @param limit  è®°å½•æ•°
     * @param offset åç§»é‡
     * @return åˆ—表
     */
    public List<ModelEntity> selectByPage(Integer layerid, Integer limit, Integer offset);
    /**
     * æŸ¥è¯¢æ‰€æœ‰
     *
     * @return
     */
    public List<ModelEntity> selectAll();
    /**
     * æ ¹æ®ID查询
     *
     * @param id
     * @return
     */
    public ModelEntity selectById(int id);
    /**
     * æ’入一条
     *
     * @param entity
     * @return
     */
    public Integer insert(ModelEntity entity);
    /**
     * æ’入多条
     *
     * @param list
     * @return
     */
    public Integer inserts(List<ModelEntity> list);
    /**
     * åˆ é™¤ä¸€æ¡
     *
     * @param id
     * @return
     */
    public Integer delete(int id);
    /**
     * åˆ é™¤å¤šæ¡
     *
     * @param ids
     * @return
     */
    public Integer deletes(List<Integer> ids);
    /**
     * æ›´æ–°ä¸€æ¡
     *
     * @param entity
     * @return
     */
    public Integer update(ModelEntity entity);
    /**
     * æ›´æ–°å¤šæ¡
     *
     * @param list
     * @return
     */
    public Integer updates(List<ModelEntity> list);
}
src/main/java/com/lf/server/service/show/ModelService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,69 @@
package com.lf.server.service.show;
import com.lf.server.entity.show.ModelEntity;
import com.lf.server.helper.StringHelper;
import com.lf.server.mapper.show.ModelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
 * æ¨¡åž‹
 * @author WWW
 */
@Service
public class ModelService implements ModelMapper {
    @Autowired
    ModelMapper modelMapper;
    @Override
    public Integer selectCount(Integer layerid) {
        return modelMapper.selectCount(layerid);
    }
    @Override
    public List<ModelEntity> selectByPage(Integer layerid, Integer limit, Integer offset) {
        return modelMapper.selectByPage(layerid, limit, offset);
    }
    @Override
    public List<ModelEntity> selectAll() {
        return modelMapper.selectAll();
    }
    @Override
    public ModelEntity selectById(int id) {
        return modelMapper.selectById(id);
    }
    @Override
    public Integer insert(ModelEntity entity) {
        return modelMapper.insert(entity);
    }
    @Override
    public Integer inserts(List<ModelEntity> list) {
        return modelMapper.inserts(list);
    }
    @Override
    public Integer delete(int id) {
        return modelMapper.delete(id);
    }
    @Override
    public Integer deletes(List<Integer> ids) {
        return modelMapper.deletes(ids);
    }
    @Override
    public Integer update(ModelEntity entity) {
        return modelMapper.update(entity);
    }
    @Override
    public Integer updates(List<ModelEntity> list) {
        return modelMapper.updates(list);
    }
}
src/main/resources/mapper/show/ModelMapper.xml
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,74 @@
<?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.lf.server.mapper.show.ModelMapper">
    <select id="selectCount" resultType="java.lang.Integer">
        select count(*) from lf.sys_model
        <where>
            <if test="layerid != null">
                layerid = #{layerid}
            </if>
        </where>
    </select>
    <select id="selectByPage" resultType="com.lf.server.entity.show.ModelEntity">
        select * from lf.sys_model
        <where>
            <if test="layerid != null">
                layerid = #{layerid}
            </if>
        </where>
        order by id
        limit #{limit} offset #{offset}
    </select>
    <select id="selectAll" resultType="com.lf.server.entity.show.ModelEntity">
        select * from lf.sys_model order by id;
    </select>
    <select id="selectById" resultType="com.lf.server.entity.show.ModelEntity">
        select * from lf.sys_model where id = #{id}
    </select>
    <insert id="insert" parameterType="com.lf.server.entity.show.ModelEntity">
        insert into lf.sys_model
        (layerid,modelid,guid,name,type,info,url,icon,create_user,create_time,bak)
        values
        (#{layerid},#{modelid},#{guid},#{name},#{type},#{info},#{url},#{icon},#{createUser},now(),#{bak})
    </insert>
    <insert id="inserts">
        insert into lf.sys_model
        (layerid,modelid,guid,name,type,info,url,icon,create_user,create_time,bak)
        values
        <foreach collection="list" item="item" index="index" separator=",">
            (#{item.layerid},#{item.modelid},#{item.guid},#{item.name},#{item.type},#{item.info},#{item.url},#{item.icon},#{item.createUser},now(),#{item.bak})
        </foreach>
    </insert>
    <delete id="delete">
        delete from lf.sys_model where id = #{id}
    </delete>
    <delete id="deletes">
        delete from lf.sys_model where id in
        <foreach item="id" collection="ids" index="index" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    <update id="update">
        update lf.sys_model
        set layerid=#{layerid},modelid=#{modelid},guid=#{guid},name=#{name},type=#{type},info=#{info},url=#{url},icon=#{icon},update_user=#{updateUser},update_time=now(),bak=#{bak}
        where id=#{id}
    </update>
    <update id="updates">
        <foreach collection="list" item="item" index="index" separator=";">
            update lf.sys_model
            <set>
                layerid=#{item.layerid},modelid=#{item.modelid},guid=#{item.guid},name=#{item.name},type=#{item.type},info=#{item.info},url=#{item.url},icon=#{item.icon},update_user=#{item.updateUser},update_time=now(),bak=#{item.bak}
            </set>
            where id = #{item.id}
        </foreach>
    </update>
</mapper>