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


import com.yuchen.saas.manage.user.api.entity.*;
import com.yuchen.saas.manage.user.api.request.UserNameRequest;
import com.yuchen.saas.manage.user.api.vo.UserAdminVO;
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;
import java.util.Map;


@FeignClient(
        value = AppNameConstant.SAAS_USER,
        fallback = UserClientFallback.class
)
public interface IUserClient {

    String API_PREFIX = "/client";
    String USER_INFO = API_PREFIX + "/user-info";
    String USER_INFO_BY_TYPE = API_PREFIX + "/user-info-by-type";
    String USER_INFO_BY_ID = API_PREFIX + "/user-info-by-id";
    String USER_INFO_BY_ID_V1 = API_PREFIX + "/user-info-by-id-v1";
    String USER_INFO_BY_ACCOUNT = API_PREFIX + "/user-info-by-account";
    String USER_INFO_BY_PHONE = API_PREFIX + "/user-info-by-phone";
    String USER_DETAIL_BY_PHONE = API_PREFIX + "/user-detail-by-phone";

    String USER_INFO_DETAIL_BY_PHONE = API_PREFIX + "/user-info-detail-by-phone";
    String USER_INFO_DETAIL_BY_Id = API_PREFIX + "/user-info-detail-by-id";

    String USER_AUTH_INFO = API_PREFIX + "/user-auth-info";
    String SAVE_USER = API_PREFIX + "/save-user";
    String UPDATE_USER = API_PREFIX + "/update-user";
    String SUBMIT_USER = API_PREFIX + "/submit-user";
    String SUBMIT_USER_DETAIL = API_PREFIX + "/submit-user-detail";

    String SELECT_USER_DETAIL_BY_WECHAT = API_PREFIX + "/select_user_detail_by_wechat";

    String SELECT_USER_DETAIL_LIST_BY_WECHAT = API_PREFIX + "/select_user_detail_list_detail_by_wechat";

    String SUBMIT_WATCH_USER = API_PREFIX + "/submit-watch-user";
    String REMOVE_USER = API_PREFIX + "/remove-user";

    String FIND_USER_BY_NAME_AND_PHONE = API_PREFIX + "/find/by/name/and/phone";

    String FIND_BY_TENANT_AND_PHONE = API_PREFIX + "/find/by/tenant/and/phone";

    String FIND_BY_TENANT_AND_USERID = API_PREFIX + "/find/by/tenant/and/user-id";

    String FIND_BY_ACCOUNT = API_PREFIX + "/find/by/account";

    String USER_NAME = API_PREFIX + "/user-name";

    String USER_BY_ACCOUNT=API_PREFIX + "/user-by-account";

    String USER_INFO_BY_NAME=API_PREFIX + "/user-info-by-name";

    String USER_BY_NAME = API_PREFIX + "/userByName";

    String USER_BY_NAME_OR_PHONE = API_PREFIX + "/userByNameOrPhone";

    String FIND_USER_LIST_BY_PARK_ID = API_PREFIX + "/findUserListByParkId";

    String FIND_USER_LIST_BY_USER_IDS = API_PREFIX + "/findUserListByUserIds";

    String USER_GET_OR_SAVE = API_PREFIX + "/user-get-or-save";

    String USER_BY_PHONE_AND_TENANT_ID = API_PREFIX + "/user-by-phone-and-tenant-id";

    String USER_DETAIL_BY_USER_ID=API_PREFIX+"user-detail-by-user-id";

    String USER_DETAIL_BY_ID=API_PREFIX+"user-detail-by-id";

    String GET_ADMIN_USER= API_PREFIX + "/getAdminUser";

    String USER_DETAIL_BY_USER_ID_NOT_TENANT_ID=API_PREFIX + "/user-detail-by-user-id-not_tenant_id";

    String USER_BY_USER_ID_NOT_TENANT_ID=API_PREFIX + "/user-by-user-id-not_tenant_id";

    String GET_USER_BY_ID = API_PREFIX + "/getUserById";

    String GET_USER_LIST = API_PREFIX + "/getUserList";

    String GET_OPENID_BY_USERID = API_PREFIX + "/getOpenIdByUserId";

    String GET_WECHATUSER_BY_PHONE = API_PREFIX + "/getWechatUserByPhone";

    String List_USER_DETAIL_BY_IDS=API_PREFIX+"list_user-detail-by-ids";

    String List_USER_DETAIL_BY_PHONE=API_PREFIX+"list_user-detail-by-phone";

    String GET_WECHATUSER_BY_PLATENO = API_PREFIX + "/getWechatUserByPlateNo";

    String GET_MERGE_WECHAT_USER_LIST = API_PREFIX + "/getWechatUserList";

    String List_USER_BY_PHONE_AND_SEX=API_PREFIX+"/listUserByPhoneAndSex";

    String GET_USER_INFO_BY_PHONE=API_PREFIX+"/getUserInfoByPhone";
    String GET_WECHAT_USER_LIST_BY_PHONE_LIST=API_PREFIX+"/getWechatUserListByPhoneList";
    String GET_WECHAT_USER_LIST_BY_PHONE_OPENID_NAME=API_PREFIX+"/getWechatUserListByPhoneOpenidName";

