1
This commit is contained in:
105
src/api/shop/shopCommunity/index.ts
Normal file
105
src/api/shop/shopCommunity/index.ts
Normal file
@@ -0,0 +1,105 @@
|
||||
import request from '@/utils/request';
|
||||
import type { ApiResult, PageResult } from '@/api';
|
||||
import type { ShopCommunity, ShopCommunityParam } from './model';
|
||||
|
||||
/**
|
||||
* 分页查询小区
|
||||
*/
|
||||
export async function pageShopCommunity(params: ShopCommunityParam) {
|
||||
const res = await request.get<ApiResult<PageResult<ShopCommunity>>>(
|
||||
'/shop/shop-community/page',
|
||||
{
|
||||
params
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询小区列表
|
||||
*/
|
||||
export async function listShopCommunity(params?: ShopCommunityParam) {
|
||||
const res = await request.get<ApiResult<ShopCommunity[]>>(
|
||||
'/shop/shop-community',
|
||||
{
|
||||
params
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加小区
|
||||
*/
|
||||
export async function addShopCommunity(data: ShopCommunity) {
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
'/shop/shop-community',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改小区
|
||||
*/
|
||||
export async function updateShopCommunity(data: ShopCommunity) {
|
||||
const res = await request.put<ApiResult<unknown>>(
|
||||
'/shop/shop-community',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除小区
|
||||
*/
|
||||
export async function removeShopCommunity(id?: number) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
'/shop/shop-community/' + id
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除小区
|
||||
*/
|
||||
export async function removeBatchShopCommunity(data: (number | undefined)[]) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
'/shop/shop-community/batch',
|
||||
{
|
||||
data
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id查询小区
|
||||
*/
|
||||
export async function getShopCommunity(id: number) {
|
||||
const res = await request.get<ApiResult<ShopCommunity>>(
|
||||
'/shop/shop-community/' + id
|
||||
);
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
35
src/api/shop/shopCommunity/model/index.ts
Normal file
35
src/api/shop/shopCommunity/model/index.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import type { PageParam } from '@/api';
|
||||
|
||||
/**
|
||||
* 小区
|
||||
*/
|
||||
export interface ShopCommunity {
|
||||
// ID
|
||||
id?: number;
|
||||
// 小区名称
|
||||
name?: string;
|
||||
// 小区编号
|
||||
code?: string;
|
||||
// 详细地址
|
||||
address?: string;
|
||||
// 排序(数字越小越靠前)
|
||||
sortNumber?: number;
|
||||
// 备注
|
||||
comments?: string;
|
||||
// 状态, 0正常, 1冻结
|
||||
status?: number;
|
||||
// 租户id
|
||||
tenantId?: number;
|
||||
// 创建时间
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 小区搜索条件
|
||||
*/
|
||||
export interface ShopCommunityParam extends PageParam {
|
||||
id?: number;
|
||||
name?: string;
|
||||
code?: string;
|
||||
keywords?: string;
|
||||
}
|
||||
Reference in New Issue
Block a user