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

import com.yuchen.saas.manage.system.api.entity.*;
import com.yuchen.saas.manage.system.api.vo.MenuVO;
import com.yuchen.saas.manage.system.api.vo.UserDeptVO;
import com.yuchen.saas.manage.system.api.vo.UserInDeptVO;
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_SYSTEM,
        fallback = ISysClientFallback.class
)
public interface ISysClient {

    String API_PREFIX = "/client";
    String MENU = API_PREFIX + "/menu";
    String DEPT = API_PREFIX + "/dept";
    String DEPT_IDS = API_PREFIX + "/dept-ids";
    String DEPT_NAME = API_PREFIX + "/dept-name";
    String DEPT_NAMES = API_PREFIX + "/dept-names";
    String DEPT_CHILD = API_PREFIX + "/dept-child";
    String POST = API_PREFIX + "/post";
    String POST_IDS = API_PREFIX + "/post-ids";
    String POST_NAME = API_PREFIX + "/post-name";
    String POST_NAMES = API_PREFIX + "/post-names";
    String ROLE = API_PREFIX + "/role";
    String ROLE_IDS = API_PREFIX + "/role-ids";
    String ROLE_NAME = API_PREFIX + "/role-name";
    String ROLE_NAMES = API_PREFIX + "/role-names";
    String ROLE_ALIAS = API_PREFIX + "/role-alias";
    String ROLE_ALIASES = API_PREFIX + "/role-aliases";
    String TENANT = API_PREFIX + "/tenant";
    String TENANT_ID = API_PREFIX + "/tenant-id";
    String PARAM = API_PREFIX + "/param";
    String PARAM_VALUE = API_PREFIX + "/param-value";
    String REGION = API_PREFIX + "/region";

    String BUTTONS = API_PREFIX + "/buttons";

    String DEPT_CHILD_BY_PARENT_ID = API_PREFIX + "/dept-child-by-parent-id";

    String POST_IS_DEFAULT = API_PREFIX + "/post-default-by-tenant-id";

    String DEPT_IS_DEFAULT = API_PREFIX + "/dept-default-by-tenant-id";

    String ROLE_BY_IDS = API_PREFIX + "/role-by-ids";

    String GET_USER_MENUS = API_PREFIX + "/get-user-menus";

    String List_DEPT_MENU_BY_MENU_CODE=API_PREFIX + "/list-dept-menu-by-menu-code";

    String LIST_DEPT_BY_MENU_CODE=API_PREFIX+ "/list-dept-by-menu-code";

    String GET_USER_DEPT=API_PREFIX+ "getUserDept";

    String LIST_USER_IN_DEPT=API_PREFIX+ "listUserInDept";

    String GET_ORG_USER_BY_ID=API_PREFIX+ "getOrgUserById";

    String ORG_USER_LIST_BY_IDS=API_PREFIX+ "orgUserListByIds";

    @GetMapping(BUTTONS)
    R<List<MenuVO>> buttons(@RequestParam("id") String roleId,@RequestParam("isAdmin") Integer isAdmin,@RequestParam("deptId") String deptId);

    // ==================================================================


    @GetMapping(MENU)
    R<Menu> getMenu(@RequestParam("id") Long id);


    @GetMapping(DEPT)
    R<Dept> getDept(@RequestParam("id") Long id);


    @GetMapping(DEPT_IDS)
    R<String> getDeptIds(@RequestParam("tenantId") String tenantId, @RequestParam("deptNames") String deptNames);


    @GetMapping(DEPT_NAME)
    R<String> getDeptName(@RequestParam("id") Long id);


    @GetMapping(DEPT_NAMES)
    R<List<String>> getDeptNames(@RequestParam("deptIds") String deptIds);


    @GetMapping(DEPT_CHILD)
    R<List<Dept>> getDeptChild(@RequestParam("deptId") Long deptId);


    @GetMapping(POST)
    R<Post> getPost(@RequestParam("id") Long id);


    @GetMapping(POST_IDS)
    R<String> getPostIds(@RequestParam("tenantId") String tenantId, @RequestParam("postNames") String postNames);