    @GetMapping(USER_INFO_BY_ID)
    R<User> userInfoById(@RequestParam("userId") Long userId);
    @GetMapping(USER_INFO_BY_ID_V1)
    R<UserInfo> userInfoById(@RequestParam("userId")Long userId, @RequestParam("deptId")String deptId,@RequestParam(value ="openId" ,required = false)String openId,@RequestParam(value ="appId" ,required = false)String appId,  @RequestParam("userType")String userType);

    @GetMapping(USER_INFO_BY_ACCOUNT)
    R<User> userByAccount(@RequestParam("tenantId") String tenantId, @RequestParam("account") String account);

   /* @GetMapping(USER_INFO_DETAIL_BY_PHONE)
    R<UserInfo> userInfoByPhone(@RequestParam("tenantId")String tenantId, @RequestParam("phone")String phone, @RequestParam("deptId")String deptId);
*/    @GetMapping(USER_INFO_DETAIL_BY_PHONE)
    R<UserInfo> userInfoByPhone(@RequestParam("tenantId")String tenantId, @RequestParam("phone")String phone, @RequestParam("deptId")String deptId,  @RequestParam(value = "openId",required = false)String openId,
                                @RequestParam(value="appId",required = false)String appId,  @RequestParam("userType")String userType,@RequestParam(value="applySource",required = false)Integer applySource,@RequestParam(value="orgUserId",required = false)Long orgUserId);
  /*  @GetMapping(USER_INFO_DETAIL_BY_Id)
    R<UserInfo> userInfoById(@RequestParam("tenantId")String tenantId, @RequestParam("id")String id, @RequestParam("deptId")String deptId,  @RequestParam("userType")String userType);
*/
     @GetMapping(USER_DETAIL_BY_PHONE)
     R<UserDetail> userDetailByPhone(@RequestParam("phone") String phone);


    @GetMapping(USER_INFO_BY_PHONE)
    R<User> userByPhone(@RequestParam("tenantId")String tenantId, @RequestParam("phone")String phone, @RequestParam("deptId")String deptId);

    @GetMapping(USER_INFO)
    R<UserInfo> userInfo(@RequestParam("tenantId") String tenantId, @RequestParam("account") String account);


    @GetMapping(USER_INFO_BY_TYPE)
    R<UserInfo> userInfo(@RequestParam("tenantId") String tenantId, @RequestParam("account") String account,
                         @RequestParam("userType") String userType);


    @PostMapping(USER_AUTH_INFO)
    R<UserInfo> userAuthInfo(@RequestBody UserOauth userOauth);


    @PostMapping(SAVE_USER)
    R<Boolean> saveUser(@RequestBody User user);

    @PostMapping(UPDATE_USER)
    R<Boolean> updateUser(@RequestBody User user);


    @PostMapping(SUBMIT_USER)
    R<User> submitUser(@RequestParam("phone") String phone, @RequestParam("realName") String realName, @RequestParam("tenantId") String tenantId, @RequestParam("id")Long id, @RequestParam("applySource")Integer applySource);
    @PostMapping(SUBMIT_WATCH_USER)
    R<Boolean> submitWeChatUser(@RequestBody SaasWechatUser wechatUser);
    @PostMapping(SELECT_USER_DETAIL_BY_WECHAT)
    R<UserDetail> selectUserDetailByWechat(@RequestParam("appId") String appId, @RequestParam("openId") String openId);
    @PostMapping(SELECT_USER_DETAIL_LIST_BY_WECHAT)
    R<List<UserDetail>> selectUserDetailListByWechat(@RequestParam("appId") String appId, @RequestParam("openId") String openId);
    @PostMapping(SUBMIT_USER_DETAIL)
    R<UserDetail> submitUserDetail(@RequestParam("phone") String phone, @RequestParam("name") String name);

    @PostMapping(REMOVE_USER)
    R<Boolean> removeUser(@RequestParam("tenantIds") String tenantIds);

    @GetMapping(FIND_USER_BY_NAME_AND_PHONE)
    R<User> findUserByNameAndPhone(@RequestParam("realName") String realName, @RequestParam("phone") String phone);

    @GetMapping(FIND_BY_TENANT_AND_PHONE)
    R<UserInfoEntity> userEntityInfo(@RequestParam("tenantId") String tenantId,@RequestParam("phone")  String phone);
    @GetMapping(FIND_BY_TENANT_AND_USERID)
    R<User> accountInfo(@RequestParam("userId") String userId,@RequestParam("tenantId") String tenantId);
    @GetMapping(FIND_BY_ACCOUNT)
    R<User> accountInfoByAccount(@RequestParam("account") String account);


    /**
     * 目前只用来后台要显示用户名称还是账号名称
     * @return
     */
    @PostMapping(USER_NAME)
    R<Map<Long,String>> userNameById(@RequestBody List<UserNameRequest> requestList);


