Browse Source

Merge branch 'dev-1.1.0' of https://172.16.32.165/hurugang/thmz_system into dev-1.1.0

hurugang 4 years ago
parent
commit
b14eb6260c

+ 6 - 3
src/main/java/cn/hnthyy/thmz/controller/UserController.java

@@ -11,6 +11,7 @@ import cn.hnthyy.thmz.service.thmz.RoleService;
 import cn.hnthyy.thmz.service.thmz.UserRoleRelationService;
 import cn.hnthyy.thmz.service.thmz.UserService;
 import cn.hnthyy.thmz.vo.UserRoleRelationVo;
+import cn.hnthyy.thmz.vo.UserVo;
 import com.auth0.jwt.interfaces.DecodedJWT;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
@@ -181,12 +182,13 @@ public class UserController {
      * @return
      */
     @UserLoginToken
-    @RequestMapping(value = "/getAllUser", method = {RequestMethod.POST})
-    public Map<String, Object> getAllUser() {
+    @RequestMapping(value = "/getUserPage", method = {RequestMethod.GET, RequestMethod.POST})
+    public Map<String, Object> getUserPage(@RequestBody UserVo userVo) {
         Map<String, Object> resultMap = new HashMap<>();
         try {
             ArrayList<UserRoleRelationVo> userRoleRelationVos = new ArrayList<>();
-            List<User> users = userService.queryAllUser();
+            int total = userService.countUser(userVo);
+            List<User> users = userService.queryUserPage(userVo);
             for (User user : users) {//通过user基础信息查询关联角色
                 UserRoleRelationVo userRoleRelationVo = new UserRoleRelationVo();
                 List<UserRoleRelation> userRoleRelations = userRoleRelationService.queryByUserId(user.getId());
@@ -215,6 +217,7 @@ public class UserController {
             }
             resultMap.put("code", 0);
             resultMap.put("message", "查询所有用户成功");
+            resultMap.put("total", total);
             resultMap.put("data", userRoleRelationVos);
             return resultMap;
         } catch (Exception e) {

+ 94 - 46
src/main/java/cn/hnthyy/thmz/mapper/thmz/UserMapper.java

@@ -2,6 +2,7 @@ package cn.hnthyy.thmz.mapper.thmz;
 
 
 import cn.hnthyy.thmz.entity.thmz.User;
+import cn.hnthyy.thmz.vo.UserVo;
 import org.apache.ibatis.annotations.*;
 
 import java.util.List;
@@ -12,11 +13,58 @@ import java.util.List;
 public interface UserMapper {
     /**
      * 查询所有的用户
+     *
      * @return
      */
     @Select("select id,user_id_code,user_code,user_name,password,id_card,create_time,create_user,update_time,update_user,status,profile_image,email,phone_number,gender,lock_screen_password from t_user ")
     List<User> selectAllUser();
 
+    /**
+     * 分页查询用户
+     *
+     * @return
+     */
+    @Select({"<script>",
+            "select id,user_id_code,user_code,user_name,password,id_card,create_time,create_user,update_time,update_user," +
+                    "status,profile_image,email,phone_number,gender,lock_screen_password FROM t_user WHERE 1 = 1 " +
+                    "<when test='id != null'>" +
+                    " and id = #{id}" +
+                    "</when>" +
+                    "<when test='userIdCode != null'>" +
+                    " and user_id_code = #{userIdCode}" +
+                    "</when>" +
+                    "<when test='userCode != null'>" +
+                    " and user_code = #{userCode}" +
+                    "</when>"+
+                    "<when test='userName != null'>" +
+                    " and user_name = #{userName}" +
+                    "</when>" +
+                    " ORDER BY ID desc limit #{offset},#{pageSize} ",
+            "</script>"})
+    List<User> selectUserPage(UserVo userVo);
+
+    /**
+     * 用户统计
+     *
+     * @param userVo 用户查询条件
+     * @return
+     */
+    @Select({"<script>",
+            "select count(1) FROM t_user WHERE 1 = 1 " +
+                    "<when test='id != null'>" +
+                    " and id = #{id}" +
+                    "</when>" +
+                    "<when test='userIdCode != null'>" +
+                    " and user_id_code = #{userIdCode}" +
+                    "</when>" +
+                    "<when test='userCode != null'>" +
+                    " and user_code = #{userCode}" +
+                    "</when>"+
+                    "<when test='userName != null'>" +
+                    " and user_name = #{userName}" +
+                    "</when>",
+            "</script>"})
+    int countUser(UserVo userVo);
 
     /**
      * 按照主键询员工对象
@@ -51,63 +99,63 @@ public interface UserMapper {
 
     /**
      * 更新用户信息
+     *
      * @param user
      * @return
      */
     @Update({"<script>",
             "update t_user",
             "<trim prefix='set' prefixOverrides=',' suffix=' where id = #{id} '>",
-              "<when test='userIdCode!=null'>",
-                "user_id_code =#{userIdCode,jdbcType=VARCHAR}",
-              "</when>",
-              "<when test='userCode!=null'>",
-                 ",user_code =#{userCode,jdbcType=VARCHAR}",
-              "</when>",
-              "<when test='userName!=null'>",
-                 ",user_name =#{userName,jdbcType=VARCHAR}",
-              "</when>",
-              "<when test='password!=null'>",
-                 ",password =#{password,jdbcType=VARCHAR}",
-              "</when>",
-              "<when test='idCard!=null'>",
-                 ",id_card =#{idCard,jdbcType=VARCHAR}",
-              "</when>",
-              "<when test='createTime!=null'>",
-                 ",create_time =#{createTime,jdbcType=TIMESTAMP}",
-              "</when>",
-              "<when test='createUser!=null'>",
-                 ",create_user =#{createUser,jdbcType=BIGINT}",
-              "</when>",
-              "<when test='updateTime!=null'>",
-                 ",update_time =#{updateTime,jdbcType=TIMESTAMP}",
-              "</when>",
-              "<when test='updateUser!=null'>",
-                  ",update_user =#{updateUser,jdbcType=BIGINT}",
-              "</when>",
-              "<when test='status!=null'>",
-                  ",status =#{status,jdbcType=INTEGER}",
-              "</when>",
-              "<when test='profileImage!=null'>",
-                  ",profile_image =#{profileImage,jdbcType=BIGINT}",
-              "</when>",
-              "<when test='email!=null'>",
-                  ",email =#{email,jdbcType=VARCHAR}",
-              "</when>",
-              "<when test='phoneNumber!=null'>",
-                  ",phone_number =#{phoneNumber,jdbcType=VARCHAR}",
-              "</when>",
-              "<when test='gender!=null'>",
-                  ",gender =#{gender,jdbcType=CHAR}",
-              "</when>",
-              "<when test='lockScreenPassword!=null'>",
-                  ",lock_screen_password =#{lockScreenPassword,jdbcType=VARCHAR}",
-              "</when>",
+            "<when test='userIdCode!=null'>",
+            "user_id_code =#{userIdCode,jdbcType=VARCHAR}",
+            "</when>",
+            "<when test='userCode!=null'>",
+            ",user_code =#{userCode,jdbcType=VARCHAR}",
+            "</when>",
+            "<when test='userName!=null'>",
+            ",user_name =#{userName,jdbcType=VARCHAR}",
+            "</when>",
+            "<when test='password!=null'>",
+            ",password =#{password,jdbcType=VARCHAR}",
+            "</when>",
+            "<when test='idCard!=null'>",
+            ",id_card =#{idCard,jdbcType=VARCHAR}",
+            "</when>",
+            "<when test='createTime!=null'>",
+            ",create_time =#{createTime,jdbcType=TIMESTAMP}",
+            "</when>",
+            "<when test='createUser!=null'>",
+            ",create_user =#{createUser,jdbcType=BIGINT}",
+            "</when>",
+            "<when test='updateTime!=null'>",
+            ",update_time =#{updateTime,jdbcType=TIMESTAMP}",
+            "</when>",
+            "<when test='updateUser!=null'>",
+            ",update_user =#{updateUser,jdbcType=BIGINT}",
+            "</when>",
+            "<when test='status!=null'>",
+            ",status =#{status,jdbcType=INTEGER}",
+            "</when>",
+            "<when test='profileImage!=null'>",
+            ",profile_image =#{profileImage,jdbcType=BIGINT}",
+            "</when>",
+            "<when test='email!=null'>",
+            ",email =#{email,jdbcType=VARCHAR}",
+            "</when>",
+            "<when test='phoneNumber!=null'>",
+            ",phone_number =#{phoneNumber,jdbcType=VARCHAR}",
+            "</when>",
+            "<when test='gender!=null'>",
+            ",gender =#{gender,jdbcType=CHAR}",
+            "</when>",
+            "<when test='lockScreenPassword!=null'>",
+            ",lock_screen_password =#{lockScreenPassword,jdbcType=VARCHAR}",
+            "</when>",
             "</trim>",
             "</script>"})
     int updateUser(User user);
 
 
-
     /**
      * 按照员工编码查询员工对象
      *

+ 11 - 0
src/main/java/cn/hnthyy/thmz/service/impl/thmz/UserServiceImpl.java

@@ -7,6 +7,7 @@ import cn.hnthyy.thmz.entity.thmz.User;
 import cn.hnthyy.thmz.mapper.thmz.FileUploadMapper;
 import cn.hnthyy.thmz.mapper.thmz.UserMapper;
 import cn.hnthyy.thmz.service.thmz.UserService;
+import cn.hnthyy.thmz.vo.UserVo;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -29,6 +30,16 @@ public class UserServiceImpl implements UserService {
         return userMapper.selectAllUser();
     }
 
+    @Override
+    public List<User> queryUserPage(UserVo userVo) {
+        return userMapper.selectUserPage(userVo);
+    }
+
+    @Override
+    public int countUser(UserVo userVo) {
+        return userMapper.countUser(userVo);
+    }
+
     @Override
     public User queryUserById(Long id) {
         return userMapper.selectUserById(id);

+ 15 - 0
src/main/java/cn/hnthyy/thmz/service/thmz/UserService.java

@@ -2,6 +2,7 @@ package cn.hnthyy.thmz.service.thmz;
 
 
 import cn.hnthyy.thmz.entity.thmz.User;
+import cn.hnthyy.thmz.vo.UserVo;
 
 import java.util.List;
 
@@ -15,6 +16,20 @@ public interface UserService {
      */
     List<User> queryAllUser();
 
+    /**
+     * 分页查询用户
+     * @return
+     */
+    List<User> queryUserPage(UserVo userVo);
+
+    /**
+     * 统计用户
+     *
+     * @param userVo 用户查询条件
+     * @return
+     */
+    int countUser(UserVo userVo);
+
     /**
      * 按照主键询员工对象
      *

+ 6 - 1
src/main/java/cn/hnthyy/thmz/vo/UserVo.java

@@ -2,13 +2,14 @@ package cn.hnthyy.thmz.vo;
 
 import lombok.Data;
 
+import java.math.BigDecimal;
 import java.util.Date;
 
 /**
  * 用户信息
  */
 @Data
-public class UserVo {
+public class UserVo  extends PageParams{
     //主键
     private Long id;
     //老系统员工表编码
@@ -47,4 +48,8 @@ public class UserVo {
     private String createUserName;
     //更新人姓名
     private String updateUserName;
+    //上一次查询到的总额
+    private BigDecimal amount;
+    //上一次查询到的总数
+    private Integer total;
 }

+ 6 - 5
src/main/resources/static/js/user_manage.js

@@ -120,7 +120,7 @@ function clearInput() {
 function getAllUser() {
     $('#tb_table').bootstrapTable("destroy");
     $('#tb_table').bootstrapTable({
-        url: '/thmz/getAllUser',         //请求后台的URL(*)
+        url: '/thmz/getUserPage',         //请求后台的URL(*)
         method: 'post',                      //请求方式(*)
         toolbar: '#toolbar',                //工具按钮用哪个容器
         striped: true,                      //是否显示行间隔色
@@ -129,7 +129,7 @@ function getAllUser() {
         sortable: true,                     //是否启用排序
         sortOrder: "asc",                   //排序方式
         queryParams: queryParams,           //传递参数(*)
-        sidePagination: "client",           //分页方式:client客户端分页,server服务端分页(*)
+        sidePagination: "server",           //分页方式:client客户端分页,server服务端分页(*)
         pageNumber: 1,                       //初始化加载第一页,默认第一页
         pageSize: 10,                       //每页的记录行数(*)
         pageList: [10, 25, 50, 100],        //可供选择的每页的行数(*)
@@ -163,7 +163,7 @@ function getAllUser() {
             },
             {
                 field: 'userIdCode',
-                title: '老系统工号',
+                title: '员工编号',
                 align: "center",
                 valign: 'middle',
                 formatter: function (value, row, index) {
@@ -231,7 +231,7 @@ function getAllUser() {
                 };
             }
             return {
-                "total": ress.data.length,//总页数
+                "total": ress.total,//总页数
                 "rows": ress.data   //数据
             };
         },
@@ -245,7 +245,8 @@ function getAllUser() {
  */
 function queryParams(params) {
     var temp = {
-        name: $('#nameParam').val()
+        pageSize: params.limit,
+        offset:params.offset,
     };
     return temp;
 };

+ 3 - 3
src/main/resources/templates/role_manage.html

@@ -36,7 +36,7 @@
             <div class="modal-body">
                 <form class="form-horizontal form-label-left" novalidate id="editUserForm" autocomplete="off">
                     <div class="item form-group thmz_alert">
-                        <label class="control-label col-md-4 col-sm-4 col-xs-12" for="roleName">角色名称 <span
+                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="roleName">角色名称 <span
                                 class="required">*</span>
                         </label>
                         <div class="col-md-6 col-sm-6 col-xs-12">
@@ -47,7 +47,7 @@
                         </div>
                     </div>
                     <div class="item form-group thmz_alert">
-                        <label class="control-label col-md-4 col-sm-4 col-xs-12" for="relationTypeId">菜单权限
+                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="relationTypeId">菜单权限
                         </label>
                         <div class="col-md-6 col-sm-6 col-xs-12">
                             <!--  select用于存放值,后台等获取用  -->
@@ -68,7 +68,7 @@
                         </div>
                     </div>
                     <div class="item form-group thmz_alert">
-                        <label class="control-label col-md-4 col-sm-4 col-xs-12" for="remark">备注
+                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="remark">备注
                         </label>
                         <div class="col-md-6 col-sm-6 col-xs-12">
                             <textarea  id="remark" class="form-control optional"

+ 3 - 3
src/main/resources/templates/user_manage.html

@@ -36,7 +36,7 @@
             <div class="modal-body">
                 <form class="form-horizontal form-label-left" novalidate id="editUserForm" autocomplete="off">
                     <div class="item form-group thmz_alert">
-                        <label class="control-label col-md-4 col-sm-4 col-xs-12" for="userCode">工号 <span
+                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="userCode">工号 <span
                                 class="required">*</span>
                         </label>
                         <div class="col-md-6 col-sm-6 col-xs-12">
@@ -46,7 +46,7 @@
                         </div>
                     </div>
                     <div class="item form-group thmz_alert">
-                        <label class="control-label col-md-4 col-sm-4 col-xs-12" for="userName">姓名 <span
+                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="userName">姓名 <span
                                 class="required">*</span>
                         </label>
                         <div class="col-md-6 col-sm-6 col-xs-12">
@@ -55,7 +55,7 @@
                         </div>
                     </div>
                     <div class="item form-group thmz_alert">
-                        <label class="control-label col-md-4 col-sm-4 col-xs-12" for="roleName">角色 <span
+                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="roleName">角色 <span
                                 class="required">*</span>
                         </label>
                         <div class="col-md-6 col-sm-6 col-xs-12">