123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- package com.jd.controller;
- import com.jd.code.ConstString;
- import com.jd.entity.basic.SsoUser;
- import com.jd.service.SsoUserService;
- import com.jd.util.Blank;
- import com.jd.util.SendUtil;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.web.bind.annotation.GetMapping;
- import org.springframework.web.bind.annotation.PostMapping;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RestController;
- import java.util.Map;
- /**
- * @author Admin
- */
- @RestController
- @RequestMapping("ssoUser")
- @Api(value = "SSO用户管理", tags = {"SSO用户管理"})
- public class SsoUserController {
- @Value("${security.oauth2.client.user.password}")
- private String oauth2Pwd;
- private final SsoUserService ssoUserService;
- public SsoUserController(SsoUserService ssoUserService) {
- this.ssoUserService = ssoUserService;
- }
- /**
- * SSO用户登录
- * @param loginAccount
- * @param loginPwd
- * @param clientId
- * @return
- */
- @PostMapping("userLogin")
- @ApiOperation(value = "SSO用户登录")
- public Map<String, Object> ssoUserLogin(String loginAccount, String loginPwd, String clientId) {
- if (Blank.isEmpty(loginAccount, loginPwd)) {
- return SendUtil.send(false, ConstString.REQUEST_WRONGPARAMS);
- }
- return ssoUserService.userLogin(loginAccount, loginPwd, clientId, oauth2Pwd);
- }
- /**
- * 根据登录帐号查询当前登录用户信息
- * @param clientId
- * @param loginAccount
- * @return
- */
- @PostMapping("getCurrentLoginInfo")
- @ApiOperation(value = "根据登录帐号查询当前登录用户信息")
- public Map<String, Object> getCurrentLoginInfo(String clientId, String loginAccount) {
- if (Blank.isEmpty(clientId, loginAccount)) {
- return SendUtil.send(false, ConstString.REQUEST_WRONGPARAMS);
- }
- return ssoUserService.getCurrentLoginInfo(clientId, loginAccount);
- }
- /**
- * 分页查询SSO用户列表
- * @param page
- * @param limit
- * @return
- */
- @GetMapping("getSsoUserListByPage")
- @ApiOperation(value = "分页查询SSO用户列表")
- public Map<String, Object> getSsoUserListByPage(Integer page, Integer limit, String queryValue) {
- if (Blank.isEmpty(page, limit)) {
- return SendUtil.send(false, ConstString.REQUEST_WRONGPARAMS);
- }
- return ssoUserService.getSsoUserListByPage(page, limit, queryValue);
- }
- /**
- * 新增SSO用户
- * @param ssoUser
- * @return
- */
- @PostMapping("insertSsoUser")
- @ApiOperation(value = "新增SSO用户")
- public Map<String, Object> insertSsoUser(SsoUser ssoUser) {
- String[] params = new String[]{"systemId", "loginAccount", "loginPwd"};
- if (!Blank.checkObjectParamNotNull(ssoUser, params)) {
- return SendUtil.send(false, ConstString.REQUEST_WRONGPARAMS);
- }
- return ssoUserService.insertSsoUser(ssoUser);
- }
- /**
- * 编辑SSO用户
- * @param ssoUser
- * @return
- */
- @PostMapping("updateSsoUser")
- @ApiOperation(value = "编辑SSO用户")
- public Map<String, Object> updateSsoUser(SsoUser ssoUser) {
- String[] params = new String[]{"userId", "systemId", "loginAccount"};
- if (!Blank.checkObjectParamNotNull(ssoUser, params)) {
- return SendUtil.send(false, ConstString.REQUEST_WRONGPARAMS);
- }
- return ssoUserService.updateSsoUser(ssoUser);
- }
- /**
- * 根据Id删除SSO用户
- * @param userId
- * @return
- */
- @PostMapping("deleteSsoUser")
- @ApiOperation(value = "根据Id删除SSO用户")
- public Map<String, Object> deleteSsoUser(Integer userId) {
- if (Blank.isEmpty(userId)) {
- return SendUtil.send(false, ConstString.REQUEST_WRONGPARAMS);
- }
- return ssoUserService.deleteSsoUser(userId);
- }
- /**
- * 根据Id查询SSO用户详情
- * @param userId
- * @return
- */
- @GetMapping("getSsoUserInfo")
- @ApiOperation(value = "根据Id查询SSO用户详情")
- public Map<String, Object> getSsoUserInfo(Integer userId) {
- if (Blank.isEmpty(userId)) {
- return SendUtil.send(false, ConstString.REQUEST_WRONGPARAMS);
- }
- return ssoUserService.getSsoUserInfo(userId);
- }
- /**
- * 注销
- * @param clientId 客户机id
- * @param loginAccount 登录账户
- * @return {@link Map}<{@link String}, {@link Object}>
- */
- @GetMapping("logout")
- @ApiOperation("退出登录")
- public Map<String, Object> logout(String clientId, String loginAccount) {
- if (Blank.isEmpty(clientId, loginAccount)) {
- return SendUtil.send(false, ConstString.REQUEST_WRONGPARAMS);
- }
- return ssoUserService.logout(clientId, loginAccount);
- }
- }
|