import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CommunityVO, CommunityForm, CommunityQuery } from '@/api/system/community/types';

/**
 * 查询社区列表
 * @param query
 * @returns {*}
 */

export const listCommunity = (query?: CommunityQuery): AxiosPromise<CommunityVO[]> => {
  return request({
    url: '/system/community/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询社区详细
 * @param communityId
 */
export const getCommunity = (communityId: string | number): AxiosPromise<CommunityVO> => {
  return request({
    url: '/system/community/' + communityId,
    method: 'get'
  });
};

/**
 * 新增社区
 * @param data
 */
export const addCommunity = (data: CommunityForm) => {
  console.log(data, 'data');
  return request({
    url: '/system/community',
    method: 'post',
    data: data
  });
};

/**
 * 修改社区
 * @param data
 */
export const updateCommunity = (data: CommunityForm) => {
  return request({
    url: '/system/community',
    method: 'put',
    data: data
  });
};

/**
 * 删除社区
 * @param communityId
 */
export const delCommunity = (communityId: string | number | Array<string | number>) => {
  return request({
    url: '/system/community/' + communityId,
    method: 'delete'
  });
};
