diff --git a/pom.xml b/pom.xml
index 55d0624b1064a49afe6914be6641f1c7ba9bb335..5118fd41a454bdb28949b28fdfec8846d521b065 100644
--- a/pom.xml
+++ b/pom.xml
@@ -119,6 +119,12 @@
aliyun-sdk-oss
3.10.2
+
+
+ org.springframework.boot
+ spring-boot-starter-thymeleaf
+
+
diff --git a/src/main/java/com/example/meetingroom/config/EmployeeRealm.java b/src/main/java/com/example/meetingroom/config/EmployeeRealm.java
index 2239bf5d029dd60030256348ed4986720dbefaf7..2cfff9e07c5f1dc01c6f503f25a7d7ef4edcf754 100644
--- a/src/main/java/com/example/meetingroom/config/EmployeeRealm.java
+++ b/src/main/java/com/example/meetingroom/config/EmployeeRealm.java
@@ -30,8 +30,10 @@ public class EmployeeRealm extends AuthorizingRealm {
@Autowired
private RoleService roleService;
- /**+
+ /**
+ * +
* 对用户进行授权,同时传递该用户的身份信息。
+ *
* @param principalCollection
* @return
*/
@@ -39,14 +41,14 @@ public class EmployeeRealm extends AuthorizingRealm {
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) {
System.out.println("正在授权...");
EmployeeInfo primaryPrincipal = (EmployeeInfo) principalCollection.getPrimaryPrincipal();
- System.out.println("------------------"+primaryPrincipal);
+ System.out.println("------------------" + primaryPrincipal);
String id = employeeInfoService.getRoleIdByPhone(primaryPrincipal.getPhone());
- String role = roleService.getRoleByEmployeeId(id);
+ String role = roleService.getRoleByRoleId(primaryPrincipal.getRoleId());
SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
- SecurityUtils.getSubject().getSession().setAttribute("identity",role);
- SecurityUtils.getSubject().getSession().setAttribute("id",primaryPrincipal.getId());
+ SecurityUtils.getSubject().getSession().setAttribute("identity", role);
+ SecurityUtils.getSubject().getSession().setAttribute("id", primaryPrincipal.getId());
System.out.println(SecurityUtils.getSubject().getSession().getAttribute("identity"));
- System.out.println("授权-----------"+role);
+ System.out.println("授权-----------" + role);
info.addRole(role);
return info;
}
@@ -54,6 +56,7 @@ public class EmployeeRealm extends AuthorizingRealm {
/**
* 进行用户的登录。登录之前会调用Session管理器,来找到活跃的Sessions,查看是否有相同的用户进行登录,有则进行下线处理。
* 然后再进行账号密码的比对进行登录。
+ *
* @param authenticationToken
* @return
* @throws AuthenticationException
@@ -67,21 +70,21 @@ public class EmployeeRealm extends AuthorizingRealm {
EmployeeInfo employee = employeeInfoService.getEmployeeInfoByPhone(username);
//处理session
DefaultWebSecurityManager securityManager = (DefaultWebSecurityManager) SecurityUtils.getSecurityManager();
- DefaultWebSessionManager sessionManager = (DefaultWebSessionManager)securityManager.getSessionManager();
+ DefaultWebSessionManager sessionManager = (DefaultWebSessionManager) securityManager.getSessionManager();
Collection sessions = sessionManager.getSessionDAO().getActiveSessions();//获取当前已登录的用户session列表
- System.out.println("principal:"+principal);
- System.out.println("当前正活跃Session个数:"+sessions.size());
- for(Session session:sessions){
+ System.out.println("principal:" + principal);
+ System.out.println("当前正活跃Session个数:" + sessions.size());
+ for (Session session : sessions) {
//通过比较当前用户的toString及Session中的用户toString,来判断是否是同一账号。是则进行剔除。
- System.out.println("已存在的活跃Session:"+session.getAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY));
- if(String.valueOf(employee).equals(String.valueOf(session.getAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY)))) {
+ System.out.println("已存在的活跃Session:" + session.getAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY));
+ if (String.valueOf(employee).equals(String.valueOf(session.getAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY)))) {
sessionManager.getSessionDAO().delete(session);
System.out.println("成功剔除相同用户。");
}
}
System.out.println("正在认证...");
//根据是否查询到用户而进行对应处理:查无则抛异常,查到则进行认证。
- if (employee == null){
+ if (employee == null) {
throw new UnknownAccountException("请检查您的用户名及密码是否有误。");
}
AuthenticationInfo info = new SimpleAuthenticationInfo(employee, employee.getPassword(), null, getName());
diff --git a/src/main/java/com/example/meetingroom/config/GlobalCorsConfig.java b/src/main/java/com/example/meetingroom/config/GlobalCorsConfig.java
new file mode 100644
index 0000000000000000000000000000000000000000..ac0f8cbe90ed6a1e4fda9b04f8192a3541047a27
--- /dev/null
+++ b/src/main/java/com/example/meetingroom/config/GlobalCorsConfig.java
@@ -0,0 +1,53 @@
+package com.example.meetingroom.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.cors.CorsConfiguration;
+import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
+import org.springframework.web.filter.CorsFilter;
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+/**
+ * 前后端分离所产生的跨域问题所需配置,全局跨域
+ */
+@Configuration
+public class GlobalCorsConfig {
+
+ /**
+ * 返回一个Cors过滤器,对相应的HTTP请求的放行及配置。
+ * @return
+ */
+ @Bean
+ public CorsFilter corsFilter() {
+ CorsConfiguration corsConfig = new CorsConfiguration();
+ //设置Origin(原始域)
+ corsConfig.addAllowedOrigin("*");
+ //设置是否发送cookie
+ corsConfig.setAllowCredentials(true);
+ //放行哪些原始域(头部信息)
+ corsConfig.addAllowedHeader("*");
+ //暴露哪些头部信息
+ corsConfig.addExposedHeader("*");
+ //配置映射路径
+ UrlBasedCorsConfigurationSource configurationSource = new UrlBasedCorsConfigurationSource();
+ configurationSource.registerCorsConfiguration("/**", corsConfig);
+ return new CorsFilter(configurationSource);
+ }
+
+ /**
+ * 对请求方式的放行。
+ * @return
+ */
+ @Bean
+ public WebMvcConfigurer webMvcConfigurer() {
+ return new WebMvcConfigurer() {
+ @Override
+ public void addCorsMappings(CorsRegistry registry) {
+ registry.addMapping("/**").allowedOriginPatterns("*").allowCredentials(true).
+ allowedMethods("*").maxAge(3600);
+ }
+ };
+ }
+
+}
diff --git a/src/main/java/com/example/meetingroom/config/ShiroConfig.java b/src/main/java/com/example/meetingroom/config/ShiroConfig.java
index 18854a04d6cfee805724bdebd03e39c1fbe6c795..566b13d459febd62977cf396090ad48a34fa5a84 100644
--- a/src/main/java/com/example/meetingroom/config/ShiroConfig.java
+++ b/src/main/java/com/example/meetingroom/config/ShiroConfig.java
@@ -23,6 +23,7 @@ public class ShiroConfig {
/**
* 配置过滤的相关信息。如过滤何种界面,设置登录返回界面等。
+ *
* @param webSecurityManager
* @return ShiroFilterFactoryBean
*/
@@ -32,18 +33,16 @@ public class ShiroConfig {
shiroFilterFactoryBean.setSecurityManager(webSecurityManager);
Map filterChainDefinitionMap = new LinkedHashMap<>();
Map filterMap = new LinkedHashMap<>();
- filterMap.put("roleOf", new CustomRolesAuthorizationFilter());
+ filterMap.put("roleOf", new CustomRolesAuthorizationFilter());
shiroFilterFactoryBean.setFilters(filterMap);
//设置登录失败返回的页面
- shiroFilterFactoryBean.setLoginUrl("/");
+ shiroFilterFactoryBean.setLoginUrl("/api/");
//静态资源的放行
//权限放行
- filterChainDefinitionMap.put("/toLogin","anon");
- filterChainDefinitionMap.put("/login","anon");
- filterChainDefinitionMap.put("/user/**","authc,roleOf[普通用户,普通管理员]");
- filterChainDefinitionMap.put("/oper/**","authc,roles[超级管理员]");
- filterChainDefinitionMap.put("/logout","logout");
+ filterChainDefinitionMap.put("/login", "anon");
+ filterChainDefinitionMap.put("/api/oper/**", "authc,roles[超级管理员]");
+ filterChainDefinitionMap.put("/logout", "logout");
shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);
return shiroFilterFactoryBean;
@@ -51,6 +50,7 @@ public class ShiroConfig {
/**
* Session管理器,设置全局Session的配置。
+ *
* @return DefaultWebSessionManager
*/
@Bean
@@ -58,13 +58,14 @@ public class ShiroConfig {
DefaultWebSessionManager defaultSessionManager = new DefaultWebSessionManager();
//分别设置 session状态,全局会话时间,及删除失效session
defaultSessionManager.setSessionValidationSchedulerEnabled(false);
- defaultSessionManager.setGlobalSessionTimeout(60*30*1000);
+ defaultSessionManager.setGlobalSessionTimeout(60 * 30 * 1000);
defaultSessionManager.setDeleteInvalidSessions(true);
return defaultSessionManager;
}
/**
* 安全管理器,设置自用Realm和其他管理器。
+ *
* @param realm
* @param sessionManager
* @return SecurityManager
@@ -81,10 +82,11 @@ public class ShiroConfig {
/**
* 自用Realm,当前是EmployeeRealm。
+ *
* @return EmployeeRealm
*/
@Bean
- public EmployeeRealm realm(){
+ public EmployeeRealm realm() {
return new EmployeeRealm();
}
}
\ No newline at end of file
diff --git a/src/main/java/com/example/meetingroom/controller/DepartController.java b/src/main/java/com/example/meetingroom/controller/DepartController.java
index 757fd1a69fe27316729a7aa8ed4b43b2a8cc09d4..f7944278e45e0c1e42cfa1c48f0593144bfc9f8b 100644
--- a/src/main/java/com/example/meetingroom/controller/DepartController.java
+++ b/src/main/java/com/example/meetingroom/controller/DepartController.java
@@ -17,7 +17,7 @@ import java.util.Map;
*/
@RestController
@CrossOrigin
-@RequestMapping("/api")
+@RequestMapping("/api/oper")
public class DepartController {
@Autowired
@@ -32,7 +32,7 @@ public class DepartController {
* 用于超管新增部门信息
*/
// @RequestMapping(value = "/depart",method = RequestMethod.POST)
- @PostMapping("/depart")
+ @PostMapping("/super/depart")
public ResultVo insertDepart(@RequestBody Depart depart){
judge = departService.insertDepart(depart);
@@ -53,7 +53,7 @@ public class DepartController {
* 用于超管对会议室信息的修改操作
*/
// @RequestMapping(value = "/updateDepart",method = RequestMethod.PUT)
- @PutMapping("/depart")
+ @PutMapping("/super/depart")
public ResultVo updateDepart(@RequestBody Depart depart){
judge = departService.updateDepart(depart);
@@ -73,8 +73,7 @@ public class DepartController {
* @return ResultVo 统一消息回复
* 用于超管对会议室信息的删除操作
*/
-// @RequestMapping(value = "/deleteDepart",method = RequestMethod.DELETE)
- @DeleteMapping("/depart/{id}")
+ @DeleteMapping("/super/depart/{id}")
public ResultVo deleteDepart(@PathVariable("id")String id){
judge = departService.deleteDepart(id);
@@ -90,9 +89,8 @@ public class DepartController {
/**
* @return ResultVo 统一消息回复
- * 用于向超管展示部门信息
+ * 用于向管理员展示部门信息
*/
-// @RequestMapping(value = "/selectDepartList",method = RequestMethod.GET)
@GetMapping("/depart")
public ResultVo selectDepartList(){
diff --git a/src/main/java/com/example/meetingroom/controller/EmployeeInfoController.java b/src/main/java/com/example/meetingroom/controller/EmployeeInfoController.java
index 291cf14ca74d76cdd9e67e0cebd6b503bcc11a33..093d39b1fafb8575e107f727f04396843f630dc4 100644
--- a/src/main/java/com/example/meetingroom/controller/EmployeeInfoController.java
+++ b/src/main/java/com/example/meetingroom/controller/EmployeeInfoController.java
@@ -26,7 +26,7 @@ import java.util.Map;
* @Date: 2021-9-8 08:10:07
*/
@RestController
-@CrossOrigin
+@CrossOrigin()
@RequestMapping("/api")
public class EmployeeInfoController {
@@ -46,20 +46,15 @@ public class EmployeeInfoController {
public ResultVo selectEmployeeInfoPage(@PathVariable("currentPage")Integer currentPage
, @PathVariable("currentCount")Integer currentCount,HttpServletRequest request){
-// Object role = request.getSession().getAttribute("identity");
+ // 授权
+ Integer role = roleService.superOrCommon();
-
-// if (role == "???"){
-// PageVo_xuan EmployeeInfoList = employeeInfoService.selectEmployeeInfoPage(currentPage, currentCount,1);
-// }else {
-// PageVo_xuan EmployeeInfoList = employeeInfoService.selectEmployeeInfoPage(currentPage, currentCount,0);
-//
-// }
+ SecurityUtils.getSubject().getSession().getAttribute("identity");
Map map = new HashMap<>();
PageVo_xuan EmployeeInfoList = null;
try {
- EmployeeInfoList = employeeInfoService.selectEmployeeInfoPage(currentPage, currentCount,1);
+ EmployeeInfoList = employeeInfoService.selectEmployeeInfoPage(currentPage, currentCount,role);
} catch (Exception e) {
return ResultVo.error(500, "参数异常,跳转页不能为0",map);
}
@@ -77,11 +72,18 @@ public class EmployeeInfoController {
}
+ /**
+ * @param str
+ * @return
+ * 根据员工姓名和编号查询员工信息
+ */
@GetMapping("/employeeInfo/{str}")
public ResultVo selectNameOrNunberObtainEmployeeInfo(@PathVariable("str") String str){
- //最后 int 类型参数为权限信息,现为虚假数据
- List employeeInfoVoList = employeeInfoService.selectNameOrNunberObtainEmployeeInfo(str, 0);
+ // 授权
+ Integer role = roleService.superOrCommon();
+
+ List employeeInfoVoList = employeeInfoService.selectNameOrNunberObtainEmployeeInfo(str, role);
Map map = new HashMap<>();
@@ -95,31 +97,32 @@ public class EmployeeInfoController {
/**
* @param employeeInfo
- * @param request 判断身份
* @return ResultVo 统一消息回复
* 用于普管和超管修改员工信息
*/
@PutMapping("/employeeInfo")
public ResultVo updateEmployeeInfo(@RequestBody EmployeeInfo employeeInfo){
-// Object role = request.getSession();
-// if (role != null){
-// judge = employeeInfoService.updateEmployeeInfo(employeeInfo,1);
-// }else {
-// judge = employeeInfoService.updateEmployeeInfo(employeeInfo,0);
-// }
-
- //最后 int 类型参数为权限信息,现为虚假数据
- judge = employeeInfoService.updateEmployeeInfo(employeeInfo,1);
+ // 授权
+ Integer role = roleService.superOrCommon();
Map map = new HashMap<>();
-// map.put("超管修改员工信息", judge);
+
+ if(employeeInfoService.judgePhone(employeeInfo.getPhone()) != null){
+ return ResultVo.error(500, "该电话号码已存在,请更换!",map);
+ }else if(employeeInfo.getRoleId().equals("3")){
+ return ResultVo.error(500, "不许修改成超级管理员,请更换!",map);
+ }
+
+ judge = employeeInfoService.updateEmployeeInfo(employeeInfo,role);
+
+
//判断成功与否
if(judge != 1){
- return ResultVo.error(500,"超管修改员工信息失败",map);
+ return ResultVo.error(500,"管理员修改员工信息失败",map);
}
- return ResultVo.ok(200,"超管修改员工信息成功",map);
+ return ResultVo.ok(200,"管理员修改员工信息成功",map);
}
@@ -133,13 +136,12 @@ public class EmployeeInfoController {
judge = employeeInfoService.deleteEmployeeInfo(id);
Map map = new HashMap<>();
-// map.put("管理员删除员工信息", judge);
//判断成功与否
if(judge != 1){
- return ResultVo.error(500,"超管删除员工信息失败",map);
+ return ResultVo.error(500,"管理员删除员工信息失败",map);
}
- return ResultVo.ok(200,"超管删除员工信息成功",map);
+ return ResultVo.ok(200,"管理员删除员工信息成功",map);
}
/**
@@ -147,15 +149,23 @@ public class EmployeeInfoController {
* @return
* 用于普管和超管对员工信息的新增操作
*/
-// @RequestMapping(value = "/insertEmployeeInfo",method = RequestMethod.POST)
@PostMapping("/employeeInfo")
public ResultVo insertEmployeeInfo(@RequestBody EmployeeInfo employeeInfo){
- //最后一个参数为权限,现为模拟
- judge = employeeInfoService.insertEmployeeInfo(employeeInfo,0);
-
Map map = new HashMap<>();
-// map.put("超管新增员工信息", judge);
+
+ if(employeeInfoService.judgePhone(employeeInfo.getPhone()) != null){
+ return ResultVo.error(500, "该电话号码已存在,请更换!",map);
+ }else if(employeeInfo.getRoleId().equals("3")){
+ return ResultVo.error(500, "不许添加超级管理员,请更换!",map);
+ }
+
+ // 授权
+ Integer role = roleService.superOrCommon();
+ judge = employeeInfoService.insertEmployeeInfo(employeeInfo,role);
+
+
+
//判断成功与否
if(judge != 1){
@@ -166,11 +176,12 @@ public class EmployeeInfoController {
/**
* 用户登录。若登录成功,会根据其所有的权限来进行相应界面的跳转。
+ *
* @param phone 账号
* @param password 前端加密后的MD5密码
* @return
*/
- @RequestMapping(value = "/login",method = RequestMethod.POST)
+ @RequestMapping(value = "/login", method = RequestMethod.POST)
public ResultVo login(@RequestParam("phone") String phone,
@RequestParam("password") String password) {
Map data = new LinkedHashMap<>();
@@ -196,32 +207,34 @@ public class EmployeeInfoController {
/**
* 用户登出,登出之后会进行JSESSION的清空。
+ *
* @return 提示用户已经登出。
*/
- @RequestMapping(value = "/logout",method = RequestMethod.GET)
- public ResultVo logout(){
+ @RequestMapping(value = "/logout", method = RequestMethod.GET)
+ public ResultVo logout() {
SecurityUtils.getSubject().logout();
- return ResultVo.ok(200,"用户已登出系统。",null);
+ return ResultVo.ok(200, "用户已登出系统。", null);
}
/**
* 用户修改密码,会先验证存在的账号和旧密码是否属实,若成功则进行密码的修改。
- * @param phone 账号
+ *
+ * @param phone 账号
* @param oldPassword 旧密码
* @param newPassword 新密码
* @return 根据密码是否修改来返回是否修改成功的信息。
*/
- @RequestMapping(value = "/changePassword",method = RequestMethod.POST)
+ @RequestMapping(value = "/changePassword", method = RequestMethod.POST)
public ResultVo changePassword(@RequestParam("phone") String phone,
@RequestParam("oldPassword") String oldPassword,
- @RequestParam("newPassword") String newPassword){
- EmployeeInfo employee = employeeInfoService.getEmployeeInfoByPhoneAndPassword(phone,oldPassword);
- if (employee!=null){
+ @RequestParam("newPassword") String newPassword) {
+ EmployeeInfo employee = employeeInfoService.getEmployeeInfoByPhoneAndPassword(phone, oldPassword);
+ if (employee != null) {
int isSuccess = employeeInfoService.updatePassword(phone, newPassword);
- }else{
- return ResultVo.error(404,"请确认您的旧密码是否有误!",null);
+ } else {
+ return ResultVo.error(404, "请确认您的旧密码是否有误!", null);
}
- return ResultVo.ok(200,"您的密码已成功修改!",null);
+ return ResultVo.ok(200, "您的密码已成功修改!", null);
}
}
diff --git a/src/main/java/com/example/meetingroom/controller/EmployeeRegisterController.java b/src/main/java/com/example/meetingroom/controller/EmployeeRegisterController.java
index 3aaca7e5f67bcfc007b3891ead0003cbadd9674b..3912e6226cd580dbcee103b02e5cd635e7ad8878 100644
--- a/src/main/java/com/example/meetingroom/controller/EmployeeRegisterController.java
+++ b/src/main/java/com/example/meetingroom/controller/EmployeeRegisterController.java
@@ -4,10 +4,12 @@ import com.example.meetingroom.entity.EmployeeInfo;
import com.example.meetingroom.entity.EmployeeRegister;
import com.example.meetingroom.service.EmployeeInfoService;
import com.example.meetingroom.service.EmployeeRegisterService;
+import com.example.meetingroom.service.RoleService;
import com.example.meetingroom.vo.EmployeeRegisterVo;
import com.example.meetingroom.vo.PageVo_xuan;
import com.example.meetingroom.vo.ResultVo;
import io.lettuce.core.output.SocketAddressOutput;
+import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -42,26 +44,18 @@ public class EmployeeRegisterController {
* @return ResultVo 统一消息回复
* 用于分页和分页跳转
*/
-// @RequestMapping(value = "/selectEmployeeRegisterPage/{currentPage}/{currentCount}",method = RequestMethod.GET)
@GetMapping("/employeeRegister/{currentPage}/{currentCount}")
public ResultVo selectEmployeeRegisterPage(@PathVariable("currentPage")Integer currentPage
, @PathVariable("currentCount")Integer currentCount, HttpServletRequest request){
- // Object role = request.getSession().getAttribute("identity");
-
-
-// if (role == "???"){
-// PageVo_xuan EmployeeInfoList = employeeInfoService.selectEmployeeInfoPage(currentPage, currentCount,1);
-// }else {
-// PageVo_xuan EmployeeInfoList = employeeInfoService.selectEmployeeInfoPage(currentPage, currentCount,0);
-//
-// }
+ // 授权
+ Integer role = roleService.superOrCommon();
Map map = new HashMap<>();
- //最后 int 类型参数为权限信息,现为虚假数据
+
PageVo_xuan employeeRegisterVoPageVo = null;
try {
- employeeRegisterVoPageVo = employeeRegisterService.selectEmployeeRegisterPage(currentPage, currentCount, 1);
+ employeeRegisterVoPageVo = employeeRegisterService.selectEmployeeRegisterPage(currentPage, currentCount, role);
} catch (Exception e) {
return ResultVo.error(500, "参数异常,跳转页不能为0",map);
}
@@ -88,9 +82,9 @@ public class EmployeeRegisterController {
//判断成功与否
if(judge != 1){
- return ResultVo.error(500,"超管删除注册表信息失败",map);
+ return ResultVo.error(500,"管理员删除注册表信息失败",map);
}
- return ResultVo.ok(200,"超管删除注册表信息成功",map);
+ return ResultVo.ok(200,"管理员删除注册表信息成功",map);
}
@@ -108,8 +102,8 @@ public class EmployeeRegisterController {
@PutMapping("/employeeRegister")
public ResultVo updateEmployeeRegister(@RequestBody EmployeeRegister employeeRegister){
- //模拟管理员id
- String adminId = "1";
+ //获取管理员id
+ Object adminId = SecurityUtils.getSubject().getSession().getAttribute("id");
judge = 0;
@@ -122,29 +116,26 @@ public class EmployeeRegisterController {
if (previousState.equals(afterState) || (previousState.equals("待审核") && afterState.equals("未通过"))){
System.out.println("(相同状态) || (审前待审核 && 审后未通过)这种情况不用新增和删除员工,只用更改注册表");
- judge = employeeRegisterService.updateEmployeeRegister(employeeRegister,adminId);
+ judge = employeeRegisterService.updateEmployeeRegister(employeeRegister, (String) adminId);
} else if((previousState.equals("待审核") && afterState.equals("已通过")) ||
(previousState.equals("未通过") && afterState.equals("已通过"))){
//(审前待审核 && 审后已通过) || (审前未通过 && 审后已通过) 这种情况需要新增员工和用更改注册表
System.out.println("(审前待审核 && 审后已通过) || (审前未通过 && 审后已通过) 这种情况需要新增员工和用更改注册表");
- judge = employeeRegisterService.updateEmployeeRegister(employeeRegister,adminId);
+ judge = employeeRegisterService.updateEmployeeRegister(employeeRegister, (String) adminId);
//查询注册密码
employeeRegister.setPassword(employeeRegisterService.selectEmployeeInfoPasswode(employeeRegister.getPhone()));
employeeRegisterService.insertEmployeeInfo(employeeRegister);
- } else if(previousState.equals("已通过") && afterState.equals("未通过")){
+ } else if(previousState.equals("已通过") && afterState.equals("未通过")) {
// 审前已通过 && 审后未通过 这种情况需要删除员工和用更改注册表
System.out.println("审前已通过 && 审后未通过 这种情况需要删除员工和用更改注册表");
- judge = employeeRegisterService.updateEmployeeRegister(employeeRegister,adminId);
+ judge = employeeRegisterService.updateEmployeeRegister(employeeRegister, (String) adminId);
employeeRegisterService.deleteEmployeeRegisterPhone(employeeRegister.getPhone());
-
- }else{
- System.out.println("error");
}
@@ -153,9 +144,39 @@ public class EmployeeRegisterController {
//判断成功与否
if(judge != 1){
- return ResultVo.error(500,"超管修改注册表审核结果和原因失败",map);
+ return ResultVo.error(500,"管理员修改注册表审核结果和原因失败",map);
+ }
+ return ResultVo.ok(200,"管理员修改注册表审核结果和原因成功",map);
+ }
+
+ /**
+ * 传入的数据封装成EmployeeRegister,再通过EmployeeRegisterDao插入一名新用户。
+ * 考虑到会有已注册账号进行注册的问题,同时需要管理员审核的问题,故会检测是否有该用户注册过,返回验证的信息、
+ * @param register Post请求传入的注册信息
+ * @return 返回是否能够注册,同时返回是否已经注册过。
+ */
+ @PostMapping("/register")
+ public ResultVo register(EmployeeRegister register) {
+ EmployeeRegister registerEmployee = register;
+ ResultVo resultVo;
+ Map data = new LinkedHashMap<>();
+ //设置注册状态为”待审批“。
+ registerEmployee.setEmployeeRegisterStatus("待审批");
+ //查看是否有重复手机号码注册的情况,如若有则提示存在相同号码,但不影响待审批
+ EmployeeInfo registeredUser = employeeInfoService.getEmployeeInfoByPhone(register.getPhone());
+ if (registeredUser == null) {
+ data.put("用户注册状态", "该手机号未注册。");
+ } else {
+ data.put("用户注册状态", "该手机号已注册。");
}
- return ResultVo.ok(200,"超管修改注册表审核结果和原因成功",map);
+ //调用EmployeeRegisterDao来插入一条新用户,并根据成功与否来决定返回的结果
+ int isInsert = employeeRegisterService.insertRegister(registerEmployee);
+ if (isInsert == 1) {
+ resultVo = ResultVo.ok(200, "成功将注册信息添加至审核表中。", data);
+ } else {
+ resultVo = ResultVo.error(500, "系统出错。", data);
+ }
+ return resultVo;
}
/**
diff --git a/src/main/java/com/example/meetingroom/controller/RoleController.java b/src/main/java/com/example/meetingroom/controller/RoleController.java
index d633c5292a64e39c95a35652cee70db84b87c193..4f52bf0a055869483adb030869c941944b403def 100644
--- a/src/main/java/com/example/meetingroom/controller/RoleController.java
+++ b/src/main/java/com/example/meetingroom/controller/RoleController.java
@@ -1,6 +1,7 @@
package com.example.meetingroom.controller;
import com.example.meetingroom.entity.Depart;
+import com.example.meetingroom.entity.EmployeeInfo;
import com.example.meetingroom.entity.Role;
import com.example.meetingroom.service.RoleService;
import com.example.meetingroom.vo.ResultVo;
@@ -53,17 +54,25 @@ public class RoleController {
}
/**
- * 首页,同时解决同个浏览器一个session却有多个用户共用的问题。
+ * 首页,登录界面,解决同个浏览器一个session却有多个用户共用的问题(即一个会话多用户登录)
* 通过检查Subject中principal是否为空来判断是否已经有用户登录过。
- * @return 返回至index页面
+ * @return 根据情况返回相应页面
*/
@GetMapping({"/","/index"})
- public String index(){
- Object principal = SecurityUtils.getSubject().getPrincipal();
- System.out.println("登录首页,存在principal:"+principal);
+ public ResultVo index(){
+ EmployeeInfo principal = (EmployeeInfo) SecurityUtils.getSubject().getPrincipal();
if (principal != null){
- return "redirect:/user/test";
+ Map data = new HashMap<>();
+ System.out.println("当前存在已登录用户:"+principal);
+ String principalRole = roleService.getRoleByRoleId(principal.getRoleId());
+ System.out.println("当前用户权限为:"+SecurityUtils.getSubject().getSession().getAttribute("identity"));
+ data.put("role",principalRole);
+ if ("超级管理员".equals(principalRole)){
+ return ResultVo.ok(200,"已存在用户登录,跳转至超级管理员界面。",data);
+ }else{
+ return ResultVo.ok(200,"已存在用户登录,跳转至用户界面。",data);
+ }
}
- return "index";
+ return ResultVo.ok(200,"当前会话无用户登录,则显示登录的界面。",null);
}
}
diff --git a/src/main/java/com/example/meetingroom/controller/RoomInfoController.java b/src/main/java/com/example/meetingroom/controller/RoomInfoController.java
index f19d105767a5c7ed420b27299293e5da25a41389..f5d7258b469839541b18c0a6b773936c63b26d1f 100644
--- a/src/main/java/com/example/meetingroom/controller/RoomInfoController.java
+++ b/src/main/java/com/example/meetingroom/controller/RoomInfoController.java
@@ -16,7 +16,7 @@ import java.util.*;
*/
@RestController
@CrossOrigin
-@RequestMapping("/api")
+@RequestMapping("/api/oper")
public class RoomInfoController {
@@ -32,8 +32,7 @@ public class RoomInfoController {
* @return ResultVo 统一消息回复
* 用于超管对会议室信息的修改操作,
*/
-// @RequestMapping(value = "/updateRoomInfo",method = RequestMethod.PUT)
- @PutMapping("/roomInfo")
+ @PutMapping("/super/roomInfo")
public ResultVo updateRoomInfo(@RequestBody RoomInfo roomInfo){
//用于判断是否成功
@@ -61,8 +60,7 @@ public class RoomInfoController {
* @return ResultVo 统一消息回复
* 用于超管对会议室信息的删除操作
*/
-// @RequestMapping(value = "/deleteRoomInfo",method = RequestMethod.DELETE)
- @DeleteMapping("/roomInfo/{id}")
+ @DeleteMapping("/super/roomInfo/{id}")
public ResultVo deleteRoomInfo(@PathVariable("id")String id){
judge = roomInfoService.deleteRoomInfo(id);
@@ -82,8 +80,7 @@ public class RoomInfoController {
* @return ResultVo 统一消息回复
* 用于超管新增会议室信息
*/
-// @RequestMapping(value = "/insertRoomInfo",method = RequestMethod.POST)
- @PostMapping("/roomInfo")
+ @PostMapping("/super/roomInfo")
public ResultVo insertRoomInfo(@RequestBody RoomInfo roomInfo){
judge = roomInfoService.insertRoomInfo(roomInfo);
@@ -105,8 +102,7 @@ public class RoomInfoController {
* @return ResultVo 统一消息回复
* 用于分页和分页跳转
*/
-// @RequestMapping(value = "/selectRoomInfoPage/{currentPage}/{currentCount}",method = RequestMethod.GET)
- @GetMapping("/roomInfo/{currentPage}/{currentCount}")
+ @GetMapping("/super/roomInfo/{currentPage}/{currentCount}")
public ResultVo selectRoomInfoPage(@PathVariable("currentPage")Integer currentPage
,@PathVariable("currentCount")Integer currentCount){
diff --git a/src/main/java/com/example/meetingroom/controller/RoomOrderController.java b/src/main/java/com/example/meetingroom/controller/RoomOrderController.java
index c9f70a20a5e13b28d837a12afff0ceff773466b4..3985e85f05f6a6b5aed9fd74659fcd84d5274f1e 100644
--- a/src/main/java/com/example/meetingroom/controller/RoomOrderController.java
+++ b/src/main/java/com/example/meetingroom/controller/RoomOrderController.java
@@ -2,6 +2,7 @@ package com.example.meetingroom.controller;
import com.example.meetingroom.service.RoomOrderService;
import com.example.meetingroom.vo.*;
+import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -111,6 +112,9 @@ public class RoomOrderController {
map.put("ExecuteNumber",RoomOrderMessage);
+ if (RoomOrderMessage==null){
+ return ResultVo.error(500,"插入失败,申请人错误",map);
+ }
return ResultVo.ok(200,"成功",map);
}
@@ -130,13 +134,14 @@ public class RoomOrderController {
public ResultVo selectOrder(@PathVariable String selectType, @PathVariable Integer lineNum, @PathVariable Integer pageNum){
//普通管理员0,超级管理员1,普通员工也是0,员工用不到role,因为他只需要查他自己,role是为了分辨超管和普管,因为超管可以看到被逻辑删除的数据,普管不可以
- // Integer role =SecurityUtils.getSubject().getSession().getAttribute("identity").equals("普通管理员")?0:1;
+ Integer role = ((String)SecurityUtils.getSubject().getSession().getAttribute("identity")).equals("普通管理员")?0:1;
//用户id
- //String userId = (String) SecurityUtils.getSubject().getSession().getAttribute("userid");
+ String userId = (String) SecurityUtils.getSubject().getSession().getAttribute("id");
+
//还没合体所以,先用默认参数
+// Integer role=1;
+// String userId = "1";
- Integer role=1;
- String userId = "1";
//判断参数是否合法
PageVo pageVo = roomOrderService.checkParams(selectType,lineNum,pageNum,role,userId);
diff --git a/src/main/java/com/example/meetingroom/dao/DepartDao.java b/src/main/java/com/example/meetingroom/dao/DepartDao.java
index 0abcb9d1f52d2e7913c0555155bb58880e2d1e03..38102320af1b922c0fc5ec7d3a5af2f180504c61 100644
--- a/src/main/java/com/example/meetingroom/dao/DepartDao.java
+++ b/src/main/java/com/example/meetingroom/dao/DepartDao.java
@@ -36,7 +36,7 @@ public interface DepartDao {
/**
* @param id 会议室id,根据id进行删除操作
* @return int 0或1
- * 用于超管对会议室信息的删除操作
+ * 用于超管对部门信息的删除操作
*/
int deleteDepart(String id);
diff --git a/src/main/java/com/example/meetingroom/dao/EmployeeInfoDao.java b/src/main/java/com/example/meetingroom/dao/EmployeeInfoDao.java
index 7c1bfc2739fce11514ead265669c356a777a4110..3703af78230dfeb6d499ab03b8d8f130c51c454d 100644
--- a/src/main/java/com/example/meetingroom/dao/EmployeeInfoDao.java
+++ b/src/main/java/com/example/meetingroom/dao/EmployeeInfoDao.java
@@ -75,15 +75,48 @@ public interface EmployeeInfoDao {
*/
int insertBatch(List lists);
+ /**
+ * @param phone
+ * @return
+ * 用于管理员新增员工时判断电话号码是否重复
+ */
+ String judgePhone(String phone);
+
+ /**
+ * @param str
+ * @param role
+ * @return
+ * 根据员工姓名和编号查询员工信息
+ */
List selectNameOrNunberObtainEmployeeInfo(@Param("str")String str, @Param("role")Integer role);
+ /**
+ * 根据账号和密码得到EmployeeInfo
+ * @param phone 账号
+ * @param password 密码
+ * @return EmployeeInfo
+ */
EmployeeInfo getEmployeeInfoByPhoneAndPassword(String phone,String password);
- String getPasswordByPhone(String phone);
-
+ /**
+ * 根据账号得到EmployeeInfo
+ * @param phone 账号
+ * @return EmployeeInfo
+ */
EmployeeInfo getEmployeeInfoByPhone(String phone);
+ /**
+ * 根据账号获取权限ID
+ * @param phone 账号
+ * @return 权限ID
+ */
String getRoleIdByPhone(String phone);
+ /**
+ * 根据账号来修改密码
+ * @param phone 账号
+ * @param newPassword 密码
+ * @return
+ */
int updatePassword(String phone, String newPassword);
}
\ No newline at end of file
diff --git a/src/main/java/com/example/meetingroom/dao/RoleDao.java b/src/main/java/com/example/meetingroom/dao/RoleDao.java
index 2d1f0bc718f003147ba03cdc26cf0e1b9f0b4ac7..22736de3875d9eec69012984a931e5aa86eb78f8 100644
--- a/src/main/java/com/example/meetingroom/dao/RoleDao.java
+++ b/src/main/java/com/example/meetingroom/dao/RoleDao.java
@@ -26,5 +26,10 @@ public interface RoleDao {
String getRoleByPhone(String Phone);
- String getRoleByEmployeeId(String id);
+ /**
+ * 根据权限ID来获取权限名
+ * @param id 权限ID
+ * @return 权限名
+ */
+ String getRoleByRoleId(String id);
}
diff --git a/src/main/java/com/example/meetingroom/service/DepartService.java b/src/main/java/com/example/meetingroom/service/DepartService.java
index 156b4f03ed4df6f2743a1c5ba4cdfa96d6ee7334..d04e9e2cbd4ac95622cc0aa44e3676c242b4e9f8 100644
--- a/src/main/java/com/example/meetingroom/service/DepartService.java
+++ b/src/main/java/com/example/meetingroom/service/DepartService.java
@@ -30,7 +30,7 @@ public interface DepartService {
/**
* @param id 会议室id,根据id进行删除操作
* @return int 0或1
- * 用于超管对会议室信息的删除操作
+ * 用于超管对部门信息的删除操作
*/
int deleteDepart(String id);
diff --git a/src/main/java/com/example/meetingroom/service/EmployeeInfoService.java b/src/main/java/com/example/meetingroom/service/EmployeeInfoService.java
index c1301f38aadba3c7c8f9dfd68ff3ab30c4b553e5..6409ee3f5de67835ce394aec6315bbf6d538d815 100644
--- a/src/main/java/com/example/meetingroom/service/EmployeeInfoService.java
+++ b/src/main/java/com/example/meetingroom/service/EmployeeInfoService.java
@@ -23,7 +23,12 @@ public interface EmployeeInfoService {
*/
PageVo_xuan selectEmployeeInfoPage(Integer currentPage, Integer currentCount, Integer role) throws Exception;
-
+ /**
+ * @param str
+ * @param role
+ * @return
+ * 根据员工姓名和编号查询员工信息
+ */
List selectNameOrNunberObtainEmployeeInfo(String str,Integer role);
@@ -66,13 +71,39 @@ public interface EmployeeInfoService {
*/
Boolean insertBatch(List> excelDataList, int role);
- String getPasswordByPhone(String phone);
-
+ /**
+ * 根据账号得到EmployeeInfo
+ * @param phone 账号
+ * @return EmployeeInfo
+ */
EmployeeInfo getEmployeeInfoByPhone(String phone);
+ /**
+ * 根据账号和密码获取EmployeeInfo
+ * @param phone 账号
+ * @param password 密码
+ * @return EmployeeInfo
+ */
EmployeeInfo getEmployeeInfoByPhoneAndPassword(String phone,String password);
+ /**
+ * 根据用户手机号码来获得权限ID
+ * @param phone 账号
+ * @return 权限ID
+ */
String getRoleIdByPhone(String phone);
+ /**
+ * 用户更新密码
+ * @param phone 账号
+ * @param newPassword 密码
+ * @return 成功更新条数
+ */
int updatePassword(String phone, String newPassword);
+
+ /**
+ * @param phone
+ * @return
+ */
+ String judgePhone(String phone);
}
diff --git a/src/main/java/com/example/meetingroom/service/EmployeeRegisterService.java b/src/main/java/com/example/meetingroom/service/EmployeeRegisterService.java
index da334ea0be7395ad1081b9c2541154fc71b7110b..254754d00b9b747918ea9e842864508c47e33dd0 100644
--- a/src/main/java/com/example/meetingroom/service/EmployeeRegisterService.java
+++ b/src/main/java/com/example/meetingroom/service/EmployeeRegisterService.java
@@ -65,5 +65,10 @@ public interface EmployeeRegisterService {
*/
String selectEmployeeInfoPasswode(String phone);
+ /**
+ * 插入新的注册用户
+ * @param register
+ * @return 成功条数
+ */
int insertRegister(EmployeeRegister register);
}
diff --git a/src/main/java/com/example/meetingroom/service/RoleService.java b/src/main/java/com/example/meetingroom/service/RoleService.java
index e8c4b51d9f5e03f2c474300ef1b0a58d887513c7..d0fc511c94e818a41b237e13633d5a1b094e0e09 100644
--- a/src/main/java/com/example/meetingroom/service/RoleService.java
+++ b/src/main/java/com/example/meetingroom/service/RoleService.java
@@ -21,5 +21,10 @@ public interface RoleService {
String getRoleByPhone(String phone);
- String getRoleByEmployeeId(String id);
+ /**
+ * 根据权限ID来获取权限名
+ * @param id 权限ID
+ * @return 权限名
+ */
+ String getRoleByRoleId(String id);
}
diff --git a/src/main/java/com/example/meetingroom/service/impl/DepartServiceImpl.java b/src/main/java/com/example/meetingroom/service/impl/DepartServiceImpl.java
index 2ef5104abbb8ee8df08ba902a0da881f226aa1a5..f00974d231479382c38d5a005044b70c10c913bf 100644
--- a/src/main/java/com/example/meetingroom/service/impl/DepartServiceImpl.java
+++ b/src/main/java/com/example/meetingroom/service/impl/DepartServiceImpl.java
@@ -47,7 +47,7 @@ public class DepartServiceImpl implements DepartService {
/**
* @param id 会议室id,根据id进行删除操作
* @return int 0或1
- * 用于超管对会议室信息的删除操作
+ * 用于超管对部门信息的删除操作
*/
@Override
public int deleteDepart(String id){
diff --git a/src/main/java/com/example/meetingroom/service/impl/EmployeeInfoServiceImpl.java b/src/main/java/com/example/meetingroom/service/impl/EmployeeInfoServiceImpl.java
index 1763da582ee99d9e0cb2ea33c133eb30c74f7142..8f7168257111046dabfcd85d910bcfb13a870860 100644
--- a/src/main/java/com/example/meetingroom/service/impl/EmployeeInfoServiceImpl.java
+++ b/src/main/java/com/example/meetingroom/service/impl/EmployeeInfoServiceImpl.java
@@ -56,10 +56,18 @@ public class EmployeeInfoServiceImpl implements EmployeeInfoService {
return employeeInfoVoPageVo;
}
-
+ /**
+ * @param str
+ * @param role
+ * @return
+ * 根据员工姓名和编号查询员工信息
+ */
@Override
public List selectNameOrNunberObtainEmployeeInfo(String str, Integer role){
+
return employeeInfoDao.selectNameOrNunberObtainEmployeeInfo(str, role);
+
+
}
/**
@@ -174,26 +182,43 @@ public class EmployeeInfoServiceImpl implements EmployeeInfoService {
return false;
}
- @Override
- public String getPasswordByPhone(String phone) {
- return employeeInfoDao.getPasswordByPhone(phone);
- }
-
+ /**
+ * 根据账号得到EmployeeInfo
+ * @param phone 账号
+ * @return EmployeeInfo
+ */
@Override
public EmployeeInfo getEmployeeInfoByPhone(String phone) {
return employeeInfoDao.getEmployeeInfoByPhone(phone);
}
+ /**
+ * 根据账号和密码得到EmployeeInfo
+ * @param phone 账号
+ * @param password 密码
+ * @return EmployeeInfo
+ */
@Override
public EmployeeInfo getEmployeeInfoByPhoneAndPassword(String phone, String password) {
return employeeInfoDao.getEmployeeInfoByPhoneAndPassword(phone,password);
}
+ /**
+ * 根据账号获取权限ID
+ * @param phone 账号
+ * @return 权限ID
+ */
@Override
public String getRoleIdByPhone(String phone) {
return employeeInfoDao.getRoleIdByPhone(phone);
}
+ /**
+ * 根据账号来修改密码
+ * @param phone 账号
+ * @param newPassword 密码
+ * @return
+ */
@Override
public int updatePassword(String phone, String newPassword) {
return employeeInfoDao.updatePassword(phone,newPassword);
diff --git a/src/main/java/com/example/meetingroom/service/impl/EmployeeRegisterServiceImpl.java b/src/main/java/com/example/meetingroom/service/impl/EmployeeRegisterServiceImpl.java
index 2781f65dfc2a2c67d55492e3ca5834faa1f084e2..fc6b214faaa9e93c648d2c0b3cce3e6f8fa29574 100644
--- a/src/main/java/com/example/meetingroom/service/impl/EmployeeRegisterServiceImpl.java
+++ b/src/main/java/com/example/meetingroom/service/impl/EmployeeRegisterServiceImpl.java
@@ -156,6 +156,15 @@ public class EmployeeRegisterServiceImpl implements EmployeeRegisterService {
return employeeRegisterDao.selectEmployeeInfoPasswode(phone);
}
+ /**
+ * 插入新的注册用户
+ * @param register
+ * @return 成功条数
+ */
+ @Override
+ public int insertRegister(EmployeeRegister register) {
+ return employeeRegisterDao.insertRegister(register);
+ }
@Override
public int insertRegister(EmployeeRegister register) {
diff --git a/src/main/java/com/example/meetingroom/service/impl/RoleServiceImpl.java b/src/main/java/com/example/meetingroom/service/impl/RoleServiceImpl.java
index 60d2d1b6995aaec4df170eef364d198d2c0ededc..4f9eff74d7c3b25d708fab2330680831bfbb21b6 100644
--- a/src/main/java/com/example/meetingroom/service/impl/RoleServiceImpl.java
+++ b/src/main/java/com/example/meetingroom/service/impl/RoleServiceImpl.java
@@ -4,6 +4,7 @@ import com.example.meetingroom.dao.RoleDao;
import com.example.meetingroom.dao.RoomInfoDao;
import com.example.meetingroom.entity.Role;
import com.example.meetingroom.service.RoleService;
+import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -34,13 +35,33 @@ public class RoleServiceImpl implements RoleService {
return roleDao.selectRoleList();
}
+ /**
+ * @return
+ * 超,普管判断
+ */
+ @Override
+ public Integer superOrCommon(){
+ Integer role = 0;
+ if (SecurityUtils.getSubject().getSession().getAttribute("identity").equals("超级管理员")){
+ role = 1;
+ }else if (SecurityUtils.getSubject().getSession().getAttribute("identity").equals("普通管理员")){
+ role = 0;
+ }
+ return role;
+ }
+
@Override
public String getRoleByPhone(String phone) {
return roleDao.getRoleByPhone(phone);
}
+ /**
+ * 根据权限ID来获取权限名
+ * @param id 权限ID
+ * @return 权限名
+ */
@Override
- public String getRoleByEmployeeId(String id) {
- return roleDao.getRoleByEmployeeId(id);
+ public String getRoleByRoleId(String id) {
+ return roleDao.getRoleByRoleId(id);
}
}
diff --git a/src/main/java/com/example/meetingroom/service/impl/RoomOrderServiceImpl.java b/src/main/java/com/example/meetingroom/service/impl/RoomOrderServiceImpl.java
index 2fe53f5915aebad2b2a75a76f6b4e8d13802031e..b389416ade38a6bf706663590d3074ad7244756b 100644
--- a/src/main/java/com/example/meetingroom/service/impl/RoomOrderServiceImpl.java
+++ b/src/main/java/com/example/meetingroom/service/impl/RoomOrderServiceImpl.java
@@ -77,11 +77,16 @@ public class RoomOrderServiceImpl implements RoomOrderService {
/**
* 分业务:“提交申请”
- * 功能:实现接口,将前端返回的“会议室预订”信息,插入到room_order表中
+ * 功能:实现接口,将前端返回的“会议室预订”信息,插入到room_order表中.
*/
@Override
public Object insertRoomOrderMessage(RoomOrderMessageVo roomOrderMessageVo) {
+ //根据applicant从employee_info表中查询申请人的id
String employee_info_id = roomOrderDao.getEmployeeInfoId(roomOrderMessageVo.getApplicant());
+ //若该申请人不在employee_info表中,则return null
+ if (employee_info_id==null){
+ return null;
+ }
return roomOrderDao.insertRoomOrderMessage(roomOrderMessageVo.getRoom_id(),
employee_info_id,
roomOrderMessageVo.getSubject(),
@@ -162,6 +167,10 @@ public class RoomOrderServiceImpl implements RoomOrderService {
Integer counts = selectCounts(selectType,role,userId);
//总页数
Integer pageCount = selectPages(lineNum,counts);
+ //判断总记录是否为0
+ if(counts == 0){
+ return new PageVo(0,0,0,0);
+ }
//判断参数
if(lineNum<0 || pageNum<0 || pageNum>pageCount){
return null;
diff --git a/src/main/java/com/example/meetingroom/vo/EmployeeInfoVo.java b/src/main/java/com/example/meetingroom/vo/EmployeeInfoVo.java
index ed5a2495b2ed7bb21c4b26960ad6e33eb9372b14..f524514a55d25b517dd4c4690c4627021c55935d 100644
--- a/src/main/java/com/example/meetingroom/vo/EmployeeInfoVo.java
+++ b/src/main/java/com/example/meetingroom/vo/EmployeeInfoVo.java
@@ -35,6 +35,8 @@ public class EmployeeInfoVo {
//性别(0为女,1为男)
private int sex;
+ private String sexString;
+
// //创建时间
// private Date createTime;
//
@@ -47,7 +49,7 @@ public class EmployeeInfoVo {
public EmployeeInfoVo() {
}
- public EmployeeInfoVo(String id, String roleName, String departName, String name, int number, String phone, String password, int sex) {
+ public EmployeeInfoVo(String id, String roleName, String departName, String name, int number, String phone, String password, int sex, String sexString) {
this.id = id;
this.roleName = roleName;
this.departName = departName;
@@ -56,6 +58,7 @@ public class EmployeeInfoVo {
this.phone = phone;
this.password = password;
this.sex = sex;
+ this.sexString = sexString;
}
/**
@@ -127,7 +130,15 @@ public class EmployeeInfoVo {
this.sex = sex;
}
-// /**
+ public String getSexString() {
+ return sexString;
+ }
+
+ public void setSexString(String sexString) {
+ this.sexString = sexString;
+ }
+
+ // /**
// * function: 获取创建时间并格式化
// * @return
// */
@@ -154,6 +165,7 @@ public class EmployeeInfoVo {
", phone='" + phone + '\'' +
", password='" + password + '\'' +
", sex=" + sex +
+ ", sexString='" + sexString + '\'' +
'}';
}
}
diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml
index 3fb901146cfd458ec15efca6454f99ace68c5742..1c768ab8a237f759abd3c0674a89f98dd3a0bc26 100644
--- a/src/main/resources/application.yaml
+++ b/src/main/resources/application.yaml
@@ -5,9 +5,9 @@ spring:
#mysql数据源配置
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
- url: jdbc:mysql:// chensiran.cn:3306/meeting_room?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
+ url: jdbc:mysql://chensiran.cn:3306/meeting_room?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
username: root
- password: root
+ password: chenzikang
mybatis:
mapper-locations: classpath*:mapper/*.xml
diff --git a/src/main/resources/mapper/DepartMapper.xml b/src/main/resources/mapper/DepartMapper.xml
index 342aebf4477df1e4825be4f17790fccc53cc45e5..84f573a8927550a7a58d3b543fd934b813bed32e 100644
--- a/src/main/resources/mapper/DepartMapper.xml
+++ b/src/main/resources/mapper/DepartMapper.xml
@@ -19,7 +19,7 @@
where depart.id = #{id};
-
+
delete from meeting_room.depart
where id = #{id};
diff --git a/src/main/resources/mapper/EmployeeInfoMapper.xml b/src/main/resources/mapper/EmployeeInfoMapper.xml
index 0cb48ad2bc3890c5485e75853a47d1d836a4e20a..0d8997edb0dd7a7d7b8980bda3cd458cca6733bb 100644
--- a/src/main/resources/mapper/EmployeeInfoMapper.xml
+++ b/src/main/resources/mapper/EmployeeInfoMapper.xml
@@ -60,10 +60,10 @@
+
+
-
-
+
+
+
select name from role
where id = #{id}
diff --git a/src/main/resources/mapper/RoomOrderMapper.xml b/src/main/resources/mapper/RoomOrderMapper.xml
index 098177795041e54829ece6be7277c72070c0ef5f..c34411209895007bc50d00c728065a89fa64dc79 100644
--- a/src/main/resources/mapper/RoomOrderMapper.xml
+++ b/src/main/resources/mapper/RoomOrderMapper.xml
@@ -275,26 +275,32 @@
where id = #{orderId}
+
select count(*) value,name from room_info,room_order WHERE room_info.id = room_order.room_id AND substr(start_time,1,7)=#{selectTime} and room_order_status='已通过' and deleted=1 GROUP BY name
+
select name,type,num,equipment,address from room_info
+
select name,applicant,start_time startTime,room_order_status roomOrderStatus from room_order,room_info where room_info.id = room_order.room_id and name=#{name}
+
select name from room_info
+
select name from employee_info
+
select REPLACE(UUID(),'-','')
@@ -305,6 +311,7 @@
(#{id},#{room_id},#{employee_info_id},#{subject},#{is_use},#{applicant},#{phone},#{employee_list},#{start_time},#{end_time},#{room_order_status},#{deleted})
+
select id from employee_info where name = #{applicant}
diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html
index 1122c09912c4e88363f45b6112b2b0d5654f80fb..42bbcc5c0fd63a910fe81b34e62173b2943baa28 100644
--- a/src/main/resources/templates/index.html
+++ b/src/main/resources/templates/index.html
@@ -6,7 +6,7 @@
-