Files
ArmedPolice/app/api/dashboard.go

118 lines
3.1 KiB
Go
Raw Normal View History

2021-11-15 17:32:23 +08:00
package api
import (
"ArmedPolice/app/controller/dashboard"
"ArmedPolice/app/service"
"github.com/gin-gonic/gin"
)
/**
* @apiDefine Dashboard 仪表盘
*/
type Dashboard struct{}
/**
* @api {get} /api/v1/dashboard 工作台
* @apiVersion 1.0.0
* @apiName DashboardIndex
* @apiGroup Dashboard
*
* @apiHeader {string} x-token token
*
* @apiSuccess (200) {Object} data 数据信息
* @apiSuccess (200) {Object} data.workbench 待办事项
* @apiSuccess (200) {String} data.workbench.id ID
* @apiSuccess (200) {String} data.workbench.equipment_code 设备标识
* @apiSuccess (200) {String} data.workbench.equipment_title 设备名称
* @apiSuccess (200) {String} data.workbench.breakdown_title 故障信息
* @apiSuccess (200) {String} data.workbench.username 用户名
* @apiSuccess (200) {Time} data.workbench.created_at 创建时间
* @apiSuccess (200) {Object} data.notice 公告信息
* @apiSuccess (200) {String} data.notice.id ID
* @apiSuccess (200) {String} data.notice.title 公告标题
* @apiSuccess (200) {Time} data.notice.created_at 公告创建时间
2021-11-16 11:46:44 +08:00
* @apiSuccess (200) {Object} data.evaluate 评价信息
* @apiSuccess (200) {String} data.evaluate.name ID
* @apiSuccess (200) {Number} data.evaluate.praise 好评数
* @apiSuccess (200) {Number} data.evaluate.middle 中评数
* @apiSuccess (200) {Number} data.evaluate.negative 差评数
2021-11-15 17:32:23 +08:00
* @apiSuccess (200) {Number} code 成功响应状态码!
* @apiSuccess (200) {String} msg 成功提示
*
* @apiSuccessExample {json} Success response:
* HTTPS 200 OK
* {
* "code": 200
* "msg": "ok"
* "data": {
* "workbench": [
* "id": "",
* "equipment_code": "",
* "equipment_title": ""
* "breakdown_title": ""
* "username": ""
* "created_at": ""
2021-11-16 11:46:44 +08:00
* ],
2021-11-15 17:32:23 +08:00
* "notice": [
* "id": "",
* "title": "",
* "created_at": "2021-11-01"
2021-11-16 11:46:44 +08:00
* ],
* "evaluate": [
* "name": "",
* "praise": 1,
* "middle": 0,
* "negative": 0,
2021-11-15 17:32:23 +08:00
* ]
* }
* }
*/
func (*Dashboard) Index(c *gin.Context) {
data, err := dashboard.NewInstance()(getSession()(c).(*service.Session)).Index()
APIResponse(err, data)(c)
}
/**
* @api {post} /api/v1/dashboard/repair 工单维修信息
* @apiVersion 1.0.0
* @apiName DashboardRepair
* @apiGroup Dashboard
*
* @apiHeader {string} x-token token
*
* @apiParam {String} date 具体月份 - 2021-10-01
*
* @apiSuccess (200) {Object} data 数据信息
* @apiSuccess (200) {Number} data.count 数量
* @apiSuccess (200) {Number} data.amount 金额
* @apiSuccess (200) {String} data.date 时间
* @apiSuccess (200) {Number} code 成功响应状态码!
* @apiSuccess (200) {String} msg 成功提示
*
* @apiSuccessExample {json} Success response:
* HTTPS 200 OK
* {
* "code": 200
* "msg": "ok"
* "data": [
* {
* "count": 0,
* "amount": 0,
* "date": "2021-11-01"
* }...
* ]
* }
*/
func (*Dashboard) Repair(c *gin.Context) {
form := &struct {
Date string `json:"date" form:"date" binding:"required"`
}{}
if err := bind(form)(c); err != nil {
APIFailure(err.(error))(c)
return
}
data, err := dashboard.NewRepair()(getSession()(c).(*service.Session)).Static(form.Date)
APIResponse(err, data)(c)
}