| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- package com.ims.eval.controller;
- import com.alibaba.fastjson.JSONObject;
- import com.ims.eval.entity.dto.result.R;
- import com.ims.eval.entity.Myuser;
- import com.ims.eval.feign.RemoteServiceBuilder;
- import com.ims.eval.service.IUserService;
- import io.swagger.annotations.ApiOperation;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.*;
- import java.util.List;
- import java.util.concurrent.atomic.AtomicBoolean;
- /**
- * <p>
- * 前端控制器
- * </p>
- *
- * @author wang
- * @since 2023-03-03
- */
- @Slf4j
- @RestController
- @RequestMapping("//user")
- public class UserController {
- @Autowired
- private IUserService userService;
- @Autowired
- private RemoteServiceBuilder remoteServiceBuilder;
- /**
- * 更具code获取用户信息
- * @return
- */
- @GetMapping(value = "getSysUser")
- public JSONObject getSysUser(
- @RequestParam(value = "code", required = false) String code) {
- JSONObject json = null;
- try {
- json = remoteServiceBuilder.getGatewayUrl().getSysUser(code);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return json;
- }
- /**
- * 根据token获取code
- * @return
- */
- @GetMapping(value = "getCodeByToken")
- public JSONObject getCodeByToken(
- @RequestParam(value = "token", required = false) String token) {
- JSONObject json = null;
- try {
- json = remoteServiceBuilder.getGatewayUrl().getCodeByToken(token);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return json;
- }
- /**
- * 登录接口
- * @param username
- * @param password
- * @return
- */
- @PostMapping(value = "bladeAuth")
- public R bladeAuth(
- @RequestParam(value = "username", required = false) String username,
- @RequestParam(value = "password", required = false) String password) {
- JSONObject json = null;
- try {
- json = userService.getbladeAuth("000000",username,password,"password","all","account");
- } catch (Exception e) {
- log.error("错误",e);
- return R.error().customError("登录失败");
- }
- return R.ok().data(json);
- }
- /**
- * 退出登录
- * @param token
- * @return
- */
- @PostMapping(value = "removeByToken")
- public JSONObject removeByToken(@RequestParam(value = "token", required = true) String token) {
- JSONObject json = null;
- try {
- json = remoteServiceBuilder.getGatewayUrl().removeByToken(token);
- } catch (Exception e) {
- log.error("错误",e);
- }
- return json;
- }
- //@ImsPreAuth("eval:dataDictionary:edit")
- @PostMapping(value = "/save")
- @ApiOperation(value = "新增(修改)", notes = "新增(修改)")
- public R addAll(@RequestBody List<Myuser> user) {
- AtomicBoolean b = new AtomicBoolean(false);
- user.stream().forEach(i -> {
- b.set(userService.saveOrUpdate(i));
- });
- if (b.get()) {
- return R.ok().data(b);
- } else {
- return R.error().data("保存失败!");
- }
- }
- /**
- * 查询所有数据
- * @param id 主键
- * @param orgId 组织id
- * @return
- */
- //@ImsPreAuth("eval:organizationEvaluationRule:view")
- @GetMapping(value = "listAll")
- public R listAll(
- @RequestParam(value = "id", required = false) String id,
- @RequestParam(value = "orgId", required = false) String orgId,
- @RequestParam(value = "unitId", required = false) String unitId) {
- List<Myuser> list = userService.listAll(id, orgId,unitId);
- return R.ok().data(list);
- }
- /**
- * 查询所有数据
- * @param id 主键
- * @return
- */
- //@ImsPreAuth("eval:organizationEvaluationRule:view")
- @GetMapping(value = "getId")
- public R getByid(
- @RequestParam(value = "id", required = false) String id) {
- Myuser user = userService.getById(id);
- return R.ok().data(user);
- }
- }
|