Merge remote-tracking branch 'origin/main' into main

main
rong.liu 12 months ago
commit 1bab75ece5
  1. 2
      common/src/main/java/com/huoran/common/entity/UserAccount.java
  2. 2
      common/src/main/java/com/huoran/common/entity/UserInfo.java
  3. 2
      common/src/main/java/com/huoran/common/utils/HttpClientUtils.java
  4. 4
      gateway/src/main/resources/jwt.properties
  5. 2
      nakadai/src/main/java/com/huoran/nakadai/NakadaiApplication.java
  6. 213
      nakadai/src/main/java/com/huoran/nakadai/controller/PlatformTeamAccountController.java
  7. 23
      nakadai/src/main/java/com/huoran/nakadai/controller/PlatformTeamClassificationController.java
  8. 23
      nakadai/src/main/java/com/huoran/nakadai/controller/PlatformTeamController.java
  9. 41
      nakadai/src/main/java/com/huoran/nakadai/entity/PlatformTeam.java
  10. 47
      nakadai/src/main/java/com/huoran/nakadai/entity/PlatformTeamAccount.java
  11. 85
      nakadai/src/main/java/com/huoran/nakadai/entity/PlatformTeamClassification.java
  12. 8
      nakadai/src/main/java/com/huoran/nakadai/entity/UserAccount.java
  13. 47
      nakadai/src/main/java/com/huoran/nakadai/entity/req/AccountRegisterReq.java
  14. 28
      nakadai/src/main/java/com/huoran/nakadai/entity/req/AppletCallbackReq.java
  15. 39
      nakadai/src/main/java/com/huoran/nakadai/entity/req/PlatformTeamAccountListReq.java
  16. 97
      nakadai/src/main/java/com/huoran/nakadai/entity/res/PlatformTeamAccountResp.java
  17. 98
      nakadai/src/main/java/com/huoran/nakadai/entity/res/TeamAccountResp.java
  18. 2
      nakadai/src/main/java/com/huoran/nakadai/mapper/HrStaffMapper.java
  19. 2
      nakadai/src/main/java/com/huoran/nakadai/mapper/PartnerClassificationMapper.java
  20. 2
      nakadai/src/main/java/com/huoran/nakadai/mapper/PartnerTeamMapper.java
  21. 39
      nakadai/src/main/java/com/huoran/nakadai/mapper/PlatformTeamAccountMapper.java
  22. 20
      nakadai/src/main/java/com/huoran/nakadai/mapper/PlatformTeamClassificationMapper.java
  23. 18
      nakadai/src/main/java/com/huoran/nakadai/mapper/PlatformTeamMapper.java
  24. 136
      nakadai/src/main/java/com/huoran/nakadai/mapper/xml/PlatformTeamAccountMapper.xml
  25. 29
      nakadai/src/main/java/com/huoran/nakadai/mapper/xml/PlatformTeamClassificationMapper.xml
  26. 5
      nakadai/src/main/java/com/huoran/nakadai/mapper/xml/PlatformTeamMapper.xml
  27. 34
      nakadai/src/main/java/com/huoran/nakadai/service/PlatformTeamAccountService.java
  28. 16
      nakadai/src/main/java/com/huoran/nakadai/service/PlatformTeamClassificationService.java
  29. 16
      nakadai/src/main/java/com/huoran/nakadai/service/PlatformTeamService.java
  30. 223
      nakadai/src/main/java/com/huoran/nakadai/service/impl/PlatformTeamAccountServiceImpl.java
  31. 20
      nakadai/src/main/java/com/huoran/nakadai/service/impl/PlatformTeamClassificationServiceImpl.java
  32. 20
      nakadai/src/main/java/com/huoran/nakadai/service/impl/PlatformTeamServiceImpl.java
  33. 18
      nakadai/src/main/java/com/huoran/nakadai/utils/WeChatPropertiesUtil.java
  34. 26
      nakadai/src/main/resources/bootstrap.properties
  35. 8
      nakadai/src/test/java/com/huoran/nakadai/code/CodeGenerator.java
  36. 16
      users/src/main/java/com/huoran/users/config/WeChatPropertiesUtil.java
  37. 22
      users/src/main/java/com/huoran/users/controller/UserLoginController.java
  38. 44
      users/src/main/java/com/huoran/users/entity/req/AccountRegisterReq.java
  39. 9
      users/src/main/java/com/huoran/users/entity/req/AppletCallbackReq.java
  40. 2
      users/src/main/java/com/huoran/users/entity/vo/LoginVo.java
  41. 8
      users/src/main/java/com/huoran/users/mapper/HrUserInfoMapper.java
  42. 2
      users/src/main/java/com/huoran/users/mapper/RoleMapper.java
  43. 21
      users/src/main/java/com/huoran/users/mapper/xml/HrUserInfoMapper.xml
  44. 5
      users/src/main/java/com/huoran/users/service/IHrUserInfoService.java
  45. 98
      users/src/main/java/com/huoran/users/service/impl/HrUserInfoServiceImpl.java
  46. 7
      users/src/main/resources/bootstrap.properties

