|
|
|
@ -6,12 +6,16 @@ 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.PlatformTeam; |
|
|
|
|
import com.huoran.nakadai.entity.PlatformTeamClassification; |
|
|
|
|
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.entity.vo.TeamClassificationVO; |
|
|
|
|
import com.huoran.nakadai.service.PlatformTeamAccountService; |
|
|
|
|
import com.huoran.nakadai.service.PlatformTeamClassificationService; |
|
|
|
|
import com.huoran.nakadai.service.PlatformTeamService; |
|
|
|
|
import com.huoran.nakadai.service.SupplierClassificationConfigService; |
|
|
|
|
import com.huoran.nakadai.utils.GenerateCodeUtil; |
|
|
|
|
import io.swagger.annotations.Api; |
|
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
@ -25,6 +29,7 @@ import org.springframework.web.bind.annotation.*; |
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
import javax.validation.Valid; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.Objects; |
|
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
@ -51,34 +56,33 @@ public class PlatformTeamAccountController { |
|
|
|
|
@Autowired |
|
|
|
|
public PlatformTeamClassificationService platformTeamClassificationService; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
public SupplierClassificationConfigService supplierClassificationConfigService; |
|
|
|
|
|
|
|
|
|
@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) { |
|
|
|
|
public R generateInvitationCode(@ApiParam(name = "platformId", value = "平台id", required = true) @RequestParam("platformId") String platformId, HttpServletRequest request) { |
|
|
|
|
//平台唯一标识码
|
|
|
|
|
String uniqueIdentification = platformId+TokenUtils.getIdByJwtToken(request)+"kindergartenInvitationCode"; |
|
|
|
|
String uniqueIdentification = platformId + TokenUtils.getIdByJwtToken(request) + "kindergartenInvitationCode"; |
|
|
|
|
//存在直接返回邀请码
|
|
|
|
|
String code = redisTemplate.opsForValue().get(uniqueIdentification); |
|
|
|
|
if (StringUtils.isEmpty(code)){ |
|
|
|
|
if (StringUtils.isEmpty(code)) { |
|
|
|
|
code = GenerateCodeUtil.generateCode(); |
|
|
|
|
redisTemplate.opsForValue().set(uniqueIdentification,code,7, TimeUnit.DAYS); |
|
|
|
|
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); |
|
|
|
|
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); |
|
|
|
|
@GetMapping(value = "/generationQrCode", produces = "image/png") |
|
|
|
|
public void generationQrCode(@ApiParam(name = "url", value = "链接", required = true) @RequestParam String url, HttpServletResponse response) { |
|
|
|
|
platformTeamAccountService.generationQrCode(url, response); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -145,11 +149,7 @@ public class PlatformTeamAccountController { |
|
|
|
|
|
|
|
|
|
@GetMapping("/removeOrganization") |
|
|
|
|
@ApiOperation(value = "移除组织") |
|
|
|
|
public R removeOrganization( |
|
|
|
|
@ApiParam(name = "teamId", value = "团队id") |
|
|
|
|
@RequestParam Integer teamId, |
|
|
|
|
@ApiParam(name = "manageId", value = "组织id") |
|
|
|
|
@RequestParam Integer manageId) { |
|
|
|
|
public R removeOrganization(@ApiParam(name = "teamId", value = "团队id") @RequestParam Integer teamId, @ApiParam(name = "manageId", value = "组织id") @RequestParam Integer manageId) { |
|
|
|
|
PlatformTeamClassification teamClassification = platformTeamClassificationService.getById(teamId); |
|
|
|
|
if (teamClassification.getIsTeam() == 1) { |
|
|
|
|
throw new CustomException(ExceptionEnum.PARTNER_REMOVAL); |
|
|
|
@ -158,30 +158,26 @@ public class PlatformTeamAccountController { |
|
|
|
|
platformTeamClassificationService.removeById(teamId); |
|
|
|
|
//TODO 删除该团队相关角色信息
|
|
|
|
|
platformTeamAccountService.removeById(manageId); |
|
|
|
|
boolean remove = platformTeamService.remove(new QueryWrapper<PlatformTeam>(). |
|
|
|
|
eq("manage_id", manageId). |
|
|
|
|
eq("classification_id", teamId)); |
|
|
|
|
boolean remove = platformTeamService.remove(new QueryWrapper<PlatformTeam>().eq("manage_id", manageId).eq("classification_id", teamId)); |
|
|
|
|
return remove ? R.ok() : R.error(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "后台更新团队状态,禁用无法查询到该组织") |
|
|
|
|
@PostMapping("/updateTeamStatus") |
|
|
|
|
public R updateTeamStatus( |
|
|
|
|
@RequestParam("teamId") @ApiParam(value = "团队id") Integer teamId, |
|
|
|
|
@RequestParam("isEnable") @ApiParam(value = "是否禁用(1->禁用,0->启用)") Integer isEnable) { |
|
|
|
|
public R updateTeamStatus(@RequestParam("teamId") @ApiParam(value = "团队id") Integer teamId, @RequestParam("isEnable") @ApiParam(value = "是否禁用(1->禁用,0->启用)") Integer isEnable) { |
|
|
|
|
PlatformTeamClassification platformTeamClassification = new PlatformTeamClassification(); |
|
|
|
|
platformTeamClassification.setId(teamId); |
|
|
|
|
platformTeamClassification.setIsEnable(isEnable); |
|
|
|
|
boolean update = platformTeamClassificationService.updateById(platformTeamClassification); |
|
|
|
|
return update? R.ok() : R.error(); |
|
|
|
|
return update ? R.ok() : R.error(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//================================以下接口为小程序调用===================================
|
|
|
|
|
@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); |
|
|
|
|
Map<String, Object> result = platformTeamAccountService.kindergartenWeChatAccountApplication(appletCallbackReq); |
|
|
|
|
return R.ok().put("data", result); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -193,11 +189,9 @@ public class PlatformTeamAccountController { |
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "获取当前平台用户的团队信息", response = PartnerAccountResp.class) |
|
|
|
|
@GetMapping("/getTeamsByPlatformId") |
|
|
|
|
public R getTeamsByPlatformId( |
|
|
|
|
@ApiParam(name = "platformId", value = "平台id") |
|
|
|
|
@RequestParam Integer platformId,HttpServletRequest request) { |
|
|
|
|
public R getTeamsByPlatformId(@ApiParam(name = "platformId", value = "平台id") @RequestParam Integer platformId, HttpServletRequest request) { |
|
|
|
|
String accountId = TokenUtils.getIdByJwtToken(request); |
|
|
|
|
return platformTeamAccountService.getTeamsByPlatformId(accountId,platformId); |
|
|
|
|
return platformTeamAccountService.getTeamsByPlatformId(accountId, platformId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@PostMapping("/platformTeamAccountList") |
|
|
|
@ -210,18 +204,36 @@ public class PlatformTeamAccountController { |
|
|
|
|
@PostMapping("/updateTeamInfo") |
|
|
|
|
public R updateTeamInfo(@RequestBody TeamInfo teamInfo) { |
|
|
|
|
PlatformTeamClassification platformTeamClassification = new PlatformTeamClassification(); |
|
|
|
|
BeanUtils.copyProperties(teamInfo,platformTeamClassification); |
|
|
|
|
BeanUtils.copyProperties(teamInfo, platformTeamClassification); |
|
|
|
|
// 供应商角色下编辑分类
|
|
|
|
|
// 查询供应商的分类信息(只有当前团队为供应商才有supplierClassification数据)
|
|
|
|
|
|
|
|
|
|
Integer accountId = platformTeamService.getAccountIdByTeamId(teamInfo.getId()); |
|
|
|
|
|
|
|
|
|
//删除原有分类重新新增分类配置信息
|
|
|
|
|
supplierClassificationConfigService.deleteByAccountId(accountId); |
|
|
|
|
//设置分类配置信息中的accountId
|
|
|
|
|
teamInfo.getSupplierClassificationConfigs().forEach(config -> config.setAccountId(accountId)); |
|
|
|
|
|
|
|
|
|
//新增分类配置信息
|
|
|
|
|
supplierClassificationConfigService.saveBatch(teamInfo.getSupplierClassificationConfigs()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean update = platformTeamClassificationService.updateById(platformTeamClassification); |
|
|
|
|
return update? R.ok() : R.error(); |
|
|
|
|
return update ?R.ok():R.error(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "查询团队信息") |
|
|
|
|
@GetMapping("/queryTeamInfo") |
|
|
|
|
public R queryTeamInfo( |
|
|
|
|
@ApiParam(value = "团队id") |
|
|
|
|
@RequestParam("teamId") Integer teamId) { |
|
|
|
|
public R queryTeamInfo(@ApiParam(value = "团队id") @RequestParam("teamId") Integer teamId) { |
|
|
|
|
PlatformTeamClassification teamInfo = platformTeamClassificationService.getById(teamId); |
|
|
|
|
return R.ok().put("teamInfo",teamInfo); |
|
|
|
|
//查询供应商的分类信息(只有当前团队为供应商才有supplierClassification数据)
|
|
|
|
|
List<TeamClassificationVO> supplierClassification = platformTeamService.getTeamClassificationVOByTeamId(teamId); |
|
|
|
|
return R.ok().put("teamInfo", teamInfo).put("supplierClassification", supplierClassification); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@PostMapping("/inviteJoinOrganization") |
|
|
|
|