update some code

This commit is contained in:
fumeiai 2020-05-25 20:56:58 +08:00
parent e25faebd30
commit 1a3de75590
18 changed files with 464 additions and 240 deletions

41
.idea/workspace.xml generated
View File

@ -2,16 +2,21 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="e4baaf01-a2c2-445d-98a1-9f4c50c148cf" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/src/main/java/com/lz/modules/app/Dto/UserDto.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/lz/modules/job/business/FeishuBusiness.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/lz/modules/job/business/FeishuBusiness.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/lz/modules/sys/controller/SysLoginController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/lz/modules/sys/controller/SysLoginController.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/lz/modules/app/entity/UserEntity.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/lz/modules/app/entity/UserEntity.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/lz/modules/app/service/impl/StaffServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/lz/modules/app/service/impl/StaffServiceImpl.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/lz/modules/sys/controller/SysUserController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/lz/modules/sys/controller/SysUserController.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/application-dev.yml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/application-dev.yml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/mapper/generator/StaffOccupationDao.xml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/mapper/generator/StaffOccupationDao.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/application-dev.yml" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/application-dev.yml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/com/lz/modules/job/business/FeishuBusiness.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/lz/modules/job/business/FeishuBusiness.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/com/lz/modules/sys/controller/SysLoginController.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/lz/modules/sys/controller/SysLoginController.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/lz/modules/sys/dao/SysUserDao.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/lz/modules/sys/dao/SysUserDao.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/lz/modules/sys/entity/SysUserEntity.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/lz/modules/sys/entity/SysUserEntity.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/lz/modules/sys/service/impl/SysUserServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/lz/modules/sys/service/impl/SysUserServiceImpl.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/logback-spring.xml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/logback-spring.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/mapper/sys/SysUserDao.xml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/mapper/sys/SysUserDao.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/com/lz/modules/app/entity/UserEntity.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/lz/modules/app/entity/UserEntity.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/com/lz/modules/app/service/impl/StaffServiceImpl.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/lz/modules/app/service/impl/StaffServiceImpl.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/com/lz/modules/sys/controller/SysUserController.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/lz/modules/sys/controller/SysUserController.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/com/lz/modules/sys/entity/SysUserEntity.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/lz/modules/sys/entity/SysUserEntity.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/com/lz/modules/sys/service/impl/SysUserServiceImpl.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/lz/modules/sys/service/impl/SysUserServiceImpl.class" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
@ -57,8 +62,8 @@
</component>
<component name="RecentsManager">
<key name="CopyClassDialog.RECENTS_KEY">
<recent name="com.lz.common.utils" />
<recent name="com.lz.modules.app.Dto" />
<recent name="com.lz.common.utils" />
<recent name="com.lz.modules.app.enums" />
<recent name="com.lz.modules.app.entity.excel" />
<recent name="com.lz.modules.job.model.responseBo" />
@ -179,7 +184,7 @@
<workItem from="1588163384182" duration="74761000" />
<workItem from="1588936950753" duration="95758000" />
<workItem from="1590038091791" duration="38394000" />
<workItem from="1590136970394" duration="14639000" />
<workItem from="1590136970394" duration="24193000" />
</task>
<servers />
</component>
@ -204,13 +209,23 @@
<breakpoints>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/com/lz/modules/app/service/impl/StaffServiceImpl.java</url>
<line>233</line>
<line>232</line>
<option name="timeStamp" value="104" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/com/lz/common/utils/FeishuUtil.java</url>
<line>144</line>
<option name="timeStamp" value="112" />
<url>file://$PROJECT_DIR$/src/main/java/com/lz/modules/sys/controller/SysUserController.java</url>
<line>121</line>
<option name="timeStamp" value="114" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/com/lz/modules/sys/controller/SysUserController.java</url>
<line>139</line>
<option name="timeStamp" value="115" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/com/lz/modules/sys/service/impl/SysUserServiceImpl.java</url>
<line>57</line>
<option name="timeStamp" value="117" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>

View File

@ -0,0 +1,94 @@
/**
* Copyright (c) 2020 fumeiai All rights reserved.
* <p>
* <p>
* <p>
* 版权所有侵权必究
*/
package com.lz.modules.app.Dto;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* 用户
*
* @author fumeiai@Linzikg.com
*/
@Data
public class UserDto implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 用户ID
*/
@TableId
private Long userId;
/**
* 员工姓名
*/
private String realName;
/**
* 员工工号
*/
private String userNo;
/**
* 用户名
*/
private String username;
/**
* 密码
*/
private String password;
/**
* 手机号
*/
private String mobile;
/**
*
*/
private String salt;
/**
* 邮箱
*/
private String email;
/**
* 状态 0禁用 1正常
*/
private Integer status;
/**
* 角色ID列表
*/
@TableField(exist = false)
private List<Long> roleIdList;
/**
* 创建者ID
*/
private Long createUserId;
/**
* 创建时间
*/
private Date createTime;
private String roleName;
}

View File

