Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/main/java/com/yipin/liuwanr/controller/UserInfoController.java
#	src/main/java/com/yipin/liuwanr/mapper/UserInfoMapper.java
#	src/main/java/com/yipin/liuwanr/service/UserInfoService.java
master
zhiyong.ning 4 years ago
commit affc2a7e0b
  1. 13
      pom.xml
  2. 20
      src/main/java/com/yipin/liuwanr/controller/SysPermissionController.java
  3. 20
      src/main/java/com/yipin/liuwanr/controller/SysRoleController.java
  4. 20
      src/main/java/com/yipin/liuwanr/controller/SysRolePermissionController.java
  5. 20
      src/main/java/com/yipin/liuwanr/controller/SysUserRoleController.java
  6. 44
      src/main/java/com/yipin/liuwanr/controller/UserInfoController.java
  7. 99
      src/main/java/com/yipin/liuwanr/entity/SysPermission.java
  8. 120
      src/main/java/com/yipin/liuwanr/entity/SysRole.java
  9. 67
      src/main/java/com/yipin/liuwanr/entity/SysRolePermission.java
  10. 67
      src/main/java/com/yipin/liuwanr/entity/SysUserRole.java
  11. 3
      src/main/java/com/yipin/liuwanr/mapper/StaffMapper.java
  12. 7
      src/main/java/com/yipin/liuwanr/mapper/StaffProfessionalArchitectureMapper.java
  13. 29
      src/main/java/com/yipin/liuwanr/mapper/SysPermissionMapper.java
  14. 18
      src/main/java/com/yipin/liuwanr/mapper/SysRoleMapper.java
  15. 30
      src/main/java/com/yipin/liuwanr/mapper/SysRolePermissionMapper.java
  16. 18
      src/main/java/com/yipin/liuwanr/mapper/SysUserRoleMapper.java
  17. 19
      src/main/java/com/yipin/liuwanr/mapper/UserInfoMapper.java
  18. 18
      src/main/java/com/yipin/liuwanr/service/ISysPermissionService.java
  19. 16
      src/main/java/com/yipin/liuwanr/service/ISysRolePermissionService.java
  20. 16
      src/main/java/com/yipin/liuwanr/service/ISysRoleService.java
  21. 16
      src/main/java/com/yipin/liuwanr/service/ISysUserRoleService.java
  22. 1
      src/main/java/com/yipin/liuwanr/service/StaffProfessionalArchitectureService.java
  23. 41
      src/main/java/com/yipin/liuwanr/service/UserInfoService.java
  24. 72
      src/main/java/com/yipin/liuwanr/service/impl/SysPermissionServiceImpl.java
  25. 20
      src/main/java/com/yipin/liuwanr/service/impl/SysRolePermissionServiceImpl.java
  26. 20
      src/main/java/com/yipin/liuwanr/service/impl/SysRoleServiceImpl.java
  27. 20
      src/main/java/com/yipin/liuwanr/service/impl/SysUserRoleServiceImpl.java
  28. 115
      src/main/java/com/yipin/liuwanr/util/MyBatisPlusCodeGenerator.java

@ -259,6 +259,18 @@
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<version>3.3.1</version>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.28</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<finalName>ROOT</finalName>
@ -278,4 +290,5 @@
</plugins>
</build>
</project>

@ -0,0 +1,20 @@
package com.yipin.liuwanr.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
/**
* <p>
* 菜单权限表 前端控制器
* </p>
*
* @author Qyq
* @since 2021-02-26
*/
@Controller
@RequestMapping("/sys-permission")
public class SysPermissionController {
}

@ -0,0 +1,20 @@
package com.yipin.liuwanr.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
/**
* <p>
* 用户角色表 前端控制器
* </p>
*
* @author Qyq
* @since 2021-02-26
*/
@Controller
@RequestMapping("/sys-role")
public class SysRoleController {
}

@ -0,0 +1,20 @@
package com.yipin.liuwanr.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
/**
* <p>
* 角色权限中间表 前端控制器
* </p>
*
* @author Qyq
* @since 2021-02-26
*/
@Controller
@RequestMapping("/sys-role-permission")
public class SysRolePermissionController {
}

@ -0,0 +1,20 @@
package com.yipin.liuwanr.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
/**
* <p>
* 用户角色中间表 前端控制器
* </p>
*
* @author Qyq
* @since 2021-02-26
*/
@Controller
@RequestMapping("/sys-user-role")
public class SysUserRoleController {
}

