广州市综治平台后端
xusd
2025-06-07 36306491396230522fa20585c2621a7fc899849a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package cn.huge.module.ctuser.controller.client;
 
import cn.huge.base.common.utils.ObjectUtils;
import cn.huge.base.common.utils.ReturnFailUtils;
import cn.huge.base.common.utils.ReturnSucUtils;
import cn.huge.module.ctuser.domain.po.CtUser;
import cn.huge.module.ctuser.service.*;
import cn.huge.module.cust.dto.CtUserDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
 
/**
 * @title: 客户用户表接口api-微服务调用
 * @description: 客户用户表接口api-微服务调用
 * @company: hugeinfo
 * @author: liyj
 * @time: 2024-08-19 20:04:19
 * @version: 1.0.0
 */
@Slf4j
@RestController
@RequestMapping("/api/client/ctUser")
public class CtUserClientController {
 
    @Autowired(required = false)
    private HttpServletRequest request;
 
    @Autowired
    private CtUserService service;
 
    /**
     * 微服务调用,只获取用户信息
     * @url {ctx}/api/client/ctUser/clientGetUser
     * @param userId 登录用户编号
     * @return Object
     */
    @GetMapping("/clientGetUser")
    public Object clientGetUser(@RequestParam(value = "userId") String userId) {
        try {
            CtUser ctUser = service.getById(userId);
            if (ObjectUtils.isNotEmpty(ctUser)){
                CtUserDTO ctUserDTO = new CtUserDTO();
                BeanUtils.copyProperties(ctUser, ctUserDTO);
                return ReturnSucUtils.getRepInfo(ctUserDTO);
            }else {
                return ReturnFailUtils.getRepInfo("用户不存在!");
            }
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo();
        }
    }
 
    /**
     * 微服务调用,获取用户所有信息(用户信息、角色等)
     * @url {ctx}/api/client/ctUser/clientGetUserAll
     * @param userId 登录用户编号
     * @return Object
     */
    @GetMapping("/clientGetUserAll")
    public Object clientGetUserAll(@RequestParam(value = "userId") String userId) {
        try {
            CtUserDTO ctUserDTO = service.clientGetUserAll(userId);
            if (ObjectUtils.isEmpty(ctUserDTO)){
                return ReturnFailUtils.getRepInfo("用户不存在!");
            }
            return ReturnSucUtils.getRepInfo(ctUserDTO);
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo();
        }
    }
}