管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2022-11-02 09fcdb0b61e454a7697d18d7b2ae3b4a385d0988
1
已添加5个文件
已修改1个文件
674 ■■■■■ 文件已修改
data/db_tab.sql 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/controller/data/DomainController.java 253 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/entity/data/DomainEntity.java 145 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/mapper/data/DomainMapper.java 96 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/service/data/DomainService.java 73 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/data/DomainMapper.xml 74 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
data/db_tab.sql
@@ -917,4 +917,37 @@
comment on column lf.sys_mark.update_time is '更新时间';
select * from lf.sys_mark;
----------------------------------------------------------------------------------------------------- 27.值域表
-- drop table if exists lf.sys_domain;
create table if not exists lf.sys_domain(
    id serial primary key,
    dom_desc varchar(100),
    dom_name varchar(50),
    dom_code varchar(50),
    code_desc varchar(50),
    level integer,
    orderid integer,
    bsm varchar(50),
    create_user integer default 1,
    create_time timestamp(6) without time zone default now(),
    update_user integer,
    update_time timestamp(6) without time zone,
    bak varchar(1024)
);
comment on table lf.sys_domain is '值域表';
comment on column lf.sys_domain.id is '主键id';
comment on column lf.sys_domain.dom_desc is '值域表描述';
comment on column lf.sys_domain.dom_name is '值域表名';
comment on column lf.sys_domain.dom_code is '编码';
comment on column lf.sys_domain.code_desc is '编码描述';
comment on column lf.sys_domain.level is '层级';
comment on column lf.sys_domain.orderid is '序号';
comment on column lf.sys_domain.bsm is '标识码';
comment on column lf.sys_domain.create_user is '创建人id';
comment on column lf.sys_domain.create_time is '创建时间';
comment on column lf.sys_domain.update_user is '更新人id';
comment on column lf.sys_domain.update_time is '更新时间';
comment on column lf.sys_domain.bak is '备注';
select * from lf.sys_domain order by dom_name,orderid;
-----------------------------------------------------------------------------------------------------
src/main/java/com/lf/server/controller/data/DomainController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,253 @@
package com.lf.server.controller.data;
import com.lf.server.aspect.SysLog;
import com.lf.server.controller.all.BaseController;
import com.lf.server.entity.all.ResponseMsg;
import com.lf.server.entity.data.DomainEntity;
import com.lf.server.entity.sys.UserEntity;
import com.lf.server.service.data.DomainService;
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("/domain")
public class DomainController extends BaseController {
    @Autowired
    DomainService domainService;
    @Autowired
    TokenService tokenService;
    @SysLog()
    @ApiOperation(value = "查询记录数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "domName", value = "值域表名", dataType = "String", paramType = "query", required = false, example = "")
    })
    @GetMapping({"/selectCount"})
    public ResponseMsg<Integer> selectCount(String domName) {
        try {
            int count = domainService.selectCount(domName);
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
        }
    }
    @SysLog()
    @ApiOperation(value = "分页查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "domName", value = "值域表名", dataType = "String", 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<DomainEntity>> selectByPage(String domName, Integer pageSize, Integer pageIndex) {
        try {
            if (pageSize < 1 || pageIndex < 1) {
                return fail("每页页数或分页数小于1", null);
            }
            List<DomainEntity> rs = domainService.selectByPage(domName, pageSize, pageSize * (pageIndex - 1));
            return success(rs);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
        }
    }
    @SysLog()
    @ApiOperation(value = "分页查询并返回记录数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "domName", value = "值域表名", dataType = "String", 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<DomainEntity>> selectByPageAndCount(String domName, Integer pageSize, Integer pageIndex) {
        try {
            if (pageSize < 1 || pageIndex < 1) {
                return fail("每页页数或分页数小于1", null);
            }
            int count = domainService.selectCount(domName);
            if (count == 0) {
                return success(0, null);
            }
            List<DomainEntity> rs = domainService.selectByPage(domName, 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<DomainEntity>> selectAll() {
        try {
            List<DomainEntity> list = domainService.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<DomainEntity> selectById(int id) {
        try {
            DomainEntity entity = domainService.selectById(id);
            return success(entity);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
        }
    }
    @SysLog()
    @ApiOperation(value = "插入一条")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "entity", value = "实体类", dataType = "DomainEntity", paramType = "body")
    })
    @PostMapping(value = "/insert", produces = "application/json; charset=UTF-8")
    public ResponseMsg<Integer> insert(@RequestBody DomainEntity entity, HttpServletRequest req) {
        try {
            UserEntity ue = tokenService.getCurrentUser(req);
            if (ue != null) {
                entity.setCreateUser(ue.getId());
            }
            int count = domainService.insert(entity);
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
        }
    }
    @SysLog()
    @ApiOperation(value = "插入多条")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "list", value = "实体类集合", dataType = "DomainEntity", paramType = "body")
    })
    @PostMapping(value = "/inserts", produces = "application/json; charset=UTF-8")
    public ResponseMsg<Integer> inserts(@RequestBody List<DomainEntity> list, HttpServletRequest req) {
        try {
            UserEntity ue = tokenService.getCurrentUser(req);
            if (ue != null) {
                for (DomainEntity entity : list) {
                    entity.setCreateUser(ue.getId());
                }
            }
            int count = domainService.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 = domainService.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 = domainService.deletes(ids);
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
        }
    }
    @SysLog()
    @ApiOperation(value = "更新一条")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "entity", value = "实体类", dataType = "DomainEntity", paramType = "body")
    })
    @ResponseBody
    @PostMapping(value = "/update", produces = "application/json; charset=UTF-8")
    public ResponseMsg<Integer> update(@RequestBody DomainEntity entity, HttpServletRequest req) {
        try {
            UserEntity ue = tokenService.getCurrentUser(req);
            if (ue != null) {
                entity.setUpdateUser(ue.getId());
            }
            int count = domainService.update(entity);
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
        }
    }
    @SysLog()
    @ApiOperation(value = "更新多条")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "list", value = "实体类集合", dataType = "DomainEntity", paramType = "body")
    })
    @ResponseBody
    @PostMapping(value = "/updates", produces = "application/json; charset=UTF-8")
    public ResponseMsg<Integer> updates(@RequestBody List<DomainEntity> list, HttpServletRequest req) {
        try {
            UserEntity ue = tokenService.getCurrentUser(req);
            if (ue != null) {
                for (DomainEntity entity : list) {
                    entity.setUpdateUser(ue.getId());
                }
            }
            int count = domainService.updates(list);
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
        }
    }
}
src/main/java/com/lf/server/entity/data/DomainEntity.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,145 @@
package com.lf.server.entity.data;
import java.io.Serializable;
import java.sql.Timestamp;
/**
 * å€¼åŸŸ
 * @author WWW
 */
