|
|
|
|
import http, { type EnumInfoDto } from './index'
|
|
|
|
|
|
|
|
|
|
export interface Bag {
|
|
|
|
|
id: number
|
|
|
|
|
name: string
|
|
|
|
|
rarity: number
|
|
|
|
|
capacity: number
|
|
|
|
|
description: string | null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface CharacterBag {
|
|
|
|
|
id: number
|
|
|
|
|
characterId: number
|
|
|
|
|
bagId: number
|
|
|
|
|
bagName: string | null
|
|
|
|
|
bagCapacity: number
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface BagItem {
|
|
|
|
|
id: number
|
|
|
|
|
characterBagId: number
|
|
|
|
|
itemType: number
|
|
|
|
|
itemId: number
|
|
|
|
|
quantity: number
|
|
|
|
|
itemName: string | null
|
|
|
|
|
itemRarity: number | null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface AddBagItemDto {
|
|
|
|
|
itemType: number
|
|
|
|
|
itemId: number
|
|
|
|
|
quantity: number
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface AssignBagDto {
|
|
|
|
|
characterId: number
|
|
|
|
|
bagId: number
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Bag配置管理
|
|
|
|
|
export const GetAllBags = (): Promise<Bag[]> => {
|
|
|
|
|
return http.get('bag/all')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const GetBagById = (id: number): Promise<Bag> => {
|
|
|
|
|
return http.get(`bag/${id}`)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const CreateBag = (data: Bag): Promise<boolean> => {
|
|
|
|
|
return http.post('bag', data)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const UpdateBag = (id: number, data: Bag): Promise<boolean> => {
|
|
|
|
|
return http.put(`bag/${id}`, data)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const DeleteBag = (id: number): Promise<boolean> => {
|
|
|
|
|
return http.delete(`bag/${id}`)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 角色背包管理
|
|
|
|
|
export const GetCharacterBag = (characterId: number): Promise<CharacterBag | null> => {
|
|
|
|
|
return http.get(`bag/character/${characterId}`)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const AssignBagToCharacter = (data: AssignBagDto): Promise<boolean> => {
|
|
|
|
|
return http.post('bag/assign', data)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 背包物品管理
|
|
|
|
|
export const GetBagItems = (characterBagId: number): Promise<BagItem[]> => {
|
|
|
|
|
return http.get(`bag/${characterBagId}/items`)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const AddItemToBag = (characterBagId: number, data: AddBagItemDto): Promise<boolean> => {
|
|
|
|
|
return http.post(`bag/${characterBagId}/items/with-mission`, data)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const RemoveItemFromBag = (characterBagId: number, itemId: number): Promise<boolean> => {
|
|
|
|
|
return http.delete(`bag/${characterBagId}/items/${itemId}`)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const GetBagRarities = (): Promise<EnumInfoDto[]> => {
|
|
|
|
|
return http.get('bag/rarities')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const GetBagItemTypes = (): Promise<EnumInfoDto[]> => {
|
|
|
|
|
return http.get('bag/item-types')
|
|
|
|
|
}
|