package jnpf.personnels;

import io.swagger.v3.oas.annotations.Operation;
import jnpf.base.ActionResult;
import jnpf.base.vo.PageListVO;
import jnpf.model.personnels.dto.roster.QueryCompanyAgeDto;
import jnpf.model.personnels.dto.staff.employment.FtbPersonnelsStaffEmploymentApplyDto;
import jnpf.model.personnels.dto.staff.roster.FtbPersonnelsStaffRosterDto;
import jnpf.model.personnels.dto.staff.roster.ShopManagerUserDto;
import jnpf.model.personnels.dto.staff.roster.StaffRosterInfoDto;
import jnpf.model.personnels.req.roster.StaffRosterListReq;
import jnpf.model.personnels.req.roster.StaffRosterReq;
import jnpf.permission.model.user.UserListVO;
import jnpf.permission.vo.user.UserListMatchVO;
import jnpf.personnels.fallback.FtbPersonnelsRosterManagerFallBackApi;
import jnpf.util.NoDataSourceBind;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@FeignClient(name = "jnpf-ftb", fallback = FtbPersonnelsRosterManagerFallBackApi.class, path = "/web/personnels-staff-roster")
public interface FtbPersonnelsRosterManagerApi {

    @NoDataSourceBind
    @GetMapping("/updateCompanyAge")
    ActionResult updateCompanyAge(@RequestParam("tenantId") String tenantId);


    /**
     * 绑定手机号
     *
     * @param userId 用户ID
     * @param phone  手机号
     * @return
     */
    @PostMapping("/bindPhone")
    @NoDataSourceBind
    public ActionResult<Boolean> bindPhone(@RequestParam("tenantCode") String tenantCode, @RequestParam("userId") String userId, @RequestParam("phone") String phone);


    @NoDataSourceBind
    @PostMapping("/queryCompanyAge/{tenantId}")
    ActionResult<List<QueryCompanyAgeDto>> queryCompanyAge(@RequestBody List<String> userIds, @PathVariable("tenantId") String tenantId);

    /**
     * 查询未提交入职登记表的用户
     *
     * @param tenantId
     * @return
     */
    @NoDataSourceBind
    @GetMapping("/queryNoSubmitForm")
    ActionResult<List<StaffRosterInfoDto>> queryNoSubmitForm(@RequestParam("tenantId") String tenantId);


    /**
     * 查询健康证过期的用户
     *
     * @param tenantId
     * @param days     距离健康证 快过期的天数
     * @return
     */
    @NoDataSourceBind
    @GetMapping("/queryHealthExpire")
    ActionResult<List<StaffRosterInfoDto>> queryHealthExpire(@RequestParam("tenantId") String tenantId, @RequestParam(value = "days", required = false) Long days, @RequestParam(value = "months", required = false) Long months);


    /**
     * 花名册查询列表
     *
     * @param req
     * @return {@link ActionResult}<{@link FtbPersonnelsStaffEmploymentApplyDto}>
     */
    @GetMapping("/query-list")
    ActionResult<PageListVO<FtbPersonnelsStaffRosterDto>> pageLists(@Validated @SpringQueryMap StaffRosterListReq req);

    /**
     * 花名册查询列表 _post
     *
     * @param req
     * @return {@link ActionResult}<{@link FtbPersonnelsStaffEmploymentApplyDto}>
     */
    @PostMapping("/query-list/postWithSalary")
    ActionResult<PageListVO<FtbPersonnelsStaffRosterDto>> postWithSalary(@Validated @RequestBody StaffRosterListReq req);

    /**
     * 花名册查询列表不分页
     */
    @PostMapping("/query-list/post-with-salary-no-page")
    List<FtbPersonnelsStaffRosterDto> postWithSalaryNoPage(@Validated @RequestBody StaffRosterListReq req);

    /**
     * 花名册列表查询-无权限
     * @param req
     * @return ActionResult<FtbPersonnelsStaffRosterDto>
     */
    @PostMapping("/query-list/byUserIds")
    ActionResult<List<FtbPersonnelsStaffRosterDto>> getPersonnelByUserIds(@RequestBody StaffRosterListReq req);

    @PostMapping("/query-list/post")
    ActionResult<PageListVO<FtbPersonnelsStaffRosterDto>> pageListsPost(@Validated @RequestBody StaffRosterListReq req);

    /**
     * 查询离职人员信息
     * @return
     */
    @PostMapping("/queryDepartUser")
    ActionResult<List<FtbPersonnelsStaffRosterDto>> queryDepartUser(@RequestBody List<String> userIds);

    @Operation(summary = "[匹配]-指定user们哪些存在,哪些不存在, 包含花名册离职的用户")
    @PostMapping("/user/list/match/ids")
    ActionResult<UserListMatchVO> getUserListByMatch(@RequestBody List<String> userIds);

    /**
     * 根据用户ID查询所属门店负责人信息
     *
     * @param tenantId
     * @param  userIds    用户ID
     * @return
     */
    @NoDataSourceBind
    @PostMapping("/queryShopManagerUser/{tenantId}")
    ActionResult<ShopManagerUserDto> queryShopManagerUser(@PathVariable("tenantId") String tenantId, @RequestBody List<String> userIds);

    @NoDataSourceBind
    @GetMapping("/timingAlertTrialJob/{tenantId}")
    @Deprecated(since = "人事2.1废弃试岗状态")
    ActionResult<List<UserListVO>> timingAlertTrialJob(@PathVariable("tenantId") String tenantId);

    /**
     * 根据用户ID查询用户信息
     * @param req
     * @return
     */
    @PostMapping("/queryWithUserIds")
    List<FtbPersonnelsStaffRosterDto> queryWithUserIds( @RequestBody StaffRosterListReq req);

    /**
     * 查询指定userIds用户信息
     */
    @PostMapping("/queryWithUserIds/post")
    List<FtbPersonnelsStaffRosterDto> queryWithUserIdsPost(@RequestBody StaffRosterReq req);
}
