123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- import MonitorApiBase from './base'
- import {
- ajaxFollowEntInfo,
- ajaxFollowEntAdd,
- ajaxFollowEntCancel
- } from '../api/follow-ent'
- export default class MonitorEntApi extends MonitorApiBase {
- constructor({ id }) {
- super()
- this.id = id
- }
- /**
- * 提供覆盖的ajax请求
- * @return {{}}
- */
- async ajaxGetState() {
- return ajaxFollowEntInfo({ endId: this.id }).then((res) => {
- const result = this.createModel()
- result.canFollow = res?.data?.isShow || false
- result.follow = res?.data?.followed || false
- if (res?.data?.info) {
- result.expands = res.data.info
- }
- return result
- })
- }
- async ajaxAdd() {
- return ajaxFollowEntAdd({ entId: this.id }).then((res) => {
- const result = {
- success: false,
- data: {}
- }
- result.success = res?.error_code === 0 && res?.data?.status === 0
- result.data = res?.data
- return result
- })
- }
- async ajaxRemove() {
- return ajaxFollowEntCancel({ entId: this.id }).then(
- (res) => {
- const result = {
- success: false,
- data: {}
- }
- result.success = res?.error_code === 0 && res?.data === 'success'
- result.data = res?.data
- return result
- }
- )
- }
- }
|