小程序登录员工登录客户端小程序的情况处理

master
shijie 4 years ago
parent 4e279e136b
commit 508f041b4b
  1. 2
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/dao/UserLoginDao.java
  2. 17
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserLoginServiceImpl.java
  3. 4
      dq-financial-hrms-auth/src/main/resources/mapper/hrauth/UserLoginMapper.xml

@ -37,4 +37,6 @@ public interface UserLoginDao extends BaseMapper<UserEntity> {
UserEntity selectByManagerId();
int updateManagePassword(String newMD5);
int selectUserEmpCount(@Param("md5UnionId")String md5UnionId);
}

@ -393,10 +393,12 @@ public class UserLoginServiceImpl extends ServiceImpl<UserLoginDao, UserEntity>
loginRequest.setTenDayEffective(2);
if(identify==0){//员工小程序登录
if(count<=0){
return ResponseResult.FAIL(60001,"您不是员工,请使用客户小程序登录!");
return ResponseResult.FAIL(60001,"您的账号没有权限,无法登录!");
}
}else{//客户小程序登录
if(count <=0){//新用户
//如果员工使用客户小程序登录的情况,关联用户表和员工表查询,如果有数据则代表是员工的数据
int count2 = userLoginDao.selectUserEmpCount(md5UnionId);
if(count2>0 || count <=0){//代表员工或者新用户
UserEntity userEntity = new UserEntity();
userEntity.setAccount(userMap.get("nickName").toString());//账号默认为微信名称
userEntity.setWechatId(md5UnionId);//加密后unionId
@ -404,6 +406,17 @@ public class UserLoginServiceImpl extends ServiceImpl<UserLoginDao, UserEntity>
userEntity.setCreateTime(new Date());//创建时间
userLoginDao.insert(userEntity);
}
/* if(count2>0){//代表员工
return ResponseResult.FAIL(60002,"您不是客户,请使用员工小程序登录!");
}else if(count <=0){//新用户
UserEntity userEntity = new UserEntity();
userEntity.setAccount(userMap.get("nickName").toString());//账号默认为微信名称
userEntity.setWechatId(md5UnionId);//加密后unionId
userEntity.setHeadPortaritUrl(userMap.get("avatarUrl").toString());//头像路径
userEntity.setCreateTime(new Date());//创建时间
userLoginDao.insert(userEntity);
}*/
}
ResponseResult result = login(loginRequest);

@ -74,4 +74,8 @@
update hrms_user set password = #{password} where id=1
</update>
<select id="selectUserEmpCount" parameterType="string" resultType="integer">
SELECT COUNT(0) FROM hrms_user hu LEFT JOIN hrms_employee he ON he.user_id=hu.id WHERE hu.wechat_id = #{md5UnionId}
</select>
</mapper>
Loading…
Cancel
Save