Commit 6ae5bf4b authored by tianyiming's avatar tianyiming

企业管理员变更

parent 171a9332
......@@ -68,4 +68,6 @@ public interface IRegUnitInfoService {
void updateAdminInfo(JSONObject dataResult);
Boolean creatQrCode();
RegUnitInfoDto adminInfo(String unitCode);
}
......@@ -173,7 +173,7 @@ public class TzBaseEnterpriseInfoController {
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@RequestMapping(value = "/info", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "查询企业端当前登录人所在企业详情", notes = "查询企业端当前登录人所在企业详情")
public ResponseModel<IPage<TzBaseEnterpriseInfoDto>> pageInfo(PageParam pageParam,Long id) {
public ResponseModel<IPage<TzBaseEnterpriseInfoDto>> pageInfo(PageParam pageParam) {
ReginParams reginParams = JSON.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
if(ObjectUtils.isEmpty(reginParams)){
return null;
......
......@@ -110,6 +110,11 @@ public class TzBaseEnterpriseInfoServiceImpl
/**机器人用户token缓存key */
public static final String TZS_USER_TOKEN = "TZS_USER_TOKEN";
/**
* 企业管理员变更缓存key前缀
*/
private final String adminChange = "ADMIN_CHANGE_";
@Autowired
private EquipmentCategoryServiceImpl equipmentCategoryService;
......@@ -459,36 +464,33 @@ public class TzBaseEnterpriseInfoServiceImpl
}
public Map<String,Object> adminInfoUpdate(Map<String, Object> map) {
public Map<String, Object> adminInfoUpdate(Map<String, Object> map) {
//每一个企业只有一个管理员,所以当前登录用户即管理员用户
AgencyUserModel me = Privilege.agencyUserClient.getme().getResult();
RequestContext.setAppKey(appkey);
RequestContext.setProduct(webProduct);
//获取机器人的token,获取不到则去登录
if(ObjectUtils.isEmpty(redisUtil.get(TZS_USER_TOKEN))){
if (ObjectUtils.isEmpty(redisUtil.get(TZS_USER_TOKEN))) {
loginCtiUser();
}
RequestContext.setToken(String.valueOf(redisUtil.get(TZS_USER_TOKEN)));
Map<String,Object> resultMap = new HashMap<>();
Map<String, Object> resultMap = new HashMap<>();
if (!ObjectUtils.isEmpty(me)) {
if (String.valueOf(map.get("adminTel")).equals(me.getMobile())) {
RegUnitInfo regUnitInfo = new RegUnitInfo();
String useCode = String.valueOf(map.get("useCode"));
regUnitInfo.setAdminName(String.valueOf(map.get("adminName")));
regUnitInfo.setAdminIdNumber(String.valueOf(map.get("adminIdNumber")));
regUnitInfo.setAdminIdCardPhoto(JSON.toJSONString(map.get("adminIdCardPhoto")));
regUnitInfo.setAdminTel(ObjectUtils.isEmpty(map.get("adminNewTel")) ? me.getMobile() : String.valueOf(map.get("adminNewTel")));
me.setMobile(ObjectUtils.isEmpty(map.get("adminNewTel")) ? me.getMobile() : String.valueOf(map.get("adminNewTel")));
me.setRealName(String.valueOf(map.get("adminName")));
FeignClientResult<AgencyUserModel> updateResult = Privilege.agencyUserClient.update(me, String.valueOf(map.get("adminUserId")));
if (200 == updateResult.getStatus()) {
regUnitInfoService.update(regUnitInfo, new QueryWrapper<RegUnitInfo>().eq("unit_code", useCode));
resultMap.put("success", regUnitInfo);
} else {
resultMap.put("fail", "平台用户修改失败,请联系管理员");
}
RegUnitInfo regUnitInfo = new RegUnitInfo();
String unitCode = String.valueOf(map.get("unitCode"));
regUnitInfo.setAdminName(String.valueOf(map.get("adminName")));
regUnitInfo.setAdminIdNumber(String.valueOf(map.get("adminIdNumber")));
regUnitInfo.setAdminIdCardPhoto(JSON.toJSONString(map.get("adminIdCardPhoto")));
regUnitInfo.setAdminTel(String.valueOf(map.get("adminTel")));
me.setMobile(String.valueOf(map.get("adminTel")));
me.setRealName(String.valueOf(map.get("adminName")));
FeignClientResult<AgencyUserModel> updateResult = Privilege.agencyUserClient.update(me, String.valueOf(map.get("adminUserId")));
if (200 == updateResult.getStatus()) {
regUnitInfoService.update(regUnitInfo, new QueryWrapper<RegUnitInfo>().eq("unit_code", unitCode));
resultMap.put("success", regUnitInfo);
redisUtil.del(adminChange + map.get("adminTel"));
} else {
resultMap.put("fail", "请输入正确的原始手机号!");
resultMap.put("fail", "平台用户修改失败,请联系管理员");
}
} else {
resultMap.put("fail", "平台用户不存在");
......
package com.yeejoin.amos.boot.module.tzs.flc.biz.controller;
import com.alibaba.fastjson.JSON;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.entity.DataDictionary;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
......@@ -11,6 +13,7 @@ import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
......@@ -82,6 +85,21 @@ public class RegUnitInfoController extends BaseController {
return ResponseHelper.buildResponse(iRegUnitInfoService.creatQrCode());
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@RequestMapping(value = "/adminInfo", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "查询企业管理员信息", notes = "查询企业管理员信息")
public ResponseModel<RegUnitInfoDto> adminInfo() {
ReginParams reginParams = JSON.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
String unitCode = null;
if (ObjectUtils.isEmpty(reginParams)) {
return null;
} else {
unitCode = reginParams.getUserModel().getCompanys().get(0).getCompanyCode();
}
return ResponseHelper.buildResponse(iRegUnitInfoService.adminInfo(unitCode));
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@GetMapping(value = "/{unitCode}/check")
@ApiOperation(httpMethod = "GET", value = "单位注册校验", notes = "单位注册校验")
......
......@@ -26,6 +26,7 @@ import com.yeejoin.amos.feign.systemctl.model.RegionModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
......@@ -70,6 +71,11 @@ public class UnitInfoController extends BaseController {
*/
private long time = 600l;
/**
* 企业管理员变更缓存key前缀
*/
private final String adminChange = "ADMIN_CHANGE_";
@Autowired
UnitInfoServiceImpl unitInfoServiceImpl;
......@@ -235,7 +241,8 @@ public class UnitInfoController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@GetMapping(value = "/sendTelCode/{tel}")
@ApiOperation(httpMethod = "GET", value = "发送手机号验证码", notes = "发送手机号验证码")
public ResponseModel<Boolean> sendTelCode( @PathVariable(value = "tel") String tel) {
public ResponseModel<Boolean> sendTelCode( @PathVariable(value = "tel") String tel,
@RequestParam(value = "type", required = false) String type) {
if (ValidationUtil.isEmpty(tel)) {
throw new BadRequest("参数校验失败.");
}
......@@ -251,8 +258,9 @@ public class UnitInfoController extends BaseController {
} catch (Exception e) {
throw new BadRequest("发送短信失败:" + e.getMessage());
}
String Key = ObjectUtils.isEmpty(type) ? RedisKey.FLC_USER_TEL : adminChange;
// code 保存到缓存中
redisUtils.set(RedisKey.FLC_USER_TEL + tel, code,time);
redisUtils.set(Key + tel, code,time);
return ResponseHelper.buildResponse(flag);
}
......@@ -264,13 +272,16 @@ public class UnitInfoController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@GetMapping(value = "/verifyTelCode/{tel}/{code}")
@ApiOperation(httpMethod = "GET", value = "验证手机号验证码是否成功", notes = "验证手机号验证码是否成功")
public ResponseModel<Boolean> verifyTelCode(@PathVariable(value = "tel") String tel, @PathVariable(value = "code") String code) {
public ResponseModel<Boolean> verifyTelCode(@PathVariable(value = "tel") String tel,
@PathVariable(value = "code") String code,
@RequestParam(value = "type", required = false) String type) {
Boolean flag = false;
if (ValidationUtil.isEmpty(tel) || ValidationUtil.isEmpty(code)) {
throw new BadRequest("参数校验失败.");
}
if(redisUtils.hasKey(RedisKey.FLC_USER_TEL + tel)) {
String redisCode = redisUtils.get(RedisKey.FLC_USER_TEL + tel).toString();
String Key = ObjectUtils.isEmpty(type) ? RedisKey.FLC_USER_TEL : adminChange;
if(redisUtils.hasKey(Key + tel)) {
String redisCode = redisUtils.get(Key + tel).toString();
if(code.equals(redisCode)) {
flag = true;
}
......
......@@ -20,6 +20,7 @@ import com.yeejoin.amos.boot.module.tzs.biz.service.impl.BaseUnitLicenceServiceI
import com.yeejoin.amos.boot.module.tzs.biz.service.impl.StartPlatformTokenService;
import com.yeejoin.amos.boot.module.tzs.biz.service.impl.TzBaseEnterpriseInfoServiceImpl;
import com.yeejoin.amos.boot.module.tzs.biz.service.impl.TzsAuthServiceImpl;
import com.yeejoin.amos.boot.module.tzs.biz.utils.RedisUtil;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.RegUnitIcDto;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.RegUnitInfoDto;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.RegUnitIc;
......@@ -37,6 +38,7 @@ import com.yeejoin.amos.feign.systemctl.Systemctl;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.entity.ContentType;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mock.web.MockMultipartFile;
......@@ -71,6 +73,9 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
implements IRegUnitInfoService {
@Autowired
RedisUtil redisUtil;
@Autowired
BaseUnitLicenceServiceImpl baseUnitLicenceService;
@Autowired
......@@ -505,6 +510,19 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
}
}
@Override
public RegUnitInfoDto adminInfo(String unitCode) {
// 管理员信息
RegUnitInfo regUnitInfo = this.getOne(
new LambdaQueryWrapper<RegUnitInfo>().eq(RegUnitInfo::getUnitCode, unitCode));
RegUnitInfoDto regUnitInfoDto = new RegUnitInfoDto();
if (regUnitInfo != null) {
BeanUtils.copyProperties(regUnitInfo, regUnitInfoDto);
}
regUnitInfoDto.setAdminIdCardPhoto(ObjectUtils.isEmpty(regUnitInfo.getAdminIdCardPhoto()) ? new ArrayList() : JSON.parseArray(regUnitInfo.getAdminIdCardPhoto()));
return regUnitInfoDto;
}
private CompanyModel dealChildCompany(CompanyModel cm) {
cm.setChildren(this.getFilterChild(cm.getChildren() != null ? cm.getChildren() : new ArrayList()));
cm.getChildren().stream().filter(n -> {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment