package com.muyu.enterpise.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.domain.BaseEntity;
import com.muyu.common.system.domain.SysUser;
import com.muyu.enterpise.service.FirmUserService;
import io.swagger.v3.oas.annotations.media.Schema;
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;

import javax.annotation.Resource;

/**
 * 公司员工信息控制层
 *
 * @Author WangXin
 * @Data 2024/10/9
 * @Version 1.0.0
 */
@RestController
@RequestMapping("/firmUser")
public class FirmUserController extends BaseController<BaseEntity> {

    @Resource
    private FirmUserService firmUserService;

    /**
     * 通过用户名查询用户信息
     * @param username 用户名
     * @return 用户信息
     */
    @Schema(name = "通过用户名查询用户信息",description = "通过用户名查询用户信息")
    @GetMapping("/info/{username}")
    public Result<SysUser> info(@PathVariable("username") String username) {
        LambdaQueryWrapper<SysUser> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(SysUser::getUserName, username);
        return success(firmUserService.getOne(wrapper));
    }

}