@ -81,6 +81,8 @@ public class UserAccount implements Serializable {
@TableField(exist = false) @TableField(exist = false)
private String userName; private String userName;
@ApiModelProperty(value = "小程序id")
private String appOpenId;
@ApiModelProperty(value = "绑定时间") @ApiModelProperty(value = "绑定时间")
private String phoneBindingTime; private String phoneBindingTime;

@ -76,7 +76,7 @@ public class UserInfo implements Serializable {
private Integer isDel; private Integer isDel;
@ApiModelProperty(value = "最后登陆时间") @ApiModelProperty(value = "最后登陆时间")
private String lastLoginTime; private Date lastLoginTime;
@ApiModelProperty(value = "绑定多个角色id") @ApiModelProperty(value = "绑定多个角色id")
private String roleId; private String roleId;

@ -1,4 +1,4 @@
package com.huoran.users.utils; package com.huoran.common.utils;
import org.apache.http.NameValuePair; import org.apache.http.NameValuePair;
import org.apache.http.client.config.RequestConfig; import org.apache.http.client.config.RequestConfig;

@ -99,4 +99,6 @@ jwt.ignoreUrlList=/users/users/user/captcha,\
/nakadai/nakadai/subject/subjectCategoryCited,\ /nakadai/nakadai/subject/subjectCategoryCited,\
/nakadai/productType/productTypeList,\ /nakadai/productType/productTypeList,\
/nakadai/tags/tagsList,\ /nakadai/tags/tagsList,\
/nakadai/nakadai/partner/schemeManagement/schemeList /nakadai/nakadai/partner/schemeManagement/schemeList,\
/nakadai/kindergarten/platformTeamAccount/weChatAppletCallbackByKindergarten,\
/nakadai/kindergarten/platformTeamAccount/kindergartenWeChatApplication

@ -17,7 +17,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
//@EnableRabbit//开启rabbitmq //@EnableRabbit//开启rabbitmq
@EnableFeignClients(basePackages = "com.huoran.api") @EnableFeignClients(basePackages = "com.huoran.api")
@MapperScan(basePackages = "com.huoran.nakadai.mapper") @MapperScan(basePackages = "com.huoran.nakadai.mapper")
@ComponentScan(basePackages = {"com.huoran","com.huoran.nakadai.config.interceptor"}) @ComponentScan(basePackages = {"com.huoran"})
public class NakadaiApplication { public class NakadaiApplication {
public static void main(String[] args) { public static void main(String[] args) {

@ -0,0 +1,213 @@
package com.huoran.nakadai.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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.*;
import com.huoran.nakadai.entity.req.*;
import com.huoran.nakadai.entity.res.PartnerAccountResp;
import com.huoran.nakadai.entity.res.PlatformTeamAccountResp;
import com.huoran.nakadai.entity.vo.TeamMemberVo;
import com.huoran.nakadai.service.*;
import com.huoran.nakadai.utils.GenerateCodeUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
/**
* <p>
* 幼教产业平台团队账号表
* </p>
*
* @author chen
* @since 2023-12-12
*/
@Api(tags = "幼教产业平台幼儿园与供应商团队账号管理")
@RestController
@RequestMapping("/kindergarten/platformTeamAccount")
public class PlatformTeamAccountController {
@Autowired
public PlatformTeamAccountService platformTeamAccountService;
@Autowired
public PlatformTeamService platformTeamService;
@Autowired
public PlatformTeamClassificationService platformTeamClassificationService;
@Autowired
private RedisTemplate<String, String> redisTemplate;
@PostMapping("/generateInvitationCode")
@ApiOperation(value = "生成不同平台专属邀请码")
public R generateInvitationCode(
@ApiParam(name = "platformId", value = "平台id", required = true)
@RequestParam("platformId") String platformId,HttpServletRequest request) {
//平台唯一标识码
String uniqueIdentification = platformId+TokenUtils.getIdByJwtToken(request)+"kindergartenInvitationCode";
//存在直接返回邀请码
String code = redisTemplate.opsForValue().get(uniqueIdentification);
if (StringUtils.isEmpty(code)){
code = GenerateCodeUtil.generateCode();
redisTemplate.opsForValue().set(uniqueIdentification,code,7, TimeUnit.DAYS);
}
//过期时间
Long expireTime = redisTemplate.opsForValue().getOperations().getExpire(uniqueIdentification);
return Objects.requireNonNull(R.ok().put("invitationCode", code)).put("expireTime",expireTime);
}
@ApiOperation(value = "平台邀请二维码生成")
@GetMapping(value = "/generationQrCode",produces = "image/png")
public void generationQrCode(
@ApiParam(name = "url", value = "链接", required = true)
@RequestParam String url, HttpServletResponse response){
platformTeamAccountService.generationQrCode(url,response);
}
// @PostMapping("/platformTeamAccountMergeList")
// @ApiOperation(value = "平台团队账号列表--合并数据查询(以账号为维度查询合并-后台调用)", response = PlatformTeamAccountResp.class)
// public R partnerAccountMergeList(@RequestBody @Valid PlatformTeamAccountListReq req) {
// return platformTeamAccountService.platformTeamAccountMergeList(req);
// }
// @PostMapping("/teamPartnerList")
// @ApiOperation(value = "团队合伙人列表(以团队维度查询-小程序调用)", response = PlatformTeamAccountResp.class)
// public R teamPartnerList(@RequestBody @Valid PlatformTeamAccountListReq req) {
// return platformTeamAccountService.teamPartnerList(req);
// }
// @PostMapping("/queryTeamMembers")
// @ApiOperation(value = "查询团队成员", response = PlatformTeamAccountResp.class)
// public R queryTeamMembers(@RequestBody TeamMemberVo teamMemberVo) {
// return platformTeamAccountService.queryTeamMembers(teamMemberVo);
// }
// @GetMapping("/partnerAccountDetail")
// // @ApiOperation(value = "合伙人账号详情", response = PlatformTeamAccountResp.class)
// public R partnerAccountDetail(@ApiParam(name = "accountId", value = "合伙人账号账号id")
// @RequestParam Integer accountId) {
// return platformTeamAccountService.partnerAccountDetail(accountId);
// }
// @PostMapping("/modifyPartnerAccount")
// // @ApiOperation(value = "编辑合伙人账号")
// public R modifyPartnerAccount(@RequestBody @Valid PartnerAccountUpdateReq updateReq) {
// return platformTeamAccountService.modifyPartnerAccount(updateReq);
// }
// @PostMapping("/generateTransferCode")
// @ApiOperation(value = "生成转让邀请码")
// public R generateTransferCode(@RequestParam("accountId") String accountId) {
// //存在直接返回邀请码
// String code = redisTemplate.opsForValue().get(accountId+"transferCode");
// if (StringUtils.isEmpty(code)){
// code = GenerateCodeUtil.generateCode();
// redisTemplate.opsForValue().set(accountId+"transferCode",code,1, TimeUnit.DAYS);
// }
// //过期时间
// Long expireTime = redisTemplate.opsForValue().getOperations().getExpire(accountId+"transferCode");
// return R.ok().put("transferCode",code).put("expireTime",expireTime);
// }
// @PostMapping("/transferAdmin")
// @ApiOperation(value = "新增转让超管")
// public R transferAdmin(@RequestBody @Valid TransferAdminReq transferAdminReq) {
// return platformTeamAccountService.transferAdmin(transferAdminReq);
// }
// @PostMapping("/transferTeam")
// @ApiOperation(value = "团队内转让超管")
// public R transferTeam(@RequestBody @Valid TransferTeamReq transferTeamReq) {
// return platformTeamAccountService.transferTeam(transferTeamReq);
// }
// @PostMapping("/delPartnerAccount")
// @ApiOperation(value = "删除合伙人")
// public R delPartnerAccount(
// @ApiParam(name = "accountId", value = "账号id")
// @RequestParam Integer accountId) {
// return platformTeamAccountService.delPartnerAccount(accountId);
// }
// @GetMapping("/partnerRemoval")
// @ApiOperation(value = "移除团队")
// public R partnerRemoval(
// @ApiParam(name = "teamId", value = "团队id")
// @RequestParam String teamId,
// @ApiParam(name = "partnerId", value = "合伙人id")
// @RequestParam String partnerId) {
// PartnerClassification partnerClassification = partnerClassificationService.getById(teamId);
// if (partnerClassification.getIsTeam() == 1) {
// throw new CustomException(ExceptionEnum.PARTNER_REMOVAL);
// }
// PartnerAccount partnerAccount = platformTeamAccountService.getById(partnerId);
// //删除团队成员
// partnerClassificationService.removeById(Integer.parseInt(teamId));
// //同步删除该团队相关角色信息
// partnerClassificationService.removeRole(teamId,partnerAccount.getAccountId());
// return partnerTeamService.remove(new QueryWrapper<PartnerTeam>().
// eq("partner_id", partnerId).
// eq("classification_id", teamId)) ? R.ok() : R.error();
// }
// @ApiOperation(value = "查询合伙人账号信息")
// @PostMapping("/queryPartnerAccount")
// public R queryPartnerAccount(@RequestParam String phone) {
// return platformTeamAccountService.queryPartnerAccount(phone);
// }
//================================以下接口为小程序调用===================================
@ApiOperation(value = "幼教产品微信小程序回调登录")
@PostMapping("/weChatAppletCallbackByKindergarten")
public R weChatAppletCallbackByKindergarten(@RequestBody @Valid AppletCallbackReq appletCallbackReq, HttpServletResponse response) throws Exception {
Map<String ,Object> result = platformTeamAccountService.kindergartenWeChatAccountApplication(appletCallbackReq);
return R.ok().put("data",result);
}
@ApiOperation(value = "幼教产品微信小程序账号注册(根据openid)")
@PostMapping("/kindergartenWeChatApplication")
public R kindergartenWeChatApplication(@RequestBody @Valid AppletCallbackReq appletCallbackReq) {
return platformTeamAccountService.kindergartenWeChatApplication(appletCallbackReq);
}
@ApiOperation(value = "获取当前平台用户的团队信息", response = PartnerAccountResp.class)
@GetMapping("/getTeamsByPlatformId")
public R getTeamsByPlatformId(
@ApiParam(name = "platformId", value = "平台id")
@RequestParam Integer platformId,HttpServletRequest request) {
String accountId = TokenUtils.getIdByJwtToken(request);
return platformTeamAccountService.getTeamsByPlatformId(accountId,platformId);
}
@PostMapping("/platformTeamAccountList")
@ApiOperation(value = "小程序根据不同平台查询分类下所有团队及成员", response = PlatformTeamAccountResp.class)
public R platformTeamAccountList(@RequestBody @Valid PlatformTeamAccountListReq req) {
return platformTeamAccountService.pagePlatformTeamAccountList(req);
}
}

@ -0,0 +1,23 @@
package com.huoran.nakadai.controller;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 幼教产业平台团队分类表 前端控制器
* </p>
*
* @author chen
* @since 2023-12-12
*/
@Api(tags = "幼教产业平台幼儿园与供应商团队分类管理")
@RestController
@RequestMapping("/kindergarten/platformTeamClassification")
public class PlatformTeamClassificationController {
}

@ -0,0 +1,23 @@
package com.huoran.nakadai.controller;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 幼教产业团队账号与分类中间表 前端控制器
* </p>
*
* @author chen
* @since 2023-12-12
*/
@Api(tags = "幼教产业平台幼儿园与供应商团队管理")
@RestController
@RequestMapping("/kindergarten/platformTeam")
public class PlatformTeamController {
}

@ -0,0 +1,41 @@
package com.huoran.nakadai.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
* 幼教产业团队账号与分类中间表
* </p>
*
* @author chen
* @since 2023-12-12
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("k_platform_team")
@ApiModel(value="PlatformTeam对象", description="幼教产业团队账号与分类中间表")
public class PlatformTeam implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "团队主键id")
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@ApiModelProperty(value = "团队账号主键id")
private Integer manageId;
@ApiModelProperty(value = "团队分类id")
private Integer classificationId;
}

@ -0,0 +1,47 @@
package com.huoran.nakadai.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
* 幼教产业平台团队账号表
* </p>
*
* @author chen
* @since 2023-12-12
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("k_platform_team_account")
@ApiModel(value="PlatformTeamAccount对象", description="幼教产业平台团队账号表")
public class PlatformTeamAccount implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键ID")
@TableId(value = "manage_id", type = IdType.AUTO)
private Integer manageId;
@ApiModelProperty(value = "绑定账号id")
private Integer accountId;
@ApiModelProperty(value = "邀请账号")
private String invitationAccount;
@ApiModelProperty(value = "是否删除(0、未删除 1、已删除)")
private Integer isDel;
@ApiModelProperty(value = "平台id")
private Integer platformId;
}

@ -0,0 +1,85 @@
package com.huoran.nakadai.entity;
import com.baomidou.mybatisplus.annotation.*;
import java.util.Date;
import java.io.Serializable;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
* 幼教产业平台团队分类表
* </p>
*
* @author chen
* @since 2023-12-12
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("k_platform_team_classification")
@ApiModel(value="PlatformTeamClassification对象", description="幼教产业平台团队分类表")
public class PlatformTeamClassification implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键")
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@ApiModelProperty(value = "团队分类名称")
private String classificationName;
@ApiModelProperty(value = "父id 一级为0", example = "0", name = "parentId")
private Integer parentId;
@ApiModelProperty(value = "层级")
private Integer level;
@ApiModelProperty(value = "子级")
@TableField(exist = false)
private List<PartnerClassification> children;
@ApiModelProperty(value = "层级拼接")
@TableField(exist = false)
private String splicingLevel;
@ApiModelProperty(value = "logo_url")
private String logo_url;
@ApiModelProperty(value = "地址")
private String address;
@ApiModelProperty(value = "简介")
private String briefIntroduction;
@ApiModelProperty(value = "更新时间")
@TableField(fill = FieldFill.INSERT_UPDATE)
@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd")
private Date updateTime;
@ApiModelProperty(value = "创建时间")
@TableField(fill = FieldFill.INSERT)
@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd")
private Date createTime;
@ApiModelProperty(value = "逻辑删除")
@TableLogic
private Integer isDel;
@ApiModelProperty(value = "是否为团队(默认0不是团体,1为团队)")
private Integer isTeam;
@ApiModelProperty(value = "团队主键id")
@TableField(exist = false)
private Integer manageId;
}

@ -51,12 +51,18 @@ public class UserAccount implements Serializable {
@ApiModelProperty(value = "所属平台id") @ApiModelProperty(value = "所属平台id")
private String platformId; private String platformId;
@ApiModelProperty(value = "所属平台id") @ApiModelProperty(value = "小程序id")
private String appOpenId; private String appOpenId;
@ApiModelProperty(value = "开放平台与公众平台唯一id")
private String unionid;
@ApiModelProperty(value = "平台(系统)绑定时间") @ApiModelProperty(value = "平台(系统)绑定时间")
private Date platformBindTime; private Date platformBindTime;
@ApiModelProperty(value = "手机绑定时间")
private Date phoneBindingTime;
@ApiModelProperty(value = "平台端区分:0->教师端 1->学生端 2->无端") @ApiModelProperty(value = "平台端区分:0->教师端 1->学生端 2->无端")
private Integer type; private Integer type;

@ -0,0 +1,47 @@
package com.huoran.nakadai.entity.req;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
@Data
public class AccountRegisterReq {
@ApiModelProperty(value = "姓名")
private String userName;
@ApiModelProperty(value = "账号")
private String account;
@ApiModelProperty(value = "密码")
private String password;
@ApiModelProperty(value = "平台id")
@NotNull(message = "请选择平台注册!")
private String platformId;
@ApiModelProperty(value = "唯一标识账号")
@NotNull(message = "唯一标识不能为空!")
private String uniqueIdentification;
@ApiModelProperty(value = "手机号")
@NotNull(message = "手机号不能为空")
private String phone;
@ApiModelProperty(value = "邮箱")
private String email;
@ApiModelProperty(value = "小程序openid")
private String appOpenId;
// @ApiModelProperty(value = "意向省份")
// private Integer provinceId;
//
// @ApiModelProperty(value = "意向城市")
// private Integer cityId;
//
// @ApiModelProperty(value = "openId")
// private String openId;
}

@ -0,0 +1,28 @@
package com.huoran.nakadai.entity.req;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
/**
* @Author chen
* @DATE 2022/7/12 15:03
* @Version 1.0
*/
@Data
public class AppletCallbackReq {
@ApiModelProperty("微信code")
private String code;
@ApiModelProperty("平台标识:5幼儿园,6供应商,7个人端")
private Integer platformId;
@ApiModelProperty("唯一标识")
private String openId;
@ApiModelProperty("手机号")
private String phone;
}

@ -0,0 +1,39 @@
package com.huoran.nakadai.entity.req;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
/**
* @Author chen
* @DATE 2022/5/18 17:15
* @Version 1.0
*/
@Data
public class PlatformTeamAccountListReq {
@ApiModelProperty(value = "类型:必填一个(1.有团队 2.未加入团队)", required = true, example = "1")
private Integer type;
@ApiModelProperty(value = "搜索关键词", example = "1")
private String keyWord;
@ApiModelProperty(value = "分类主键ID", example = "2")
@NotNull(message = "先选择分类/团队进行查询!")
private String classificationId;
@ApiModelProperty(value = "平台ID", example = "5")
@NotNull(message = "平台ID不能为空")
private String platformId;
@ApiModelProperty(value = "当前页数", name = "pageNum", example = "1", required = true)
private Integer pageNum;
@ApiModelProperty(value = "当前页需要显示的数量", name = "pageSize", example = "10", required = true)
private Integer pageSize;
//合伙人id
private ArrayList<Integer> ids;
}

@ -0,0 +1,97 @@
package com.huoran.nakadai.entity.res;
import com.huoran.nakadai.entity.PartnerClassification;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
import java.util.List;
/**
* @Author chen
* @DATE 2022/5/18 17:04
* @Version 1.0
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "platformTeamAccountResp", description = "平台团队列表")
public class PlatformTeamAccountResp {
@ApiModelProperty(value = "主键IDd")
private Integer manageId;
@ApiModelProperty(value = "父id")
private Integer parentId;
@ApiModelProperty(value = "邀请人")
private String invitationAccount;
@ApiModelProperty(value = "分类id")
private String classificationId;
@ApiModelProperty(value = "分类名称(团队名称)")
private String classificationName;
@ApiModelProperty(value = "账号id")
private Integer accountId;
@ApiModelProperty(value = "职工姓名")
private String userName;
@ApiModelProperty(value = "职工工号")
private String workNumber;
@ApiModelProperty(value = "唯一标识账号")
private String uniqueIdentification;
@ApiModelProperty("用户头像路径")
private String userAvatars;
@ApiModelProperty(value = "电话")
private String phone;
@ApiModelProperty(value = "邮箱")
private String email;
//用于列表逗号隔开展示
@ApiModelProperty(value = "角色")
private String roleName;
@ApiModelProperty(value = "角色id")
private String roleId;
@ApiModelProperty(value = "账号")
private String account;
@ApiModelProperty(value = "登陆次数")
private Integer loginNumber;
@ApiModelProperty(value = "最后登陆时间")
private String lastLoginTime;
@ApiModelProperty(value = "用户id")
private Integer userId;
@ApiModelProperty(value = "团队id")
private Integer teamId;
@ApiModelProperty(value = "商务经理ids")
private List<Integer> businessManagerIds;
// @ApiModelProperty(value = "团队信息")
// private PartnerClassification partnerClassificationList;
@ApiModelProperty(value = "是否是团队")
private String isTeam;
@ApiModelProperty(value = "团队数")
private Integer teamSize;
@ApiModelProperty(value = "团队名称")
private String teamName;
}

@ -0,0 +1,98 @@
package com.huoran.nakadai.entity.res;
import com.huoran.nakadai.entity.PartnerClassification;
import com.huoran.nakadai.entity.PlatformTeamClassification;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
import java.util.List;
/**
* @Author chen
* @DATE 2022/5/18 17:04
* @Version 1.0
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "TeamAccountResp", description = "平台团队列表")
public class TeamAccountResp {
@ApiModelProperty(value = "团队管理id")
private Integer manageId;
@ApiModelProperty(value = "父id")
private Integer parentId;
@ApiModelProperty(value = "邀请人")
private String invitationAccount;
@ApiModelProperty(value = "团队分类id")
private String classificationId;
@ApiModelProperty(value = "合伙人分类名称(团队名称)")
private String classificationName;
@ApiModelProperty(value = "账号id")
private Integer accountId;
@ApiModelProperty(value = "职工姓名")
private String userName;
@ApiModelProperty(value = "职工工号")
private String workNumber;
@ApiModelProperty(value = "唯一标识账号")
private String uniqueIdentification;
@ApiModelProperty("用户头像路径")
private String userAvatars;
@ApiModelProperty(value = "电话")
private String phone;
@ApiModelProperty(value = "邮箱")
private String email;
//用于列表逗号隔开展示
@ApiModelProperty(value = "角色")
private String roleName;
@ApiModelProperty(value = "角色id")
private String roleId;
@ApiModelProperty(value = "账号")
private String account;
@ApiModelProperty(value = "登陆次数")
private Integer loginNumber;
@ApiModelProperty(value = "最后登陆时间")
private String lastLoginTime;
@ApiModelProperty(value = "用户id")
private Integer userId;
@ApiModelProperty(value = "团队id")
private Integer teamId;
@ApiModelProperty(value = "团队信息")
private PlatformTeamClassification platformTeamClassificationList;
@ApiModelProperty(value = "是否是团队")
private String isTeam;
@ApiModelProperty(value = "区域")
private String area;
@ApiModelProperty(value = "团队数")
private Integer teamSize;
@ApiModelProperty(value = "团队名称")
private String teamName;
}

@ -8,6 +8,7 @@ import com.huoran.nakadai.entity.UserAccount;
import com.huoran.nakadai.entity.UserInfo; import com.huoran.nakadai.entity.UserInfo;
import com.huoran.nakadai.entity.req.StaffListReq; import com.huoran.nakadai.entity.req.StaffListReq;
import com.huoran.nakadai.entity.res.StaffResp; import com.huoran.nakadai.entity.res.StaffResp;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@ -20,6 +21,7 @@ import java.util.List;
* @author chen * @author chen
* @since 2022-03-22 * @since 2022-03-22
*/ */
@Mapper
public interface HrStaffMapper extends BaseMapper<HrStaff> { public interface HrStaffMapper extends BaseMapper<HrStaff> {
int addUserInfo(UserInfo userInfo); int addUserInfo(UserInfo userInfo);

@ -3,6 +3,7 @@ package com.huoran.nakadai.mapper;
import com.huoran.nakadai.entity.PartnerClassification; import com.huoran.nakadai.entity.PartnerClassification;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.huoran.nakadai.entity.res.TeamInformationResp; import com.huoran.nakadai.entity.res.TeamInformationResp;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@ -15,6 +16,7 @@ import java.util.List;
* @author chen * @author chen
* @since 2022-05-18 * @since 2022-05-18
*/ */
@Mapper
public interface PartnerClassificationMapper extends BaseMapper<PartnerClassification> { public interface PartnerClassificationMapper extends BaseMapper<PartnerClassification> {
List<Integer> selectIdByPid(@Param("id") Integer id,@Param("type") Integer type); List<Integer> selectIdByPid(@Param("id") Integer id,@Param("type") Integer type);

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.huoran.nakadai.entity.PartnerTeam; import com.huoran.nakadai.entity.PartnerTeam;
import com.huoran.nakadai.entity.res.PartnerAccountResp; import com.huoran.nakadai.entity.res.PartnerAccountResp;
import com.huoran.nakadai.entity.res.UserInfoByPhoneRes; import com.huoran.nakadai.entity.res.UserInfoByPhoneRes;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@ -16,6 +17,7 @@ import java.util.List;
* @author chen * @author chen
* @since 2022-05-18 * @since 2022-05-18
*/ */
@Mapper
public interface PartnerTeamMapper extends BaseMapper<PartnerTeam> { public interface PartnerTeamMapper extends BaseMapper<PartnerTeam> {
List<Integer> getMembersUnderTheSameTeam(Integer classificationId); List<Integer> getMembersUnderTheSameTeam(Integer classificationId);

@ -0,0 +1,39 @@
package com.huoran.nakadai.mapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.huoran.nakadai.entity.PlatformTeamAccount;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.huoran.nakadai.entity.UserAccount;
import com.huoran.nakadai.entity.req.PlatformTeamAccountListReq;
import com.huoran.nakadai.entity.res.PlatformTeamAccountResp;
import com.huoran.nakadai.entity.res.TeamAccountResp;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.ArrayList;
import java.util.List;
/**
* <p>
* 幼教产业平台团队账号表 Mapper 接口
* </p>
*
* @author chen
* @since 2023-12-12
*/
@Mapper
public interface PlatformTeamAccountMapper extends BaseMapper<PlatformTeamAccount> {
IPage<PlatformTeamAccountResp> platformTeamAccountMergeList(Page<PlatformTeamAccountResp> page, PlatformTeamAccountListReq req);
Integer selectAccount(@Param("phone") String phone,@Param("platformId") String platformId);
UserAccount selectAccountByOpenId(@Param("openid") String openid,@Param("platformId") Integer platform);
List<TeamAccountResp> getTeamsByPlatformId(@Param("accountId")String accountId,@Param("platformId") Integer platformId);
ArrayList<Integer> selectTeamIdByClassificationId(@Param("classificationId")String classificationId);
IPage<PlatformTeamAccountResp> pagePlatformTeamAccountList(Page<PlatformTeamAccountResp> page, PlatformTeamAccountListReq req);
}

@ -0,0 +1,20 @@
package com.huoran.nakadai.mapper;
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;
/**
* <p>
* 幼教产业平台团队分类表 Mapper 接口
* </p>
*
* @author chen
* @since 2023-12-12
*/
@Mapper
public interface PlatformTeamClassificationMapper extends BaseMapper<PlatformTeamClassification> {
PlatformTeamClassification getParentInformationBasedOnChild(@Param("id") String classificationId);
}

@ -0,0 +1,18 @@
package com.huoran.nakadai.mapper;
import com.huoran.nakadai.entity.PlatformTeam;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* <p>
* 幼教产业团队账号与分类中间表 Mapper 接口
* </p>
*
* @author chen
* @since 2023-12-12
*/
@Mapper
public interface PlatformTeamMapper extends BaseMapper<PlatformTeam> {
}

@ -0,0 +1,136 @@
<?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">
<mapper namespace="com.huoran.nakadai.mapper.PlatformTeamAccountMapper">
<select id="platformTeamAccountMergeList"
resultType="com.huoran.nakadai.entity.res.PlatformTeamAccountResp">
SELECT
hpa.manage_id,
hpa.invitation_account,
u.user_name,
u.last_login_time,
u.login_number,
a.work_number,
a.user_id,
a.phone,
hpa.account_id,
a.account,
GROUP_CONCAT( pc.id SEPARATOR ',' ) as classificationId,
GROUP_CONCAT( pc.classification_name SEPARATOR ',' ) as classificationName
FROM
k_platform_team_account hpa
INNER JOIN hr_user_account a ON a.id = hpa.account_id
INNER JOIN hr_user_info u ON u.user_id = a.user_id
left join k_platform_team pt on hpa.manage_id = pt.manage_id
left join k_platform_team_classification pc on pt.classification_id = pc.id and pc.is_del = 0
where a.is_del = 0 and u.is_del = 0 and hpa.platform_id = #{req.platformId}
<if test="req.keyWord != '' and req.keyWord != null">
AND CONCAT(u.user_name LIKE '%' #{req.keyWord} '%' or a.phone LIKE '%' #{req.keyWord} '%')
</if>
GROUP BY
hpa.account_id
<if test="req.type == 2">
having
partnerClassificationId is null
</if>
ORDER BY
hpa.manage_id DESC
</select>
<select id="selectAccount" resultType="java.lang.Integer">
SELECT id
from hr_user_account
WHERE is_del = 0 and platform_id = #{platformId} and phone = #{phone}
</select>
<select id="selectAccountByOpenId" resultType="com.huoran.nakadai.entity.UserAccount">
SELECT *
from hr_user_account
WHERE is_del = 0 and platform_id = #{platformId} and app_open_id = #{openid}
</select>
<select id="getTeamsByPlatformId" resultType="com.huoran.nakadai.entity.res.TeamAccountResp">
SELECT
t.manage_id,
c.id AS classificationId,
c.parent_id,
a.account_id,
c.is_team,
(
SELECT
u.user_name
FROM
hr_user_info u
INNER JOIN hr_user_account ua
WHERE
ua.user_id = u.user_id
AND a.account_id = ua.id
) AS userName
FROM
k_platform_team t
INNER JOIN k_platform_team_classification c ON c.id = t.classification_id
INNER JOIN k_platform_team_account a ON a.manage_id = t.manage_id
WHERE
c.is_del = 0
AND a.is_del = 0 and a.platform_id = #{platformId}
AND account_id = #{accountId}
</select>
<select id="selectTeamIdByClassificationId" resultType="java.lang.Integer">
SELECT
DATA.id
FROM
(
SELECT
@ids AS _ids,
( SELECT @ids := GROUP_CONCAT( id ) FROM k_platform_team_classification WHERE FIND_IN_SET( parent_id, @ids ) ) AS cids,
@l := @l + 1 AS LEVEL
FROM
k_platform_team_classification,
( SELECT @ids := #{classificationId}, @l := 0 ) b
WHERE
@ids IS NOT NULL
) ID,
k_platform_team_classification DATA
WHERE
FIND_IN_SET( DATA.id, ID._ids )
ORDER BY
id DESC
</select>
<select id="pagePlatformTeamAccountList"
resultType="com.huoran.nakadai.entity.res.PlatformTeamAccountResp">
SELECT
hpa.manage_id,
hpa.invitation_account,
u.user_name,
u.last_login_time,
u.login_number,
a.work_number,
a.user_id,
a.phone,
hpa.account_id,
a.account,
pc.classification_name as teamName,
pc.id as partnerClassificationId,
pc.is_team,
u.user_avatars,pc.parent_id
FROM
k_platform_team_account hpa
left join k_platform_team pt on hpa.manage_id = pt.manage_id
left JOIN k_platform_team_classification pc ON pt.classification_id = pc.id
left JOIN acl_user_role ur on ur.is_del = 0 AND ur.team_id = pc.id and ur.account_id = hpa.account_id
left JOIN acl_role r ON r.id = ur.role_id
left JOIN hr_user_account a ON a.id = hpa.account_id
left JOIN hr_user_info u ON u.user_id = a.user_id
WHERE a.is_del = 0
AND u.is_del = 0 and pc.is_del = 0
<if test="req.keyWord != '' and req.keyWord != null">
AND CONCAT(u.user_name LIKE '%' #{req.keyWord} '%' or a.phone LIKE '%' #{req.keyWord} '%')
</if>
<if test="req.ids != null and req.ids.size > 0">
and pc.id in
<foreach collection="req.ids" open="(" separator="," close=")" item="ids">
#{ids}
</foreach>
</if>
GROUP BY pc.id
ORDER BY hpa.manage_id DESC
</select>
</mapper>

@ -0,0 +1,29 @@
<?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">
<mapper namespace="com.huoran.nakadai.mapper.PlatformTeamClassificationMapper">
<select id="getParentInformationBasedOnChild"
resultType="com.huoran.nakadai.entity.PlatformTeamClassification">
SELECT
T2.id,
T2.classification_name,
T2.is_team
FROM
(
SELECT
@r AS _id,
( SELECT @r := parent_id FROM k_platform_team_classification WHERE id = _id ) AS parent_id,
@l := @l + 1 AS lvl
FROM
( SELECT @r := #{id}, @l := 0 ) vars,
k_platform_team_classification h
WHERE
@r != 0
) T1
JOIN k_platform_team_classification T2 ON T1._id = T2.id
WHERE
is_team = 1
ORDER BY
T1.lvl DESC
</select>
</mapper>

@ -0,0 +1,5 @@
<?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">
<mapper namespace="com.huoran.nakadai.mapper.PlatformTeamMapper">
</mapper>

@ -0,0 +1,34 @@
package com.huoran.nakadai.service;
import com.huoran.common.response.R;
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.PlatformTeamAccountListReq;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;
/**
* <p>
* 幼教产业平台团队账号表 服务类
* </p>
*
* @author chen
* @since 2023-12-12
*/
public interface PlatformTeamAccountService extends IService<PlatformTeamAccount> {
void generationQrCode(String url, HttpServletResponse response);
R platformTeamAccountMergeList(PlatformTeamAccountListReq req);
Map<String, Object> kindergartenWeChatAccountApplication(AppletCallbackReq appletCallbackReq) throws Exception;
R kindergartenWeChatApplication(AppletCallbackReq appletCallbackReq);
R getTeamsByPlatformId(String accountId, Integer platformId);
R pagePlatformTeamAccountList(PlatformTeamAccountListReq req);
}

@ -0,0 +1,16 @@
package com.huoran.nakadai.service;
import com.huoran.nakadai.entity.PlatformTeamClassification;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 幼教产业平台团队分类表 服务类
* </p>
*
* @author chen
* @since 2023-12-12
*/
public interface PlatformTeamClassificationService extends IService<PlatformTeamClassification> {
}

@ -0,0 +1,16 @@
package com.huoran.nakadai.service;
import com.huoran.nakadai.entity.PlatformTeam;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 幼教产业团队账号与分类中间表 服务类
* </p>
*
* @author chen
* @since 2023-12-12
*/
public interface PlatformTeamService extends IService<PlatformTeam> {
}

@ -0,0 +1,223 @@
package com.huoran.nakadai.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.huoran.common.response.R;
import com.huoran.common.utils.HttpClientUtils;
import com.huoran.common.utils.JwtUtils;
import com.huoran.common.utils.MD5;
import com.huoran.nakadai.entity.*;
import com.huoran.nakadai.entity.req.AccountRegisterReq;
import com.huoran.nakadai.entity.req.AppletCallbackReq;
import com.huoran.nakadai.entity.req.PlatformTeamAccountListReq;
import com.huoran.nakadai.entity.res.PartnerAccountResp;
import com.huoran.nakadai.entity.res.PlatformTeamAccountResp;
import com.huoran.nakadai.entity.res.TeamAccountResp;
import com.huoran.nakadai.mapper.HrStaffMapper;
import com.huoran.nakadai.mapper.PlatformTeamAccountMapper;
import com.huoran.nakadai.mapper.PlatformTeamClassificationMapper;
import com.huoran.nakadai.mapper.PlatformTeamMapper;
import com.huoran.nakadai.service.PlatformTeamAccountService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huoran.nakadai.utils.QrCodeUtil;
import com.huoran.nakadai.utils.WeChatPropertiesUtil;
import org.apache.commons.collections4.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
import java.util.stream.Collectors;
/**
* <p>
* 幼教产业平台团队账号表 服务实现类
* </p>
*
* @author chen
* @since 2023-12-12
*/
@Service
public class PlatformTeamAccountServiceImpl extends ServiceImpl<PlatformTeamAccountMapper, PlatformTeamAccount> implements PlatformTeamAccountService {
@Autowired
private HrStaffMapper staffMapper;
@Autowired
private PlatformTeamClassificationMapper platformTeamClassificationMapper;
@Autowired
private PlatformTeamMapper platformTeamMapper;
private static final String REQUEST_URL = "https://api.weixin.qq.com/sns/jscode2session";
private static final String GRANT_TYPE = "authorization_code";
@Override
public void generationQrCode(String url, HttpServletResponse response) {
response.setHeader("Content-Type", "image/png");
response.setHeader("Content-Disposition", "inline;filename=qrcode.png");
QrCodeUtil.encode(url, response);
}
@Override
public R platformTeamAccountMergeList(PlatformTeamAccountListReq req) {
Page<PlatformTeamAccountResp> page = new Page<>(req.getPageNum(), req.getPageSize());
//查询团队合伙人
IPage<PlatformTeamAccountResp> partnerAccountList = baseMapper.platformTeamAccountMergeList(page, req);
return R.ok().put("pageList", partnerAccountList);
}
@Override
public Map<String, Object> kindergartenWeChatAccountApplication(AppletCallbackReq appletCallbackReq) throws Exception {
String code = appletCallbackReq.getCode();
Map<String, Object> data = new HashedMap<>();
JSONObject sessionKeyOrOpenId = this.getSessionKeyOrOpenIdByKindergarten(code);
String openid =(String) sessionKeyOrOpenId.get("openid");
// 根据openid查询用户,存在则返回登录状态
ArrayList<Integer> arrayList = new ArrayList<>();
arrayList.add(5);
arrayList.add(6);
arrayList.add(7);
boolean userExists = false; // 添加标志位,判断用户是否存在
for (Integer platformId : arrayList) {
UserAccount userAccount = baseMapper.selectAccountByOpenId(openid,platformId);
// 有平台存在返回登录信息
if (userAccount!= null){
data.put("state", "login");
data.put("platformId", platformId);
data.put("token", JwtUtils.getJwtToken(userAccount.getId().toString()));
userExists = true; // 如果用户存在,将标志位设为true
break; // 如果找到用户,就不需要继续查找
}
}
// 如果用户不存在,返回状态为"绑定"
if (!userExists) {
data.put("state", "bind");
}
data.put("sessionKey", sessionKeyOrOpenId);
return data;
}
@Override
public R kindergartenWeChatApplication(AppletCallbackReq appletCallbackReq) {
Map<String, Object> data = new HashedMap<String, Object>();
String randomNumbers = cn.hutool.core.util.RandomUtil.randomNumbers(6);
String accountId = null;
String userName = "";
String accountName = "";
// 根据不同的平台ID设置用户名和账户名
switch (appletCallbackReq.getPlatformId()) {
case 5:
userName = "幼儿园" + randomNumbers;
accountName = "幼儿园" + randomNumbers;
break;
case 6:
userName = "供应商" + randomNumbers;
accountName = "供应商" + randomNumbers;
break;
case 7:
userName = "个人" + randomNumbers;
accountName = "个人" + randomNumbers;
break;
}
// 创建并设置用户信息
UserInfo userInfo = new UserInfo();
userInfo.setUserName(userName);
userInfo.setLoginNumber(1);
userInfo.setLastLoginTime(new Date());
staffMapper.addUserInfo(userInfo);
// 创建并设置用户账户
UserAccount userAccount = new UserAccount();
userAccount.setPhone(appletCallbackReq.getPhone());
userAccount.setPhoneBindingTime(new Date());
userAccount.setPassword(MD5.encrypt("1122aa"));
userAccount.setUserId(userInfo.getUserId());
userAccount.setType(2); // 平台端区分:0->教师端 1->学生端 2->无端
userAccount.setPlatformId(appletCallbackReq.getPlatformId().toString());
userAccount.setAppOpenId(appletCallbackReq.getOpenId());
userAccount.setAccount(accountName);
staffMapper.addUserAccount(userAccount);
accountId = userAccount.getId().toString();
// 如果平台ID不是7,添加供应商信息和团队信息
if (appletCallbackReq.getPlatformId() != 7) {
// 添加供应商信息
PlatformTeamAccount platformTeamAccount = new PlatformTeamAccount();
platformTeamAccount.setAccountId(userAccount.getId());
platformTeamAccount.setPlatformId(appletCallbackReq.getPlatformId());
baseMapper.insert(platformTeamAccount);
// 添加所属供应商分类,分类为空直接新增团队
PlatformTeamClassification platformTeamClassification = new PlatformTeamClassification();
platformTeamClassification.setIsTeam(1);
platformTeamClassification.setParentId(1);
platformTeamClassification.setLevel(1);
String teamName = userAccount.getAccount() + "的团队";
platformTeamClassification.setClassificationName(teamName);
int insert = platformTeamClassificationMapper.insert(platformTeamClassification);
if (insert > 0) {
PlatformTeam platformTeam = new PlatformTeam();
platformTeam.setManageId(platformTeamAccount.getManageId());
platformTeam.setClassificationId(platformTeamClassification.getId());
platformTeamMapper.insert(platformTeam);
}
data.put("teamId",platformTeamClassification.getId());
}
// 注册成功返回token
data.put("token", JwtUtils.getJwtToken(accountId));
return R.ok().put("data",data);
}
@Override
public R getTeamsByPlatformId(String accountId, Integer platformId) {
List<TeamAccountResp> teamsByPlatformId = baseMapper.getTeamsByPlatformId(accountId,platformId);
teamsByPlatformId.forEach(teamAccountResp -> {
PlatformTeamClassification platformTeamClassification = platformTeamClassificationMapper.getParentInformationBasedOnChild(teamAccountResp.getClassificationId());
teamAccountResp.setPlatformTeamClassificationList(platformTeamClassification);
});
return R.ok().put("data", teamsByPlatformId);
}
@Override
public R pagePlatformTeamAccountList(PlatformTeamAccountListReq req) {
Page<PlatformTeamAccountResp> page = new Page<>(req.getPageNum(), req.getPageSize());
//查询分类下所有团队id
ArrayList<Integer> ids = baseMapper.selectTeamIdByClassificationId(req.getClassificationId());
req.setIds(ids);
IPage<PlatformTeamAccountResp> platformTeamAccountList = baseMapper.pagePlatformTeamAccountList(page, req);
return R.ok().put("pageList", platformTeamAccountList);
}
private JSONObject getSessionKeyOrOpenIdByKindergarten(String code) throws Exception {
Map<String, String> requestUrlParam = new HashMap<>();
requestUrlParam.put("appid", WeChatPropertiesUtil.KINDERGARTEN_WX_OPEN_APP_ID);
requestUrlParam.put("secret", WeChatPropertiesUtil.KINDERGARTEN_WX_OPEN_APP_SECRET);
// 小程序端返回的code
requestUrlParam.put("js_code", code);
// 默认参数
requestUrlParam.put("grant_type", GRANT_TYPE);
// 发送post请求读取调用微信接口获取openid用户唯一标识
String result = HttpClientUtils.doPost(REQUEST_URL, requestUrlParam);
return JSON.parseObject(result);
}
}

@ -0,0 +1,20 @@
package com.huoran.nakadai.service.impl;
import com.huoran.nakadai.entity.PlatformTeamClassification;
import com.huoran.nakadai.mapper.PlatformTeamClassificationMapper;
import com.huoran.nakadai.service.PlatformTeamClassificationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 幼教产业平台团队分类表 服务实现类
* </p>
*
* @author chen
* @since 2023-12-12
*/
@Service
public class PlatformTeamClassificationServiceImpl extends ServiceImpl<PlatformTeamClassificationMapper, PlatformTeamClassification> implements PlatformTeamClassificationService {
}

@ -0,0 +1,20 @@
package com.huoran.nakadai.service.impl;
import com.huoran.nakadai.entity.PlatformTeam;
import com.huoran.nakadai.mapper.PlatformTeamMapper;
import com.huoran.nakadai.service.PlatformTeamService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 幼教产业团队账号与分类中间表 服务实现类
* </p>
*
* @author chen
* @since 2023-12-12
*/
@Service
public class PlatformTeamServiceImpl extends ServiceImpl<PlatformTeamMapper, PlatformTeam> implements PlatformTeamService {
}

@ -31,6 +31,20 @@ public class WeChatPropertiesUtil implements InitializingBean {
@Value("${operation.wxopen.redirect_url}") @Value("${operation.wxopen.redirect_url}")
private String operationRedirectUrl; private String operationRedirectUrl;
@Value("${kindergarten.wxopen.appid}")
private String kindergartenAppId;
@Value("${kindergarten.wxopen.appsecret}")
private String kindergartenAppSecret;
@Value("${kindergarten.wxopen.redirect_url}")
private String kindergartenRedirectUrl;
public static String KINDERGARTEN_WX_OPEN_APP_ID;
public static String KINDERGARTEN_WX_OPEN_APP_SECRET;
public static String KINDERGARTEN_WX_OPEN_REDIRECT_URL;
public static String PARTNER_WX_OPEN_APP_ID; public static String PARTNER_WX_OPEN_APP_ID;
public static String PARTNER_WX_OPEN_APP_SECRET; public static String PARTNER_WX_OPEN_APP_SECRET;
public static String PARTNER_WX_OPEN_REDIRECT_URL; public static String PARTNER_WX_OPEN_REDIRECT_URL;
@ -48,5 +62,9 @@ public class WeChatPropertiesUtil implements InitializingBean {
OPERATION_WX_OPEN_APP_ID = operationAppId; OPERATION_WX_OPEN_APP_ID = operationAppId;
OPERATION_WX_OPEN_APP_SECRET = operationAppSecret; OPERATION_WX_OPEN_APP_SECRET = operationAppSecret;
OPERATION_WX_OPEN_REDIRECT_URL = operationRedirectUrl; OPERATION_WX_OPEN_REDIRECT_URL = operationRedirectUrl;
KINDERGARTEN_WX_OPEN_APP_ID = kindergartenAppId;
KINDERGARTEN_WX_OPEN_APP_SECRET = kindergartenAppSecret;
KINDERGARTEN_WX_OPEN_REDIRECT_URL = kindergartenRedirectUrl;
} }
} }

@ -6,7 +6,6 @@ spring.cloud.nacos.config.server-addr=127.0.0.1:8848
#namespace #namespace
spring.cloud.nacos.config.namespace=kindergarten-microservice-configuration-namespace spring.cloud.nacos.config.namespace=kindergarten-microservice-configuration-namespace
#合伙人微信小程序配置 #合伙人微信小程序配置
partner.wxopen.appid=wx2b506fdb0eeee65d partner.wxopen.appid=wx2b506fdb0eeee65d
partner.wxopen.appsecret=d14ccc2f188e6e64a263086f91dfa71c partner.wxopen.appsecret=d14ccc2f188e6e64a263086f91dfa71c
@ -16,16 +15,21 @@ partner.wxopen.redirect_url=http://192.168.31.116:9000/apiHrmsAuth/hrms/auth/use
#运营微信小程序配置 #运营微信小程序配置
operation.wxopen.appid=wx88cd6037d54f230a operation.wxopen.appid=wx88cd6037d54f230a
operation.wxopen.appsecret=82c18212b17bf8b2fa17c680feb5b012 operation.wxopen.appsecret=82c18212b17bf8b2fa17c680feb5b012
operation.wxopen.redirect_url=http://192.168.31.116:9000/apiHrmsAuth/hrms/auth/userlogin/user/callback operation.wxopen.redirect_url=http://192.168.31.116:9000/apiHrmsAuth/hrms/auth/userlogin/user/callback\
spring.mail.host=smtp.qq.com #幼教微信小程序配置
spring.mail.port=587 kindergarten.wxopen.appid=wxd210bb4686c9c580
spring.mail.username=1251790704@qq.com kindergarten.wxopen.appsecret=23b2ecfdd893f1feef31fd1a8ce65379
spring.mail.password=tgbteukyosdnhadh kindergarten.wxopen.redirect_url=http://192.168.31.116:9000/apiHrmsAuth/hrms/auth/userlogin/user/callback
spring.mail.default-encoding=UTF-8
spring.mail.properties.mail.smtp.socketFactoryClass=javax.net.ssl.SSLSocketFactory #spring.mail.host=smtp.qq.com
spring.mail.properties.mail.debug=true #spring.mail.port=587
spring.mail.from=1251790704@qq.com #spring.mail.username=1251790704@qq.com
#spring.mail.password=tgbteukyosdnhadh
#spring.mail.default-encoding=UTF-8
#spring.mail.properties.mail.smtp.socketFactoryClass=javax.net.ssl.SSLSocketFactory
#spring.mail.properties.mail.debug=true
#spring.mail.from=1251790704@qq.com
#email.url=D:/copyWriting/ #email.url=D:/copyWriting/

@ -43,10 +43,10 @@ public class CodeGenerator {
// 3、数据源配置 // 3、数据源配置
// 3、数据源配置 // 3、数据源配置
DataSourceConfig dsc = new DataSourceConfig(); DataSourceConfig dsc = new DataSourceConfig();
dsc.setUrl("jdbc:mysql://121.37.12.51:3308/nakadai?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8"); dsc.setUrl("jdbc:mysql://139.9.47.170:3306/nakadai?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8");
dsc.setDriverName("com.mysql.cj.jdbc.Driver"); dsc.setDriverName("com.mysql.cj.jdbc.Driver");
dsc.setUsername("root"); dsc.setUsername("root");
dsc.setPassword("root"); dsc.setPassword("HuoRan@2021");
dsc.setDbType(DbType.MYSQL); dsc.setDbType(DbType.MYSQL);
mpg.setDataSource(dsc); mpg.setDataSource(dsc);
@ -63,9 +63,9 @@ public class CodeGenerator {
// 5、策略配置 // 5、策略配置
StrategyConfig strategy = new StrategyConfig(); StrategyConfig strategy = new StrategyConfig();
strategy.setInclude("sys_platform"); strategy.setInclude("k_platform_team","k_platform_team_account","k_platform_team_classification");
strategy.setNaming(NamingStrategy.underline_to_camel);//数据库表映射到实体的命名策略 strategy.setNaming(NamingStrategy.underline_to_camel);//数据库表映射到实体的命名策略
strategy.setTablePrefix("sys_"); //生成实体时去掉表前缀 strategy.setTablePrefix("k_"); //生成实体时去掉表前缀
strategy.setColumnNaming(NamingStrategy.underline_to_camel);//数据库表字段映射到实体的命名策略 strategy.setColumnNaming(NamingStrategy.underline_to_camel);//数据库表字段映射到实体的命名策略
strategy.setEntityLombokModel(true); // lombok 模型 @Accessors(chain = true) setter链式操作 strategy.setEntityLombokModel(true); // lombok 模型 @Accessors(chain = true) setter链式操作

@ -31,6 +31,15 @@ public class WeChatPropertiesUtil implements InitializingBean {
@Value("${operation.wxopen.redirect_url}") @Value("${operation.wxopen.redirect_url}")
private String operationRedirectUrl; private String operationRedirectUrl;
@Value("${kindergarten.wxopen.appid}")
private String kindergartenAppId;
@Value("${kindergarten.wxopen.appsecret}")
private String kindergartenAppSecret;
@Value("${kindergarten.wxopen.redirect_url}")
private String kindergartenRedirectUrl;
public static String PARTNER_WX_OPEN_APP_ID; public static String PARTNER_WX_OPEN_APP_ID;
public static String PARTNER_WX_OPEN_APP_SECRET; public static String PARTNER_WX_OPEN_APP_SECRET;
public static String PARTNER_WX_OPEN_REDIRECT_URL; public static String PARTNER_WX_OPEN_REDIRECT_URL;
@ -40,6 +49,10 @@ public class WeChatPropertiesUtil implements InitializingBean {
public static String OPERATION_WX_OPEN_APP_SECRET; public static String OPERATION_WX_OPEN_APP_SECRET;
public static String OPERATION_WX_OPEN_REDIRECT_URL; public static String OPERATION_WX_OPEN_REDIRECT_URL;
public static String KINDERGARTEN_WX_OPEN_APP_ID;
public static String KINDERGARTEN_WX_OPEN_APP_SECRET;
public static String KINDERGARTEN_WX_OPEN_REDIRECT_URL;
@Override @Override
public void afterPropertiesSet() throws Exception { public void afterPropertiesSet() throws Exception {
PARTNER_WX_OPEN_APP_ID = partnerAppId; PARTNER_WX_OPEN_APP_ID = partnerAppId;
@ -48,5 +61,8 @@ public class WeChatPropertiesUtil implements InitializingBean {
OPERATION_WX_OPEN_APP_ID = operationAppId; OPERATION_WX_OPEN_APP_ID = operationAppId;
OPERATION_WX_OPEN_APP_SECRET = operationAppSecret; OPERATION_WX_OPEN_APP_SECRET = operationAppSecret;
OPERATION_WX_OPEN_REDIRECT_URL = operationRedirectUrl; OPERATION_WX_OPEN_REDIRECT_URL = operationRedirectUrl;
KINDERGARTEN_WX_OPEN_APP_ID = kindergartenAppId;
KINDERGARTEN_WX_OPEN_APP_SECRET = kindergartenAppSecret;
KINDERGARTEN_WX_OPEN_REDIRECT_URL = kindergartenRedirectUrl;
} }
} }

@ -7,6 +7,7 @@ import com.huoran.common.utils.TokenUtils;
import com.huoran.users.entity.HrUserAccount; import com.huoran.users.entity.HrUserAccount;
import com.huoran.users.entity.PlatformLogin; import com.huoran.users.entity.PlatformLogin;
import com.huoran.users.entity.dto.LoginDTO; import com.huoran.users.entity.dto.LoginDTO;
import com.huoran.users.entity.req.AccountRegisterReq;
import com.huoran.users.entity.req.AppletCallbackReq; import com.huoran.users.entity.req.AppletCallbackReq;
import com.huoran.users.entity.req.UnbindAccountsReq; import com.huoran.users.entity.req.UnbindAccountsReq;
import com.huoran.users.entity.req.WxUserBindingReq; import com.huoran.users.entity.req.WxUserBindingReq;
@ -121,6 +122,27 @@ public class UserLoginController {
return platformLoginService.platformLoginStatistics(platform,schoolId); return platformLoginService.platformLoginStatistics(platform,schoolId);
} }
@ApiOperation(value = "幼教产品个人端账号快速注册登录")
@PostMapping("/personalAccountApplication")
public R personalAccountApplication(@RequestBody @Valid AccountRegisterReq registerReq) {
return userInfoService.personalAccountApplication(registerReq);
}
/**
* 微信小程序绑定回调
*/
@ApiOperation(value = "微信小程序绑定回调(幼教产业版)")
@PostMapping("/weChatAppletCallbackByKindergarten")
public R weChatAppletCallbackByKindergarten(@RequestBody AppletCallbackReq appletCallbackReq, HttpServletResponse response) throws Exception {
Map<String ,Object> result = userInfoService.weChatAppletCallbackByKindergarten(appletCallbackReq, response);
return R.ok().put("data",result);
}
/** /**
* 登录成功后返回token值用于其他模块验证 * 登录成功后返回token值用于其他模块验证
* @param loginVo 登录信息 * @param loginVo 登录信息

@ -0,0 +1,44 @@
package com.huoran.users.entity.req;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
@Data
public class AccountRegisterReq {
@ApiModelProperty(value = "姓名,可不填写")
private String userName;
@ApiModelProperty(value = "账号,可不填写")
private String account;
@ApiModelProperty(value = "密码,可不填写")
private String password;
@ApiModelProperty(value = "平台id,个人端默认为7",example = "7")
@NotNull(message = "请选择平台注册!")
private String platformId;
@ApiModelProperty(value = "唯一标识账号")
@NotNull(message = "唯一标识不能为空!")
private String uniqueIdentification;
@ApiModelProperty(value = "手机号")
@NotNull(message = "手机号不能为空")
private String phone;
@ApiModelProperty(value = "邮箱")
private String email;
@ApiModelProperty(value = "小程序openid")
private String appOpenId;
// @ApiModelProperty(value = "意向省份")
// private Integer provinceId;
//
// @ApiModelProperty(value = "意向城市")
// private Integer cityId;
}

@ -1,7 +1,9 @@
package com.huoran.users.entity.req; package com.huoran.users.entity.req;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
/** /**
* @Author chen * @Author chen
* @DATE 2022/7/12 15:03 * @DATE 2022/7/12 15:03
@ -9,6 +11,13 @@ import lombok.Data;
*/ */
@Data @Data
public class AppletCallbackReq { public class AppletCallbackReq {
@ApiModelProperty("微信标识")
private String code; private String code;
@ApiModelProperty("头像地址")
private String avatarUrl; private String avatarUrl;
@ApiModelProperty("平台标识,1职站,2数据平台,3中台,4合伙人,5幼儿园,6供应商,7个人端")
private Integer platform;
} }

@ -22,7 +22,7 @@ public class LoginVo {
@NotEmpty(message = "验证码不能为空") @NotEmpty(message = "验证码不能为空")
private String code; private String code;
@ApiModelProperty("平台标识,1职站,2数据平台,3中台") @ApiModelProperty("平台标识,1职站,2数据平台,3中台,4合伙人,5幼儿园,6供应商,7个人端")
@NotNull(message = "登录平台不能为空") @NotNull(message = "登录平台不能为空")
private Integer platform; private Integer platform;

@ -1,6 +1,8 @@
package com.huoran.users.mapper; package com.huoran.users.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.huoran.common.entity.UserAccount;
import com.huoran.common.entity.UserInfo;
import com.huoran.common.entity.resp.PhoneBindingrResp; import com.huoran.common.entity.resp.PhoneBindingrResp;
import com.huoran.users.entity.DataRole; import com.huoran.users.entity.DataRole;
import com.huoran.users.entity.HrUserAccount; import com.huoran.users.entity.HrUserAccount;
@ -54,4 +56,10 @@ public interface HrUserInfoMapper extends BaseMapper<HrUserInfo> {
List<PhoneBindingrResp> userBindingPhoneInfo(@Param("account") HrUserAccount account); List<PhoneBindingrResp> userBindingPhoneInfo(@Param("account") HrUserAccount account);
ProfileDetailsRes personalFile(Integer userId); ProfileDetailsRes personalFile(Integer userId);
Integer selectAccount(@Param("phone") String phone,@Param("platformId") String platformId);
int addUserInfo(UserInfo userInfo);
int addUserAccount(UserAccount userAccount);
} }

@ -2,6 +2,7 @@ package com.huoran.users.mapper;
import com.huoran.users.entity.Role; import com.huoran.users.entity.Role;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/** /**
* <p> * <p>
@ -11,6 +12,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* @author chen * @author chen
* @since 2021-09-29 * @since 2021-09-29
*/ */
@Mapper
public interface RoleMapper extends BaseMapper<Role> { public interface RoleMapper extends BaseMapper<Role> {
Integer selectCustomerSuper(Integer id); Integer selectCustomerSuper(Integer id);

@ -1,6 +1,22 @@
<?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.users.mapper.HrUserInfoMapper"> <mapper namespace="com.huoran.users.mapper.HrUserInfoMapper">
<!--新增用户信息-->
<insert id="addUserInfo" parameterType="com.huoran.common.entity.UserInfo" useGeneratedKeys="true"
keyProperty="userId">
INSERT INTO nakadai.hr_user_info (user_name, unique_identification, email,role_id,school_id,create_time,
update_time,user_avatars)
VALUES (#{userName}, #{uniqueIdentification}, #{email},0,0,now(), now(),#{userAvatars})
</insert>
<!--新增账号信息-->
<insert id="addUserAccount" parameterType="com.huoran.common.entity.UserAccount" useGeneratedKeys="true"
keyProperty="id">
INSERT INTO nakadai.hr_user_account(user_id, account,phone , password, work_number, school_id, platform_id,
type, create_time, update_time,app_open_id)
VALUES (#{userId}, #{account},#{phone}, #{password}, #{workNumber}, 0, #{platformId}, #{type},
now(), now(),#{appOpenId})
</insert>
<!-- 通用查询映射结果 --> <!-- 通用查询映射结果 -->
<!-- <resultMap id="BaseResultMap" type="com.huoran.users.entity.HrUserInfo"> <!-- <resultMap id="BaseResultMap" type="com.huoran.users.entity.HrUserInfo">
@ -298,5 +314,10 @@
INNER JOIN hr_user_account a ON u.user_id = a.user_id INNER JOIN hr_user_account a ON u.user_id = a.user_id
WHERE u.user_id = #{user_id} WHERE u.user_id = #{user_id}
</select> </select>
<select id="selectAccount" resultType="java.lang.Integer">
SELECT id
from hr_user_account
WHERE is_del = 0 and platform_id = #{platformId} and phone = #{phone}
</select>
</mapper> </mapper>

@ -5,6 +5,7 @@ import com.huoran.common.response.R;
import com.huoran.users.entity.HrUserAccount; import com.huoran.users.entity.HrUserAccount;
import com.huoran.users.entity.HrUserInfo; import com.huoran.users.entity.HrUserInfo;
import com.huoran.users.entity.dto.LoginDTO; import com.huoran.users.entity.dto.LoginDTO;
import com.huoran.users.entity.req.AccountRegisterReq;
import com.huoran.users.entity.req.AppletCallbackReq; import com.huoran.users.entity.req.AppletCallbackReq;
import com.huoran.users.entity.req.UnbindAccountsReq; import com.huoran.users.entity.req.UnbindAccountsReq;
import com.huoran.users.entity.req.WxUserBindingReq; import com.huoran.users.entity.req.WxUserBindingReq;
@ -79,4 +80,8 @@ public interface IHrUserInfoService extends IService<HrUserInfo> {
R loginByOpenid(String openid); R loginByOpenid(String openid);
R updateAvatars(String url,String id); R updateAvatars(String url,String id);
R personalAccountApplication(AccountRegisterReq registerReq);
Map<String, Object> weChatAppletCallbackByKindergarten(AppletCallbackReq appletCallbackReq, HttpServletResponse response) throws Exception;
} }

@ -15,6 +15,8 @@ import com.google.common.collect.Maps;
import com.huoran.api.NakadaiClient; import com.huoran.api.NakadaiClient;
import com.huoran.api.UserClient; import com.huoran.api.UserClient;
import com.huoran.common.constant.*; import com.huoran.common.constant.*;
import com.huoran.common.entity.UserAccount;
import com.huoran.common.entity.UserInfo;
import com.huoran.common.exception.CustomException; 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;
@ -35,7 +37,7 @@ import com.huoran.users.mapper.RoleMapper;
import com.huoran.users.service.IHrUserInfoService; import com.huoran.users.service.IHrUserInfoService;
import com.huoran.users.utils.EmailUtil; import com.huoran.users.utils.EmailUtil;
import com.huoran.users.utils.ExcelImportHelper; import com.huoran.users.utils.ExcelImportHelper;
import com.huoran.users.utils.HttpClientUtils; import com.huoran.common.utils.HttpClientUtils;
import com.huoran.users.utils.WeChatUtil; import com.huoran.users.utils.WeChatUtil;
import com.huoran.users.utils.poi.CommonCode; import com.huoran.users.utils.poi.CommonCode;
import com.huoran.users.utils.poi.Constant; import com.huoran.users.utils.poi.Constant;
@ -612,8 +614,8 @@ public class HrUserInfoServiceImpl extends ServiceImpl<HrUserInfoMapper, HrUserI
} }
//验证码校验 //验证码校验
// Boolean check = check(loginVo.getRandom(), loginVo.getCode()); Boolean check = check(loginVo.getRandom(), loginVo.getCode());
if (true) { if (check) {
//账号、学号、工号登录 //账号、学号、工号登录
if (loginVo.getDistinguish() == 1) { if (loginVo.getDistinguish() == 1) {
@ -1266,6 +1268,23 @@ public class HrUserInfoServiceImpl extends ServiceImpl<HrUserInfoMapper, HrUserI
return JSON.parseObject(result); return JSON.parseObject(result);
} }
private JSONObject getSessionKeyOrOpenIdByKindergarten(String code) throws Exception {
Map<String, String> requestUrlParam = new HashMap<>();
// 小程序appId,自己补充
requestUrlParam.put("appid", WeChatPropertiesUtil.KINDERGARTEN_WX_OPEN_APP_ID);
// 小程序secret,自己补充
requestUrlParam.put("secret", WeChatPropertiesUtil.KINDERGARTEN_WX_OPEN_APP_SECRET);
// 小程序端返回的code
requestUrlParam.put("js_code", code);
// 默认参数
requestUrlParam.put("grant_type", GRANT_TYPE);
// 发送post请求读取调用微信接口获取openid用户唯一标识
String result = HttpClientUtils.doPost(REQUEST_URL, requestUrlParam);
return JSON.parseObject(result);
}
/** /**
* 微信接口请求令牌生产环境下 要用redis缓存起来 * 微信接口请求令牌生产环境下 要用redis缓存起来
* @return AccessToken * @return AccessToken
@ -1401,6 +1420,33 @@ public class HrUserInfoServiceImpl extends ServiceImpl<HrUserInfoMapper, HrUserI
return data; return data;
} }
@Override
public Map<String, Object> weChatAppletCallbackByKindergarten(AppletCallbackReq appletCallbackReq, HttpServletResponse response) throws Exception {
String code = appletCallbackReq.getCode();
Map<String, Object> data = new HashedMap<String, Object>();
JSONObject sessionKeyOrOpenId = this.getSessionKeyOrOpenIdByKindergarten(code);
Object openid = sessionKeyOrOpenId.get("openid");
//根据openid查询用户,存在则返回登录状态
QueryWrapper<HrUserAccount> wrapper = new QueryWrapper<>();
wrapper.eq("app_open_id",openid);
wrapper.eq("platform_id",appletCallbackReq.getPlatform());
HrUserAccount userAccount = hrUserAccountMapper.selectOne(wrapper);
//为空注册用户信息
if (ObjectUtil.isNull(userAccount)){
data.put("state", "bind");
}else {
//更新登录时间
updateUserInfo(userAccount.getUserId(),false,userAccount.getId());
data.put("token", JwtUtils.getJwtToken(userAccount.getId().toString()));
data.put("accountId", userAccount.getId());
}
System.out.println(sessionKeyOrOpenId);
data.put("sessionKey", sessionKeyOrOpenId);
return data;
}
@Override @Override
public String userBinding(WxUserBindingReq userBindingReq) { public String userBinding(WxUserBindingReq userBindingReq) {
if (userBindingReq.getPlatformId()==4){ if (userBindingReq.getPlatformId()==4){
@ -1558,7 +1604,53 @@ public class HrUserInfoServiceImpl extends ServiceImpl<HrUserInfoMapper, HrUserI
*/ */
} }
@Override
public R personalAccountApplication(AccountRegisterReq registerReq) {
registerReq.setPlatformId("7");
//创建账号,用户信息
//查看平台账号信息,账号不为空直接返回token登录
HrUserAccount hrUserAccount = hrUserAccountMapper.selectOne(new QueryWrapper<HrUserAccount>().
eq("phone", registerReq.getPhone()).eq("platform_id",registerReq.getPlatformId()));
if (ObjectUtil.isNull(hrUserAccount)) {
String randomNumbers = cn.hutool.core.util.RandomUtil.randomNumbers(6);
//用户相关信息表
UserInfo userInfo = new UserInfo();
BeanUtils.copyProperties(registerReq, userInfo);
userInfo.setUserName("U"+randomNumbers);
userInfo.setLoginNumber(1);
userInfo.setLastLoginTime(new Date());
int addUserInfo = baseMapper.addUserInfo(userInfo);
UserAccount userAccount = new UserAccount();
BeanUtils.copyProperties(registerReq, userAccount);
userAccount.setPassword(MD5.encrypt("1122aa"));
userAccount.setUserId(userInfo.getUserId());
userAccount.setType(2);//平台端区分:0->教师端 1->学生端 2->无端
userAccount.setPlatformId(registerReq.getPlatformId());
userAccount.setAppOpenId(registerReq.getAppOpenId());
userAccount.setAccount("A"+randomNumbers);
int addAccount = baseMapper.addUserAccount(userAccount);
//注册成功返回token
if (addUserInfo > 0 && addAccount > 0){
LoginDTO loginDTO = new LoginDTO();
loginDTO.setToken(JwtUtils.getJwtToken(userAccount.getId().toString()));
return R.ok().put("data", loginDTO);
}
}else {
//是否禁用
if (hrUserAccount.getIsEnable().equals(OrderConstant.Not_enabled)) {
throw new CustomException(ExceptionEnum.ACCOUNT_DISABLED);
}
//更新用户信息
updateUserInfo(hrUserAccount.getUserId(), false, hrUserAccount.getId());
LoginDTO loginDTO = new LoginDTO();
loginDTO.setToken(JwtUtils.getJwtToken(hrUserAccount.getId().toString()));
return R.ok().put("data", loginDTO);
}
return R.error();
}
} }

@ -16,7 +16,12 @@ partner.wxopen.redirect_url=http://192.168.31.116:9000/apiHrmsAuth/hrms/auth/use
#运营微信小程序配置 #运营微信小程序配置
operation.wxopen.appid=wx88cd6037d54f230a operation.wxopen.appid=wx88cd6037d54f230a
operation.wxopen.appsecret=82c18212b17bf8b2fa17c680feb5b012 operation.wxopen.appsecret=82c18212b17bf8b2fa17c680feb5b012
operation.wxopen.redirect_url=http://192.168.31.116:9000/apiHrmsAuth/hrms/auth/userlogin/user/callback operation.wxopen.redirect_url=http://192.168.31.116:9000/apiHrmsAuth/hrms/auth/userlogin/user/callback\
#运营微信小程序配置
kindergarten.wxopen.appid=wxd210bb4686c9c580
kindergarten.wxopen.appsecret=82c18212b17bf8b2fa17c680feb5b012
kindergarten.wxopen.redirect_url=http://192.168.31.116:9000/apiHrmsAuth/hrms/auth/userlogin/user/callback
#邮箱配置 #邮箱配置
spring.mail.host=smtp.qq.com spring.mail.host=smtp.qq.com

Loading…
Cancel
Save