package com.yuchen.saas.manage.user.api.feign;


import com.yuchen.saas.manage.user.api.entity.*;
import com.yuchen.saas.manage.user.api.request.*;
import com.yuchen.saas.manage.user.api.vo.MoveUserDeptVo;
import com.yuchen.saas.manage.user.api.vo.UserDeptInfoVo;
import com.yuchen.saas.manage.user.api.vo.UserDeptIsDeptAdminVo;
import org.nest.springwrap.core.launch.app.AppNameConstant;
import org.nest.springwrap.core.tool.api.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;


@FeignClient(
        value = AppNameConstant.SAAS_USER,
        fallback = UserDeptClientFallback.class
)
public interface IUserDeptClient {

    String API_PREFIX = "/userDept";
    String LIST_BY_DEPT_ID = API_PREFIX + "/listByDeptId";
    String LIST_BY_DEPT_IDS = API_PREFIX + "/listByDeptIds";
    String SAVE = API_PREFIX + "/save";
    String SAVE_List = API_PREFIX + "/saveList";

    String UPDATE_IS_ADMIN = API_PREFIX + "/updateIsAdmin";
    String UPDATE_IS_CREATE = API_PREFIX + "/updateIsCreate";
    String DELETE_LIST = API_PREFIX + "/deleteList";

    String MOVE_LIST = API_PREFIX + "/moveList";

    String LIST_INFO_BY_DEPT_ID = API_PREFIX + "/listInfoByDeptId";

    String DELETE_BY_ORG_USER_ID = API_PREFIX + "/deleteByOrgUserId";

    String DELETE_BY_DEPT_ID = API_PREFIX + "/deleteByDeptId";

    String LIST__BY_ORG_USER_IDS = API_PREFIX + "/listByOrgUserIds";

    String  PUT_DEPT_ADMIN= API_PREFIX + "/putDeptAdmin";

    String  PUT_DEPT_ADMIN_BY_USER= API_PREFIX + "/putDeptAdminByUser";

    String  GET_BY_ID= API_PREFIX + "/getById";

    String  UPDATE_BINDING_BY_ORG_USER_ID= API_PREFIX + "/updateBinDingByOrgUserId";

    String  GET_BY_DEPT_ID_AND_ORG_USER_ID= API_PREFIX + "/getByDeptIdAndOrgUserId";

    String LIST__BY_IDS = API_PREFIX + "/listByIds";

    String SAVE_OR_UPDATE_BY_PARAM = API_PREFIX + "/saveOrUpdateByParam";

    String REMOVE_BY_EXTERNAL= API_PREFIX + "/removeByExternal";

    String USER_DEPT_SYNC= API_PREFIX + "/userDeptSync";

    String MOVE_USER_DEPT_SYNC= API_PREFIX + "/moveUserDeptSync";

    String SAVE_AND_SYNC= API_PREFIX + "/saveAndSync";

    String MOVE_AND_SYNC= API_PREFIX + "/moveAndSync";

    String DELETE_BY_DEPT_ID_AND_ORG_USER_ID= API_PREFIX + "/deleteByDeptIdAndOrgUserId";

    String REMOVE_BY_DEPT_ID= API_PREFIX + "/removeByDeptId";

    String UPDATE_BY_ID= API_PREFIX + "/updateById";

    String LIST_DEPT_ADMIN=API_PREFIX + "/listDeptAdmin";

    String LIST_DEPT_ADMIN_BY_DEPT_IDS=API_PREFIX+"/listDeptAdminByDeptIds";

    String LIST_DEPT_CREATE_BY_DEPT_IDS=API_PREFIX+"/listDeptCreateByDeptIds";



    @GetMapping(LIST_INFO_BY_DEPT_ID)
    R<List<UserDeptInfoVo>> listInfoByDeptId(@RequestParam("deptId") Long deptId);

    @GetMapping(LIST_BY_DEPT_ID)
    R<List<UserDept>> listByDeptId(@RequestParam("deptId") Long deptId);

    @GetMapping(LIST_BY_DEPT_IDS)
    R<List<UserDept>> listByDeptIds(@RequestParam("deptIds") List<Long> deptIds);


    @PostMapping(SAVE)
    R<UserDept> saveOrgUserBinding(@RequestBody UserDept userDeptDto);

    @PostMapping(SAVE_OR_UPDATE_BY_PARAM)
    R saveOrUpdateByParam(@RequestBody UserDept userDeptDto);

