123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224 |
- package apis
- import (
- "fmt"
- "github.com/gin-gonic/gin"
- "github.com/go-admin-team/go-admin-core/sdk/api"
- "github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user"
- _ "github.com/go-admin-team/go-admin-core/sdk/pkg/response"
- "go-admin/app/admin/models"
- "go-admin/app/admin/service"
- "go-admin/app/admin/service/dto"
- "go-admin/common/actions"
- )
- type OtFireEvents struct {
- api.Api
- }
- // GetPage 获取OtFireEvents列表
- // @Summary 获取OtFireEvents列表
- // @Description 获取OtFireEvents列表
- // @Tags OtFireEvents
- // @Param appId query int64 false "业务ID"
- // @Param ruleId query int64 false ""
- // @Param exceptionName query string false "告警名称/信息"
- // @Param appName query string false ""
- // @Param appAlias query string false ""
- // @Param alertStatus query int64 false ""
- // @Param isKnow query int64 false "已知悉"
- // @Param isResolve query int64 false "已解决"
- // @Param isIgnore query int64 false "已忽略"
- // @Param pageSize query int false "页条数"
- // @Param pageIndex query int false "页码"
- // @Success 200 {object} response.Response{data=response.Page{list=[]models.OtFireEvents}} "{"code": 200, "data": [...]}"
- // @Router /api/v1/ot-fire-events [get]
- // @Security Bearer
- func (e OtFireEvents) GetPage(c *gin.Context) {
- req := dto.OtFireEventsGetPageReq{}
- s := service.OtFireEvents{}
- err := e.MakeContext(c).
- MakeOrm().
- Bind(&req).
- MakeService(&s.Service).
- Errors
- if err != nil {
- e.Logger.Error(err)
- e.Error(500, err, err.Error())
- return
- }
- p := actions.GetPermissionFromContext(c)
- list := make([]models.OtFireEvents, 0)
- var count int64
- err = s.GetPage(&req, p, &list, &count)
- if err != nil {
- e.Error(500, err, fmt.Sprintf("获取OtFireEvents失败,\r\n失败信息 %s", err.Error()))
- return
- }
- e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
- }
- // Get 获取OtFireEvents
- // @Summary 获取OtFireEvents
- // @Description 获取OtFireEvents
- // @Tags OtFireEvents
- // @Param id path int false "id"
- // @Success 200 {object} response.Response{data=models.OtFireEvents} "{"code": 200, "data": [...]}"
- // @Router /api/v1/ot-fire-events/{id} [get]
- // @Security Bearer
- func (e OtFireEvents) Get(c *gin.Context) {
- req := dto.OtFireEventsGetReq{}
- s := service.OtFireEvents{}
- err := e.MakeContext(c).
- MakeOrm().
- Bind(&req).
- MakeService(&s.Service).
- Errors
- if err != nil {
- e.Logger.Error(err)
- e.Error(500, err, err.Error())
- return
- }
- var object models.OtFireEvents
- p := actions.GetPermissionFromContext(c)
- err = s.Get(&req, p, &object)
- if err != nil {
- e.Error(500, err, fmt.Sprintf("获取OtFireEvents失败,\r\n失败信息 %s", err.Error()))
- return
- }
- e.OK(object, "查询成功")
- }
- // Insert 创建OtFireEvents
- // @Summary 创建OtFireEvents
- // @Description 创建OtFireEvents
- // @Tags OtFireEvents
- // @Accept application/json
- // @Product application/json
- // @Param data body dto.OtFireEventsInsertReq true "data"
- // @Success 200 {object} response.Response "{"code": 200, "message": "添加成功"}"
- // @Router /api/v1/ot-fire-events [post]
- // @Security Bearer
- func (e OtFireEvents) Insert(c *gin.Context) {
- req := dto.OtFireEventsInsertReq{}
- s := service.OtFireEvents{}
- err := e.MakeContext(c).
- MakeOrm().
- Bind(&req).
- MakeService(&s.Service).
- Errors
- if err != nil {
- e.Logger.Error(err)
- e.Error(500, err, err.Error())
- return
- }
- // 设置创建人
- req.SetCreateBy(user.GetUserId(c))
- err = s.Insert(&req)
- if err != nil {
- e.Error(500, err, fmt.Sprintf("创建OtFireEvents失败,\r\n失败信息 %s", err.Error()))
- return
- }
- e.OK(req.GetId(), "创建成功")
- }
- // Update 修改OtFireEvents
- // @Summary 修改OtFireEvents
- // @Description 修改OtFireEvents
- // @Tags OtFireEvents
- // @Accept application/json
- // @Product application/json
- // @Param id path int true "id"
- // @Param data body dto.OtFireEventsUpdateReq true "body"
- // @Success 200 {object} response.Response "{"code": 200, "message": "修改成功"}"
- // @Router /api/v1/ot-fire-events/{id} [put]
- // @Security Bearer
- func (e OtFireEvents) Update(c *gin.Context) {
- req := dto.OtFireEventsUpdateReq{}
- s := service.OtFireEvents{}
- err := e.MakeContext(c).
- MakeOrm().
- Bind(&req).
- MakeService(&s.Service).
- Errors
- if err != nil {
- e.Logger.Error(err)
- e.Error(500, err, err.Error())
- return
- }
- req.SetUpdateBy(user.GetUserId(c))
- p := actions.GetPermissionFromContext(c)
- err = s.Update(&req, p)
- if err != nil {
- e.Error(500, err, fmt.Sprintf("修改OtFireEvents失败,\r\n失败信息 %s", err.Error()))
- return
- }
- e.OK(req.GetId(), "修改成功")
- }
- // Delete 删除OtFireEvents
- // @Summary 删除OtFireEvents
- // @Description 删除OtFireEvents
- // @Tags OtFireEvents
- // @Param data body dto.OtFireEventsDeleteReq true "body"
- // @Success 200 {object} response.Response "{"code": 200, "message": "删除成功"}"
- // @Router /api/v1/ot-fire-events [delete]
- // @Security Bearer
- func (e OtFireEvents) Delete(c *gin.Context) {
- s := service.OtFireEvents{}
- req := dto.OtFireEventsDeleteReq{}
- err := e.MakeContext(c).
- MakeOrm().
- Bind(&req).
- MakeService(&s.Service).
- Errors
- if err != nil {
- e.Logger.Error(err)
- e.Error(500, err, err.Error())
- return
- }
- // req.SetUpdateBy(user.GetUserId(c))
- p := actions.GetPermissionFromContext(c)
- err = s.Remove(&req, p)
- if err != nil {
- e.Error(500, err, fmt.Sprintf("删除OtFireEvents失败,\r\n失败信息 %s", err.Error()))
- return
- }
- e.OK(req.GetId(), "删除成功")
- }
- func (e OtFireEvents) Notate(c *gin.Context) {
- req := dto.OtFireEventsUpdateReq{}
- s := service.OtFireEvents{}
- err := e.MakeContext(c).
- MakeOrm().
- Bind(&req).
- MakeService(&s.Service).
- Errors
- if err != nil {
- e.Logger.Error(err)
- e.Error(500, err, err.Error())
- return
- }
- req.SetUpdateBy(user.GetUserId(c))
- p := actions.GetPermissionFromContext(c)
- err = s.Notate(&req, p)
- if err != nil {
- e.Error(500, err, fmt.Sprintf("Notate OtFireEvents失败,\r\n失败信息 %s", err.Error()))
- return
- }
- e.OK(req.GetId(), "标记成功")
- }
|