增加市域治理名片认证资源接口

This commit is contained in:
wanggeng 2022-05-25 01:20:20 +08:00
parent b2200e5ccb
commit 6590546865
6 changed files with 188 additions and 9 deletions

View File

@ -104,6 +104,12 @@
</exclusions> </exclusions>
</dependency> </dependency>
<dependency>
<groupId>ink.wgink</groupId>
<artifactId>login-wechat</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency> <dependency>
<groupId>ink.wgink</groupId> <groupId>ink.wgink</groupId>
<artifactId>service-position</artifactId> <artifactId>service-position</artifactId>

View File

@ -1,6 +1,8 @@
package cn.com.tenlion.usercenter.controller.resource.userexpand; package cn.com.tenlion.usercenter.controller.resource.userexpand;
import cn.com.tenlion.usercenter.pojo.dtos.userexpand.GridUserAuthBindDTO;
import cn.com.tenlion.usercenter.pojo.dtos.userexpand.UserExpandDTO; import cn.com.tenlion.usercenter.pojo.dtos.userexpand.UserExpandDTO;
import cn.com.tenlion.usercenter.pojo.vos.userexpand.GridUserAuthBindVO;
import cn.com.tenlion.usercenter.pojo.vos.userexpand.UserExpandVO; import cn.com.tenlion.usercenter.pojo.vos.userexpand.UserExpandVO;
import cn.com.tenlion.usercenter.service.userexpand.IUserExpandService; import cn.com.tenlion.usercenter.service.userexpand.IUserExpandService;
import ink.wgink.annotation.CheckRequestBodyAnnotation; import ink.wgink.annotation.CheckRequestBodyAnnotation;
@ -43,6 +45,17 @@ public class UserExpandResourceController extends DefaultBaseController {
return new SuccessResult(); return new SuccessResult();
} }
@ApiOperation(value = "认证并绑定网格员", notes = "认证并绑定网格员接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "access_token", value = "token", paramType = "query")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PostMapping(name = "auth-and-bind")
@CheckRequestBodyAnnotation
public GridUserAuthBindDTO authAndBind(@RequestBody GridUserAuthBindVO gridUserAuthBindVO) {
return userExpandService.getAuthAndBindResult(gridUserAuthBindVO);
}
@ApiOperation(value = "拓展属性详情", notes = "拓展属性详情接口") @ApiOperation(value = "拓展属性详情", notes = "拓展属性详情接口")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "userId", value = "用户ID", paramType = "path") @ApiImplicitParam(name = "userId", value = "用户ID", paramType = "path")

View File

