commit
1bab75ece5
46 changed files with 1604 additions and 25 deletions
@ -1,4 +1,4 @@ |
||||
package com.huoran.users.utils; |
||||
package com.huoran.common.utils; |
||||
|
||||
import org.apache.http.NameValuePair; |
||||
import org.apache.http.client.config.RequestConfig; |
@ -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; |
||||
|
||||
|
||||
} |
@ -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; |
||||
|
||||
} |
@ -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 { |
||||
|
||||
} |
@ -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;
|
||||
|
||||
} |
Loading…
Reference in new issue