diff --git a/pom.xml b/pom.xml
index 26d0da4..5d82d82 100644
--- a/pom.xml
+++ b/pom.xml
@@ -259,6 +259,18 @@
javax.servlet-api
provided
+
+
+ com.baomidou
+ mybatis-plus-generator
+ 3.3.1
+
+
+ org.freemarker
+ freemarker
+ 2.3.28
+ compile
+
ROOT
@@ -278,4 +290,5 @@
+
diff --git a/src/main/java/com/yipin/liuwanr/controller/SysPermissionController.java b/src/main/java/com/yipin/liuwanr/controller/SysPermissionController.java
new file mode 100644
index 0000000..c0836be
--- /dev/null
+++ b/src/main/java/com/yipin/liuwanr/controller/SysPermissionController.java
@@ -0,0 +1,20 @@
+package com.yipin.liuwanr.controller;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.stereotype.Controller;
+
+/**
+ *
+ * 菜单权限表 前端控制器
+ *
+ *
+ * @author Qyq
+ * @since 2021-02-26
+ */
+@Controller
+@RequestMapping("/sys-permission")
+public class SysPermissionController {
+
+}
diff --git a/src/main/java/com/yipin/liuwanr/controller/SysRoleController.java b/src/main/java/com/yipin/liuwanr/controller/SysRoleController.java
new file mode 100644
index 0000000..7df5542
--- /dev/null
+++ b/src/main/java/com/yipin/liuwanr/controller/SysRoleController.java
@@ -0,0 +1,20 @@
+package com.yipin.liuwanr.controller;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.stereotype.Controller;
+
+/**
+ *
+ * 用户角色表 前端控制器
+ *
+ *
+ * @author Qyq
+ * @since 2021-02-26
+ */
+@Controller
+@RequestMapping("/sys-role")
+public class SysRoleController {
+
+}
diff --git a/src/main/java/com/yipin/liuwanr/controller/SysRolePermissionController.java b/src/main/java/com/yipin/liuwanr/controller/SysRolePermissionController.java
new file mode 100644
index 0000000..c07ee63
--- /dev/null
+++ b/src/main/java/com/yipin/liuwanr/controller/SysRolePermissionController.java
@@ -0,0 +1,20 @@
+package com.yipin.liuwanr.controller;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.stereotype.Controller;
+
+/**
+ *
+ * 角色权限中间表 前端控制器
+ *
+ *
+ * @author Qyq
+ * @since 2021-02-26
+ */
+@Controller
+@RequestMapping("/sys-role-permission")
+public class SysRolePermissionController {
+
+}
diff --git a/src/main/java/com/yipin/liuwanr/controller/SysUserRoleController.java b/src/main/java/com/yipin/liuwanr/controller/SysUserRoleController.java
new file mode 100644
index 0000000..4499faf
--- /dev/null
+++ b/src/main/java/com/yipin/liuwanr/controller/SysUserRoleController.java
@@ -0,0 +1,20 @@
+package com.yipin.liuwanr.controller;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.stereotype.Controller;
+
+/**
+ *
+ * 用户角色中间表 前端控制器
+ *
+ *
+ * @author Qyq
+ * @since 2021-02-26
+ */
+@Controller
+@RequestMapping("/sys-user-role")
+public class SysUserRoleController {
+
+}
diff --git a/src/main/java/com/yipin/liuwanr/controller/UserInfoController.java b/src/main/java/com/yipin/liuwanr/controller/UserInfoController.java
index 22745dd..e46d4a3 100644
--- a/src/main/java/com/yipin/liuwanr/controller/UserInfoController.java
+++ b/src/main/java/com/yipin/liuwanr/controller/UserInfoController.java
@@ -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 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 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 ret = userInfoService.updateLogInNumber(userInfo);
+ }else{
+ HashMap ret = userInfoService.updateLogInNumber(user);
int status = (int) ret.get("retcode");
if (200 == status) {
resp.setStatus(status);
diff --git a/src/main/java/com/yipin/liuwanr/entity/SysPermission.java b/src/main/java/com/yipin/liuwanr/entity/SysPermission.java
new file mode 100644
index 0000000..dedd836
--- /dev/null
+++ b/src/main/java/com/yipin/liuwanr/entity/SysPermission.java
@@ -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;
+
+/**
+ *
+ * 菜单权限表
+ *
+ *
+ * @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;
+
+ /**
+ * 是否是菜单:1、是,0、不是(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 children;
+}
diff --git a/src/main/java/com/yipin/liuwanr/entity/SysRole.java b/src/main/java/com/yipin/liuwanr/entity/SysRole.java
new file mode 100644
index 0000000..c6c2421
--- /dev/null
+++ b/src/main/java/com/yipin/liuwanr/entity/SysRole.java
@@ -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;
+
+/**
+ *
+ * 用户角色表
+ *
+ *
+ * @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 +
+ "}";
+ }
+}
diff --git a/src/main/java/com/yipin/liuwanr/entity/SysRolePermission.java b/src/main/java/com/yipin/liuwanr/entity/SysRolePermission.java
new file mode 100644
index 0000000..556d2bd
--- /dev/null
+++ b/src/main/java/com/yipin/liuwanr/entity/SysRolePermission.java
@@ -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;
+
+/**
+ *
+ * 角色权限中间表
+ *
+ *
+ * @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 +
+ "}";
+ }
+}
diff --git a/src/main/java/com/yipin/liuwanr/entity/SysUserRole.java b/src/main/java/com/yipin/liuwanr/entity/SysUserRole.java
new file mode 100644
index 0000000..0bac9b3
--- /dev/null
+++ b/src/main/java/com/yipin/liuwanr/entity/SysUserRole.java
@@ -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;
+
+/**
+ *
+ * 用户角色中间表
+ *
+ *
+ * @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 +
+ "}";
+ }
+}
diff --git a/src/main/java/com/yipin/liuwanr/mapper/StaffMapper.java b/src/main/java/com/yipin/liuwanr/mapper/StaffMapper.java
index 8b52956..c282345 100644
--- a/src/main/java/com/yipin/liuwanr/mapper/StaffMapper.java
+++ b/src/main/java/com/yipin/liuwanr/mapper/StaffMapper.java
@@ -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);
}
\ No newline at end of file
diff --git a/src/main/java/com/yipin/liuwanr/mapper/StaffProfessionalArchitectureMapper.java b/src/main/java/com/yipin/liuwanr/mapper/StaffProfessionalArchitectureMapper.java
index 3df3d3e..88f7d35 100644
--- a/src/main/java/com/yipin/liuwanr/mapper/StaffProfessionalArchitectureMapper.java
+++ b/src/main/java/com/yipin/liuwanr/mapper/StaffProfessionalArchitectureMapper.java
@@ -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}",
" "})
List 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();
}
\ No newline at end of file
diff --git a/src/main/java/com/yipin/liuwanr/mapper/SysPermissionMapper.java b/src/main/java/com/yipin/liuwanr/mapper/SysPermissionMapper.java
new file mode 100644
index 0000000..463bd62
--- /dev/null
+++ b/src/main/java/com/yipin/liuwanr/mapper/SysPermissionMapper.java
@@ -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;
+
+/**
+ *
+ * 菜单权限表 Mapper 接口
+ *
+ *
+ * @author Qyq
+ * @since 2021-02-26
+ */
+public interface SysPermissionMapper extends BaseMapper {
+ @Select({" "})
+ List queryPermissionsByIds(@Param("ids")List ids);
+}
diff --git a/src/main/java/com/yipin/liuwanr/mapper/SysRoleMapper.java b/src/main/java/com/yipin/liuwanr/mapper/SysRoleMapper.java
new file mode 100644
index 0000000..ff4cf9d
--- /dev/null
+++ b/src/main/java/com/yipin/liuwanr/mapper/SysRoleMapper.java
@@ -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;
+
+/**
+ *
+ * 用户角色表 Mapper 接口
+ *
+ *
+ * @author Qyq
+ * @since 2021-02-26
+ */
+@Mapper
+public interface SysRoleMapper extends BaseMapper {
+
+}
diff --git a/src/main/java/com/yipin/liuwanr/mapper/SysRolePermissionMapper.java b/src/main/java/com/yipin/liuwanr/mapper/SysRolePermissionMapper.java
new file mode 100644
index 0000000..1371efb
--- /dev/null
+++ b/src/main/java/com/yipin/liuwanr/mapper/SysRolePermissionMapper.java
@@ -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;
+
+/**
+ *
+ * 角色权限中间表 Mapper 接口
+ *
+ *
+ * @author Qyq
+ * @since 2021-02-26
+ */
+public interface SysRolePermissionMapper extends BaseMapper {
+
+ @Select({" "})
+ List queryPermissionsByRoleIds(@Param("ids") List ids);
+}
diff --git a/src/main/java/com/yipin/liuwanr/mapper/SysUserRoleMapper.java b/src/main/java/com/yipin/liuwanr/mapper/SysUserRoleMapper.java
new file mode 100644
index 0000000..17fe947
--- /dev/null
+++ b/src/main/java/com/yipin/liuwanr/mapper/SysUserRoleMapper.java
@@ -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;
+
+/**
+ *
+ * 用户角色中间表 Mapper 接口
+ *
+ *
+ * @author Qyq
+ * @since 2021-02-26
+ */
+@Mapper
+public interface SysUserRoleMapper extends BaseMapper {
+
+}
diff --git a/src/main/java/com/yipin/liuwanr/mapper/UserInfoMapper.java b/src/main/java/com/yipin/liuwanr/mapper/UserInfoMapper.java
index dbb8be6..02b86a8 100644
--- a/src/main/java/com/yipin/liuwanr/mapper/UserInfoMapper.java
+++ b/src/main/java/com/yipin/liuwanr/mapper/UserInfoMapper.java
@@ -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 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 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 queryStudentWorkNumberIsExist(String workNumber, Integer roleId, Integer schoolId);
//查询平台
@@ -338,6 +338,9 @@ public interface UserInfoMapper {
""})
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);
}
\ No newline at end of file
diff --git a/src/main/java/com/yipin/liuwanr/service/ISysPermissionService.java b/src/main/java/com/yipin/liuwanr/service/ISysPermissionService.java
new file mode 100644
index 0000000..f95a120
--- /dev/null
+++ b/src/main/java/com/yipin/liuwanr/service/ISysPermissionService.java
@@ -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;
+
+/**
+ *
+ * 菜单权限表 服务类
+ *
+ *
+ * @author Qyq
+ * @since 2021-02-26
+ */
+public interface ISysPermissionService extends IService {
+ List getPermission(String roleIds);
+}
diff --git a/src/main/java/com/yipin/liuwanr/service/ISysRolePermissionService.java b/src/main/java/com/yipin/liuwanr/service/ISysRolePermissionService.java
new file mode 100644
index 0000000..6cf0b51
--- /dev/null
+++ b/src/main/java/com/yipin/liuwanr/service/ISysRolePermissionService.java
@@ -0,0 +1,16 @@
+package com.yipin.liuwanr.service;
+
+import com.yipin.liuwanr.entity.SysRolePermission;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ *
+ * 角色权限中间表 服务类
+ *
+ *
+ * @author Qyq
+ * @since 2021-02-26
+ */
+public interface ISysRolePermissionService extends IService {
+
+}
diff --git a/src/main/java/com/yipin/liuwanr/service/ISysRoleService.java b/src/main/java/com/yipin/liuwanr/service/ISysRoleService.java
new file mode 100644
index 0000000..b5e0b87
--- /dev/null
+++ b/src/main/java/com/yipin/liuwanr/service/ISysRoleService.java
@@ -0,0 +1,16 @@
+package com.yipin.liuwanr.service;
+
+import com.yipin.liuwanr.entity.SysRole;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ *
+ * 用户角色表 服务类
+ *
+ *
+ * @author Qyq
+ * @since 2021-02-26
+ */
+public interface ISysRoleService extends IService {
+
+}
diff --git a/src/main/java/com/yipin/liuwanr/service/ISysUserRoleService.java b/src/main/java/com/yipin/liuwanr/service/ISysUserRoleService.java
new file mode 100644
index 0000000..511b6b9
--- /dev/null
+++ b/src/main/java/com/yipin/liuwanr/service/ISysUserRoleService.java
@@ -0,0 +1,16 @@
+package com.yipin.liuwanr.service;
+
+import com.yipin.liuwanr.entity.SysUserRole;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ *
+ * 用户角色中间表 服务类
+ *
+ *
+ * @author Qyq
+ * @since 2021-02-26
+ */
+public interface ISysUserRoleService extends IService {
+
+}
diff --git a/src/main/java/com/yipin/liuwanr/service/StaffProfessionalArchitectureService.java b/src/main/java/com/yipin/liuwanr/service/StaffProfessionalArchitectureService.java
index 7dc3231..03a3914 100644
--- a/src/main/java/com/yipin/liuwanr/service/StaffProfessionalArchitectureService.java
+++ b/src/main/java/com/yipin/liuwanr/service/StaffProfessionalArchitectureService.java
@@ -93,6 +93,7 @@ public class StaffProfessionalArchitectureService {
HashMap resp = new HashMap();
try {
staffProfessionalArchitectureMapper.updateStaffProfessionalArchitecture(staffProfessionalArchitecture);
+ staffProfessionalArchitectureMapper.updateStaffArchitectureName();
resp.put("retcode", 200);
} catch (RuntimeException e) {
logger.error(e.getMessage());
diff --git a/src/main/java/com/yipin/liuwanr/service/UserInfoService.java b/src/main/java/com/yipin/liuwanr/service/UserInfoService.java
index 24ab730..f486acc 100644
--- a/src/main/java/com/yipin/liuwanr/service/UserInfoService.java
+++ b/src/main/java/com/yipin/liuwanr/service/UserInfoService.java
@@ -449,8 +449,7 @@ public class UserInfoService {
List studentList = userInfoMapper.queryStudentAll(id,roleId,schoolId);
obj.put("studentList",studentList);
ValueOperations 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 resp = new HashMap();
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 updateLogInNumber(UserInfo userInfo){
+ public HashMap updateLogInNumber(UserInfo user){
HashMap resp = new HashMap();
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());
diff --git a/src/main/java/com/yipin/liuwanr/service/impl/SysPermissionServiceImpl.java b/src/main/java/com/yipin/liuwanr/service/impl/SysPermissionServiceImpl.java
new file mode 100644
index 0000000..89977ed
--- /dev/null
+++ b/src/main/java/com/yipin/liuwanr/service/impl/SysPermissionServiceImpl.java
@@ -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;
+
+/**
+ *
+ * 菜单权限表 服务实现类
+ *
+ *
+ * @author Qyq
+ * @since 2021-02-26
+ */
+@Service
+public class SysPermissionServiceImpl extends ServiceImpl 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 rolePermissionList = rolePermissionMapper.queryPermissionsByRoleIds(Arrays.asList(strArrNum));
+ List 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 permissionEntityList = permissionMapper.queryPermissionsByIds(Arrays.asList(permissionIds));
+ return getListDepartmentAndEmployeeTree(permissionEntityList, 0L);
+ }else{
+ return null;
+ }
+
+ }
+
+ private List getListDepartmentAndEmployeeTree(List 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());
+ }
+}
diff --git a/src/main/java/com/yipin/liuwanr/service/impl/SysRolePermissionServiceImpl.java b/src/main/java/com/yipin/liuwanr/service/impl/SysRolePermissionServiceImpl.java
new file mode 100644
index 0000000..7a1a632
--- /dev/null
+++ b/src/main/java/com/yipin/liuwanr/service/impl/SysRolePermissionServiceImpl.java
@@ -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;
+
+/**
+ *
+ * 角色权限中间表 服务实现类
+ *
+ *
+ * @author Qyq
+ * @since 2021-02-26
+ */
+@Service
+public class SysRolePermissionServiceImpl extends ServiceImpl implements ISysRolePermissionService {
+
+}
diff --git a/src/main/java/com/yipin/liuwanr/service/impl/SysRoleServiceImpl.java b/src/main/java/com/yipin/liuwanr/service/impl/SysRoleServiceImpl.java
new file mode 100644
index 0000000..507af56
--- /dev/null
+++ b/src/main/java/com/yipin/liuwanr/service/impl/SysRoleServiceImpl.java
@@ -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;
+
+/**
+ *
+ * 用户角色表 服务实现类
+ *
+ *
+ * @author Qyq
+ * @since 2021-02-26
+ */
+@Service
+public class SysRoleServiceImpl extends ServiceImpl implements ISysRoleService {
+
+}
diff --git a/src/main/java/com/yipin/liuwanr/service/impl/SysUserRoleServiceImpl.java b/src/main/java/com/yipin/liuwanr/service/impl/SysUserRoleServiceImpl.java
new file mode 100644
index 0000000..0013d47
--- /dev/null
+++ b/src/main/java/com/yipin/liuwanr/service/impl/SysUserRoleServiceImpl.java
@@ -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;
+
+/**
+ *
+ * 用户角色中间表 服务实现类
+ *
+ *
+ * @author Qyq
+ * @since 2021-02-26
+ */
+@Service
+public class SysUserRoleServiceImpl extends ServiceImpl implements ISysUserRoleService {
+
+}
diff --git a/src/main/java/com/yipin/liuwanr/util/MyBatisPlusCodeGenerator.java b/src/main/java/com/yipin/liuwanr/util/MyBatisPlusCodeGenerator.java
new file mode 100644
index 0000000..0bd7ed3
--- /dev/null
+++ b/src/main/java/com/yipin/liuwanr/util/MyBatisPlusCodeGenerator.java
@@ -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 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();
+ }
+}