diff --git a/esua-epdc/epdc-auth/src/main/java/com/elink/esua/epdc/controller/AuthController.java b/esua-epdc/epdc-auth/src/main/java/com/elink/esua/epdc/controller/AuthController.java index 15e584b9..0a7c2585 100644 --- a/esua-epdc/epdc-auth/src/main/java/com/elink/esua/epdc/controller/AuthController.java +++ b/esua-epdc/epdc-auth/src/main/java/com/elink/esua/epdc/controller/AuthController.java @@ -139,14 +139,15 @@ public class AuthController { public Result workScripLogin(@RequestBody WorkUserScripLoginDTO workUserLoginDto) { //效验数据 ValidatorUtils.validateEntity(workUserLoginDto); - Result result = authService.workScripLogin(workUserLoginDto.getScrip()); + Result result = authService.workScripLogin(workUserLoginDto.getScrip()); if (result.success()) { + workUserLoginDto.setUsername(result.getData().getUsername()); // 解绑上一次登录账户并绑定当前账户 SysUserOpenIdFormDTO sysUserOpenIdFormDto = ConvertUtils.sourceToTarget(workUserLoginDto, SysUserOpenIdFormDTO.class); authService.modifyOpenId(sysUserOpenIdFormDto); } - return result; + return new Result().ok(result.getData().getWorkUserAuthorizationDTO()); } @PostMapping(value = "logout") diff --git a/esua-epdc/epdc-auth/src/main/java/com/elink/esua/epdc/service/AuthService.java b/esua-epdc/epdc-auth/src/main/java/com/elink/esua/epdc/service/AuthService.java index d5985dd4..a8163dcf 100644 --- a/esua-epdc/epdc-auth/src/main/java/com/elink/esua/epdc/service/AuthService.java +++ b/esua-epdc/epdc-auth/src/main/java/com/elink/esua/epdc/service/AuthService.java @@ -10,6 +10,7 @@ package com.elink.esua.epdc.service; import com.elink.esua.epdc.common.token.dto.TokenDto; import com.elink.esua.epdc.common.token.dto.WorkUserAuthorizationDTO; +import com.elink.esua.epdc.common.token.dto.WorkUserAuthorizationScripDTO; import com.elink.esua.epdc.commons.tools.utils.Result; import com.elink.esua.epdc.dto.AuthorizationDTO; import com.elink.esua.epdc.dto.DataScopeDeptList; @@ -82,5 +83,5 @@ public interface AuthService { * @Param [scrip] * @return com.elink.esua.epdc.commons.tools.utils.Result **/ - Result workScripLogin(String scrip); + Result workScripLogin(String scrip); } diff --git a/esua-epdc/epdc-auth/src/main/java/com/elink/esua/epdc/service/impl/AuthServiceImpl.java b/esua-epdc/epdc-auth/src/main/java/com/elink/esua/epdc/service/impl/AuthServiceImpl.java index 835d95c8..3e249bd1 100644 --- a/esua-epdc/epdc-auth/src/main/java/com/elink/esua/epdc/service/impl/AuthServiceImpl.java +++ b/esua-epdc/epdc-auth/src/main/java/com/elink/esua/epdc/service/impl/AuthServiceImpl.java @@ -12,6 +12,7 @@ import com.elink.esua.epdc.async.UserDeptTask; import com.elink.esua.epdc.common.token.dto.DeptDataScopeDTO; import com.elink.esua.epdc.common.token.dto.TokenDto; import com.elink.esua.epdc.common.token.dto.WorkUserAuthorizationDTO; +import com.elink.esua.epdc.common.token.dto.WorkUserAuthorizationScripDTO; import com.elink.esua.epdc.common.token.util.CpUserDetailRedis; import com.elink.esua.epdc.commons.tools.constant.Constant; import com.elink.esua.epdc.commons.tools.constant.NumConstant; @@ -299,7 +300,7 @@ public class AuthServiceImpl implements AuthService { } @Override - public Result workScripLogin(String scrip) { + public Result workScripLogin(String scrip) { HttpServletRequest request = HttpContextUtils.getHttpServletRequest(); //获取用户信息 @@ -324,7 +325,7 @@ public class AuthServiceImpl implements AuthService { log.setCreatorName(scrip); logProducer.saveLog(log); authorization.setRegisterState(NumConstant.ZERO_STR); - return new Result().error("未根据凭证获取到用户"); + return new Result().error("未根据凭证获取到用户"); } //账号停用 @@ -333,7 +334,7 @@ public class AuthServiceImpl implements AuthService { log.setCreator(user.getId()); log.setCreatorName(user.getUsername()); logProducer.saveLog(log); - return new Result().error("账号已停用"); + return new Result().error("账号已停用"); } //保存到Redis @@ -360,6 +361,9 @@ public class AuthServiceImpl implements AuthService { authorization.setRegisterState(NumConstant.ONE_STR); userDeptTask.packageUserDeptOptions(user.getId()); - - return new Result().ok(authorization); } + WorkUserAuthorizationScripDTO workUserAuthorizationScripDTO = new WorkUserAuthorizationScripDTO(); + workUserAuthorizationScripDTO.setWorkUserAuthorizationDTO(authorization); + workUserAuthorizationScripDTO.setUsername(user.getUsername()); + return new Result().ok(workUserAuthorizationScripDTO); + } } diff --git a/esua-epdc/epdc-commons/epdc-common-clienttoken/src/main/java/com/elink/esua/epdc/common/token/dto/WorkUserAuthorizationScripDTO.java b/esua-epdc/epdc-commons/epdc-common-clienttoken/src/main/java/com/elink/esua/epdc/common/token/dto/WorkUserAuthorizationScripDTO.java new file mode 100644 index 00000000..8d206dfd --- /dev/null +++ b/esua-epdc/epdc-commons/epdc-common-clienttoken/src/main/java/com/elink/esua/epdc/common/token/dto/WorkUserAuthorizationScripDTO.java @@ -0,0 +1,19 @@ +package com.elink.esua.epdc.common.token.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @author songyunpeng + * @Description 数据端临时凭证登录返回 + * @create 2020-06-23 + */ +@Data +public class WorkUserAuthorizationScripDTO implements Serializable { + private static final long serialVersionUID = 1905641243346550379L; + + private String username; + private WorkUserAuthorizationDTO workUserAuthorizationDTO; + +}