|
@@ -8,6 +8,18 @@ import {
|
|
|
|
|
|
import type { Model } from './model'
|
|
|
|
|
|
+interface ServerTagging {
|
|
|
+ "hotIconId": number,
|
|
|
+ "hotIconUrl": string,
|
|
|
+ "getMethod": string,
|
|
|
+ "getUser": string,
|
|
|
+ "id": number,
|
|
|
+ "meta": { "name": string, "url": string } [],
|
|
|
+ "remark": string,
|
|
|
+ "tagDescribe": string,
|
|
|
+ "tagTitle": string,
|
|
|
+}
|
|
|
+
|
|
|
export interface TaggingPosition {
|
|
|
modelId: Model['id']
|
|
|
localPos: SceneLocalPos
|
|
@@ -24,67 +36,52 @@ export interface Tagging {
|
|
|
positions: TaggingPosition[]
|
|
|
}
|
|
|
|
|
|
+
|
|
|
export type Taggings = Tagging[]
|
|
|
|
|
|
-export const fetchTaggings = async () => {
|
|
|
- // axios.post<Taggings>(TAGGING_LIST)
|
|
|
- return [
|
|
|
- {
|
|
|
- id: '1231',
|
|
|
- title: 'aaaa',
|
|
|
- styleId: '1231',
|
|
|
- desc: '123123',
|
|
|
- modelId: '123',
|
|
|
- part: '123asd',
|
|
|
- method: '123123a',
|
|
|
- principal: 'asdasd',
|
|
|
- images: [
|
|
|
- 'https://gw.alicdn.com/tps/TB1W_X6OXXXXXcZXVXXXXXXXXXX-400-400.png',
|
|
|
- 'https://gw.alicdn.com/tps/TB1W_X6OXXXXXcZXVXXXXXXXXXX-400-400.png'
|
|
|
- ],
|
|
|
- positions: [
|
|
|
- {
|
|
|
- modelId: '124',
|
|
|
- localPos: { x: 1, y: 1, z: 1 }
|
|
|
- }
|
|
|
- ]
|
|
|
- },
|
|
|
|
|
|
- {
|
|
|
- id: '1231a',
|
|
|
- title: 'aaaa',
|
|
|
- styleId: '1231',
|
|
|
- desc: '123123',
|
|
|
- part: '123asd',
|
|
|
- method: '123123a',
|
|
|
- principal: 'asdasd',
|
|
|
- images: [
|
|
|
- 'https://gw.alicdn.com/tps/TB1W_X6OXXXXXcZXVXXXXXXXXXX-400-400.png',
|
|
|
- 'https://gw.alicdn.com/tps/TB1W_X6OXXXXXcZXVXXXXXXXXXX-400-400.png'
|
|
|
- ],
|
|
|
- positions: [{
|
|
|
- modelId: '123',
|
|
|
- localPos: { x: 1, y: 1, z: 1 }
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
- ]
|
|
|
+const serviceToLocal = (serviceTagging: ServerTagging): Tagging => ({
|
|
|
+ id: serviceTagging.id.toString(),
|
|
|
+ styleId: serviceTagging.hotIconId.toString(),
|
|
|
+ title: serviceTagging.tagTitle,
|
|
|
+ desc: serviceTagging.tagDescribe,
|
|
|
+ part: serviceTagging.remark,
|
|
|
+ method: serviceTagging.getMethod,
|
|
|
+ principal: serviceTagging.getUser,
|
|
|
+ images: serviceTagging.meta.map(({url}) => url),
|
|
|
+ positions: []
|
|
|
+})
|
|
|
+
|
|
|
+const localToService = (tagging: Tagging): ServerTagging => ({
|
|
|
+ "hotIconId": Number(tagging.styleId),
|
|
|
+ "hotIconUrl": tagging.styleId,
|
|
|
+ "getMethod": tagging.method,
|
|
|
+ "getUser": tagging.principal,
|
|
|
+ "id": Number(tagging.id),
|
|
|
+ "meta": tagging.images.map(((item, i) => ({ "name": item, "url": item }))),
|
|
|
+ "remark": tagging.part,
|
|
|
+ "tagDescribe": tagging.desc,
|
|
|
+ "tagTitle": tagging.title,
|
|
|
+})
|
|
|
+
|
|
|
+
|
|
|
+export const fetchTaggings = async () => {
|
|
|
+ const staggings = await axios.post<ServerTagging[]>(TAGGING_LIST, {})
|
|
|
+ return staggings.map(serviceToLocal)
|
|
|
}
|
|
|
|
|
|
-export const postAddTagging = (tagging: Tagging) => {
|
|
|
- console.log('add')
|
|
|
- return axios.post<Tagging>(INSERT_TAGGING, tagging)
|
|
|
+export const postAddTagging = async (tagging: Tagging) => {
|
|
|
+ const stagging = await axios.post<ServerTagging>(INSERT_TAGGING, tagging)
|
|
|
+ return serviceToLocal(stagging)
|
|
|
}
|
|
|
|
|
|
-export const postUpdateTagging = async (tagging: Tagging) => {
|
|
|
- console.log('update')
|
|
|
- // return axios.post<undefined>(UPDATE_TAGGING, tagging)
|
|
|
+export const postUpdateTagging = (tagging: Tagging) => {
|
|
|
+ return axios.post<undefined>(UPDATE_TAGGING, localToService(tagging))
|
|
|
}
|
|
|
|
|
|
|
|
|
export const postDeleteTagging = (id: Tagging['id']) => {
|
|
|
- console.log('delete')
|
|
|
- return axios.post<undefined>(DELETE_TAGGING)
|
|
|
+ return axios.post<undefined>(DELETE_TAGGING, { ids: [id] })
|
|
|
}
|
|
|
|
|
|
|