package cn.sh.stc.sict.cloud.upms.controller.feign;


import cn.sh.stc.sict.cloud.common.core.util.R;
import cn.sh.stc.sict.cloud.common.security.annotation.Inner;
import cn.sh.stc.sict.cloud.upms.dto.UserInfo;
import cn.sh.stc.sict.cloud.upms.service.SysUserBaseService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description
 * @Author F_xh
 * @Date
 */
@Slf4j
@RestController
@RequestMapping("/feign/user/base")
@AllArgsConstructor
public class UserFeignController {
    private SysUserBaseService sysUserBaseService;

    /**
     * F_xh 根据用户名获取用户登录信息
     * @param username
     * @return
     */
    @Inner
    @GetMapping("/info/{appId}/{username}")
    public R info(@PathVariable("appId") String appId,
                  @PathVariable String username) {
        UserInfo userInfo = sysUserBaseService.getUserInfo(appId, username);
        return new R(userInfo);
    }



    /**
     * F_xh 根据移动端 inStr 获取用户登录信息
     * @return
     */
    @Inner
    @GetMapping("/social/info/{appId}/{inStr}")
    public R social(@PathVariable("appId") String appId,
                    @PathVariable("inStr") String inStr){
        try {
            UserInfo info = sysUserBaseService.getUserInfoBySocial(appId, inStr);
            return new R().success(info);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}