public class DomainEntity implements Serializable {
    private static final long serialVersionUID = -334732819504445760L;
    private int id;
    private String domDesc;
    private String domName;
    private String domCode;
    private String codeDesc;
    private int level;
    private int orderid;
    private String bsm;
    private int createUser;
    private Timestamp createTime;
    private int updateUser;
    private Timestamp updateTime;
    private String bak;
    public DomainEntity() {
    }
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public String getDomDesc() {
        return domDesc;
    }
    public void setDomDesc(String domDesc) {
        this.domDesc = domDesc;
    }
    public String getDomName() {
        return domName;
    }
    public void setDomName(String domName) {
        this.domName = domName;
    }
    public String getDomCode() {
        return domCode;
    }
    public void setDomCode(String domCode) {
        this.domCode = domCode;
    }
    public String getCodeDesc() {
        return codeDesc;
    }
    public void setCodeDesc(String codeDesc) {
        this.codeDesc = codeDesc;
    }
    public int getLevel() {
        return level;
    }
    public void setLevel(int level) {
        this.level = level;
    }
    public int getOrderid() {
        return orderid;
    }
    public void setOrderid(int orderid) {
        this.orderid = orderid;
    }
    public String getBsm() {
        return bsm;
    }
    public void setBsm(String bsm) {
        this.bsm = bsm;
    }
    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/data/DomainMapper.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,96 @@
package com.lf.server.mapper.data;
import com.lf.server.entity.data.DomainEntity;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
 * å€¼åŸŸ
 * @author WWW
 */
@Mapper
@Repository
public interface DomainMapper {
    /**
     * æŸ¥è¯¢è®°å½•æ•°
     *
     * @param domName å€¼åŸŸè¡¨å
     * @return è®°å½•æ•°
     */
    public Integer selectCount(String domName);
    /**
     * åˆ†é¡µæŸ¥è¯¢
     *
     * @param domName   å€¼åŸŸè¡¨å
     * @param limit  è®°å½•表
     * @param offset åç§»é‡
     * @return åˆ—表
     */
    public List<DomainEntity> selectByPage(String domName, Integer limit, Integer offset);
    /**
     * æŸ¥è¯¢æ‰€æœ‰
     *
     * @return
     */
    public List<DomainEntity> selectAll();
    /**
     * æ ¹æ®ID查询
     *
     * @param id
     * @return
     */
    public DomainEntity selectById(int id);
    /**
     * æ’入一条
     *
     * @param entity
     * @return
     */
    public Integer insert(DomainEntity entity);
    /**
     * æ’入多条
     *
     * @param list
     * @return
     */
    public Integer inserts(List<DomainEntity> list);
    /**
     * åˆ é™¤ä¸€æ¡
     *
     * @param id
     * @return
     */
    public Integer delete(int id);
    /**
     * åˆ é™¤å¤šæ¡
     *
     * @param ids
     * @return
     */
    public Integer deletes(List<Integer> ids);
    /**
     * æ›´æ–°ä¸€æ¡
     *
     * @param entity
     * @return
     */
    public Integer update(DomainEntity entity);
    /**
     * æ›´æ–°å¤šæ¡
     *
     * @param list
     * @return
     */
    public Integer updates(List<DomainEntity> list);
}
src/main/java/com/lf/server/service/data/DomainService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,73 @@
package com.lf.server.service.data;
import com.lf.server.entity.data.DomainEntity;
import com.lf.server.helper.StringHelper;
import com.lf.server.mapper.data.DomainMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
 * å€¼åŸŸ
 * @author WWW
 */
@Service
public class DomainService implements DomainMapper {
    @Autowired
    DomainMapper domainMapper;
    @Override
    public Integer selectCount(String domName) {
        domName = StringHelper.getLikeStr(domName);
        return domainMapper.selectCount(domName);
    }
    @Override
    public List<DomainEntity> selectByPage(String domName, Integer limit, Integer offset) {
        domName = StringHelper.getLikeStr(domName);
        return domainMapper.selectByPage(domName, limit, offset);
    }
    @Override
    public List<DomainEntity> selectAll() {
        return domainMapper.selectAll();
    }
    @Override
    public DomainEntity selectById(int id) {
        return domainMapper.selectById(id);
    }
    @Override
    public Integer insert(DomainEntity entity) {
        return domainMapper.insert(entity);
    }
    @Override
    public Integer inserts(List<DomainEntity> list) {
        return domainMapper.inserts(list);
    }
    @Override
    public Integer delete(int id) {
        return domainMapper.delete(id);
    }
    @Override
    public Integer deletes(List<Integer> ids) {
        return domainMapper.deletes(ids);
    }
    @Override
    public Integer update(DomainEntity entity) {
        return domainMapper.update(entity);
    }
    @Override
    public Integer updates(List<DomainEntity> list) {
        return domainMapper.updates(list);
    }
}
src/main/resources/mapper/data/DomainMapper.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.data.DomainMapper">
    <select id="selectCount" resultType="java.lang.Integer" parameterType="java.lang.String">
        select count(*) from lf.sys_domain
        <where>
            <if test="domName != null">
                dom_name like #{domName}
            </if>
        </where>
    </select>
    <select id="selectByPage" resultType="com.lf.server.entity.data.DomainEntity">
        select * from lf.sys_domain
        <where>
            <if test="domName != null">
                dom_name like #{domName}
            </if>
        </where>
        order by id
        limit #{limit} offset #{offset}
    </select>
    <select id="selectAll" resultType="com.lf.server.entity.data.DomainEntity">
        select * from lf.sys_domain order by id;
    </select>
    <select id="selectById" resultType="com.lf.server.entity.data.DomainEntity">
        select * from lf.sys_domain where id = #{id}
    </select>
    <insert id="insert" parameterType="com.lf.server.entity.data.DomainEntity">
       insert into lf.sys_domain
       (dom_desc,dom_name,dom_code,code_desc,level,orderid,bsm,create_user,create_time,bak)
       values
       (#{domDesc},#{domName},#{domCode},#{codeDesc},#{level},#{orderid},#{bsm},#{createUser},now(),#{bak})
    </insert>
    <insert id="inserts">
        insert into lf.sys_domain
        (dom_desc,dom_name,dom_code,code_desc,level,orderid,bsm,create_user,create_time,bak)
        values
        <foreach collection="list" item="item" index="index" separator=",">
            (#{item.domDesc},#{item.domName},#{item.domCode},#{item.codeDesc},#{item.level},#{item.orderid},#{item.bsm},#{item.createUser},now(),#{item.bak})
        </foreach>
    </insert>
    <delete id="delete">
        delete from lf.sys_domain where id = #{id}
    </delete>
    <delete id="deletes">
        delete from lf.sys_domain where id in
        <foreach item="id" collection="ids" index="index" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    <update id="update">
        update lf.sys_domain
        set dom_desc=#{domDesc},dom_name=#{domName},dom_code=#{domCode},code_desc=#{codeDesc},level=#{level},orderid=#{orderid},bsm=#{bsm},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_domain
            <set>
                dom_desc=#{item.domDesc},dom_name=#{item.domName},dom_code=#{item.domCode},code_desc=#{item.codeDesc},level=#{item.level},orderid=#{item.orderid},bsm=#{item.bsm},update_user=#{item.updateUser},update_time=now(),bak=#{item.bak}
            </set>
            where id = #{item.id}
        </foreach>
    </update>
</mapper>