    @GetMapping(POST_NAME)
    R<String> getPostName(@RequestParam("id") Long id);


    @GetMapping(POST_NAMES)
    R<List<String>> getPostNames(@RequestParam("postIds") String postIds);


    @GetMapping(ROLE)
    R<Role> getRole(@RequestParam("id") Long id);


    @GetMapping(ROLE_IDS)
    R<String> getRoleIds(@RequestParam("tenantId") String tenantId, @RequestParam("roleNames") String roleNames);


    @GetMapping(ROLE_NAME)
    R<String> getRoleName(@RequestParam("id") Long id);


    @GetMapping(ROLE_ALIAS)
    R<String> getRoleAlias(@RequestParam("id") Long id);


    @GetMapping(ROLE_NAMES)
    R<List<String>> getRoleNames(@RequestParam("roleIds") String roleIds);


    @GetMapping(ROLE_ALIASES)
    R<List<String>> getRoleAliases(@RequestParam("roleIds") String roleIds);


    @GetMapping(TENANT)
    R<Tenant> getTenant(@RequestParam("id") Long id);


    @GetMapping(TENANT_ID)
    R<Tenant> getTenant(@RequestParam("tenantId") String tenantId);


    @GetMapping(PARAM)
    R<Param> getParam(@RequestParam("id") Long id);


    @GetMapping(PARAM_VALUE)
    R<String> getParamValue(@RequestParam("paramKey") String paramKey);


    @GetMapping(REGION)
    R<Region> getRegion(@RequestParam("code") String code);

    @GetMapping(DEPT_CHILD_BY_PARENT_ID)
    R<List<String>> getChildrenIdsByParentId(@RequestParam("tenantId") String tenantId,@RequestParam("deptId") String deptId);

    @GetMapping(POST_IS_DEFAULT)
    R<Post> getPost(@RequestParam("tenantId") Long tenantId,@RequestParam("isDefault") Integer isDefault);

    @GetMapping(DEPT_IS_DEFAULT)
    R<Dept> getDept(@RequestParam("tenantId") Long tenantId,@RequestParam("isDefault") Integer isDefault);

    @GetMapping(ROLE_BY_IDS)
    R<List<String>> getRoleNames(@RequestParam("roleIds") List<Long> roleIds);

    @GetMapping(GET_USER_MENUS)
    List<Menu> getUserMenus(@RequestParam(value = "roleId",required = false)String roleId, @RequestParam(value = "isAdmin",required = false)Integer isAdmin, @RequestParam(value = "deptId",required = false)String deptId, @RequestParam(value = "topMenuId",required = false)Long topMenuId);

    @GetMapping(List_DEPT_MENU_BY_MENU_CODE)
    R<List<DeptMenu>> listDeptMenuByMenuCode(@RequestParam("menuCode") String menuCode);

    @GetMapping(LIST_DEPT_BY_MENU_CODE)
    R<List<Dept>> listDeptByMenuCode(@RequestParam("menuCode") String menuCode,@RequestParam(value = "roleId",required = false) Long deptId);

    @GetMapping(GET_USER_DEPT)
    R<UserDeptVO> getUserDept(@RequestParam("orgUserId") Long orgUserId);

    @GetMapping(LIST_USER_IN_DEPT)
    R<List<UserInDeptVO>> listUserInDept(@RequestParam("userId") Long userId);

    @GetMapping("/getVisterCustomer")
    R<List<Dept>> getVisterCustomer();

    @GetMapping("/getApplyManageDetail")
    R getApplyManageDetail(@RequestParam("id")Long id);

    @GetMapping("/getListByDeptId")
    R<List<NestBusiness>> getListByDeptId();

    @GetMapping(GET_ORG_USER_BY_ID)
    R<NestOrgUser> getOrgUserById(@RequestParam("orgUserId") Long orgUserId);

    @PostMapping(ORG_USER_LIST_BY_IDS)
    R<List<NestOrgUser>> orgUserListByIds(@RequestBody List<Long> ids);

}
