import { request } from '../../boot/axios';
import { Pagination } from '../class';
import {
  AssignRolesFormData,
  UserAddOrEditForm,
  UserSearchEntity
} from './model/userRole';

// user
// 获取分页
class UserApi {
  getPage = (val?: Pagination<UserSearchEntity>) => {
    return request.postForPage('user/page', val);
  };
  // 新增或修改
  insertOrUpdate = (val?: UserAddOrEditForm) => {
    return request.post('user/save', val);
  };
  getUsersRolesByUserId = (val?: number) => {
    return request.get('user/getUsersRolesByUserId/' + val);
  };
  checkBoxList = () => {
    return request.get('role/checkBoxList');
  };
  assign = (val?: AssignRolesFormData) => {
    return request.post('user/assign', val);
  };
  // 重置密码
  reset = (val?: any) => {
    return request.put('user/resetPassword/' + val + '');
  };
  // 修改密码
  updatePassword = (val: any) => {
    return request.post('user/updatePassword', val);
  };
  kickOut = (val?: any) => {
    return request.get('auth/kickOut/' + val);
  };
  del = (val?: number) => {
    return request.delete('user/remove/' + val);
  };
  disable = (val?: any) => {
    return request.post('user/disable/' + val);
  };
}
const userApi = new UserApi();
export { userApi };
