|
@@ -1,36 +1,20 @@
|
|
|
package com.dragon.tj.portal.auth.controller;
|
|
|
|
|
|
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.dragon.tj.portal.auth.model.LoginUser;
|
|
|
+import com.dragon.tj.portal.auth.service.TokenService;
|
|
|
+import com.dragon.tj.portal.auth.web.entity.SysUser;
|
|
|
import com.dragon.tj.portal.common.base.R;
|
|
|
-import com.dragon.tj.portal.common.constants.CacheConstants;
|
|
|
-import com.dragon.tj.portal.component.log.annotation.SysLog;
|
|
|
-import com.dragon.tj.portal.entity.SysDict;
|
|
|
-import com.dragon.tj.portal.entity.SysDictItem;
|
|
|
-import com.dragon.tj.portal.service.SysDictItemService;
|
|
|
-import com.dragon.tj.portal.service.SysDictService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.cache.annotation.CacheEvict;
|
|
|
-import org.springframework.cache.annotation.Cacheable;
|
|
|
-import org.springframework.http.ResponseEntity;
|
|
|
-import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.PutMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
-import javax.validation.Valid;
|
|
|
-import java.io.IOException;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.HashSet;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
@@ -42,16 +26,30 @@ import java.util.Map;
|
|
|
* @since 2023-06-12
|
|
|
*/
|
|
|
@RestController
|
|
|
-@RequestMapping("/sso")
|
|
|
+@RequestMapping("/test")
|
|
|
public class SsoController {
|
|
|
- @RequestMapping("/login")
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TokenService tokenService;
|
|
|
+
|
|
|
+ @GetMapping("/login")
|
|
|
public R login(HttpServletResponse response) {
|
|
|
- // String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
|
|
|
- // loginBody.getUuid());
|
|
|
- // ajax.put(Constants.TOKEN, token);
|
|
|
+ SysUser sysUser = new SysUser();
|
|
|
+ sysUser.setIdcard("120222197001010002");
|
|
|
+ sysUser.setName("李四");
|
|
|
+ sysUser.setOrgCode("120000450200");
|
|
|
+ sysUser.setOrgName("服务实战值班岛");
|
|
|
+ List<String> perms = Arrays.asList("gzt", "yyzx");
|
|
|
+ LoginUser loginUser = new LoginUser(sysUser.getIdcard(), sysUser.getOrgCode(), sysUser, new HashSet<>(perms));
|
|
|
+ String token = tokenService.createToken(loginUser);
|
|
|
Map<String, String> data = new HashMap<>();
|
|
|
- data.put("token", "123");
|
|
|
+ data.put("token", token);
|
|
|
return R.ok(data);
|
|
|
}
|
|
|
+
|
|
|
+ @GetMapping("/hello")
|
|
|
+ public R<String> test() {
|
|
|
+ return R.ok("Hello World!");
|
|
|
+ }
|
|
|
}
|
|
|
|