@ -2,10 +2,7 @@ package com.yipin.liuwanr.controller;
import com.yipin.liuwanr.entity.*;
import com.yipin.liuwanr.helper.RedisHelper;
import com.yipin.liuwanr.service.StaffService;
import com.yipin.liuwanr.service.StudentService;
import com.yipin.liuwanr.service.UserInfoService;
import com.yipin.liuwanr.service.UserService;
import com.yipin.liuwanr.service.*;
import com.yipin.liuwanr.vo.UserInfoVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
@ -14,8 +11,10 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.security.Permissions;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/userInfo")
@ -36,6 +35,9 @@ public class UserInfoController {
@Autowired
RedisHelper redisHelper;
@Autowired
private ISysPermissionService permissionService;
/**
* 添加用户
@ -336,6 +338,7 @@ public class UserInfoController {
Response adminLogins(@RequestParam("account") String account, @RequestParam("password") String password,HttpServletRequest req, HttpServletResponse res) {
Response resp = new Response();
UserInfo userInfo = new UserInfo();
HashMap<String, Object> map = new HashMap<>();
if (account == null) {
resp.setStatus(300);
resp.setErrmessage("用户账号为空,登录失败!");
@ -346,10 +349,24 @@ public class UserInfoController {
userInfo.setAccount(account);
userInfo.setPassword(password);
HashMap<String, Object> ret = userInfoService.adminLogins(userInfo);
int status = (int) ret.get("retcode");
if (200 == status) {
UserInfo userInfo1 = (UserInfo)ret.get("retvalue");
String roleIds = userInfo1.getRoleId();
if(roleIds.equals(null) || roleIds.equals("")){
resp.setStatus(401);
resp.setErrmessage("无登录权限,请联系管理员处理!");
return resp;
}else{
List list = permissionService.getPermission(roleIds);
map.put("retvalue",ret.get("retvalue"));
map.put("listValue",list);
}
resp.setStatus(status);
resp.setMessage(ret.get("retvalue"));
//resp.setMessage(ret.get("retvalue"));
resp.setMessage(map);
} else {
resp.setStatus(status);
resp.setErrmessage(ret.get("retvalue").toString());
@ -521,23 +538,14 @@ public class UserInfoController {
* 更新登录次数和时间
*/
@PostMapping("/updateLogInNumber")
Response updateLogInNumber(@RequestBody UserInfo userInfo) {
Response updateLogInNumber(@RequestBody UserInfo user) {
Response resp = new Response();
Integer userId = userInfo.getUserId();
String phone = userInfo.getPhone();
String roleId = userInfo.getRoleId();
Integer userId = user.getUserId();
if (userId==null) {
resp.setStatus(300);
resp.setErrmessage("用户id不能为空!");
// }else if(phone==null||phone==""){
// resp.setStatus(300);
// resp.setErrmessage("用户电话不能为空!");
// } else if(accountRole==null){
// resp.setStatus(300);
// resp.setErrmessage("用户角色不能为空!");
}
else {
HashMap<String, Object> ret = userInfoService.updateLogInNumber(userInfo);
}else{
HashMap<String, Object> ret = userInfoService.updateLogInNumber(user);
int status = (int) ret.get("retcode");
if (200 == status) {
resp.setStatus(status);

@ -0,0 +1,99 @@
package com.yipin.liuwanr.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* <p>
* 菜单权限表
* </p>
*
* @author Qyq
* @since 2021-02-26
*/
@Data
@TableName("sys_permission")
public class SysPermission implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 权限标识符
*/
private String code;
/**
* 名称
*/
private String name;
/**
* 父权限id
*/
private Long parentId;
/**
* 层级
*/
private Integer level;
/**
* 是否是菜单10不是0目前为按钮
*/
private Integer menuOrNot;
/**
* 状态0启用1禁用
*/
private Integer status;
/**
* 路径
*/
private String url;
/**
* 页面路径
*/
private String menuUrl;
/**
* 排序
*/
private Integer sort;
/**
* 图标
*/
private String icon;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date motifyTime;
/**
* 子权限
*/
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@TableField(exist = false)
private List<SysPermission> children;
}

@ -0,0 +1,120 @@
package com.yipin.liuwanr.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
/**
* <p>
* 用户角色表
* </p>
*
* @author Qyq
* @since 2021-02-26
*/
@TableName("sys_role")
public class SysRole implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 角色名称
*/
private String name;
/**
* 角色描述
*/
private String description;
/**
* 是否删除0未删除1删除
*/
private Integer delOrNot;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date motifyTime;
/**
* 编码
*/
private String code;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Integer getDelOrNot() {
return delOrNot;
}
public void setDelOrNot(Integer delOrNot) {
this.delOrNot = delOrNot;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getMotifyTime() {
return motifyTime;
}
public void setMotifyTime(Date motifyTime) {
this.motifyTime = motifyTime;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
@Override
public String toString() {
return "SysRole{" +
"id=" + id +
", name=" + name +
", description=" + description +
", delOrNot=" + delOrNot +
", createTime=" + createTime +
", motifyTime=" + motifyTime +
", code=" + code +
"}";
}
}

@ -0,0 +1,67 @@
package com.yipin.liuwanr.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
/**
* <p>
* 角色权限中间表
* </p>
*
* @author Qyq
* @since 2021-02-26
*/
@TableName("sys_role_permission")
public class SysRolePermission implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 角色id
*/
private Long roleId;
/**
* 权限id
*/
private Long permissionId;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getRoleId() {
return roleId;
}
public void setRoleId(Long roleId) {
this.roleId = roleId;
}
public Long getPermissionId() {
return permissionId;
}
public void setPermissionId(Long permissionId) {
this.permissionId = permissionId;
}
@Override
public String toString() {
return "SysRolePermission{" +
"id=" + id +
", roleId=" + roleId +
", permissionId=" + permissionId +
"}";
}
}

@ -0,0 +1,67 @@
package com.yipin.liuwanr.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
/**
* <p>
* 用户角色中间表
* </p>
*
* @author Qyq
* @since 2021-02-26
*/
@TableName("sys_user_role")
public class SysUserRole implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 用户id
*/
private Long userId;
/**
* 角色id
*/
private Long roleId;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public Long getRoleId() {
return roleId;
}
public void setRoleId(Long roleId) {
this.roleId = roleId;
}
@Override
public String toString() {
return "SysUserRole{" +
"id=" + id +
", userId=" + userId +
", roleId=" + roleId +
"}";
}
}

@ -120,4 +120,7 @@ public interface StaffMapper {
@Update("update staff set lastTimeOfLanding=#{lastTime},logNumber=#{logNumber} where staffId=#{staffId}")
void updateStaffQ(@Param("lastTime") String lastTime,@Param("logNumber") Integer logNumber,@Param("staffId") Integer staffId);
@Select("select schoolId,staffId FROM staff WHERE userId = #{userId} AND isdel = 0 GROUP BY schoolId ORDER BY staffId limit 1")
Integer querySchoolId(Integer userId);
}

@ -35,4 +35,11 @@ public interface StaffProfessionalArchitectureMapper {
"SELECT pro.staffProfessionalArchitectureId,pro.staffProfessionalArchitectureName,pro.schoolId,sch.schoolName from staff_professional_architecture pro,school sch where pro.isdel = 0 and pro.schoolId = sch.schoolId and pro.schoolId = #{schoolId}",
"</script> "})
List<StaffProfessionalArchitecture> queryAllStaffProfessionalArchitecture(Integer schoolId);
@Update("UPDATE staff sta,\n" +
"staff_professional_architecture spa \n" +
"SET sta.staffProfessionalArchitectureName = spa.staffProfessionalArchitectureName \n" +
"WHERE\n" +
"\tsta.staffProfessionalArchitectureId = spa.staffProfessionalArchitectureId")
void updateStaffArchitectureName();
}

@ -0,0 +1,29 @@
package com.yipin.liuwanr.mapper;
import com.yipin.liuwanr.entity.SysPermission;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
* <p>
* 菜单权限表 Mapper 接口
* </p>
*
* @author Qyq
* @since 2021-02-26
*/
public interface SysPermissionMapper extends BaseMapper<SysPermission> {
@Select({"<script>",
" select id,code,name,parent_id as parentId,level,menu_or_not as menuOrNot," +
"status,url,menu_url as menuUrl,sort,icon,create_time as createTime,motify_time as motifyTime from sys_permission\n" +
" where id in\n" +
" <foreach collection=\"ids\" open=\"(\" separator=\",\" close=\")\" item=\"id\">\n" +
" #{id}\n" +
" </foreach>",
"</script> "})
List<SysPermission> queryPermissionsByIds(@Param("ids")List<Long> ids);
}

@ -0,0 +1,18 @@
package com.yipin.liuwanr.mapper;
import com.yipin.liuwanr.entity.SysRole;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* <p>
* 用户角色表 Mapper 接口
* </p>
*
* @author Qyq
* @since 2021-02-26
*/
@Mapper
public interface SysRoleMapper extends BaseMapper<SysRole> {
}

@ -0,0 +1,30 @@
package com.yipin.liuwanr.mapper;
import com.yipin.liuwanr.entity.Project_Management;
import com.yipin.liuwanr.entity.SysRolePermission;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
* <p>
* 角色权限中间表 Mapper 接口
* </p>
*
* @author Qyq
* @since 2021-02-26
*/
public interface SysRolePermissionMapper extends BaseMapper<SysRolePermission> {
@Select({"<script>",
" select permission_id as permissionId from sys_role_permission\n" +
" where role_id in\n" +
" <foreach collection=\"ids\" open=\"(\" separator=\",\" close=\")\" item=\"id\">\n" +
" #{id}\n" +
" </foreach>",
"</script> "})
List<SysRolePermission> queryPermissionsByRoleIds(@Param("ids") List<Long> ids);
}

@ -0,0 +1,18 @@
package com.yipin.liuwanr.mapper;
import com.yipin.liuwanr.entity.SysUserRole;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* <p>
* 用户角色中间表 Mapper 接口
* </p>
*
* @author Qyq
* @since 2021-02-26
*/
@Mapper
public interface SysUserRoleMapper extends BaseMapper<SysUserRole> {
}

@ -263,15 +263,15 @@ public interface UserInfoMapper {
//更新用户登录次数和最后一次登录时间
@Update({"UPDATE hr_user_info SET logInNumber=logInNumber+1, lastLoginTime=now() WHERE userId=#{userId}"})
void updateLogInNumber(UserInfo userInfo);
void updateLogInNumber(UserInfo user);
//更新学生登录次数和最后一次登录时间
@Update({"UPDATE student SET logInNumber=logInNumber+1, lastLoginTime=now() WHERE phone=#{phone}"})
void updateStudentLogInNumber(UserM user);
@Update({"UPDATE student SET logInNumber=logInNumber+1, lastLoginTime=now() WHERE userId=#{userId}"})
void updateStudentLogInNumber(UserInfo user);
//更新员工登录次数和最后一次登录时间
@Update({"UPDATE staff SET logNumber=logNumber+1, lastTimeOfLanding=now() WHERE phone=#{phone}"})
void updateStaffLogInNumber(UserM user);
@Update({"UPDATE staff SET loginNumber=loginNumber+1, lastLoginTime=now() WHERE userId=#{userId}"})
void updateStaffLogInNumber(UserInfo user);
//查询账号是否存在
@Select("SELECT account,email,userName,userId,uniqueIdentificationAccount,phone from hr_user_info where isdel = 0 and account = #{account}")
@ -282,11 +282,11 @@ public interface UserInfoMapper {
List<OrganizationRelationship> queryAccountIsExistOR(String account, Integer schoolId);
//查询员工学号、工号是否存在
@Select("SELECT userId,workNumber,schoolId,roleId from staff where workNumber = #{workNumber} and roleId = #{roleId} and schoolId = #{schoolId}")
@Select("SELECT userId,workNumber,schoolId,roleId from staff where workNumber = #{workNumber} and roleId = #{roleId} and schoolId = #{schoolId} and isdel=0")
List<Staff> queryStaffWorkNumberIsExist(String workNumber, Integer roleId, Integer schoolId);
//查询学生学号、工号是否存在
@Select("SELECT userId,workNumber,schoolId,roleId from student where workNumber = #{workNumber} and roleId = #{roleId} and schoolId = #{schoolId}")
@Select("SELECT userId,workNumber,schoolId,roleId from student where workNumber = #{workNumber} and roleId = #{roleId} and schoolId = #{schoolId} and isdel=0")
List<Student> queryStudentWorkNumberIsExist(String workNumber, Integer roleId, Integer schoolId);
//查询平台
@ -338,6 +338,9 @@ public interface UserInfoMapper {
"</script>"})
void deleteOrganizationRelationship(Integer userId);
@Select("SELECT disableAccount FROM hr_user_info WHERE schoolId = #{schoolId} AND account = #{account}")
@Select("SELECT disableAccount FROM hr_user_info u LEFT JOIN student s ON u.userId = s.userId WHERE s.schoolId = #{schoolId} AND account = #{account} AND u.isdel = 0 AND s.isdel = 0")
Integer queryDisableAccount(UserInfo userInfo);
@Select("select roleId from hr_user_info where userId = #{userId}")
UserInfo queryUser(UserInfo user);
}

@ -0,0 +1,18 @@
package com.yipin.liuwanr.service;
import com.yipin.liuwanr.entity.SysPermission;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* <p>
* 菜单权限表 服务类
* </p>
*
* @author Qyq
* @since 2021-02-26
*/
public interface ISysPermissionService extends IService<SysPermission> {
List getPermission(String roleIds);
}

@ -0,0 +1,16 @@
package com.yipin.liuwanr.service;
import com.yipin.liuwanr.entity.SysRolePermission;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 角色权限中间表 服务类
* </p>
*
* @author Qyq
* @since 2021-02-26
*/
public interface ISysRolePermissionService extends IService<SysRolePermission> {
}

@ -0,0 +1,16 @@
package com.yipin.liuwanr.service;
import com.yipin.liuwanr.entity.SysRole;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 用户角色表 服务类
* </p>
*
* @author Qyq
* @since 2021-02-26
*/
public interface ISysRoleService extends IService<SysRole> {
}

@ -0,0 +1,16 @@
package com.yipin.liuwanr.service;
import com.yipin.liuwanr.entity.SysUserRole;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 用户角色中间表 服务类
* </p>
*
* @author Qyq
* @since 2021-02-26
*/
public interface ISysUserRoleService extends IService<SysUserRole> {
}

@ -93,6 +93,7 @@ public class StaffProfessionalArchitectureService {
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
staffProfessionalArchitectureMapper.updateStaffProfessionalArchitecture(staffProfessionalArchitecture);
staffProfessionalArchitectureMapper.updateStaffArchitectureName();
resp.put("retcode", 200);
} catch (RuntimeException e) {
logger.error(e.getMessage());

@ -449,8 +449,7 @@ public class UserInfoService {
List<Student> studentList = userInfoMapper.queryStudentAll(id,roleId,schoolId);
obj.put("studentList",studentList);
ValueOperations<String, String> redis = stringRedisTemplate.opsForValue();
//设置token 1小时候过期
redis.set(token,userId+"", 1, TimeUnit.HOURS);
redis.set(token,userId+"", 30 * 60, TimeUnit.SECONDS);
resp.put("retcode", 200);
resp.put("retvalue", obj);
}else {
@ -471,10 +470,25 @@ public class UserInfoService {
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
UserInfo user=userInfoMapper.adminLogins(userInfo);
if(user != null){
if (user.getRoleId().contains("1")){
user.setSchoolId(null);
}else {
Integer schoolId = staffMapper.querySchoolId(user.getUserId());
user.setSchoolId(schoolId);
}
}
if (user==null){
resp.put("retvalue","账号密码有误,请稍后再试!");
resp.put("retcode", 300);
}else{
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
String lastLoginTime = df.format(new Date());
user.setLastLoginTime(lastLoginTime);
//登录成功,重新设置最后登录时间以及登录次数
userInfoMapper.updateLogInNumber(user);
resp.put("retvalue",user);
resp.put("retcode", 200);
}
@ -612,19 +626,20 @@ public class UserInfoService {
}
//更新登录次数和时间
public HashMap<String, Object> updateLogInNumber(UserInfo userInfo){
public HashMap<String, Object> updateLogInNumber(UserInfo user){
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
// Integer accountRole = user.getAccountRole();
userInfoMapper.updateLogInNumber(userInfo);
// if (accountRole==3){
// //更新员工登录次数和时间
// userInfoMapper.updateStaffLogInNumber(user);
// }
// if (accountRole==4){
// //更新学生登录次数和时间
// userInfoMapper.updateStudentLogInNumber(user);
// }
userInfoMapper.updateLogInNumber(user);
UserInfo userInfo = userInfoMapper.queryUser(user);
String roleId = userInfo.getRoleId();
if (roleId.contains("3")|roleId.contains("2")){
//更新员工登录次数和时间
userInfoMapper.updateStaffLogInNumber(user);
}
if (roleId.contains("4")){
//更新学生登录次数和时间
userInfoMapper.updateStudentLogInNumber(user);
}
resp.put("retcode", 200);
} catch (RuntimeException e) {
logger.error(e.getMessage());

@ -0,0 +1,72 @@
package com.yipin.liuwanr.service.impl;
import com.yipin.liuwanr.entity.SysPermission;
import com.yipin.liuwanr.entity.SysRolePermission;
import com.yipin.liuwanr.mapper.SysPermissionMapper;
import com.yipin.liuwanr.mapper.SysRolePermissionMapper;
import com.yipin.liuwanr.service.ISysPermissionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.beanutils.ConvertUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
/**
* <p>
* 菜单权限表 服务实现类
* </p>
*
* @author Qyq
* @since 2021-02-26
*/
@Service
public class SysPermissionServiceImpl extends ServiceImpl<SysPermissionMapper, SysPermission> implements ISysPermissionService {
@Resource
private SysRolePermissionMapper rolePermissionMapper;
@Resource
private SysPermissionMapper permissionMapper;
@Override
public List getPermission(String roleIds) {
//截取字符串
String[] strArr = roleIds.split(",");
//转换long类型的数组
Long[] strArrNum = (Long[]) ConvertUtils.convert(strArr,Long.class);
//根据角色id查询对应的权限id
List<SysRolePermission> rolePermissionList = rolePermissionMapper.queryPermissionsByRoleIds(Arrays.asList(strArrNum));
List<Long> permissionList = new ArrayList();
for(SysRolePermission res : rolePermissionList){
permissionList.add(res.getPermissionId());
}
if(permissionList.size()>0){
Long[] permissionIds = permissionList.toArray(new Long[permissionList.size()]);
//根据权限ids查询对应权限
List<SysPermission> permissionEntityList = permissionMapper.queryPermissionsByIds(Arrays.asList(permissionIds));
return getListDepartmentAndEmployeeTree(permissionEntityList, 0L);
}else{
return null;
}
}
private List<SysPermission> getListDepartmentAndEmployeeTree(List<SysPermission> list, Long parentId) {
return list.stream()
.filter(dept -> parentId.equals(dept.getParentId())) // 过滤出部门id为所选id的部门信息(也为递归的结果条件,找不到所对应的部门id)
.peek(dept -> {
dept.setChildren(getListDepartmentAndEmployeeTree(list, dept.getId())); // 设置该部门的子部门:递归调用
//SysPermission permission = permissionService.getById(dept.getId());
/*dept.setUserDept(employeeDao.employeeListByDeptId(dept.getId(),account));*/
})
.sorted(Comparator.comparingInt(menu -> (menu.getSort() == null ? 0 : menu.getSort()))) // 根据所选排序信息进行排序
.collect(Collectors.toList());
}
}

@ -0,0 +1,20 @@
package com.yipin.liuwanr.service.impl;
import com.yipin.liuwanr.entity.SysRolePermission;
import com.yipin.liuwanr.mapper.SysRolePermissionMapper;
import com.yipin.liuwanr.service.ISysRolePermissionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 角色权限中间表 服务实现类
* </p>
*
* @author Qyq
* @since 2021-02-26
*/
@Service
public class SysRolePermissionServiceImpl extends ServiceImpl<SysRolePermissionMapper, SysRolePermission> implements ISysRolePermissionService {
}

@ -0,0 +1,20 @@
package com.yipin.liuwanr.service.impl;
import com.yipin.liuwanr.entity.SysRole;
import com.yipin.liuwanr.mapper.SysRoleMapper;
import com.yipin.liuwanr.service.ISysRoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 用户角色表 服务实现类
* </p>
*
* @author Qyq
* @since 2021-02-26
*/
@Service
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements ISysRoleService {
}

@ -0,0 +1,20 @@
package com.yipin.liuwanr.service.impl;
import com.yipin.liuwanr.entity.SysUserRole;
import com.yipin.liuwanr.mapper.SysUserRoleMapper;
import com.yipin.liuwanr.service.ISysUserRoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 用户角色中间表 服务实现类
* </p>
*
* @author Qyq
* @since 2021-02-26
*/
@Service
public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUserRole> implements ISysUserRoleService {
}

@ -0,0 +1,115 @@
package com.yipin.liuwanr.util;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.generator.AutoGenerator;
import com.baomidou.mybatisplus.generator.InjectionConfig;
import com.baomidou.mybatisplus.generator.config.*;
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
import com.baomidou.mybatisplus.generator.config.rules.DateType;
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
import java.util.ArrayList;
import java.util.List;
/**
* @Author: LvFang
* @Date: Created in 2019/6/11.
* @Description:
*/
public class MyBatisPlusCodeGenerator {
//包名
public static final String PACKAGE_NAME = "com.yipin.liuwanr";
public static void main(String[] args) {
String[] tables = new String[] {"sys_permission","sys_role","sys_role_permission","sys_user_role"};//表名数组
String[] tablePrefixs = new String[] {""};//去掉前缀
executeCode(PACKAGE_NAME,tables,tablePrefixs);
}
private static void executeCode(String pack, String[] tables, String[] tablePrefixs) {
// 代码生成器
AutoGenerator mpg = new AutoGenerator();
// 全局配置
GlobalConfig gc = new GlobalConfig();
// 是否覆盖已有文件
gc.setFileOverride(false);
// 生成文件的输出目录
String projectPath = System.getProperty("user.dir");//user.dir 表示当前工程路径无需替换
gc.setOutputDir(projectPath + "/src/main/java");
//设置bean命名规范
gc.setEntityName("%s");
// 开发人员
gc.setAuthor("Qyq");
// 是否打开输出目录
gc.setOpen(false);
// 开启 BaseResultMap
gc.setBaseResultMap(true);
// 指定生成的主键的ID类型
gc.setIdType(IdType.ID_WORKER);
// 时间类型对应策略: 只使用 java.util.date 代替
gc.setDateType(DateType.ONLY_DATE);
mpg.setGlobalConfig(gc);
// 数据源配置
DataSourceConfig config= new DataSourceConfig();
// 从试图获取
config.setUrl("jdbc:mysql://localhost:3306/msdw_tms?serverTimezone=UTC");
config.setDriverName("com.mysql.cj.jdbc.Driver");
config.setUsername("root");
config.setPassword("root");
mpg.setDataSource(config);
// 包配置
PackageConfig pc = new PackageConfig();
// 父包名。如果为空,将下面子包名必须写全部, 否则就只需写子包名
pc.setParent(pack);
// Entity包名
pc.setEntity("entity");
mpg.setPackageInfo(pc);
// 自定义配置
InjectionConfig cfg = new InjectionConfig() {
@Override
public void initMap() {
// to do nothing
}
};
List<FileOutConfig> focList = new ArrayList<>();
focList.add(new FileOutConfig("/templates/mapper.xml.ftl") {
public String outputFile(TableInfo tableInfo) {
// 自定义输入文件名称
if (StringUtils.isEmpty(pc.getModuleName())) {
return projectPath + "/src/main/resources/mapper/tms/" + tableInfo.getXmlName() + StringPool.DOT_XML;
}else {
return projectPath + "/src/main/resources/mapper/tms/" + pc.getModuleName() + "/" + tableInfo.getXmlName() + StringPool.DOT_XML;
}
}
});
cfg.setFileOutConfigList(focList);
mpg.setCfg(cfg);
mpg.setTemplate(new TemplateConfig().setXml(null));
// 策略配置
StrategyConfig strategy = new StrategyConfig();
// 数据库表映射到实体的命名策略: 下划线转驼峰命名
strategy.setNaming(NamingStrategy.underline_to_camel);
// 数据库表字段映射到实体的命名策略: 下划线转驼峰命名
strategy.setColumnNaming(NamingStrategy.underline_to_camel);
// 【实体】是否为lombok模型(默认 false)
strategy.setEntityLombokModel(false);
// 需要包含的表名,允许正则表达式(与exclude二选一配置)
strategy.setInclude(tables);
// 驼峰转连字符
strategy.setControllerMappingHyphenStyle(true);
// 表前缀
strategy.setTablePrefix(tablePrefixs);
mpg.setStrategy(strategy);
mpg.setTemplateEngine(new FreemarkerTemplateEngine());
mpg.execute();
}
}
Loading…
Cancel
Save