@ -0,0 +1,59 @@
package cn.com.tenlion.usercenter.pojo.dtos.userexpand;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.ArrayList;
import java.util.List;
/**
* @ClassName: GridUserAuthBindDTO
* @Description: 网格用户认证绑定
* @Author: wanggeng
* @Date: 2022/5/24 15:33
* @Version: 1.0
*/
@ApiModel
public class GridUserAuthBindDTO {
@ApiModelProperty(name = "userId", value = "用户ID")
private String userId;
@ApiModelProperty(name = "areaCode", value = "区域编码")
private String areaCode;
@ApiModelProperty(name = "userLevel", value = "用户级别")
private Integer userLevel;
@ApiModelProperty(name = "areaCodes", value = "地区编码列表")
private List<String> areaCodes;
public String getUserId() {
return userId == null ? "" : userId.trim();
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getAreaCode() {
return areaCode == null ? "" : areaCode.trim();
}
public void setAreaCode(String areaCode) {
this.areaCode = areaCode;
}
public Integer getUserLevel() {
return userLevel == null ? 0 : userLevel;
}
public void setUserLevel(Integer userLevel) {
this.userLevel = userLevel;
}
public List<String> getAreaCodes() {
return areaCodes == null ? new ArrayList() : areaCodes;
}
public void setAreaCodes(List<String> areaCodes) {
this.areaCodes = areaCodes;
}
}

View File

@ -0,0 +1,51 @@
package cn.com.tenlion.usercenter.pojo.vos.userexpand;
import ink.wgink.annotation.CheckEmptyAnnotation;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* @ClassName: GridUserAuthVO
* @Description: 网格员认证+绑定
* @Author: wanggeng
* @Date: 2022/5/24 15:28
* @Version: 1.0
*/
@ApiModel
public class GridUserAuthBindVO {
@ApiModelProperty(name = "userId", value = "需要绑定的用户ID")
@CheckEmptyAnnotation(name = "用户ID")
private String userId;
@ApiModelProperty(name = "username", value = "用户名")
@CheckEmptyAnnotation(name = "用户名")
private String username;
@ApiModelProperty(name = "password", value = "密码")
@CheckEmptyAnnotation(name = "密码")
private String password;
public String getUserId() {
return userId == null ? "" : userId.trim();
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getUsername() {
return username == null ? "" : username.trim();
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password == null ? "" : password.trim();
}
public void setPassword(String password) {
this.password = password;
}
}

View File

@ -1,8 +1,10 @@
package cn.com.tenlion.usercenter.service.userexpand; package cn.com.tenlion.usercenter.service.userexpand;
import cn.com.tenlion.usercenter.pojo.dtos.userexpand.GridUserAuthBindDTO;
import cn.com.tenlion.usercenter.pojo.dtos.userexpand.OnlineGridMemberDTO; import cn.com.tenlion.usercenter.pojo.dtos.userexpand.OnlineGridMemberDTO;
import cn.com.tenlion.usercenter.pojo.dtos.userexpand.UserExpandDTO; import cn.com.tenlion.usercenter.pojo.dtos.userexpand.UserExpandDTO;
import cn.com.tenlion.usercenter.pojo.pos.userexpand.UserExpandPO; import cn.com.tenlion.usercenter.pojo.pos.userexpand.UserExpandPO;
import cn.com.tenlion.usercenter.pojo.vos.userexpand.GridUserAuthBindVO;
import cn.com.tenlion.usercenter.pojo.vos.userexpand.UserExpandVO; import cn.com.tenlion.usercenter.pojo.vos.userexpand.UserExpandVO;
import ink.wgink.interfaces.user.IUserExpandBaseService; import ink.wgink.interfaces.user.IUserExpandBaseService;
import ink.wgink.pojo.dtos.user.UserDTO; import ink.wgink.pojo.dtos.user.UserDTO;
@ -84,4 +86,12 @@ public interface IUserExpandService extends IUserExpandBaseService<UserExpandDTO
* @return * @return
*/ */
List<OnlineGridMemberDTO> listOnlineGridMemberReleaseByAreaCode(String areaCode); List<OnlineGridMemberDTO> listOnlineGridMemberReleaseByAreaCode(String areaCode);
/**
* 认证并绑定网格员
*
* @param gridUserAuthBindVO
* @return
*/
GridUserAuthBindDTO getAuthAndBindResult(GridUserAuthBindVO gridUserAuthBindVO);
} }

View File

