package com.jsh.erp.service;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jsh.erp.datasource.entities.Role;
import com.jsh.erp.datasource.entities.User;
import com.jsh.erp.datasource.entities.UserEx;
import com.jsh.erp.datasource.vo.SpinnerVO;
import com.jsh.erp.datasource.vo.TreeNodeEx;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

public interface UserService extends IService<User> {
    User getUser(long id)throws Exception;

    /**
     * 生成用户下拉框
     * @return
     */
    List<SpinnerVO> creatorSpinnerList();
    List<User> getUserListByIds(String ids)throws Exception;

    List<User> getUser(HttpServletRequest request) throws Exception;

    List<UserEx> select(String userName, String loginName)throws Exception;

    Long countUser(String userName, String loginName)throws Exception;

    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
    int insertUser(JSONObject obj, HttpServletRequest request)throws Exception;

    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
    int updateUser(JSONObject obj, HttpServletRequest request) throws Exception;

    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
    int updateUserByObj(User user) throws Exception;

    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
    int resetPwd(String md5Pwd, Long id) throws Exception;

    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
    int deleteUser(Long id, HttpServletRequest request)throws Exception;

    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
    int batchDeleteUser(String ids, HttpServletRequest request)throws Exception;

    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
    int batDeleteUser(String ids) throws Exception;

    void validateCaptcha(String code, String uuid);

    Map<String, Object> login(String loginName, String password, HttpServletRequest request) throws Exception;

    int validateUser(String loginName, String password) throws Exception;

    User getUserByLoginName(String loginName)throws Exception;

    int checkIsNameExist(Long id, String name)throws Exception;

    User getCurrentUser()throws Exception;

    Long getIdByLoginName(String loginName);

    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
    void addUserAndOrgUserRel(UserEx ue, HttpServletRequest request) throws Exception;

    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
    UserEx addUser(UserEx ue) throws Exception;

    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
    void registerUser(UserEx ue, Integer manageRoleId, HttpServletRequest request) throws Exception;

    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
    void updateUserTenant(User user) throws Exception;

    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
    void updateUserAndOrgUserRel(UserEx ue, HttpServletRequest request) throws Exception;

    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
    UserEx updateUser(UserEx ue)throws Exception;

    void checkLoginName(UserEx userEx)throws Exception;

    List<User> getUserListByloginName(String loginName);

    List<TreeNodeEx> getOrganizationUserTree()throws Exception;

    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
    Role getRoleTypeByUserId(long userId) throws Exception;

    Long getUserId(HttpServletRequest request) throws Exception;

    JSONArray getBtnStrArrById(Long userId) throws Exception;

    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
    int batchSetStatus(Byte status, String ids, HttpServletRequest request)throws Exception;

    User getUserByWeixinCode(String weixinCode) throws Exception;

    int weixinBind(String loginName, String password, String weixinCode) throws Exception;
}
