From e714d6f8978ab029772048626cb74f50a5c98f9b Mon Sep 17 00:00:00 2001 From: cheney <1251790704@qq.com> Date: Wed, 20 Dec 2023 17:44:22 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=88=A4=E9=87=8D=EF=BC=8C=E9=82=80=E8=AF=B7=E4=BA=BA=E5=91=98?= =?UTF-8?q?=E6=B3=A8=E5=86=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/exception/ExceptionEnum.java | 2 +- .../PlatformTeamAccountController.java | 6 +- .../nakadai/entity/req/InviteJoinInfo.java | 24 +++ .../nakadai/mapper/PartnerAccountMapper.java | 2 + .../mapper/PlatformTeamAccountMapper.java | 4 +- .../mapper/xml/PlatformTeamAccountMapper.xml | 9 +- .../service/PlatformTeamAccountService.java | 3 + .../impl/PlatformTeamAccountServiceImpl.java | 139 +++++++++++++++++- 8 files changed, 180 insertions(+), 9 deletions(-) create mode 100644 nakadai/src/main/java/com/huoran/nakadai/entity/req/InviteJoinInfo.java 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 3f80a75..250693a 100644 --- a/common/src/main/java/com/huoran/common/exception/ExceptionEnum.java +++ b/common/src/main/java/com/huoran/common/exception/ExceptionEnum.java @@ -59,7 +59,7 @@ public enum ExceptionEnum { JOB_ID_NOT_EXIST(10021, "工号不存在"), DATA_PLATFORM_ACCOUNT_AVALIABLE_FAIL(10022, "当前用户所在的院校在数据平台的可用账号数量不足,是否继续!"), INVITATION_CODE_EXPIRED(10023, "邀请码已失效"), - USER_ALREADY_EXISTS_GROUP(10024, "用户已存在该团队"), + USER_ALREADY_EXISTS_GROUP(10024, "用户已存在该组织"), CANT_JOIN_TEAM(10025, "无法加入自己的团队"), CANNOT_ADDED_REPEATEDLY(10026, "该用户已经是团队管理员,无法重复添加!"), DEFAULT_ROLE_NOTEXIST(10027, "默认角色不存在"), 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 9649304..4fb6eb1 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/controller/PlatformTeamAccountController.java +++ b/nakadai/src/main/java/com/huoran/nakadai/controller/PlatformTeamAccountController.java @@ -82,7 +82,6 @@ public class PlatformTeamAccountController { } - // @PostMapping("/platformTeamAccountMergeList") // @ApiOperation(value = "平台团队账号列表--合并数据查询(以账号为维度查询合并-后台调用)", response = PlatformTeamAccountResp.class) // public R partnerAccountMergeList(@RequestBody @Valid PlatformTeamAccountListReq req) { @@ -240,5 +239,10 @@ public class PlatformTeamAccountController { return R.ok().put("teamInfo",teamInfo); } + @PostMapping("/inviteJoinOrganization") + @ApiOperation(value = "邀请加入不同平台组织") + public R inviteJoinOrganization(@RequestBody @Valid InviteJoinInfo inviteJoinInfo) { + return platformTeamAccountService.inviteJoinOrganization(inviteJoinInfo); + } } diff --git a/nakadai/src/main/java/com/huoran/nakadai/entity/req/InviteJoinInfo.java b/nakadai/src/main/java/com/huoran/nakadai/entity/req/InviteJoinInfo.java new file mode 100644 index 0000000..43bfc4a --- /dev/null +++ b/nakadai/src/main/java/com/huoran/nakadai/entity/req/InviteJoinInfo.java @@ -0,0 +1,24 @@ +package com.huoran.nakadai.entity.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class InviteJoinInfo { + @ApiModelProperty(value = "邀请人账号id") + private String accountId; + + @ApiModelProperty(value = "手机验证码") + private String code; + + @ApiModelProperty(value = "电话") + private String phone; + + @ApiModelProperty(value = "platformId") + private Integer platformId; + + @ApiModelProperty(value = "分类id===团队id") + private Integer classificationId; + + +} diff --git a/nakadai/src/main/java/com/huoran/nakadai/mapper/PartnerAccountMapper.java b/nakadai/src/main/java/com/huoran/nakadai/mapper/PartnerAccountMapper.java index 2e43b14..5090fe1 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/mapper/PartnerAccountMapper.java +++ b/nakadai/src/main/java/com/huoran/nakadai/mapper/PartnerAccountMapper.java @@ -7,6 +7,7 @@ import com.huoran.nakadai.entity.PartnerAccount; import com.huoran.nakadai.entity.PartnerTeam; import com.huoran.nakadai.entity.req.PartnerAccountListReq; import com.huoran.nakadai.entity.res.PartnerAccountResp; +import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.util.ArrayList; @@ -20,6 +21,7 @@ import java.util.List; * @author chen * @since 2022-05-18 */ +@Mapper public interface PartnerAccountMapper extends BaseMapper { IPage pagePartnerAccountList(Page page, PartnerAccountListReq req); diff --git a/nakadai/src/main/java/com/huoran/nakadai/mapper/PlatformTeamAccountMapper.java b/nakadai/src/main/java/com/huoran/nakadai/mapper/PlatformTeamAccountMapper.java index 54cf0b6..a98a628 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/mapper/PlatformTeamAccountMapper.java +++ b/nakadai/src/main/java/com/huoran/nakadai/mapper/PlatformTeamAccountMapper.java @@ -28,7 +28,7 @@ public interface PlatformTeamAccountMapper extends BaseMapper platformTeamAccountMergeList(Page page, PlatformTeamAccountListReq req); - Integer selectAccount(@Param("phone") String phone,@Param("platformId") String platformId); + UserAccount selectAccount(@Param("phone") String phone,@Param("platformId") String platformId); UserAccount selectAccountByOpenId(@Param("openid") String openid,@Param("platformId") Integer platform); @@ -39,4 +39,6 @@ public interface PlatformTeamAccountMapper extends BaseMapper pagePlatformTeamAccountList(Page page, PlatformTeamAccountListReq req); void updateUserInfo(@Param("userId")Integer userId); + + void updateAccountOpenId(@Param("openid")String openid,@Param("accountId")Integer accountId); } 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 492dd7f..7eefe9f 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 @@ -6,6 +6,11 @@ SET last_login_time = now(), login_number = login_number + 1 WHERE user_id = #{userId} + + UPDATE hr_user_account + SET app_open_id = #{openid} + WHERE id = #{accountId} + - + SELECT * from hr_user_account WHERE is_del = 0 and platform_id = #{platformId} and phone = #{phone} diff --git a/nakadai/src/main/java/com/huoran/nakadai/service/PlatformTeamAccountService.java b/nakadai/src/main/java/com/huoran/nakadai/service/PlatformTeamAccountService.java index 13df417..c4a917c 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/service/PlatformTeamAccountService.java +++ b/nakadai/src/main/java/com/huoran/nakadai/service/PlatformTeamAccountService.java @@ -5,6 +5,7 @@ import com.huoran.nakadai.entity.PlatformTeamAccount; import com.baomidou.mybatisplus.extension.service.IService; import com.huoran.nakadai.entity.req.AccountRegisterReq; import com.huoran.nakadai.entity.req.AppletCallbackReq; +import com.huoran.nakadai.entity.req.InviteJoinInfo; import com.huoran.nakadai.entity.req.PlatformTeamAccountListReq; import javax.servlet.http.HttpServletResponse; @@ -31,4 +32,6 @@ public interface PlatformTeamAccountService extends IService redisTemplate; + + @Autowired + private PartnerAccountMapper partnerAccountMapper; + @Autowired private PlatformTeamClassificationMapper platformTeamClassificationMapper; @@ -102,10 +111,29 @@ public class PlatformTeamAccountServiceImpl extends ServiceImpl data = new HashedMap(); String randomNumbers = cn.hutool.core.util.RandomUtil.randomNumbers(6); Integer accountId ; @@ -187,6 +222,7 @@ public class PlatformTeamAccountServiceImpl extends ServiceImpl(). + eq("account_id", userAccount.getId())); + manageId = platformTeamAccount.getManageId(); + + //被邀请人有合伙人账号,判断是否已经存在当前团队中 + if (ObjectUtil.isNotNull(platformTeamAccount)){ + List platformTeamList = platformTeamMapper.selectList(new QueryWrapper(). + eq("manage_id", platformTeamAccount.getManageId())); + + + //查询团队下的成员是否存在团队中 + List teamMeb = platformTeamClassificationMapper.selectList(new QueryWrapper(). + eq("parent_id", inviteJoinInfo.getClassificationId())); + + for (PlatformTeam platformTeam : platformTeamList) { + for (PlatformTeamClassification platformTeamClassification : teamMeb) { + if (platformTeam!=null&&platformTeamClassification!=null){ + if (platformTeam.getClassificationId().equals(platformTeamClassification.getId())){ + throw new CustomException(ExceptionEnum.USER_ALREADY_EXISTS_GROUP); + } + } + } + } + } + }else { + //不存在创建账号,拉入组织 + AppletCallbackReq appletCallbackReq = new AppletCallbackReq(); + appletCallbackReq.setPlatformId(inviteJoinInfo.getPlatformId()); + appletCallbackReq.setPhone(inviteJoinInfo.getPhone()); + appletCallbackReq.setOpenId("0"); + R r = kindergartenWeChatApplication(appletCallbackReq); + Map data =(Map) r.get("data"); + Integer registerId =(Integer) data.get("registerId"); + //添加团队管理账号 + PlatformTeamAccount platformTeamAccount = new PlatformTeamAccount(); + platformTeamAccount.setAccountId(registerId); + platformTeamAccount.setPlatformId(inviteJoinInfo.getPlatformId()); + String username = partnerAccountMapper.selectUsername(inviteJoinInfo.getAccountId()); + platformTeamAccount.setInvitationAccount(username); + baseMapper.insert(platformTeamAccount); + + manageId = platformTeamAccount.getManageId(); + } + + PlatformTeamClassification platformTeamAdmin = platformTeamClassificationMapper.selectById(inviteJoinInfo.getClassificationId()); + //新增团队成员 + PlatformTeamClassification platformTeamMeb = new PlatformTeamClassification(); + platformTeamMeb.setIsTeam(0); + platformTeamMeb.setParentId(inviteJoinInfo.getClassificationId()); + platformTeamMeb.setLevel(platformTeamAdmin.getLevel() + 1); + platformTeamMeb.setClassificationName(platformTeamAdmin.getClassificationName()); + int insert = platformTeamClassificationMapper.insert(platformTeamMeb); + + //团队分类 + if (insert > 0) { + PlatformTeam platformTeam = new PlatformTeam(); + platformTeam.setManageId(manageId); + platformTeam.setClassificationId(platformTeamMeb.getId()); + platformTeamMapper.insert(platformTeam); + } + return insert > 0 ? R.ok() : R.error(); + + } + throw new CustomException(ExceptionEnum.CODE_ERROR); + } } From b4492a199a06a9c0c4513a86f10a2ad3736c60bf Mon Sep 17 00:00:00 2001 From: cheney <1251790704@qq.com> Date: Wed, 20 Dec 2023 18:05:10 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E7=99=BB=E5=BD=95=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=89=8B=E6=9C=BA=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nakadai/mapper/PlatformTeamAccountMapper.java | 2 ++ .../mapper/xml/PlatformTeamAccountMapper.xml | 5 +++++ .../impl/PlatformTeamAccountServiceImpl.java | 15 ++++++++++++--- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/nakadai/src/main/java/com/huoran/nakadai/mapper/PlatformTeamAccountMapper.java b/nakadai/src/main/java/com/huoran/nakadai/mapper/PlatformTeamAccountMapper.java index a98a628..d67d9ba 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/mapper/PlatformTeamAccountMapper.java +++ b/nakadai/src/main/java/com/huoran/nakadai/mapper/PlatformTeamAccountMapper.java @@ -41,4 +41,6 @@ public interface PlatformTeamAccountMapper extends BaseMapper + + UPDATE hr_user_account + SET phone = #{phone} + WHERE id = #{accountId} +