@ -5,19 +5,24 @@ import cn.com.tenlion.usercenter.consts.ISmartCityUserCenterConsts;
import cn.com.tenlion.usercenter.dao.userexpand.IUserExpandDao; import cn.com.tenlion.usercenter.dao.userexpand.IUserExpandDao;
import cn.com.tenlion.usercenter.manager.HuaWeiSMCManager; import cn.com.tenlion.usercenter.manager.HuaWeiSMCManager;
import cn.com.tenlion.usercenter.pojo.dtos.huawei.SMCMeetingDTO; import cn.com.tenlion.usercenter.pojo.dtos.huawei.SMCMeetingDTO;
import cn.com.tenlion.usercenter.pojo.dtos.userexpand.GridUserAuthBindDTO;
import cn.com.tenlion.usercenter.pojo.dtos.userexpand.OnlineGridMemberDTO; import cn.com.tenlion.usercenter.pojo.dtos.userexpand.OnlineGridMemberDTO;
import cn.com.tenlion.usercenter.pojo.dtos.userexpand.UserExpandDTO; import cn.com.tenlion.usercenter.pojo.dtos.userexpand.UserExpandDTO;
import cn.com.tenlion.usercenter.pojo.pos.userexpand.UserExpandPO; import cn.com.tenlion.usercenter.pojo.pos.userexpand.UserExpandPO;
import cn.com.tenlion.usercenter.pojo.vos.userexpand.GridUserAuthBindVO;
import cn.com.tenlion.usercenter.pojo.vos.userexpand.UserExpandVO; import cn.com.tenlion.usercenter.pojo.vos.userexpand.UserExpandVO;
import cn.com.tenlion.usercenter.service.userexpand.IUserExpandService; import cn.com.tenlion.usercenter.service.userexpand.IUserExpandService;
import ink.wgink.common.base.DefaultBaseService; import ink.wgink.common.base.DefaultBaseService;
import ink.wgink.exceptions.ParamsException;
import ink.wgink.exceptions.SearchException; import ink.wgink.exceptions.SearchException;
import ink.wgink.interfaces.department.IDepartmentBaseService; import ink.wgink.interfaces.department.IDepartmentBaseService;
import ink.wgink.interfaces.department.IDepartmentUserBaseService; import ink.wgink.interfaces.department.IDepartmentUserBaseService;
import ink.wgink.interfaces.role.IRoleUserBaseService; import ink.wgink.interfaces.role.IRoleUserBaseService;
import ink.wgink.interfaces.user.IUserBaseService;
import ink.wgink.module.dictionary.pojo.dtos.DataDTO; import ink.wgink.module.dictionary.pojo.dtos.DataDTO;
import ink.wgink.module.instantmessage.websocket.manager.WebSocketChannelManager; import ink.wgink.module.instantmessage.websocket.manager.WebSocketChannelManager;
import ink.wgink.module.map.pojo.dtos.grid.GridDTO;
import ink.wgink.module.map.service.grid.IGridRelationService;
import ink.wgink.module.map.service.grid.IGridService;
import ink.wgink.mongo.module.dictionary.service.IMongoDataService; import ink.wgink.mongo.module.dictionary.service.IMongoDataService;
import ink.wgink.pojo.ListPage; import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.dtos.department.DepartmentDTO; import ink.wgink.pojo.dtos.department.DepartmentDTO;
@ -26,12 +31,15 @@ import ink.wgink.pojo.dtos.user.UserDTO;
import ink.wgink.pojo.pos.DepartmentPO; import ink.wgink.pojo.pos.DepartmentPO;
import ink.wgink.pojo.result.SuccessResultList; import ink.wgink.pojo.result.SuccessResultList;
import ink.wgink.pojo.session.WebSocketSession; import ink.wgink.pojo.session.WebSocketSession;
import ink.wgink.service.user.pojo.pos.UserPO;
import ink.wgink.service.user.service.IUserService;
import ink.wgink.util.ArrayListUtil; import ink.wgink.util.ArrayListUtil;
import ink.wgink.util.map.HashMapUtil; import ink.wgink.util.map.HashMapUtil;
import ink.wgink.util.string.WStringUtil; import ink.wgink.util.string.WStringUtil;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
@ -52,7 +60,7 @@ public class UserExpandServiceImpl extends DefaultBaseService implements IUserEx
@Autowired @Autowired
private ParamsConfigProperties paramsConfigProperties; private ParamsConfigProperties paramsConfigProperties;
@Autowired @Autowired
private IUserBaseService userBaseService; private IUserService userService;
@Autowired @Autowired
private IUserExpandDao userExpandDao; private IUserExpandDao userExpandDao;
@Autowired @Autowired
@ -62,10 +70,17 @@ public class UserExpandServiceImpl extends DefaultBaseService implements IUserEx
@Autowired @Autowired
private IRoleUserBaseService roleUserBaseService; private IRoleUserBaseService roleUserBaseService;
@Autowired @Autowired
private IGridRelationService gridRelationService;
@Autowired
private IGridService gridService;
@Autowired
private IMongoDataService mongoDataService; private IMongoDataService mongoDataService;
@Autowired
private PasswordEncoder passwordEncoder;
private static final String SMC_STATE_DELETE = "delete"; private static final String SMC_STATE_DELETE = "delete";
private static final String SMC_STATE_BIND = "bind"; private static final String SMC_STATE_BIND = "bind";
@Override @Override
public String getRoute() { public String getRoute() {
return "route/user-expand/update"; return "route/user-expand/update";
@ -73,7 +88,7 @@ public class UserExpandServiceImpl extends DefaultBaseService implements IUserEx
@Override @Override
public UserExpandDTO get(String userId) { public UserExpandDTO get(String userId) {
UserDTO userDTO = userBaseService.get(userId); UserDTO userDTO = userService.get(userId);
if (userDTO == null) { if (userDTO == null) {
throw new SearchException("用户不存在"); throw new SearchException("用户不存在");
} }
@ -94,7 +109,7 @@ public class UserExpandServiceImpl extends DefaultBaseService implements IUserEx
@Override @Override
public List<UserExpandDTO> listByUserIds(List<String> userIds) { public List<UserExpandDTO> listByUserIds(List<String> userIds) {
List<UserDTO> userDTOs = userBaseService.listByUserIds(userIds); List<UserDTO> userDTOs = userService.listByUserIds(userIds);
if (userDTOs.isEmpty()) { if (userDTOs.isEmpty()) {
return new ArrayList<>(); return new ArrayList<>();
} }
@ -106,7 +121,7 @@ public class UserExpandServiceImpl extends DefaultBaseService implements IUserEx
@Override @Override
public List<UserExpandDTO> listByUsernames(List<String> usernames) { public List<UserExpandDTO> listByUsernames(List<String> usernames) {
List<UserDTO> userDTOs = userBaseService.listByUsernames(usernames); List<UserDTO> userDTOs = userService.listByUsernames(usernames);
if (userDTOs.isEmpty()) { if (userDTOs.isEmpty()) {
return new ArrayList<>(); return new ArrayList<>();
} }
@ -217,7 +232,7 @@ public class UserExpandServiceImpl extends DefaultBaseService implements IUserEx
* @throws Exception * @throws Exception
*/ */
private void setSMCMeeting(String userId, Map<String, Object> params) throws Exception { private void setSMCMeeting(String userId, Map<String, Object> params) throws Exception {
UserDTO userDTO = userBaseService.get(userId); UserDTO userDTO = userService.get(userId);
SMCMeetingDTO meeting = HuaWeiSMCManager.createMeeting(userDTO.getUserName(), userDTO.getUserUsername()); SMCMeetingDTO meeting = HuaWeiSMCManager.createMeeting(userDTO.getUserName(), userDTO.getUserUsername());
LOG.debug("meeting: {}", meeting); LOG.debug("meeting: {}", meeting);
params.put("smcMeetingId", meeting.getMeetingId()); params.put("smcMeetingId", meeting.getMeetingId());
@ -235,7 +250,7 @@ public class UserExpandServiceImpl extends DefaultBaseService implements IUserEx
@Override @Override
public List<UserExpandDTO> listByUserIdsAndAreaCode(List<String> userIds, String areaCode) { public List<UserExpandDTO> listByUserIdsAndAreaCode(List<String> userIds, String areaCode) {
List<UserDTO> userDTOs = userBaseService.listByUserIds(userIds); List<UserDTO> userDTOs = userService.listByUserIds(userIds);
if (userDTOs.isEmpty()) { if (userDTOs.isEmpty()) {
return new ArrayList<>(); return new ArrayList<>();
} }
@ -307,7 +322,7 @@ public class UserExpandServiceImpl extends DefaultBaseService implements IUserEx
onlineUserIds.add(webSocketSession.getUserId()); onlineUserIds.add(webSocketSession.getUserId());
}); });
LOG.debug("area code: {}, user count: {}, online user count", areaCode, userExpandDTOs.size(), webSocketSessions.size()); LOG.debug("area code: {}, user count: {}, online user count", areaCode, userExpandDTOs.size(), webSocketSessions.size());
return userBaseService.listByUserIds(onlineUserIds); return userService.listByUserIds(onlineUserIds);
} }
@Override @Override
@ -334,7 +349,7 @@ public class UserExpandServiceImpl extends DefaultBaseService implements IUserEx
onlineUserIds.add(webSocketSession.getUserId()); onlineUserIds.add(webSocketSession.getUserId());
}); });
// 在线用户列表 // 在线用户列表
List<UserDTO> userDTOs = userBaseService.listByUserIds(onlineUserIds); List<UserDTO> userDTOs = userService.listByUserIds(onlineUserIds);
LOG.debug("build online grid member list"); LOG.debug("build online grid member list");
List<OnlineGridMemberDTO> gridMemberDTOs = new ArrayList<>(); List<OnlineGridMemberDTO> gridMemberDTOs = new ArrayList<>();
userDTOs.forEach(userDTO -> { userDTOs.forEach(userDTO -> {
@ -361,6 +376,31 @@ public class UserExpandServiceImpl extends DefaultBaseService implements IUserEx
return gridMemberDTOs; return gridMemberDTOs;
} }
@Override
public GridUserAuthBindDTO getAuthAndBindResult(GridUserAuthBindVO gridUserAuthBindVO) {
// 查询小程序端要绑定的网格员账号是否正确
UserPO userPO = userService.getPOByUsername(gridUserAuthBindVO.getUsername());
if (passwordEncoder.matches(userPO.getUserPassword(), gridUserAuthBindVO.getPassword())) {
throw new ParamsException("用户名密码不匹配");
}
GridUserAuthBindDTO gridUserAuthBindDTO = new GridUserAuthBindDTO();
gridUserAuthBindDTO.setUserId(userPO.getUserId());
// 查询用户信息
UserExpandPO userExpandPO = getPO(userPO.getUserId());
if (userExpandPO != null) {
gridUserAuthBindDTO.setAreaCode(userExpandPO.getAreaCode());
gridUserAuthBindDTO.setUserLevel(userExpandPO.getUserLevel());
}
// 查询网格信息
List<String> gridIds = gridRelationService.listGridId(userPO.getUserId());
if (!gridIds.isEmpty()) {
List<GridDTO> gridDTOS = gridService.list(gridIds);
List<String> gridCodes = ArrayListUtil.listBeanStringIdValue(gridDTOS, "gridCode", GridDTO.class);
gridUserAuthBindDTO.setAreaCodes(gridCodes);
}
return gridUserAuthBindDTO;
}
/** /**
* 设置用户 * 设置用户
* *