123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- package app
- import (
- "github.com/gin-gonic/gin"
- "github.com/sirupsen/logrus"
- "lc-fangdaosha/global"
- "lc-fangdaosha/model/app/request"
- "lc-fangdaosha/model/common/response"
- "lc-fangdaosha/model/system"
- "lc-fangdaosha/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
- 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)
- }
|