    @PostMapping(UPDATE_BY_ID)
    R updateById(@RequestBody UserDept userDept);

    @PostMapping(SAVE_List)
    R saveOrgUserBindingList(@RequestBody List<UserDept> list);

    @PostMapping(UPDATE_IS_ADMIN)
    R updateIsAdmin(@RequestBody UserDept userDeptDto);

    @PostMapping(DELETE_LIST)
    R<MoveUserDeptVo> deleteList(@RequestBody UserDeptDeleteRequest param);

    @PostMapping(MOVE_LIST)
    R moveList(@RequestBody UserDeptMoveRequest param);

    @PostMapping(DELETE_BY_ORG_USER_ID)
    R deleteByOrgUserId(@RequestBody Long orgUserId);

    @PostMapping(DELETE_BY_DEPT_ID)
    R deleteByDeptId(@RequestBody UserDeptDeleteByDeptIdRequest param);

    @GetMapping(LIST__BY_ORG_USER_IDS)
    R<List<UserDept>> listByOrgUserIds(@RequestParam("orgUserIds")List<Long>orgUserIds);

    @GetMapping(GET_BY_ID)
    R<UserDept> getById(@RequestParam("id") Long id);

    @PostMapping(UPDATE_BINDING_BY_ORG_USER_ID)
    R<MoveUserDeptVo> updateBinDingByOrgUserId(@RequestBody UserDeptByOrgUserRequest param);

    @PostMapping(UPDATE_IS_CREATE)
    R <UserDept>updateIsCreate(@RequestBody UpdateIsCreatRequest userDept);

    @PostMapping(DELETE_BY_DEPT_ID_AND_ORG_USER_ID)
    R <Boolean>deleteByDeptIdAndOrgUserId(@RequestBody UserDeptRemoveRequest parm);

    @GetMapping(GET_BY_DEPT_ID_AND_ORG_USER_ID)
    R<UserDeptInfoVo> getByDeptIdAndOrgUserId(@RequestParam("deptId") Long deptId,@RequestParam("orgUserId")Long orgUserId);

    @GetMapping(LIST__BY_IDS)
    R<List<UserDept>> listByIds(@RequestParam("ids")List<Long>ids);

    /**
     * 移除部门下的外部人员绑定关系,根据外部人员原本的orguserId
     * @param param
     * @return
     */
    @PostMapping(REMOVE_BY_EXTERNAL)
    R removeByExternal(@RequestBody RemoveUserDeptByExternalRequest param);

    /**
     * 绑定下级关联同步数据
     * @param param
     * @return
     */
    @PostMapping(USER_DEPT_SYNC)
    R userDeptSync(@RequestBody UserDeptSyncRequest param);

    /**
     * 解除下级关联移除同步数据
     * @param param
     * @return
     */
    @PostMapping(MOVE_USER_DEPT_SYNC)
    R moveUserDeptSync(@RequestBody UserDeptSyncRequest param);

    /**
     * 单个人绑定关系(跟组织)及向上级组织同步数据,
     * @param param
     * @return
     */
    @PostMapping(SAVE_AND_SYNC)
    R saveAndSync(@RequestBody SaveUserDeptSyncRequest param);

    @PostMapping(MOVE_AND_SYNC)
    R moveAndSync(@RequestBody SaveUserDeptSyncRequest param);

    @PostMapping(PUT_DEPT_ADMIN)
    R<UserDeptIsDeptAdminVo> putDeptAdmin(@RequestBody UpdateDeptAdminParam param);

    @PostMapping(REMOVE_BY_DEPT_ID)
    R removeByDeptId(@RequestBody Long deptId);


    @PostMapping(PUT_DEPT_ADMIN_BY_USER)
    R<UserDept> putDeptAdminByUser(@RequestBody UpdateUserIsDeptAdminDto param);


    @GetMapping(LIST_DEPT_ADMIN)
    R<List<UserDept>> listDeptAdmin(@RequestParam("deptId") Long deptId);

    @PostMapping(LIST_DEPT_ADMIN_BY_DEPT_IDS)
    R<List<UserDept>> listDeptAdminByDeptIds(@RequestBody List<Long> deptIds);


    @PostMapping(LIST_DEPT_CREATE_BY_DEPT_IDS)
    R<List<UserDept>> listDeptCreateByDeptIds(@RequestBody List<Long> deptIds);
}
