增加获取公告列表的接口
This commit is contained in:
parent
8102bc005e
commit
878d1a3e1c
33
doc/api.md
33
doc/api.md
@ -763,4 +763,35 @@
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
> 说明, 这里获取的answer是使用 当前比赛session_当前题目的id_答案_jcfw中的sessionid, 计算md5
|
> 说明, 这里获取的answer是使用 当前比赛session_当前题目的id_答案_jcfw中的sessionid, 计算md5
|
||||||
|
>
|
||||||
|
|
||||||
|
### 22. 公告列表
|
||||||
|
|
||||||
|
1. Method: POST
|
||||||
|
2. <span id="215">URI: /api/:accountId/announces</span>
|
||||||
|
|
||||||
|
| 字段 | 说明 |
|
||||||
|
| -------- | -------------------------------------- |
|
||||||
|
| accountid | 帐号id |
|
||||||
|
|
||||||
|
> POST参数
|
||||||
|
|
||||||
|
|
||||||
|
| 字段 | 说明 |
|
||||||
|
| -------- | -------------------------------------- |
|
||||||
|
| sid | 店铺id |
|
||||||
|
| ids | 已读的公告id数组 |
|
||||||
|
|
||||||
|
3. Response: JSON
|
||||||
|
|
||||||
|
```js
|
||||||
|
{
|
||||||
|
"id": "60c1d800646792f5f3764e93", // 公告id
|
||||||
|
"content": "22", // 公告内容, 最好用ubb富文本来显示
|
||||||
|
"endTime": 1623921267010, // 公告过期时间
|
||||||
|
"sendTime": 1623316467010, // 公告发送时间
|
||||||
|
"title": "111", // 公告标题
|
||||||
|
"type": 2 // 公告类型 0: 普通 1: 店铺群发 2: 全体
|
||||||
|
}
|
||||||
|
```
|
@ -47,12 +47,12 @@ export default class AnnounceController extends BaseController {
|
|||||||
@permission(['shopannounce:publish'])
|
@permission(['shopannounce:publish'])
|
||||||
@router('post /api/announce/publish')
|
@router('post /api/announce/publish')
|
||||||
async publish(req: any) {
|
async publish(req: any) {
|
||||||
let { id, active } = req.params
|
let { id, publish } = req.params
|
||||||
let record = await SysAnnounce.findById(id)
|
let record = await SysAnnounce.findById(id)
|
||||||
if (!record) {
|
if (!record) {
|
||||||
throw new ZError(11, 'record not found')
|
throw new ZError(11, 'record not found')
|
||||||
}
|
}
|
||||||
record.publish = active
|
record.publish = publish
|
||||||
await record.save()
|
await record.save()
|
||||||
return record.toJson()
|
return record.toJson()
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import { SysMail } from '../../models/content/SysMail'
|
|||||||
import { ZError } from '../../common/ZError'
|
import { ZError } from '../../common/ZError'
|
||||||
import { UserReward } from '../../models/user/UserReward'
|
import { UserReward } from '../../models/user/UserReward'
|
||||||
import { Shop } from '../../models/shop/Shop'
|
import { Shop } from '../../models/shop/Shop'
|
||||||
|
import { SysAnnounce } from '../../models/content/SysAnnounce'
|
||||||
|
|
||||||
class MailController extends BaseController {
|
class MailController extends BaseController {
|
||||||
@role('anon')
|
@role('anon')
|
||||||
@ -89,4 +90,28 @@ class MailController extends BaseController {
|
|||||||
}
|
}
|
||||||
return results
|
return results
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@role('anon')
|
||||||
|
@router('post /api/:accountId/announces')
|
||||||
|
async announce_list(req: any) {
|
||||||
|
const { accountId, sid, ids } = req.params
|
||||||
|
if (!sid) {
|
||||||
|
throw new ZError(10, '缺少必要参数: sid')
|
||||||
|
}
|
||||||
|
const shop = await Shop.fetchByID(sid)
|
||||||
|
if (!shop) {
|
||||||
|
throw new ZError(11, '无法找到对应店铺')
|
||||||
|
}
|
||||||
|
let records = await SysAnnounce.findRecords(accountId, shop.id, ids)
|
||||||
|
return records.map(o => {
|
||||||
|
return {
|
||||||
|
id: o._id,
|
||||||
|
title: o.title,
|
||||||
|
content: o.content,
|
||||||
|
type: o.type,
|
||||||
|
sendTime: o.sendTime,
|
||||||
|
endTime: o.endTime,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,17 +22,20 @@ export class SysAnnounceClass extends BaseModule {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 类型
|
* 类型
|
||||||
* @type {number} 0: 普通邮件 1: 店铺群发 2: 全体
|
* @type {number} 0: 普通 1: 店铺群发 2: 全体
|
||||||
*/
|
*/
|
||||||
@prop()
|
@prop()
|
||||||
public type: number
|
public type: number
|
||||||
|
|
||||||
|
@noJson()
|
||||||
@prop({ default: false })
|
@prop({ default: false })
|
||||||
public publish: boolean
|
public publish: boolean
|
||||||
|
|
||||||
|
@noJson()
|
||||||
@prop({ type: () => [String] })
|
@prop({ type: () => [String] })
|
||||||
public accounts: string[]
|
public accounts: string[]
|
||||||
|
|
||||||
|
@noJson()
|
||||||
@prop({ type: () => [String] })
|
@prop({ type: () => [String] })
|
||||||
public shops: string[]
|
public shops: string[]
|
||||||
|
|
||||||
@ -51,6 +54,7 @@ export class SysAnnounceClass extends BaseModule {
|
|||||||
* 创建人
|
* 创建人
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
|
@noJson()
|
||||||
@prop()
|
@prop()
|
||||||
public createdBy: string
|
public createdBy: string
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user