@ -22,7 +22,7 @@ import java.util.Date;
* @author Mark sunlightcs@gmail.com
*/
@Data
@TableName("tb_user")
@TableName("sys_user")
public class UserEntity implements Serializable {
private static final long serialVersionUID = 1L;
@ -31,6 +31,12 @@ public class UserEntity implements Serializable {
*/
@TableId
private Long userId;
private String realName;
private String userNo;
private String status;
/**
* 用户名
*/

View File

@ -1,6 +1,5 @@
package com.lz.modules.app.service.impl;
import cn.hutool.core.util.NumberUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;

View File

@ -1,13 +1,14 @@
/**
* Copyright (c) 2020 fumeiai All rights reserved.
*
*
*
* <p>
* <p>
* <p>
* 版权所有侵权必究
*/
package com.lz.modules.sys.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lz.common.annotation.SysLog;
import com.lz.common.utils.Constant;
import com.lz.common.utils.PageUtils;
@ -16,6 +17,7 @@ import com.lz.common.validator.Assert;
import com.lz.common.validator.ValidatorUtils;
import com.lz.common.validator.group.AddGroup;
import com.lz.common.validator.group.UpdateGroup;
import com.lz.modules.app.entity.UserEntity;
import com.lz.modules.sys.entity.SysUserEntity;
import com.lz.modules.sys.form.PasswordForm;
import com.lz.modules.sys.service.SysUserRoleService;
@ -53,8 +55,10 @@ public class SysUserController extends AbstractController {
if (getUserId() != Constant.SUPER_ADMIN) {
params.put("createUserId", getUserId());
}
PageUtils page = sysUserService.queryPage(params);
return R.ok().put("page", page);
}
@ -92,6 +96,7 @@ public class SysUserController extends AbstractController {
String newPassword = new Sha256Hash("Linzi!@#123", "YzcmCZNvbXocrsz9dm8e").toHex();
System.out.println(newPassword);
}
/**
* 用户信息
*/
@ -115,7 +120,10 @@ public class SysUserController extends AbstractController {
@RequiresPermissions("sys:user:save")
public R save(@RequestBody SysUserEntity user) {
ValidatorUtils.validateEntity(user, AddGroup.class);
SysUserEntity queryUser = sysUserService.getOne(new QueryWrapper<SysUserEntity>().eq("mobile", user.getMobile()));
if (queryUser != null) {
return R.error("该手机号已存在,请重新输入!");
}
user.setCreateUserId(getUserId());
sysUserService.saveUser(user);

View File

@ -1,14 +1,15 @@
/**
* Copyright (c) 2020 fumeiai All rights reserved.
*
*
*
* <p>
* <p>
* <p>
* 版权所有侵权必究
*/
package com.lz.modules.sys.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lz.modules.app.Dto.UserDto;
import com.lz.modules.sys.entity.SysUserEntity;
import org.apache.ibatis.annotations.Mapper;
@ -38,4 +39,8 @@ public interface SysUserDao extends BaseMapper<SysUserEntity> {
*/
SysUserEntity queryByUserName(String username);
List<UserDto> getUserInfos(String realName, Long createUserId, String mobile, String roleName, int pageLimit, int startIndex);
int getTotalCount(String realName, Long createUserId, String mobile, String roleName);
}

View File

@ -37,10 +37,22 @@ public class SysUserEntity implements Serializable {
@TableId
private Long userId;
/**
* 员工姓名
*/
@NotBlank(message="员工姓名不能为空", groups = {AddGroup.class, UpdateGroup.class})
private String realName;
/**
* 员工工号
*/
@NotBlank(message="工号不能为空", groups = AddGroup.class)
private String userNo;
/**
* 用户名
*/
@NotBlank(message="用户名不能为空", groups = {AddGroup.class, UpdateGroup.class})
@NotBlank(message="账号不能为空", groups = {AddGroup.class, UpdateGroup.class})
private String username;
/**
@ -49,22 +61,25 @@ public class SysUserEntity implements Serializable {
@NotBlank(message="密码不能为空", groups = AddGroup.class)
private String password;
/**
* 手机号
*/
@NotBlank(message="手机号不能为空", groups = {AddGroup.class, UpdateGroup.class})
private String mobile;
/**
*
*/
private String salt;
/**
* 邮箱
*/
@NotBlank(message="邮箱不能为空", groups = {AddGroup.class, UpdateGroup.class})
// /**
// * 邮箱
// */
// @NotBlank(message="邮箱不能为空", groups = {AddGroup.class, UpdateGroup.class})
@Email(message="邮箱格式不正确", groups = {AddGroup.class, UpdateGroup.class})
private String email;
/**
* 手机号
*/
private String mobile;
/**
* 状态 0禁用 1正常

View File

@ -1,8 +1,8 @@
/**
* Copyright (c) 2020 fumeiai All rights reserved.
*
*
*
* <p>
* <p>
* <p>
* 版权所有侵权必究
*/
@ -15,6 +15,7 @@ import com.lz.common.exception.RRException;
import com.lz.common.utils.Constant;
import com.lz.common.utils.PageUtils;
import com.lz.common.utils.Query;
import com.lz.modules.app.Dto.UserDto;
import com.lz.modules.sys.dao.SysUserDao;
import com.lz.modules.sys.entity.SysUserEntity;
import com.lz.modules.sys.service.SysRoleService;
@ -44,20 +45,31 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserDao, SysUserEntity> i
private SysUserRoleService sysUserRoleService;
@Autowired
private SysRoleService sysRoleService;
@Autowired
private SysUserDao sysUserDao;
@Override
public PageUtils queryPage(Map<String, Object> params) {
String username = (String)params.get("username");
String realName = (String) params.get("realName");
Long createUserId = (Long) params.get("createUserId");
String mobile = (String) params.get("mobile");
String roleName = (String) params.get("roleName");
IPage<SysUserEntity> page = this.page(
new Query<SysUserEntity>().getPage(params),
new QueryWrapper<SysUserEntity>()
.like(StringUtils.isNotBlank(username),"username", username)
.eq(createUserId != null,"create_user_id", createUserId)
);
int pageSize = 20;
int currPage = 1;
if (params.containsKey("limit")) {
pageSize = Integer.parseInt(params.get("limit").toString());
}
return new PageUtils(page);
if (params.containsKey("page")) {
currPage = Integer.parseInt(params.get("page").toString());
}
List<UserDto> users = sysUserDao.getUserInfos(realName, createUserId, mobile, roleName, pageSize, (currPage - 1) * pageSize);
int totalCount = sysUserDao.getTotalCount(realName, createUserId, mobile, roleName);
PageUtils pageInfo = new PageUtils(users, totalCount, pageSize, currPage);
return pageInfo;
}
@Override

View File

@ -21,4 +21,39 @@
select * from sys_user where username = #{username}
</select>
<select id="getUserInfos" resultType="com.lz.modules.app.Dto.UserDto">
select su.*,sr.role_name from sys_user su left join sys_user_role sur on su.user_id=sur.user_id left join sys_role sr on
sur.role_id=sr.role_id where 1=1
<if test="realName != null and realName != ''">
and su.real_name like concat('%',#{realName},'%')
</if>
<if test="createUserId != null and createUserId != ''">
and su.create_user_id =#{createUserId}
</if>
<if test="mobile != null and mobile != ''">
and su.mobile = #{mobile}
</if>
<if test="roleName != null and roleName != ''">
and sr.role_name like concat('%',#{roleName},'%')
</if>
limit #{startIndex}, #{pageLimit}
</select>
<select id="getTotalCount" resultType="java.lang.Integer">
select count(su.user_id) from sys_user su left join sys_user_role sur on su.user_id=sur.user_id left join sys_role sr on
sur.role_id=sr.role_id where 1=1
<if test="realName != null and realName != ''">
and su.real_name like concat('%',#{realName},'%')
</if>
<if test="createUserId != null and createUserId != ''">
and su.create_user_id =#{createUserId}
</if>
<if test="mobile != null and mobile != ''">
and su.mobile = #{mobile}
</if>
<if test="roleName != null and roleName != ''">
and sr.role_name like concat('%',#{roleName},'%')
</if>
</select>
</mapper>

Binary file not shown.

View File

@ -8,7 +8,7 @@
<springProfile name="dev,test">
<logger name="org.springframework.web" level="INFO"/>
<logger name="org.springboot.sample" level="INFO" />
<!-- <logger name="com.lz.modules.app.dao" level="DEBUG" />-->
<logger name="com.lz.modules.app.dao" level="DEBUG" />
<logger name="io.lz" level="DEBUG" />
</springProfile>

View File

@ -21,4 +21,39 @@
select * from sys_user where username = #{username}
</select>
<select id="getUserInfos" resultType="com.lz.modules.app.Dto.UserDto">
select su.*,sr.role_name from sys_user su left join sys_user_role sur on su.user_id=sur.user_id left join sys_role sr on
sur.role_id=sr.role_id where 1=1
<if test="realName != null and realName != ''">
and su.real_name like concat('%',#{realName},'%')
</if>
<if test="createUserId != null and createUserId != ''">
and su.create_user_id =#{createUserId}
</if>
<if test="mobile != null and mobile != ''">
and su.mobile = #{mobile}
</if>
<if test="roleName != null and roleName != ''">
and sr.role_name like concat('%',#{roleName},'%')
</if>
limit #{startIndex}, #{pageLimit}
</select>
<select id="getTotalCount" resultType="java.lang.Integer">
select count(su.user_id) from sys_user su left join sys_user_role sur on su.user_id=sur.user_id left join sys_role sr on
sur.role_id=sr.role_id where 1=1
<if test="realName != null and realName != ''">
and su.real_name like concat('%',#{realName},'%')
</if>
<if test="createUserId != null and createUserId != ''">
and su.create_user_id =#{createUserId}
</if>
<if test="mobile != null and mobile != ''">
and su.mobile = #{mobile}
</if>
<if test="roleName != null and roleName != ''">
and sr.role_name like concat('%',#{roleName},'%')
</if>
</select>
</mapper>