修改企业微信svr的文件名
This commit is contained in:
parent
8988eafc90
commit
73fe7817fd
@ -1,5 +1,7 @@
|
|||||||
|
import axios, { AxiosRequestConfig } from 'axios'
|
||||||
import { singleton } from 'decorators/singleton'
|
import { singleton } from 'decorators/singleton'
|
||||||
|
|
||||||
|
const fs = require('fs')
|
||||||
const WX_API_HOST = 'https://qyapi.weixin.qq.com'
|
const WX_API_HOST = 'https://qyapi.weixin.qq.com'
|
||||||
@singleton
|
@singleton
|
||||||
export class WechatWorkService {
|
export class WechatWorkService {
|
||||||
@ -24,10 +26,14 @@ export class WechatWorkService {
|
|||||||
public async refreshAccessToken() {
|
public async refreshAccessToken() {
|
||||||
const url = `${WX_API_HOST}/cgi-bin/gettoken`
|
const url = `${WX_API_HOST}/cgi-bin/gettoken`
|
||||||
// use axios get url
|
// use axios get url
|
||||||
let config = {
|
let config: AxiosRequestConfig = {
|
||||||
method: 'get',
|
method: 'get',
|
||||||
maxBodyLength: Infinity,
|
maxBodyLength: Infinity,
|
||||||
url,
|
url,
|
||||||
|
params: {
|
||||||
|
corpid: this.wxCorpId,
|
||||||
|
corpsecret: this.wxCorpSecret,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
let response = await axios.request(config).then(response => {
|
let response = await axios.request(config).then(response => {
|
||||||
return response.data
|
return response.data
|
||||||
@ -40,6 +46,19 @@ export class WechatWorkService {
|
|||||||
*/
|
*/
|
||||||
public async fetchApprovalDetail(spNo: string) {
|
public async fetchApprovalDetail(spNo: string) {
|
||||||
const url = `${WX_API_HOST}/cgi-bin/oa/getapprovaldetail`
|
const url = `${WX_API_HOST}/cgi-bin/oa/getapprovaldetail`
|
||||||
|
let config: AxiosRequestConfig = {
|
||||||
|
method: 'post',
|
||||||
|
url,
|
||||||
|
params: {
|
||||||
|
access_token: this.accessToken,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
sp_no: spNo,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
let response = await axios.request(config).then(response => {
|
||||||
|
return response.data
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -49,5 +68,17 @@ export class WechatWorkService {
|
|||||||
*/
|
*/
|
||||||
public async fetchFile(mediaId: string) {
|
public async fetchFile(mediaId: string) {
|
||||||
const url = `${WX_API_HOST}/cgi-bin/media/get`
|
const url = `${WX_API_HOST}/cgi-bin/media/get`
|
||||||
|
let config: AxiosRequestConfig = {
|
||||||
|
method: 'get',
|
||||||
|
url,
|
||||||
|
responseType: 'stream',
|
||||||
|
params: {
|
||||||
|
access_token: this.accessToken,
|
||||||
|
media_id: mediaId,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
let response = await axios.request(config).then(response => {
|
||||||
|
response.data.pipe(fs.createWriteStream('ada_lovelace.jpg'))
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user