|
@@ -1,7 +1,5 @@
|
|
|
package com.diagbot.web;
|
|
|
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
-import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -21,7 +19,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.diagbot.annotation.SysLogger;
|
|
|
import com.diagbot.dto.RespDTO;
|
|
|
-import com.diagbot.dto.ResultModelDTO;
|
|
|
import com.diagbot.dto.UserInfoDTO;
|
|
|
import com.diagbot.entity.Organization;
|
|
|
import com.diagbot.entity.User;
|
|
@@ -32,7 +29,6 @@ import com.diagbot.facade.UserAuthenticationFacade;
|
|
|
import com.diagbot.facade.UserFacade;
|
|
|
import com.diagbot.facade.UserOrganizationFacade;
|
|
|
import com.diagbot.util.DateUtil;
|
|
|
-import com.diagbot.util.GsonUtil;
|
|
|
import com.diagbot.vo.OrganizationVO;
|
|
|
import com.diagbot.vo.UserAndOrganizationVO;
|
|
|
import com.diagbot.vo.UserInfoAuditVO;
|
|
@@ -47,202 +43,171 @@ import io.swagger.annotations.ApiOperation;
|
|
|
* @time: 2018年9月17日 下午1:53:53
|
|
|
*/
|
|
|
@RestController
|
|
|
-@Api(value="用户信息和机构信息API", tags={"用户信息和机构信息API"})
|
|
|
+@Api(value = "用户信息和机构信息API", tags = { "用户信息和机构信息API" })
|
|
|
@RequestMapping("/userInfo")
|
|
|
public class UserInfoController {
|
|
|
-
|
|
|
+
|
|
|
@Autowired
|
|
|
- private UserFacade userFacade;
|
|
|
+ private UserFacade userFacade;
|
|
|
@Autowired
|
|
|
OrganizationFacade organizationFacade;
|
|
|
@Autowired
|
|
|
UserOrganizationFacade userOrganizationFacade;
|
|
|
@Autowired
|
|
|
UserAuthenticationFacade userAuthenticationFacade;
|
|
|
-
|
|
|
- private final String MSG_SUCCESS = "操作成功!";
|
|
|
- private final String MSG_ERROR = "操作失败!";
|
|
|
-
|
|
|
- @ApiOperation(value = "分页查询获取用户信息", notes = "根据每页显示条数,默认 10,和当前页")
|
|
|
- @PostMapping("/getUserInfoPag")
|
|
|
- @SysLogger("getUserInfoPag")
|
|
|
-// @ApiIgnore
|
|
|
- public RespDTO<UserInfoDTO> getUserInfoPag(Page page, String orgName, String autStatus ){
|
|
|
- UserInfoDTO userInfo =new UserInfoDTO();
|
|
|
- userInfo.setOrgName(orgName);
|
|
|
- userInfo.setAutStatus(autStatus);
|
|
|
- IPage<UserInfoDTO> user= userFacade.selectUserInfoListPage(page,userInfo);
|
|
|
- return RespDTO.onSuc(user);
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "修改用户信息和机构信息以", notes = "用户信息和机构信息")
|
|
|
- @PostMapping("/updateUserInfoAll")
|
|
|
- @SysLogger("updateUserInfoAll")
|
|
|
- public RespDTO<UserInfoOrganizationsVO> updateUserInfoAll(@Valid @RequestBody UserInfoOrganizationsVO userInfo){
|
|
|
- int res = userFacade.updateUserInfoAll(userInfo);
|
|
|
-
|
|
|
- if(res!=0){
|
|
|
- return RespDTO.onSuc("修改用户信息成功!");
|
|
|
- }
|
|
|
- return RespDTO.onSuc("修改用户信息失败!");
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "审核用户信息和机构信息", notes = "审核用户信息和机构信息")
|
|
|
- @PostMapping("/auditUserInfoAll")
|
|
|
- @SysLogger("auditUserInfoAll")
|
|
|
- public RespDTO<UserInfoAuditVO> auditUserInfoAll(@Valid @RequestBody UserInfoAuditVO userInfoAuditVO){
|
|
|
- Map<String,Object> auditMap = new HashMap<String, Object>();
|
|
|
- auditMap.put("userId", userInfoAuditVO.getUserId());
|
|
|
- //TODO auditMap.put("modifier",UserUtils.getCurrentPrincipleID());
|
|
|
- auditMap.put("modifier","5");
|
|
|
- auditMap.put("gmtModified",DateUtil.now());
|
|
|
- auditMap.put("isReject",userInfoAuditVO.getIsReject());
|
|
|
- auditMap.put("rejectComment",userInfoAuditVO.getRejectComment());
|
|
|
- auditMap.put("rejectType",userInfoAuditVO.getRejectType());
|
|
|
- //TODO 审核前先验证该用户的的认证状态
|
|
|
- boolean res = userFacade.auditUserInfoAll(auditMap);
|
|
|
-
|
|
|
- if(res ==true){
|
|
|
- return RespDTO.onSuc("审核通过!");
|
|
|
- }
|
|
|
- return RespDTO.onSuc("审核失败!");
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "删除用户信息和机构信息", notes = "用户信息和机构信息")
|
|
|
- @PostMapping("/updateDeleted")
|
|
|
- @SysLogger("updateDeleted")
|
|
|
- public RespDTO updateDeleted(@RequestParam String userId){
|
|
|
- Map<String,Object> map = new HashMap<String, Object>();
|
|
|
- map.put("userId", userId);
|
|
|
- //TODO map.put("modifier",UserUtils.getCurrentPrincipleID());
|
|
|
- map.put("modifier","5");
|
|
|
- map.put("gmtModified",DateUtil.now());
|
|
|
- int res= userFacade.updateDeleted(map);
|
|
|
- return RespDTO.onSuc("刪除成功"+res);
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "模糊查询机构信息", notes = "机构信息")
|
|
|
- @PostMapping("/findOrganization")
|
|
|
- @SysLogger("findOrganization")
|
|
|
- public RespDTO findOrganization(@RequestParam String organizationName){
|
|
|
- //TODO 返回机构Id和机构
|
|
|
- List<Organization> organization = organizationFacade.findOrganization(organizationName);
|
|
|
-
|
|
|
- return RespDTO.onSuc(organization);
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "添加构信息", notes = "机构信息")
|
|
|
- @PostMapping("/addOrganization")
|
|
|
- @SysLogger("addOrganization")
|
|
|
- public RespDTO<OrganizationVO> addOrganization(@Valid @RequestBody OrganizationVO organizationVO){
|
|
|
- //TODO
|
|
|
- String organizationName = organizationVO.getOrganizationName();
|
|
|
- List<Organization> organizationList = organizationFacade.findOrganization(organizationName);
|
|
|
- if(organizationList.size()>0){
|
|
|
- return RespDTO.onSuc("该机构存在");
|
|
|
- }
|
|
|
- Organization organization = new Organization();
|
|
|
- organization.setName(organizationVO.getOrganizationName());
|
|
|
- organization.setType(organizationVO.getType());
|
|
|
- organization.setPrincipal(organizationVO.getPrincipal());
|
|
|
- organization.setSubNum(organizationVO.getSubNum());
|
|
|
- organization.setAddress(organizationVO.getAddress());
|
|
|
- organization.setGmtCreate(DateUtil.now());
|
|
|
- //TODO organization.setModifier(UserUtils.getCurrentPrincipleID());
|
|
|
- organization.setCreator("5");
|
|
|
-
|
|
|
- boolean res = organizationFacade.save(organization);
|
|
|
-
|
|
|
- //System.out.println(GsonUtil.toJson(organization));
|
|
|
- if(res ==true){
|
|
|
- return RespDTO.onSuc("增加机构信息成功!");
|
|
|
- }
|
|
|
- return RespDTO.onSuc("增加机构信息失败!");
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "添加用户信息和机构信息管理员", notes = "用户信息和机构信息的绑定")
|
|
|
- @PostMapping("/addUserInfo")
|
|
|
- @SysLogger("addUserInfo")
|
|
|
- public RespDTO<UserAndOrganizationVO> addUserInfo(@Valid @RequestBody UserAndOrganizationVO userAndOrganizationVO){
|
|
|
- //TODO 先查找机构,获取机构id,再注册用户,返回用户id, 取到用户id和 机构id ,查询用户机构关联表,在进行绑定
|
|
|
- //User user = new User();
|
|
|
- //验证用户是否存在
|
|
|
- String username = userAndOrganizationVO.getUserName();
|
|
|
- User userData= userFacade.getUserInfo(username);
|
|
|
- //System.out.println(user);
|
|
|
- if(userData!=null){
|
|
|
- return RespDTO.onSuc("该用户存在");
|
|
|
- }
|
|
|
- //验证机构是否被绑定
|
|
|
- UserOrganization userORG =new UserOrganization();
|
|
|
- userORG.setOrganizationId(userAndOrganizationVO.getOrganizationid());
|
|
|
-
|
|
|
- List<UserOrganization> userOrganizationData = userOrganizationFacade.getAgencyPersonnel(userORG);
|
|
|
- if(userOrganizationData.size()>0){
|
|
|
- return RespDTO.onSuc("该机构绑定了用户!");
|
|
|
- }
|
|
|
-
|
|
|
- User user =new User();
|
|
|
- user.setCreator("5");
|
|
|
- user.setUsername(userAndOrganizationVO.getUserName());
|
|
|
- PasswordEncoder passwordEncoder = PasswordEncoderFactories.createDelegatingPasswordEncoder();
|
|
|
- String entryPassword= passwordEncoder.encode(userAndOrganizationVO.getPassWord());
|
|
|
- user.setPassword(entryPassword);
|
|
|
- user.setLinkman(userAndOrganizationVO.getLinkman());
|
|
|
- user.setGmtCreate(DateUtil.now());
|
|
|
- user.setEmail(userAndOrganizationVO.getEmail());
|
|
|
- boolean res = userFacade.save(user);
|
|
|
- if(res==true){
|
|
|
- Long userId =user.getId();
|
|
|
- //用户信息的认证
|
|
|
- UserAuthentication userAuthentication = new UserAuthentication();
|
|
|
- userAuthentication.setCreator("5");//创建人Id
|
|
|
- userAuthentication.setGmtCreate(DateUtil.now());//记录创建时间
|
|
|
- userAuthentication.setPosition(userAndOrganizationVO.getPosition());//岗位信息
|
|
|
- userAuthentication.setUserId(userId);//用户id
|
|
|
- userAuthentication.setIsReject("Y");//是否通过认证 N:未通过,Y:已通过
|
|
|
- userAuthentication.setStatus(1);//认证状态(0:未认证,1:已认证,2:认证中)
|
|
|
- userAuthenticationFacade.save(userAuthentication);
|
|
|
-
|
|
|
- //用户信息和机构信息的绑定
|
|
|
- UserOrganization userOrganization = new UserOrganization();
|
|
|
- userOrganization.setCreator("5");//创建人Id
|
|
|
- userOrganization.setGmtCreate(DateUtil.now());
|
|
|
- userOrganization.setOrganizationId(userAndOrganizationVO.getOrganizationid());//机构id
|
|
|
- userOrganization.setUserId(userId);//用户id
|
|
|
-
|
|
|
- userOrganizationFacade.save(userOrganization);
|
|
|
- }
|
|
|
-
|
|
|
- return RespDTO.onSuc("绑定成功");
|
|
|
- }
|
|
|
-
|
|
|
- //TODO
|
|
|
-/* @ApiOperation(value = "根据用户id查询已开通的功能", notes = "已开通信息")
|
|
|
- @PostMapping("/getInformationAvailableByUserId")
|
|
|
- @SysLogger("getInformationAvailableByUserId")*/
|
|
|
-
|
|
|
- //TODO
|
|
|
- /*
|
|
|
- @ApiOperation(value = "根据用户id和产品id,启用和停用功能", notes = "开通信息")
|
|
|
- @PostMapping("/startAndendByuserId")
|
|
|
- @SysLogger("startAndendByuserId")*/
|
|
|
-
|
|
|
- //TODO
|
|
|
- /* @ApiOperation(value = "根据用户id和产品id,删除开通信息", notes = "删除开通信息")
|
|
|
- @PostMapping("/delInformationAvailable")
|
|
|
- @SysLogger("delInformationAvailable")*/
|
|
|
- //TODO
|
|
|
- /* @ApiOperation(value = "根据用户id和产品id,修改开通时间", notes = "修改开通时间")
|
|
|
- @PostMapping("/delInformationAvailable")
|
|
|
- @SysLogger("delInformationAvailable")*/
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
|
|
|
-}
|
|
|
+ @ApiOperation(value = "分页查询获取用户信息", notes = "根据每页显示条数,默认 10,和当前页")
|
|
|
+ @PostMapping("/getUserInfoPag")
|
|
|
+ @SysLogger("getUserInfoPag")
|
|
|
+ // @ApiIgnore
|
|
|
+ public RespDTO<UserInfoDTO> getUserInfoPag(Page page, String orgName, String autStatus) {
|
|
|
+ UserInfoDTO userInfo = new UserInfoDTO();
|
|
|
+ userInfo.setOrgName(orgName);
|
|
|
+ userInfo.setAutStatus(autStatus);
|
|
|
+ IPage<UserInfoDTO> user = userFacade.selectUserInfoListPage(page, userInfo);
|
|
|
+ return RespDTO.onSuc(user);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "修改用户信息和机构信息", notes = "用户信息和机构信息")
|
|
|
+ @PostMapping("/updateUserInfoAll")
|
|
|
+ @SysLogger("updateUserInfoAll")
|
|
|
+ public RespDTO<UserInfoOrganizationsVO> updateUserInfoAll(@Valid @RequestBody UserInfoOrganizationsVO userInfo) {
|
|
|
+ int res = userFacade.updateUserInfoAll(userInfo);
|
|
|
+
|
|
|
+ if (res != 0) {
|
|
|
+ return RespDTO.onSuc("修改用户信息成功!");
|
|
|
+ }
|
|
|
+ return RespDTO.onSuc("修改用户信息失败!");
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "审核用户信息和机构信息", notes = "审核用户信息和机构信息")
|
|
|
+ @PostMapping("/auditUserInfoAll")
|
|
|
+ @SysLogger("auditUserInfoAll")
|
|
|
+ public RespDTO<UserInfoAuditVO> auditUserInfoAll(@Valid @RequestBody UserInfoAuditVO userInfoAuditVO) {
|
|
|
+ Map<String, Object> auditMap = new HashMap<String, Object>();
|
|
|
+ auditMap.put("userId", userInfoAuditVO.getUserId());
|
|
|
+ // TODO auditMap.put("modifier",UserUtils.getCurrentPrincipleID());
|
|
|
+ auditMap.put("modifier", "5");
|
|
|
+ auditMap.put("gmtModified", DateUtil.now());
|
|
|
+ auditMap.put("isReject", userInfoAuditVO.getIsReject());
|
|
|
+ auditMap.put("rejectComment", userInfoAuditVO.getRejectComment());
|
|
|
+ auditMap.put("rejectType", userInfoAuditVO.getRejectType());
|
|
|
+ // TODO 审核前先验证该用户的的认证状态
|
|
|
+ boolean res = userFacade.auditUserInfoAll(auditMap);
|
|
|
+
|
|
|
+ if (res == true) {
|
|
|
+ return RespDTO.onSuc("审核通过!");
|
|
|
+ }
|
|
|
+ return RespDTO.onSuc("审核失败!");
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "删除用户信息和机构信息", notes = "用户信息和机构信息")
|
|
|
+ @PostMapping("/updateDeleted")
|
|
|
+ @SysLogger("updateDeleted")
|
|
|
+ public RespDTO updateDeleted(@RequestParam String userId) {
|
|
|
+ Map<String, Object> map = new HashMap<String, Object>();
|
|
|
+ map.put("userId", userId);
|
|
|
+ // TODO map.put("modifier",UserUtils.getCurrentPrincipleID());
|
|
|
+ map.put("modifier", "5");
|
|
|
+ map.put("gmtModified", DateUtil.now());
|
|
|
+ int res = userFacade.updateDeleted(map);
|
|
|
+ return RespDTO.onSuc("刪除成功" + res);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "模糊查询机构信息", notes = "机构信息")
|
|
|
+ @PostMapping("/findOrganization")
|
|
|
+ @SysLogger("findOrganization")
|
|
|
+ public RespDTO findOrganization(@RequestParam String organizationName) {
|
|
|
+ // TODO 返回机构Id和机构
|
|
|
+ List<Organization> organization = organizationFacade.findOrganization(organizationName);
|
|
|
+
|
|
|
+ return RespDTO.onSuc(organization);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "添加构信息", notes = "机构信息")
|
|
|
+ @PostMapping("/addOrganization")
|
|
|
+ @SysLogger("addOrganization")
|
|
|
+ public RespDTO<OrganizationVO> addOrganization(@Valid @RequestBody OrganizationVO organizationVO) {
|
|
|
+ // TODO
|
|
|
+ String organizationName = organizationVO.getOrganizationName();
|
|
|
+ List<Organization> organizationList = organizationFacade.findOrganization(organizationName);
|
|
|
+ if (organizationList.size() > 0) {
|
|
|
+ return RespDTO.onSuc("该机构存在");
|
|
|
+ }
|
|
|
+ Organization organization = new Organization();
|
|
|
+ organization.setName(organizationVO.getOrganizationName());
|
|
|
+ organization.setType(organizationVO.getType());
|
|
|
+ organization.setPrincipal(organizationVO.getPrincipal());
|
|
|
+ organization.setSubNum(organizationVO.getSubNum());
|
|
|
+ organization.setAddress(organizationVO.getAddress());
|
|
|
+ organization.setGmtCreate(DateUtil.now());
|
|
|
+ // TODO organization.setModifier(UserUtils.getCurrentPrincipleID());
|
|
|
+ organization.setCreator("5");
|
|
|
|
|
|
+ boolean res = organizationFacade.save(organization);
|
|
|
+
|
|
|
+ // System.out.println(GsonUtil.toJson(organization));
|
|
|
+ if (res == true) {
|
|
|
+ return RespDTO.onSuc("增加机构信息成功!");
|
|
|
+ }
|
|
|
+ return RespDTO.onSuc("增加机构信息失败!");
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "添加用户信息和机构信息管理员", notes = "用户信息和机构信息的绑定")
|
|
|
+ @PostMapping("/addUserInfo")
|
|
|
+ @SysLogger("addUserInfo")
|
|
|
+ public RespDTO<UserAndOrganizationVO> addUserInfo(@Valid @RequestBody UserAndOrganizationVO userAndOrganizationVO) {
|
|
|
+ // TODO 先查找机构,获取机构id,再注册用户,返回用户id, 取到用户id和 机构id ,查询用户机构关联表,在进行绑定
|
|
|
+ // User user = new User();
|
|
|
+ // 验证用户是否存在
|
|
|
+ String username = userAndOrganizationVO.getUserName();
|
|
|
+ User userData = userFacade.getUserInfo(username);
|
|
|
+ // System.out.println(user);
|
|
|
+ if (userData != null) {
|
|
|
+ return RespDTO.onSuc("该用户存在");
|
|
|
+ }
|
|
|
+ // 验证机构是否被绑定
|
|
|
+ UserOrganization userORG = new UserOrganization();
|
|
|
+ userORG.setOrganizationId(userAndOrganizationVO.getOrganizationid());
|
|
|
+
|
|
|
+ List<UserOrganization> userOrganizationData = userOrganizationFacade.getAgencyPersonnel(userORG);
|
|
|
+ if (userOrganizationData.size() > 0) {
|
|
|
+ return RespDTO.onSuc("该机构绑定了用户!");
|
|
|
+ }
|
|
|
+
|
|
|
+ User user = new User();
|
|
|
+ user.setCreator("5");
|
|
|
+ user.setUsername(userAndOrganizationVO.getUserName());
|
|
|
+ PasswordEncoder passwordEncoder = PasswordEncoderFactories.createDelegatingPasswordEncoder();
|
|
|
+ String entryPassword = passwordEncoder.encode(userAndOrganizationVO.getPassWord());
|
|
|
+ user.setPassword(entryPassword);
|
|
|
+ user.setLinkman(userAndOrganizationVO.getLinkman());
|
|
|
+ user.setGmtCreate(DateUtil.now());
|
|
|
+ user.setEmail(userAndOrganizationVO.getEmail());
|
|
|
+ boolean res = userFacade.save(user);
|
|
|
+ if (res == true) {
|
|
|
+ Long userId = user.getId();
|
|
|
+ // 用户信息的认证
|
|
|
+ UserAuthentication userAuthentication = new UserAuthentication();
|
|
|
+ userAuthentication.setCreator("5");// 创建人Id
|
|
|
+ userAuthentication.setGmtCreate(DateUtil.now());// 记录创建时间
|
|
|
+ userAuthentication.setPosition(userAndOrganizationVO.getPosition());// 岗位信息
|
|
|
+ userAuthentication.setUserId(userId);// 用户id
|
|
|
+ userAuthentication.setIsReject(1);// 是否通过认证 0:未通过,1:已通过
|
|
|
+ userAuthentication.setStatus(1);// 认证状态(0:未认证,1:已认证,2:认证中)
|
|
|
+ userAuthenticationFacade.save(userAuthentication);
|
|
|
+
|
|
|
+ // 用户信息和机构信息的绑定
|
|
|
+ UserOrganization userOrganization = new UserOrganization();
|
|
|
+ userOrganization.setCreator("5");// 创建人Id
|
|
|
+ userOrganization.setGmtCreate(DateUtil.now());
|
|
|
+ userOrganization.setOrganizationId(userAndOrganizationVO.getOrganizationid());// 机构id
|
|
|
+ userOrganization.setUserId(userId);// 用户id
|
|
|
+
|
|
|
+ userOrganizationFacade.save(userOrganization);
|
|
|
+ }
|
|
|
+
|
|
|
+ return RespDTO.onSuc("绑定成功");
|
|
|
+ }
|
|
|
+
|
|
|
+}
|