    /**
     * 根据账号名称模糊查询
     * @param name
     * @return
     */
    @GetMapping(USER_BY_ACCOUNT)
    R<List<User>> userByAccount(@RequestParam("name") String name);

    @GetMapping(USER_INFO_BY_NAME)
    R<List<UserInfoEntity>> userInfoByName(@RequestParam("name") String name);

    @GetMapping(USER_BY_NAME)
    R<List<User>> userByName(@RequestParam("name") String name);

    @GetMapping(USER_BY_NAME_OR_PHONE)
    R<List<User>> userByNameOrPhone(@RequestParam("keyword") String keyword);

    @GetMapping(FIND_USER_LIST_BY_PARK_ID)
    R<List<User>> findUserListByParkId(@RequestParam("parkId") Long parkId);

    @PostMapping(FIND_USER_LIST_BY_USER_IDS)
    R<List<User>> findUserListByUserIds(@RequestBody List<Long> userIds);

    /**
     *
     * @param phone
     * @return
     */
    @PostMapping(USER_GET_OR_SAVE)
    R<User> userGetOrSave(@RequestParam("phone") String phone,@RequestParam("realName") String realName,@RequestParam("tenantId")String tenantId,@RequestParam("applySource")Integer applySource);

    @GetMapping(USER_BY_PHONE_AND_TENANT_ID)
    R<List<User>> userByPhoneAndTenantId(@RequestParam("phone") String phone,@RequestParam(value="tenantId",required = false)String tenantId);

 /*   @GetMapping(WECHAT_USER_INFO_BY_PHONE)
    R<UserInfo>  weChatUserByPhone(@RequestParam("tenantId")String tenantId, @RequestParam("phone")String phone, @RequestParam("openId")String openId, @RequestParam("appId")String appId);
*/

    @GetMapping(USER_DETAIL_BY_USER_ID)
    R<UserDetail> userDetailByUserId(@RequestParam("userId") Long userId);

    @GetMapping(USER_DETAIL_BY_ID)
    R<UserDetail> userDetailById(@RequestParam("id") Long id);

    @GetMapping(GET_ADMIN_USER)
    R<List<UserAdminVO>> getAdminUser(@RequestParam("deptId")Long deptId);

    /**
     * 获取 根据用户id获取认证信息,userid不过滤租户跟其他条件,可作为回显
     * @param userId
     * @return
     */
    @GetMapping(USER_DETAIL_BY_USER_ID_NOT_TENANT_ID)
    R<UserDetail> userDetailByUserIdNotTenantId(@RequestParam("userId") Long userId);

    /**
     * 获取 根据用户id获取认证信息,userid不过滤租户跟其他条件,可作为回显
     * @param userId
     * @return
     */
    @GetMapping(USER_BY_USER_ID_NOT_TENANT_ID)
    R<User> userByUserIdNotTenantId(@RequestParam("userId") Long userId);


    @GetMapping(GET_USER_BY_ID)
    R<User> getUserById(@RequestParam("userId") Long userId);

    @GetMapping(GET_USER_LIST)
    R<List<User>> getUserList();

    @GetMapping(GET_OPENID_BY_USERID)
    R<SaasWechatUser> getOpenIdByUserId(@RequestParam("userId") Long userId, @RequestParam("appId")String appId);

    @GetMapping(GET_WECHATUSER_BY_PHONE)
    R<SaasWechatUser> getWechatUserByPhone(@RequestParam("appId") String appId,@RequestParam("phone") String phone);

    @GetMapping(List_USER_DETAIL_BY_IDS)
    R<List<UserDetail>> listUserDetailByIds(@RequestParam("ids") List<Long> ids);

    @GetMapping(List_USER_DETAIL_BY_PHONE)
    R<List<UserDetail>> listUserDetailByPhone(@RequestParam("phone") String phone);

    @GetMapping(GET_WECHATUSER_BY_PLATENO)
    R<SaasWechatUser> getWechatUserByPlateNo(@RequestParam("appId") String appId,@RequestParam("phone") String phone);

    @GetMapping(List_USER_BY_PHONE_AND_SEX)
    R<List<User>> listUserDetailByPhone(@RequestParam(value = "phone",required=false) String phone,@RequestParam(value ="sex",required=false) String sex);

    @GetMapping(GET_USER_INFO_BY_PHONE)
    R<User> getUserInfoByPhone(@RequestParam("phone") String phone);

    @GetMapping(GET_MERGE_WECHAT_USER_LIST)
    R<List<SaasWechatUser>> getMergeWechatUserList(@RequestParam("openId") String openId);

    @GetMapping(GET_WECHAT_USER_LIST_BY_PHONE_LIST)
    R<List<SaasWechatUser>> getWechatUserListByPhoneList(@RequestParam("phoneList") List<String> phoneList);

    /**
     * 根据手机号/微信号/账号名称获取微信账号
     * @param accountName
     * @return
     */
    @GetMapping(GET_WECHAT_USER_LIST_BY_PHONE_OPENID_NAME)
    R<List<SaasWechatUser>> getWechatUserListByPhoneOpenidName(@RequestParam("accountName") String accountName);
}


