From 5712adf6c8d0b9264983b295dcf6f4d7d8788274 Mon Sep 17 00:00:00 2001 From: cheney <1251790704@qq.com> Date: Tue, 2 Jan 2024 16:57:52 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=99=BB=E5=BD=95=E7=A6=81?= =?UTF-8?q?=E7=94=A8=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/exception/ExceptionEnum.java | 2 +- .../PlatformTeamAccountController.java | 48 +++++++++- .../huoran/nakadai/entity/HrUserAccount.java | 94 ++++++++----------- .../nakadai/entity/res/TeamAccountResp.java | 3 + .../PlatformTeamClassificationMapper.java | 7 ++ .../mapper/xml/PlatformTeamAccountMapper.xml | 5 +- .../xml/PlatformTeamClassificationMapper.xml | 6 ++ .../PlatformTeamClassificationService.java | 6 ++ .../impl/PlatformTeamAccountServiceImpl.java | 51 ++++++---- ...PlatformTeamClassificationServiceImpl.java | 11 +++ 10 files changed, 155 insertions(+), 78 deletions(-) diff --git a/common/src/main/java/com/huoran/common/exception/ExceptionEnum.java b/common/src/main/java/com/huoran/common/exception/ExceptionEnum.java index 5e58d0f..12448c1 100644 --- a/common/src/main/java/com/huoran/common/exception/ExceptionEnum.java +++ b/common/src/main/java/com/huoran/common/exception/ExceptionEnum.java @@ -66,7 +66,7 @@ public enum ExceptionEnum { CANNOT_ADDED_REPEATEDLY(10026, "该用户已经是团队管理员,无法重复添加!"), DEFAULT_ROLE_NOTEXIST(10027, "默认角色不存在"), TEAM_NOT_EXIST(10028, "团队不存在"), - PARTNER_REMOVAL(10029, "移除只能移除团队内成员,管理员无法移除!"), + PARTNER_REMOVAL(10029, "该用户是组织超管,请转让超管后再移除!"), SUPERVISING_ROLE(10030, "该用户存在超管角色,请转移后进行删除!"), VERIFICATION_CODE_HAS_BEEN_SENT(10031, "验证码已发,请勿重复操作!"), LOGIN_INVALID(401, "登录已失效,请重新登录"), diff --git a/nakadai/src/main/java/com/huoran/nakadai/controller/PlatformTeamAccountController.java b/nakadai/src/main/java/com/huoran/nakadai/controller/PlatformTeamAccountController.java index 681daf6..42d5ce5 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/controller/PlatformTeamAccountController.java +++ b/nakadai/src/main/java/com/huoran/nakadai/controller/PlatformTeamAccountController.java @@ -6,7 +6,9 @@ import com.huoran.common.exception.CustomException; import com.huoran.common.exception.ExceptionEnum; import com.huoran.common.response.R; import com.huoran.common.utils.TokenUtils; +import com.huoran.nakadai.entity.HrUserAccount; import com.huoran.nakadai.entity.PlatformTeam; +import com.huoran.nakadai.entity.PlatformTeamAccount; import com.huoran.nakadai.entity.PlatformTeamClassification; import com.huoran.nakadai.entity.req.*; import com.huoran.nakadai.entity.res.PartnerAccountResp; @@ -149,7 +151,9 @@ public class PlatformTeamAccountController { @GetMapping("/removeOrganization") @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); if (teamClassification.getIsTeam() == 1) { throw new CustomException(ExceptionEnum.PARTNER_REMOVAL); @@ -162,16 +166,56 @@ public class PlatformTeamAccountController { return remove ? R.ok() : R.error(); } - @ApiOperation(value = "后台更新团队状态,禁用无法查询到该组织") + @ApiOperation(value = "用户详情更新团队状态,禁用无法查询到该组织,同步禁用用户账号") @PostMapping("/updateTeamStatus") public R updateTeamStatus(@RequestParam("teamId") @ApiParam(value = "团队id") Integer teamId, @RequestParam("isEnable") @ApiParam(value = "是否禁用(1->禁用,0->启用)") Integer isEnable) { PlatformTeamClassification platformTeamClassification = new PlatformTeamClassification(); platformTeamClassification.setId(teamId); platformTeamClassification.setIsEnable(isEnable); boolean update = platformTeamClassificationService.updateById(platformTeamClassification); + //查询组织平台账号 + PlatformTeam platformTeam = platformTeamService.getOne(new QueryWrapper().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(); } + @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 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 platformTeamAccounts = platformTeamAccountService.list(new QueryWrapper().eq("account_id", userAccount.getId())); + for (PlatformTeamAccount platformTeamAccount : platformTeamAccounts) { + //查询组织平台账号 + PlatformTeam platformTeam = platformTeamService.getOne(new QueryWrapper().eq("manage_id", platformTeamAccount.getManageId())); + PlatformTeamClassification platformTeamClassification = new PlatformTeamClassification(); + platformTeamClassification.setId(platformTeam.getClassificationId()); + platformTeamClassification.setIsEnable(isEnable); + //更新账号绑定的组织信息 + platformTeamClassificationService.updateById(platformTeamClassification); + } + + } + } + return R.ok(); + } + //================================以下接口为小程序调用=================================== @ApiOperation(value = "幼教产品微信小程序回调登录") @PostMapping("/weChatAppletCallbackByKindergarten") diff --git a/nakadai/src/main/java/com/huoran/nakadai/entity/HrUserAccount.java b/nakadai/src/main/java/com/huoran/nakadai/entity/HrUserAccount.java index dd71e16..d0f12bd 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/entity/HrUserAccount.java +++ b/nakadai/src/main/java/com/huoran/nakadai/entity/HrUserAccount.java @@ -2,6 +2,7 @@ package com.huoran.nakadai.entity; import com.baomidou.mybatisplus.annotation.*; import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; @@ -21,93 +22,72 @@ public class HrUserAccount implements Serializable { private static final long serialVersionUID = 1L; - /** - * 主键id(平台用户id) - */ - @TableId(value = "id", type = IdType.AUTO) + @TableId(type = IdType.AUTO) + @ApiModelProperty(value = "主键id(平台用户id)") private Integer id; - /** - * 用户表id - */ + @ApiModelProperty(value = "用户表id") private Integer userId; + @ApiModelProperty(value = "客户表id") private Integer customerId; - /** - * 账号 - */ + @ApiModelProperty(value = "账号") private String account; - /** - * 密码 - */ + @ApiModelProperty("手机号(平台唯一标识)") + private String phone; + + @ApiModelProperty(value = "密码") private String password; - /** - * 工号 - */ + @ApiModelProperty(value = "工号") private String workNumber; - /** - * 绑定的角色id - */ + @ApiModelProperty(value = "绑定的角色id(0为数据平台普通用户)") private String roleId; - /** - * 绑定院校id - */ + @ApiModelProperty(value = "绑定院校id") private Integer schoolId; - @TableField(exist = false) - private String schoolName; - - /** - * 所属平台:1->职站 2->数据平台 - */ + @ApiModelProperty(value = "所属平台id") private String platformId; - @TableField(exist = false) - private String platformName; + @ApiModelProperty(value = "小程序id") + private String appOpenId; - /** - * 平台(系统)绑定时间 - */ - @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + @ApiModelProperty(value = "开放平台与公众平台唯一id") + private String unionid; + + @ApiModelProperty(value = "平台(系统)绑定时间") private Date platformBindTime; - /** - * 平台端区分:0->教师端 1->学生端 - */ - private Integer type; + @ApiModelProperty(value = "手机绑定时间") + private Date phoneBindingTime; - @TableField(exist = false) - private String typeName; + @ApiModelProperty(value = "平台端区分:0->教师端 1->学生端 2->无端") + private Integer type; - /** - * 是否删除(0、未删除 1、已删除) - */ - @TableLogic + @ApiModelProperty(value = "是否删除(0、未删除 1、已删除)") private Integer isDel; - /** - * 是否禁用(0->禁用,1->启用) - */ - private Integer isEnable; - + @ApiModelProperty(value = "是否禁用(0->禁用,1->启用)") + private Boolean isEnable; - /** - * 创建时间 - */ - @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + @ApiModelProperty(value = "创建时间") @TableField(fill = FieldFill.INSERT) private Date createTime; - /** - * 修改时间 - */ - @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + @ApiModelProperty(value = "更新时间") @TableField(fill = FieldFill.INSERT_UPDATE) private Date updateTime; + @ApiModelProperty(value = "班级id") + @TableField(exist = false) + private String classId; + + @ApiModelProperty(value = "班级id") + @TableField(exist = false) + private String userName; + } diff --git a/nakadai/src/main/java/com/huoran/nakadai/entity/res/TeamAccountResp.java b/nakadai/src/main/java/com/huoran/nakadai/entity/res/TeamAccountResp.java index 39a882a..315bcef 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/entity/res/TeamAccountResp.java +++ b/nakadai/src/main/java/com/huoran/nakadai/entity/res/TeamAccountResp.java @@ -92,6 +92,9 @@ public class TeamAccountResp { @ApiModelProperty(value = "团队数") private Integer teamSize; + @ApiModelProperty(value = "组织禁用") + private Integer isEnable; + @ApiModelProperty(value = "团队名称") private String teamName; diff --git a/nakadai/src/main/java/com/huoran/nakadai/mapper/PlatformTeamClassificationMapper.java b/nakadai/src/main/java/com/huoran/nakadai/mapper/PlatformTeamClassificationMapper.java index 73241be..7aa5062 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/mapper/PlatformTeamClassificationMapper.java +++ b/nakadai/src/main/java/com/huoran/nakadai/mapper/PlatformTeamClassificationMapper.java @@ -1,10 +1,13 @@ package com.huoran.nakadai.mapper; +import com.huoran.nakadai.entity.HrUserAccount; import com.huoran.nakadai.entity.PlatformTeamClassification; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import java.util.List; + /** *

* 幼教产业平台团队分类表 Mapper 接口 @@ -17,4 +20,8 @@ import org.apache.ibatis.annotations.Param; public interface PlatformTeamClassificationMapper extends BaseMapper { PlatformTeamClassification getParentInformationBasedOnChild(@Param("id") String classificationId); + + void updateByAccountId(@Param("accountId")Integer accountId, @Param("status")Integer status); + + List selectAccountList(@Param("openId")String openId); } diff --git a/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/PlatformTeamAccountMapper.xml b/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/PlatformTeamAccountMapper.xml index 44a912a..78c1f2c 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/PlatformTeamAccountMapper.xml +++ b/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/PlatformTeamAccountMapper.xml @@ -73,7 +73,8 @@ CASE WHEN count(ai.id) > 0 THEN '已认证' ELSE '未认证' - END as authentication + END as authentication, + c.is_enable FROM k_platform_team t 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 left join hr_user_authentication_information ai on ai.open_id = ua.app_open_id 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.account_id = #{accountId} diff --git a/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/PlatformTeamClassificationMapper.xml b/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/PlatformTeamClassificationMapper.xml index 40d3208..49bed54 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/PlatformTeamClassificationMapper.xml +++ b/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/PlatformTeamClassificationMapper.xml @@ -1,6 +1,9 @@ + + update hr_user_account set is_enable = #{status} WHERE is_del = 0 and id = #{accountId} + + diff --git a/nakadai/src/main/java/com/huoran/nakadai/service/PlatformTeamClassificationService.java b/nakadai/src/main/java/com/huoran/nakadai/service/PlatformTeamClassificationService.java index 47241cf..cdf20f8 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/service/PlatformTeamClassificationService.java +++ b/nakadai/src/main/java/com/huoran/nakadai/service/PlatformTeamClassificationService.java @@ -1,8 +1,11 @@ package com.huoran.nakadai.service; +import com.huoran.nakadai.entity.HrUserAccount; import com.huoran.nakadai.entity.PlatformTeamClassification; import com.baomidou.mybatisplus.extension.service.IService; +import java.util.List; + /** *

* 幼教产业平台团队分类表 服务类 @@ -13,4 +16,7 @@ import com.baomidou.mybatisplus.extension.service.IService; */ public interface PlatformTeamClassificationService extends IService { + void updateByAccountId(Integer accountId, Integer status); + + List selectAccountList(String openId); } diff --git a/nakadai/src/main/java/com/huoran/nakadai/service/impl/PlatformTeamAccountServiceImpl.java b/nakadai/src/main/java/com/huoran/nakadai/service/impl/PlatformTeamAccountServiceImpl.java index 8d72cd7..8410114 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/service/impl/PlatformTeamAccountServiceImpl.java +++ b/nakadai/src/main/java/com/huoran/nakadai/service/impl/PlatformTeamAccountServiceImpl.java @@ -98,28 +98,46 @@ public class PlatformTeamAccountServiceImpl extends ServiceImpl userAccountList = platformTeamClassificationMapper.selectAccountList(openid); + for (HrUserAccount userAccount : userAccountList) { + if(userAccount.getPlatformId().equals(platformId.toString())){ + if (!userAccount.getIsEnable()){ + if (platformId == 7) { // 如果个人账号被禁用,抛出异常 + throw new CustomException(ExceptionEnum.ACCOUNT_DISABLED); + } + 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) { data.put("state", "bind"); @@ -130,6 +148,7 @@ public class PlatformTeamAccountServiceImpl extends ServiceImpl * 幼教产业平台团队分类表 服务实现类 @@ -16,5 +19,13 @@ import org.springframework.stereotype.Service; */ @Service public class PlatformTeamClassificationServiceImpl extends ServiceImpl implements PlatformTeamClassificationService { + @Override + public void updateByAccountId(Integer accountId, Integer status) { + baseMapper.updateByAccountId(accountId, status); + } + @Override + public List selectAccountList(String openId) { + return baseMapper.selectAccountList(openId); + } }