用户登录禁用处理

main
cheney 11 months ago
parent 444c0edc91
commit 5712adf6c8
  1. 2
      common/src/main/java/com/huoran/common/exception/ExceptionEnum.java
  2. 48
      nakadai/src/main/java/com/huoran/nakadai/controller/PlatformTeamAccountController.java
  3. 94
      nakadai/src/main/java/com/huoran/nakadai/entity/HrUserAccount.java
  4. 3
      nakadai/src/main/java/com/huoran/nakadai/entity/res/TeamAccountResp.java
  5. 7
      nakadai/src/main/java/com/huoran/nakadai/mapper/PlatformTeamClassificationMapper.java
  6. 5
      nakadai/src/main/java/com/huoran/nakadai/mapper/xml/PlatformTeamAccountMapper.xml
  7. 6
      nakadai/src/main/java/com/huoran/nakadai/mapper/xml/PlatformTeamClassificationMapper.xml
  8. 6
      nakadai/src/main/java/com/huoran/nakadai/service/PlatformTeamClassificationService.java
  9. 51
      nakadai/src/main/java/com/huoran/nakadai/service/impl/PlatformTeamAccountServiceImpl.java
  10. 11
      nakadai/src/main/java/com/huoran/nakadai/service/impl/PlatformTeamClassificationServiceImpl.java

