12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- package app
- import (
- "github.com/gin-gonic/gin"
- "github.com/sirupsen/logrus"
- "lcfns/global"
- "lcfns/model/app/request"
- "lcfns/model/common/response"
- "lcfns/model/system"
- "lcfns/utils"
- )
- type EventApi struct {
- }
- // List 事件信息,以及图片链接。(事件类型,开始时间,处理时间,图片链接)
- func (ea *EventApi) List(c *gin.Context) {
- var req request.Event
- req.UId = utils.GetUserID(c)
- err := c.ShouldBindJSON(&req)
- if err != nil {
- logrus.Error()
- }
- list, err := eventService.List(req)
- if err != nil {
- logrus.Error(err)
- response.FailWithMessage("查询失败", c)
- return
- }
- response.OkWithData(response.PageResult{
- List: list,
- Total: int64(len(list)),
- Page: req.Page,
- PageSize: req.PageSize,
- }, c)
- }
- // EventType 获取事件类型字典
- func (ea *EventApi) EventType(c *gin.Context) {
- var dic []system.SysDictionaryDetail
- //SELECT label AS type_name,value AS type_id FROM sys_dictionaries s1 JOIN sys_dictionary_details s2 ON s1.id = s2.sys_dictionary_id WHERE s1.type = 'eventType';
- err := global.Db.Select("label, value").
- Table("`sys_dictionaries` JOIN `sys_dictionary_details` ON `sys_dictionaries`.id = `sys_dictionary_details`.sys_dictionary_id").
- Where("type = 'eventType'").
- Find(&dic).Error
- if err != nil {
- logrus.Error(err)
- response.Fail(c)
- return
- }
- response.OkWithData(dic, c)
- }
|