1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- import { defineStore } from 'pinia'
- import { AxiosWrapper } from '@/utils/axios-wrapper'
- import { get } from 'lodash-es'
- const url = '/incubator'
- const axios = new AxiosWrapper()
- export const IncubatorStore = defineStore('incubator', () => {
- const query = async ({ skip = 0, limit = undefined, ...info } = {}) => {
- let cond = {}
- if (skip) cond.skip = skip
- if (limit) cond.limit = limit
- cond = { ...cond, ...info }
- const res = await axios.$get(`${url}`, cond)
- return res
- }
- const list = async ({ skip = 0, limit = undefined, ...info } = {}) => {
- let cond = {}
- if (skip) cond.skip = skip
- if (limit) cond.limit = limit
- cond = { ...cond, ...info }
- const res = await axios.$get(`${url}/list`, cond)
- return res
- }
- const all = async ({ skip = 0, limit = undefined, ...info } = {}) => {
- let cond = {}
- if (skip) cond.skip = skip
- if (limit) cond.limit = limit
- cond = { ...cond, ...info }
- const res = await axios.$get(`${url}/allList`, cond)
- return res
- }
- const statistics = async (payload) => {
- const res = await axios.$get(`${url}/statistics`, payload)
- return res
- }
- const fetch = async (payload) => {
- const res = await axios.$get(`${url}/${payload}`)
- return res
- }
- const detail = async (payload) => {
- const res = await axios.$get(`${url}/detail/${payload}`)
- return res
- }
- const create = async (payload) => {
- const res = await axios.$post(`${url}`, payload)
- return res
- }
- const update = async (payload) => {
- const id = get(payload, 'id', get(payload, '_id'))
- const res = await axios.$post(`${url}/${id}`, payload)
- return res
- }
- const del = async (payload) => {
- const res = await axios.$delete(`${url}/${payload}`)
- return res
- }
- return {
- query,
- list,
- all,
- statistics,
- detail,
- fetch,
- create,
- update,
- del
- }
- })
|