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();
|
}
|
}
|
}
|