@ -66,7 +66,7 @@ public enum ExceptionEnum {
CANNOT_ADDED_REPEATEDLY(10026, "该用户已经是团队管理员,无法重复添加!"), CANNOT_ADDED_REPEATEDLY(10026, "该用户已经是团队管理员,无法重复添加!"),
DEFAULT_ROLE_NOTEXIST(10027, "默认角色不存在"), DEFAULT_ROLE_NOTEXIST(10027, "默认角色不存在"),
TEAM_NOT_EXIST(10028, "团队不存在"), TEAM_NOT_EXIST(10028, "团队不存在"),
PARTNER_REMOVAL(10029, "移除只能移除团队内成员,管理员无法移除!"), PARTNER_REMOVAL(10029, "该用户是组织超管,请转让超管后再移除!"),
SUPERVISING_ROLE(10030, "该用户存在超管角色,请转移后进行删除!"), SUPERVISING_ROLE(10030, "该用户存在超管角色,请转移后进行删除!"),
VERIFICATION_CODE_HAS_BEEN_SENT(10031, "验证码已发,请勿重复操作!"), VERIFICATION_CODE_HAS_BEEN_SENT(10031, "验证码已发,请勿重复操作!"),
LOGIN_INVALID(401, "登录已失效,请重新登录"), LOGIN_INVALID(401, "登录已失效,请重新登录"),

@ -6,7 +6,9 @@ import com.huoran.common.exception.CustomException;
import com.huoran.common.exception.ExceptionEnum; import com.huoran.common.exception.ExceptionEnum;
import com.huoran.common.response.R; import com.huoran.common.response.R;
import com.huoran.common.utils.TokenUtils; import com.huoran.common.utils.TokenUtils;
import com.huoran.nakadai.entity.HrUserAccount;
import com.huoran.nakadai.entity.PlatformTeam; import com.huoran.nakadai.entity.PlatformTeam;
import com.huoran.nakadai.entity.PlatformTeamAccount;
import com.huoran.nakadai.entity.PlatformTeamClassification; import com.huoran.nakadai.entity.PlatformTeamClassification;
import com.huoran.nakadai.entity.req.*; import com.huoran.nakadai.entity.req.*;
import com.huoran.nakadai.entity.res.PartnerAccountResp; import com.huoran.nakadai.entity.res.PartnerAccountResp;
@ -149,7 +151,9 @@ public class PlatformTeamAccountController {
@GetMapping("/removeOrganization") @GetMapping("/removeOrganization")
@ApiOperation(value = "移除组织") @ApiOperation(value = "移除组织")
public R removeOrganization(@ApiParam(name = "teamId", value = "团队id") @RequestParam Integer teamId, @ApiParam(name = "manageId", value = "组织id") @RequestParam Integer manageId) { public R removeOrganization(
@ApiParam(name = "teamId", value = "团队id") @RequestParam Integer teamId,
@ApiParam(name = "manageId", value = "组织id") @RequestParam Integer manageId) {
PlatformTeamClassification teamClassification = platformTeamClassificationService.getById(teamId); PlatformTeamClassification teamClassification = platformTeamClassificationService.getById(teamId);
if (teamClassification.getIsTeam() == 1) { if (teamClassification.getIsTeam() == 1) {
throw new CustomException(ExceptionEnum.PARTNER_REMOVAL); throw new CustomException(ExceptionEnum.PARTNER_REMOVAL);
@ -162,16 +166,56 @@ public class PlatformTeamAccountController {
return remove ? R.ok() : R.error(); return remove ? R.ok() : R.error();
} }
@ApiOperation(value = "后台更新团队状态,禁用无法查询到该组织") @ApiOperation(value = "用户详情更新团队状态,禁用无法查询到该组织,同步禁用用户账号")
@PostMapping("/updateTeamStatus") @PostMapping("/updateTeamStatus")
public R updateTeamStatus(@RequestParam("teamId") @ApiParam(value = "团队id") Integer teamId, @RequestParam("isEnable") @ApiParam(value = "是否禁用(1->禁用,0->启用)") Integer isEnable) { public R updateTeamStatus(@RequestParam("teamId") @ApiParam(value = "团队id") Integer teamId, @RequestParam("isEnable") @ApiParam(value = "是否禁用(1->禁用,0->启用)") Integer isEnable) {
PlatformTeamClassification platformTeamClassification = new PlatformTeamClassification(); PlatformTeamClassification platformTeamClassification = new PlatformTeamClassification();
platformTeamClassification.setId(teamId); platformTeamClassification.setId(teamId);
platformTeamClassification.setIsEnable(isEnable); platformTeamClassification.setIsEnable(isEnable);
boolean update = platformTeamClassificationService.updateById(platformTeamClassification); boolean update = platformTeamClassificationService.updateById(platformTeamClassification);
//查询组织平台账号
PlatformTeam platformTeam = platformTeamService.getOne(new QueryWrapper<PlatformTeam>().eq("classification_id", teamId));
PlatformTeamAccount platformTeamAccount = platformTeamAccountService.getById(platformTeam.getManageId());
int status = 1;
if (isEnable==1){
status=0;
}
platformTeamClassificationService.updateByAccountId(platformTeamAccount.getAccountId(), status);
return update ? R.ok() : R.error(); return update ? R.ok() : R.error();
} }
@ApiOperation(value = "用户列表更新账号状态,禁用整个账号禁止登录,不管是哪个端,哪个组织")
@PostMapping("/updateAccountStatus")
public R updateAccountStatus(
@RequestParam("openId") @ApiParam(value = "openId") String openId,
@RequestParam("isEnable") @ApiParam(value = "是否禁用(1->禁用,0->启用)") Integer isEnable) {
//根据openId查询账号详情List
List<HrUserAccount> userAccountList = platformTeamClassificationService.selectAccountList(openId);
for (HrUserAccount userAccount : userAccountList) {
int status = 1;
if (isEnable==1){
status=0;
}
//更新账号信息
platformTeamClassificationService.updateByAccountId(userAccount.getId(), status);
if (Integer.parseInt(userAccount.getPlatformId())!=7){
//查询账号绑定的组织信息
List<PlatformTeamAccount> platformTeamAccounts = platformTeamAccountService.list(new QueryWrapper<PlatformTeamAccount>().eq("account_id", userAccount.getId()));
for (PlatformTeamAccount platformTeamAccount : platformTeamAccounts) {
//查询组织平台账号
PlatformTeam platformTeam = platformTeamService.getOne(new QueryWrapper<PlatformTeam>().eq("manage_id", platformTeamAccount.getManageId()));
PlatformTeamClassification platformTeamClassification = new PlatformTeamClassification();
platformTeamClassification.setId(platformTeam.getClassificationId());
platformTeamClassification.setIsEnable(isEnable);
//更新账号绑定的组织信息
platformTeamClassificationService.updateById(platformTeamClassification);
}
}
}
return R.ok();
}
//================================以下接口为小程序调用=================================== //================================以下接口为小程序调用===================================
@ApiOperation(value = "幼教产品微信小程序回调登录") @ApiOperation(value = "幼教产品微信小程序回调登录")
@PostMapping("/weChatAppletCallbackByKindergarten") @PostMapping("/weChatAppletCallbackByKindergarten")

@ -2,6 +2,7 @@ package com.huoran.nakadai.entity;
import com.baomidou.mybatisplus.annotation.*; import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
@ -21,93 +22,72 @@ public class HrUserAccount implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** @TableId(type = IdType.AUTO)
* 主键id(平台用户id @ApiModelProperty(value = "主键id(平台用户id)")
*/
@TableId(value = "id", type = IdType.AUTO)
private Integer id; private Integer id;
/** @ApiModelProperty(value = "用户表id")
* 用户表id
*/
private Integer userId; private Integer userId;
@ApiModelProperty(value = "客户表id")
private Integer customerId; private Integer customerId;
/** @ApiModelProperty(value = "账号")
* 账号
*/
private String account; private String account;
/** @ApiModelProperty("手机号(平台唯一标识)")
* 密码 private String phone;
*/
@ApiModelProperty(value = "密码")
private String password; private String password;
/** @ApiModelProperty(value = "工号")
* 工号
*/
private String workNumber; private String workNumber;
/** @ApiModelProperty(value = "绑定的角色id(0为数据平台普通用户)")
* 绑定的角色id
*/
private String roleId; private String roleId;
/** @ApiModelProperty(value = "绑定院校id")
* 绑定院校id
*/
private Integer schoolId; private Integer schoolId;
@TableField(exist = false) @ApiModelProperty(value = "所属平台id")
private String schoolName;
/**
* 所属平台1->职站 2->数据平台
*/
private String platformId; private String platformId;
@TableField(exist = false) @ApiModelProperty(value = "小程序id")
private String platformName; private String appOpenId;
/** @ApiModelProperty(value = "开放平台与公众平台唯一id")
* 平台系统绑定时间 private String unionid;
*/
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") @ApiModelProperty(value = "平台(系统)绑定时间")
private Date platformBindTime; private Date platformBindTime;
/** @ApiModelProperty(value = "手机绑定时间")
* 平台端区分0->教师端 1->学生端 private Date phoneBindingTime;
*/
private Integer type;
@TableField(exist = false) @ApiModelProperty(value = "平台端区分:0->教师端 1->学生端 2->无端")
private String typeName; private Integer type;
/** @ApiModelProperty(value = "是否删除(0、未删除 1、已删除)")
* 是否删除(0未删除 1已删除)
*/
@TableLogic
private Integer isDel; private Integer isDel;
/** @ApiModelProperty(value = "是否禁用(0->禁用,1->启用)")
* 是否禁用0->禁用1->启用 private Boolean isEnable;
*/
private Integer isEnable;
/** @ApiModelProperty(value = "创建时间")
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@TableField(fill = FieldFill.INSERT) @TableField(fill = FieldFill.INSERT)
private Date createTime; private Date createTime;
/** @ApiModelProperty(value = "更新时间")
* 修改时间
*/
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@TableField(fill = FieldFill.INSERT_UPDATE) @TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateTime; private Date updateTime;
@ApiModelProperty(value = "班级id")
@TableField(exist = false)
private String classId;
@ApiModelProperty(value = "班级id")
@TableField(exist = false)
private String userName;
} }

@ -92,6 +92,9 @@ public class TeamAccountResp {
@ApiModelProperty(value = "团队数") @ApiModelProperty(value = "团队数")
private Integer teamSize; private Integer teamSize;
@ApiModelProperty(value = "组织禁用")
private Integer isEnable;
@ApiModelProperty(value = "团队名称") @ApiModelProperty(value = "团队名称")
private String teamName; private String teamName;

@ -1,10 +1,13 @@
package com.huoran.nakadai.mapper; package com.huoran.nakadai.mapper;
import com.huoran.nakadai.entity.HrUserAccount;
import com.huoran.nakadai.entity.PlatformTeamClassification; import com.huoran.nakadai.entity.PlatformTeamClassification;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List;
/** /**
* <p> * <p>
* 幼教产业平台团队分类表 Mapper 接口 * 幼教产业平台团队分类表 Mapper 接口
@ -17,4 +20,8 @@ import org.apache.ibatis.annotations.Param;
public interface PlatformTeamClassificationMapper extends BaseMapper<PlatformTeamClassification> { public interface PlatformTeamClassificationMapper extends BaseMapper<PlatformTeamClassification> {
PlatformTeamClassification getParentInformationBasedOnChild(@Param("id") String classificationId); PlatformTeamClassification getParentInformationBasedOnChild(@Param("id") String classificationId);
void updateByAccountId(@Param("accountId")Integer accountId, @Param("status")Integer status);
List<HrUserAccount> selectAccountList(@Param("openId")String openId);
} }

@ -73,7 +73,8 @@
CASE CASE
WHEN count(ai.id) > 0 THEN '已认证' WHEN count(ai.id) > 0 THEN '已认证'
ELSE '未认证' ELSE '未认证'
END as authentication END as authentication,
c.is_enable
FROM FROM
k_platform_team t k_platform_team t
INNER JOIN k_platform_team_classification c ON c.id = t.classification_id INNER JOIN k_platform_team_classification c ON c.id = t.classification_id
@ -82,7 +83,7 @@
INNER JOIN hr_user_info u on ua.user_id = u.user_id INNER JOIN hr_user_info u on ua.user_id = u.user_id
left join hr_user_authentication_information ai on ai.open_id = ua.app_open_id left join hr_user_authentication_information ai on ai.open_id = ua.app_open_id
WHERE WHERE
c.is_del = 0 and c.is_enable = 0 c.is_del = 0
AND a.is_del = 0 and a.platform_id = #{platformId} AND a.is_del = 0 and a.platform_id = #{platformId}
AND a.account_id = #{accountId} AND a.account_id = #{accountId}
</select> </select>

@ -1,6 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.huoran.nakadai.mapper.PlatformTeamClassificationMapper"> <mapper namespace="com.huoran.nakadai.mapper.PlatformTeamClassificationMapper">
<update id="updateByAccountId">
update hr_user_account set is_enable = #{status} WHERE is_del = 0 and id = #{accountId}
</update>
<select id="getParentInformationBasedOnChild" <select id="getParentInformationBasedOnChild"
resultType="com.huoran.nakadai.entity.PlatformTeamClassification"> resultType="com.huoran.nakadai.entity.PlatformTeamClassification">
@ -26,4 +29,7 @@
ORDER BY ORDER BY
T1.lvl DESC T1.lvl DESC
</select> </select>
<select id="selectAccountList" resultType="com.huoran.nakadai.entity.HrUserAccount">
select * from hr_user_account WHERE is_del = 0 and app_open_id = #{openId}
</select>
</mapper> </mapper>

@ -1,8 +1,11 @@
package com.huoran.nakadai.service; package com.huoran.nakadai.service;
import com.huoran.nakadai.entity.HrUserAccount;
import com.huoran.nakadai.entity.PlatformTeamClassification; import com.huoran.nakadai.entity.PlatformTeamClassification;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/** /**
* <p> * <p>
* 幼教产业平台团队分类表 服务类 * 幼教产业平台团队分类表 服务类
@ -13,4 +16,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
*/ */
public interface PlatformTeamClassificationService extends IService<PlatformTeamClassification> { public interface PlatformTeamClassificationService extends IService<PlatformTeamClassification> {
void updateByAccountId(Integer accountId, Integer status);
List<HrUserAccount> selectAccountList(String openId);
} }

@ -98,28 +98,46 @@ public class PlatformTeamAccountServiceImpl extends ServiceImpl<PlatformTeamAcco
arrayList.add(7); arrayList.add(7);
boolean userExists = false; // 添加标志位,判断用户是否存在 boolean userExists = false; // 添加标志位,判断用户是否存在
HrUserAccount personalAccount = null; // 用于存储个人账号
for (Integer platformId : arrayList) { for (Integer platformId : arrayList) {
UserAccount userAccount = baseMapper.selectAccountByOpenId(openid,platformId); //根据openId查询账号详情List
// 有平台存在返回登录信息 List<HrUserAccount> userAccountList = platformTeamClassificationMapper.selectAccountList(openid);
if (userAccount!= null){ for (HrUserAccount userAccount : userAccountList) {
if (!userAccount.getIsEnable()){ if(userAccount.getPlatformId().equals(platformId.toString())){
throw new CustomException(ExceptionEnum.ACCOUNT_DISABLED); if (!userAccount.getIsEnable()){
} if (platformId == 7) { // 如果个人账号被禁用,抛出异常
if (userAccount.getPhone()== null){ throw new CustomException(ExceptionEnum.ACCOUNT_DISABLED);
//登录更新手机号 }
baseMapper.updateAccountPhone(appletCallbackReq.getPhone(),userAccount.getId()); continue; // 如果组织账号被禁用,跳过当前循环
}
if (platformId == 7) { // 如果是个人账号,保存信息并跳过当前循环
personalAccount = userAccount;
continue;
}
if (userAccount.getPhone()== null){
//登录更新手机号
baseMapper.updateAccountPhone(appletCallbackReq.getPhone(),userAccount.getId());
}
//更新登录时间
baseMapper.updateUserInfo(userAccount.getUserId());
data.put("state", "login");
data.put("platformId", platformId);
data.put("token", JwtUtils.getJwtToken(userAccount.getId().toString(),getShopId(openid,platformId),platformId));
userExists = true; // 如果用户存在,将标志位设为true
break; // 如果找到用户,就不需要继续查找
} }
//更新登录时间
baseMapper.updateUserInfo(userAccount.getUserId());
data.put("state", "login");
data.put("platformId", platformId);
data.put("token", JwtUtils.getJwtToken(userAccount.getId().toString(),getShopId(openid,platformId),platformId));
userExists = true; // 如果用户存在,将标志位设为true
break; // 如果找到用户,就不需要继续查找
} }
} }
// 如果用户不存在,检查是否有个人账号
if (!userExists && personalAccount != null) {
data.put("state", "login");
data.put("platformId", 7);
data.put("token", JwtUtils.getJwtToken(personalAccount.getId().toString(),0L,7));
userExists = true;
}
// 如果用户不存在,返回状态为"绑定" // 如果用户不存在,返回状态为"绑定"
if (!userExists) { if (!userExists) {
data.put("state", "bind"); data.put("state", "bind");
@ -130,6 +148,7 @@ public class PlatformTeamAccountServiceImpl extends ServiceImpl<PlatformTeamAcco
return data; return data;
} }
public Long getShopId(String openId, Integer platformId) { public Long getShopId(String openId, Integer platformId) {
return baseMapper.selectShopIdByOpenId(openId, platformId); return baseMapper.selectShopIdByOpenId(openId, platformId);
} }

@ -1,11 +1,14 @@
package com.huoran.nakadai.service.impl; package com.huoran.nakadai.service.impl;
import com.huoran.nakadai.entity.HrUserAccount;
import com.huoran.nakadai.entity.PlatformTeamClassification; import com.huoran.nakadai.entity.PlatformTeamClassification;
import com.huoran.nakadai.mapper.PlatformTeamClassificationMapper; import com.huoran.nakadai.mapper.PlatformTeamClassificationMapper;
import com.huoran.nakadai.service.PlatformTeamClassificationService; import com.huoran.nakadai.service.PlatformTeamClassificationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
/** /**
* <p> * <p>
* 幼教产业平台团队分类表 服务实现类 * 幼教产业平台团队分类表 服务实现类
@ -16,5 +19,13 @@ import org.springframework.stereotype.Service;
*/ */
@Service @Service
public class PlatformTeamClassificationServiceImpl extends ServiceImpl<PlatformTeamClassificationMapper, PlatformTeamClassification> implements PlatformTeamClassificationService { public class PlatformTeamClassificationServiceImpl extends ServiceImpl<PlatformTeamClassificationMapper, PlatformTeamClassification> implements PlatformTeamClassificationService {
@Override
public void updateByAccountId(Integer accountId, Integer status) {
baseMapper.updateByAccountId(accountId, status);
}
@Override
public List<HrUserAccount> selectAccountList(String openId) {
return baseMapper.selectAccountList(openId);
}
} }

Loading…
Cancel
Save