package jnpf.account;

import jnpf.account.fallback.PTenantAccountApiFallBackFactory;
import jnpf.base.ActionResult;
import jnpf.exception.HandleException;
import jnpf.model.TenantGenerateDefaultAvatarVO;
import jnpf.model.personnels.dto.turnover.SaveTenantUserForm;
import jnpf.model.personnels.req.roster.UserAccountDto;
import jnpf.model.user.GenerateHeadForm;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;

@FeignClient(name = "jnpf-tenant",  fallbackFactory = PTenantAccountApiFallBackFactory.class, path = "/tenantUser")
public interface PTenantAccountApi {


    @PutMapping("/batchAddUserAccount")
    ActionResult<List<UserAccountDto>> batchAddUserAccount(@RequestBody List<UserAccountDto> userAccountForms);

    @PutMapping("/batchDisabledUserAccount")
    ActionResult<List<UserAccountDto>> batchDisabledUserAccount(@RequestBody List<UserAccountDto> userAccountForms);

    @GetMapping("/generateDefaultAvatar")
    ActionResult generateDefaultAvatar(@RequestParam("name") String name) throws IOException;


    /**
     * 批量异步生成头像 调用方自己要触发保底
     * @param names 用户名
     * @return
     */
    @PostMapping("/batch/generate/default/avatar")
    List<TenantGenerateDefaultAvatarVO> batchGenerateDefaultAvatar(@RequestBody List<String> names);

    /**
     * 用户状态修改
     * @param saveTenantUserForm
     * @return
     */
    @PutMapping("/updateJobStatus")
    ActionResult updateJobStatus(@RequestBody SaveTenantUserForm saveTenantUserForm);


    @PutMapping("/userInfoSynchronous")
    ActionResult userInfoSynchronous(@RequestBody SaveTenantUserForm saveTenantUserForm);

    @DeleteMapping("/deleteUser/{id}")
    ActionResult deleteUser(@PathVariable("id") String id);

    /**
     * 删除用户（同步删除租户用户）
     *
     * @param userId 用户ID
     * @return ActionResult
     */
    @DeleteMapping("/deleteUserWithPlatform/{userId}")
    Boolean deleteUserWithPlatform(@PathVariable("userId") String userId);

    /**
     * 批量删除用户
     */
    @DeleteMapping("/deleteUsers")
    ActionResult<Void> deleteUsers(@RequestBody List<String> userIds) ;

    @PostMapping("/generateDefaultAvatarCustomFilename")
    ActionResult generateDefaultAvatar(@RequestBody GenerateHeadForm generateHeadForm) throws IOException;

}
