管道基础大数据平台系统开发-【后端】-Server
13693261870
2022-10-10 6ab82851e9197ebd0e0af10669900bd3c0340df7
修改登录日志
已修改8个文件
123 ■■■■ 文件已修改
data/db.sql 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
data/menu-执行.xls 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/controller/sys/LoginController.java 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/entity/sys/LoginEntity.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/mapper/sys/LoginMapper.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/service/sys/LoginService.java 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/service/sys/MsgService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/sys/LoginMapper.xml 37 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
data/db.sql
@@ -219,6 +219,7 @@
insert into lf.sys_user (depid,uid,uname,pwd,create_user) values (21,'cky','穿跨越室','000000',1);
insert into lf.sys_user (depid,uid,uname,pwd,create_user) values (22,'tj','土建室','000000',1);
insert into lf.sys_user (depid,uid,uname,pwd,create_user) values (38,'kc','勘察室','000000',1);*/
update lf.sys_user set pwd='b37f70636f1164e86cc8796201737933f65af63918d8442b';
select * from lf.sys_user;
----------------------------------------------------------------------------------------------------- 5.登录日志表
data/menu-Ö´ÐÐ.xls
Binary files differ
src/main/java/com/lf/server/controller/sys/LoginController.java
@@ -12,6 +12,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.sql.Timestamp;
import java.util.List;
/**
@@ -29,12 +30,15 @@
    @SysLog()
    @ApiOperation(value = "查询记录数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userid", value = "登录人ID", dataType = "String", paramType = "query", required = false, example = "sys_login")
            @ApiImplicitParam(name = "uname", value = "用户名", dataType = "String", paramType = "query", example = "管理员"),
            @ApiImplicitParam(name = "type", value = "类型", dataType = "Integer", paramType = "query", example = "1"),
            @ApiImplicitParam(name = "start", value = "开始时间", dataType = "Timestamp", paramType = "query", example = "2022-10-09 09:00:00"),
            @ApiImplicitParam(name = "end", value = "结束时间", dataType = "Timestamp", paramType = "query", example = "2022-10-10 17:00:00")
    })
    @GetMapping({"/selectCount"})
    public ResponseMsg<Integer> selectCount(String userid) {
    public ResponseMsg<Integer> selectCount(String uname, Integer type, Timestamp start, Timestamp end) {
        try {
            int count = loginService.selectCount(userid);
            int count = loginService.selectCount(uname, type, start, end);
            return success(count);
        } catch (Exception ex) {
@@ -45,17 +49,21 @@
    @SysLog()
    @ApiOperation(value = "分页查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userid", value = "登录人ID", dataType = "String", paramType = "query", example = "sys_login"),
            @ApiImplicitParam(name = "uname", value = "用户名", dataType = "String", paramType = "query", example = "管理员"),
            @ApiImplicitParam(name = "type", value = "类型", dataType = "Integer", paramType = "query", example = "1"),
            @ApiImplicitParam(name = "start", value = "开始时间", dataType = "Timestamp", paramType = "query", example = "2022-10-09 09:00:00"),
            @ApiImplicitParam(name = "end", value = "结束时间", dataType = "Timestamp", paramType = "query", example = "2022-10-10 17:00:00"),
            @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<LoginEntity>> selectByPage(String userid, Integer pageSize, Integer pageIndex) {
    public ResponseMsg<List<LoginEntity>> selectByPage(String uname, Integer type, Timestamp start, Timestamp end, Integer pageSize, Integer pageIndex) {
        try {
            if (pageSize < 1 || pageIndex < 1) {
                return fail("每页页数或分页数小于1", null);
            }
            List<LoginEntity> rs = loginService.selectByPage(userid, pageSize, pageSize * (pageIndex - 1));
            List<LoginEntity> rs = loginService.selectByPage(uname, type, start, end, pageSize, pageSize * (pageIndex - 1));
            return success(rs);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
@@ -65,23 +73,26 @@
    @SysLog()
    @ApiOperation(value = "分页查询并返回记录数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userid", value = "登录人ID", dataType = "String", paramType = "query", example = "1"),
            @ApiImplicitParam(name = "uname", value = "用户名", dataType = "String", paramType = "query", example = "管理员"),
            @ApiImplicitParam(name = "type", value = "类型", dataType = "Integer", paramType = "query", example = "1"),
            @ApiImplicitParam(name = "start", value = "开始时间", dataType = "Timestamp", paramType = "query", example = "2022-10-09 09:00:00"),
            @ApiImplicitParam(name = "end", value = "结束时间", dataType = "Timestamp", paramType = "query", example = "2022-10-10 17:00:00"),
            @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<LoginEntity>> selectByPageAndCount(String userid, Integer pageSize, Integer pageIndex) {
    public ResponseMsg<List<LoginEntity>> selectByPageAndCount(String uname, Integer type, Timestamp start, Timestamp end, Integer pageSize, Integer pageIndex) {
        try {
            if (pageSize < 1 || pageIndex < 1) {
                return fail("每页页数或分页数小于1", null);
            }
            int count = loginService.selectCount(userid);
            int count = loginService.selectCount(uname, type, start, end);
            if (count == 0) {
                return success(0, null);
            }
            List<LoginEntity> rs = loginService.selectByPage(userid, pageSize, pageSize * (pageIndex - 1));
            List<LoginEntity> rs = loginService.selectByPage(uname, type, start, end, pageSize, pageSize * (pageIndex - 1));
            return success(count, rs);
        } catch (Exception ex) {
src/main/java/com/lf/server/entity/sys/LoginEntity.java
@@ -15,6 +15,8 @@
    private int id;
    private String uname;
    private int appid;
    private String ip;
@@ -37,6 +39,14 @@
        this.id = id;
    }
    public String getUname() {
        return uname;
    }
    public void setUname(String uname) {
        this.uname = uname;
    }
    public int getAppid() {
        return appid;
    }
src/main/java/com/lf/server/mapper/sys/LoginMapper.java
@@ -4,6 +4,7 @@
import org.apache.ibatis.annotations.Mapper;
import org.springframework.web.bind.annotation.ResponseBody;
import java.sql.Timestamp;
import java.util.List;
/**
@@ -17,20 +18,26 @@
    /**
     * æ ¹æ®è¡¨åæŸ¥è¯¢è®°å½•æ•°
     *
     * @param userid ç™»å½•人ID
     * @return è®°å½•æ•°
     * @param uname
     * @param type
     * @param start
     * @param end
     * @return
     */
    public Integer selectCount(String userid);
    public Integer selectCount(String uname, Integer type, Timestamp start, Timestamp end);
    /**
     * æ ¹æ®è¡¨ååˆ†é¡µæŸ¥è¯¢
     *
     * @param userid è¡¨å
     * @param limit  è®°å½•表
     * @param offset åç§»é‡
     * @return åˆ—表
     * @param uname
     * @param type
     * @param start
     * @param end
     * @param limit
     * @param offset
     * @return
     */
    public List<LoginEntity> selectByPage(String userid, Integer limit, Integer offset);
    public List<LoginEntity> selectByPage(String uname, Integer type, Timestamp start, Timestamp end, Integer limit, Integer offset);
    /**
     * æ·»åŠ æ•°æ®
@@ -86,5 +93,4 @@
     * @return
     */
    public List<LoginEntity> selectLoginAll();
}
}
src/main/java/com/lf/server/service/sys/LoginService.java
@@ -1,12 +1,14 @@
package com.lf.server.service.sys;
import com.lf.server.entity.sys.LoginEntity;
import com.lf.server.helper.StringHelper;
import com.lf.server.helper.WebHelper;
import com.lf.server.mapper.sys.LoginMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import java.sql.Timestamp;
import java.util.List;
/**
@@ -20,13 +22,17 @@
    LoginMapper loginMapper;
    @Override
    public Integer selectCount(String userid) {
        return loginMapper.selectCount(userid);
    public Integer selectCount(String uname, Integer type, Timestamp start, Timestamp end) {
        uname = StringHelper.isNull(uname) ? null : "%" + uname.trim() + "%";
        return loginMapper.selectCount(uname, type, start, end);
    }
    @Override
    public List<LoginEntity> selectByPage(String userid, Integer limit, Integer offset) {
        return loginMapper.selectByPage(userid, limit, offset);
    public List<LoginEntity> selectByPage(String uname, Integer type, Timestamp start, Timestamp end, Integer limit, Integer offset) {
        uname = StringHelper.isNull(uname) ? null : "%" + uname.trim() + "%";
        return loginMapper.selectByPage(uname, type, start, end, limit, offset);
    }
    @Override
src/main/java/com/lf/server/service/sys/MsgService.java
@@ -19,14 +19,14 @@
    @Override
    public Integer selectCount(String title) {
        title = "%" + (StringHelper.isNull(title) ? "" : title.trim()) + "%";
        title = StringHelper.isNull(title) ? null : "%" + title.trim() + "%";
        return msgMapper.selectCount(title);
    }
    @Override
    public List<MsgEntity> selectByPage(String title, Integer limit, Integer offset) {
        title = "%" + (StringHelper.isNull(title) ? "" : title.trim()) + "%";
        title = StringHelper.isNull(title) ? null : "%" + title.trim() + "%";
        return msgMapper.selectByPage(title, limit, offset);
    }
src/main/resources/mapper/sys/LoginMapper.xml
@@ -1,26 +1,43 @@
<?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.sys.LoginMapper">
    <!-- ç»Ÿè®¡è¡Œæ•° -->
    <select id="selectCount" resultType="java.lang.Integer" parameterType="java.lang.String">
        select count(*) from lf.sys_login
        select count(*) from lf.sys_login a inner join lf.sys_user b on a.userid = b.id
        <where>
            <if test="userid != null">
                userid = #{userid}
            1 = 1
            <if test="uname != null">
                and b.uname like #{uname}
            </if>
            <if test="type != null">
                and a.type = #{type}
            </if>
            <if test="start != null">
                and a.optime &gt;= #{start}
            </if>
            <if test="end != null">
                and a.optime &lt;= #{end}
            </if>
        </where>
    </select>
    <!-- åˆ†é¡µæŸ¥è¯¢ -->
    <select id="selectByPage" resultType="com.lf.server.entity.sys.LoginEntity">
        select * from lf.sys_login
        select a.*,b.uname from lf.sys_login a inner join lf.sys_user b on a.userid = b.id
        <where>
            <if test="userid != null">
                userid = #{userid}
            1 = 1
            <if test="uname != null">
                and b.uname like #{uname}
            </if>
            <if test="type != null">
                and a.type = #{type}
            </if>
            <if test="start != null">
                and a.optime &gt;= #{start}
            </if>
            <if test="end != null">
                and a.optime &lt;= #{end}
            </if>
        </where>
        order by id
        order by a.id
        limit #{limit} offset #{offset}
    </select>