修改登录

master
mzh820631607 4 years ago
parent 2ab06db4f8
commit ee48315916
  1. 23
      src/main/java/com/yipin/liuwanr/controller/UserInfoController.java
  2. 15
      src/main/java/com/yipin/liuwanr/mapper/UserInfoMapper.java
  3. 10
      src/main/java/com/yipin/liuwanr/service/UserInfoService.java

@ -521,21 +521,24 @@ public class UserInfoController {
* 更新登录次数和时间 * 更新登录次数和时间
*/ */
@PostMapping("/updateLogInNumber") @PostMapping("/updateLogInNumber")
Response updateLogInNumber(@RequestBody UserM user) { Response updateLogInNumber(@RequestBody UserInfo user) {
Response resp = new Response(); Response resp = new Response();
Integer userId = user.getUserId(); Integer userId = user.getUserId();
String phone = user.getPhone(); // String phone = user.getPhone();
Integer accountRole = user.getAccountRole(); // String roleId = user.getRoleId();
if (userId==null) { if (userId==null) {
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("用户id不能为空!"); resp.setErrmessage("用户id不能为空!");
}else if(phone==null||phone==""){ }else
resp.setStatus(300); // if(phone==null||phone==""){
resp.setErrmessage("用户电话不能为空!"); // resp.setStatus(300);
} else if(accountRole==null){ // resp.setErrmessage("用户电话不能为空!");
resp.setStatus(300); // } else
resp.setErrmessage("用户角色不能为空!"); // if(roleId==null){
} else { // resp.setStatus(300);
// resp.setErrmessage("用户角色不能为空!");
// } else
{
HashMap<String, Object> ret = userInfoService.updateLogInNumber(user); HashMap<String, Object> ret = userInfoService.updateLogInNumber(user);
int status = (int) ret.get("retcode"); int status = (int) ret.get("retcode");
if (200 == status) { if (200 == status) {

@ -262,16 +262,16 @@ public interface UserInfoMapper {
void updateUserAvatars(@Param("userAvatars") String userAvatars, @Param("userId") Integer userId); void updateUserAvatars(@Param("userAvatars") String userAvatars, @Param("userId") Integer userId);
//更新用户登录次数和最后一次登录时间 //更新用户登录次数和最后一次登录时间
@Update({"UPDATE user SET logInNumber=logInNumber+1, lastTimeOfLanding=now() WHERE userId=#{userId}"}) @Update({"UPDATE hr_user_info SET logInNumber=logInNumber+1, lastLoginTime=now() WHERE userId=#{userId}"})
void updateLogInNumber(UserM user); void updateLogInNumber(UserInfo user);
//更新学生登录次数和最后一次登录时间 //更新学生登录次数和最后一次登录时间
@Update({"UPDATE student SET logInNumber=logInNumber+1, lastLoginTime=now() WHERE phone=#{phone}"}) @Update({"UPDATE student SET logInNumber=logInNumber+1, lastLoginTime=now() WHERE userId=#{userId}"})
void updateStudentLogInNumber(UserM user); void updateStudentLogInNumber(UserInfo user);
//更新员工登录次数和最后一次登录时间 //更新员工登录次数和最后一次登录时间
@Update({"UPDATE staff SET logNumber=logNumber+1, lastTimeOfLanding=now() WHERE phone=#{phone}"}) @Update({"UPDATE staff SET loginNumber=loginNumber+1, lastLoginTime=now() WHERE userId=#{userId}"})
void updateStaffLogInNumber(UserM user); void updateStaffLogInNumber(UserInfo user);
//查询账号是否存在 //查询账号是否存在
@Select("SELECT account,email,userName,userId,uniqueIdentificationAccount,phone from hr_user_info where isdel = 0 and account = #{account}") @Select("SELECT account,email,userName,userId,uniqueIdentificationAccount,phone from hr_user_info where isdel = 0 and account = #{account}")
@ -340,4 +340,7 @@ public interface UserInfoMapper {
@Select("SELECT disableAccount FROM hr_user_info WHERE schoolId = #{schoolId} AND account = #{account} and isdel = 0") @Select("SELECT disableAccount FROM hr_user_info WHERE schoolId = #{schoolId} AND account = #{account} and isdel = 0")
Integer queryDisableAccount(UserInfo userInfo); Integer queryDisableAccount(UserInfo userInfo);
@Select("select roleId from hr_user_info where userId = #{userId}")
UserInfo queryUser(UserInfo user);
} }

@ -611,16 +611,18 @@ public class UserInfoService {
} }
//更新登录次数和时间 //更新登录次数和时间
public HashMap<String, Object> updateLogInNumber(UserM user){ public HashMap<String, Object> updateLogInNumber(UserInfo user){
HashMap<String, Object> resp = new HashMap<String, Object>(); HashMap<String, Object> resp = new HashMap<String, Object>();
try { try {
Integer accountRole = user.getAccountRole(); // String roleId = user.getRoleId();
userInfoMapper.updateLogInNumber(user); userInfoMapper.updateLogInNumber(user);
if (accountRole==3){ UserInfo userInfo = userInfoMapper.queryUser(user);
String roleId = userInfo.getRoleId();
if (roleId.contains("3")|roleId.contains("2")){
//更新员工登录次数和时间 //更新员工登录次数和时间
userInfoMapper.updateStaffLogInNumber(user); userInfoMapper.updateStaffLogInNumber(user);
} }
if (accountRole==4){ if (roleId.contains("4")){
//更新学生登录次数和时间 //更新学生登录次数和时间
userInfoMapper.updateStudentLogInNumber(user); userInfoMapper.updateStudentLogInNumber(user);
} }

Loading…
Cancel
Save