1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- package admin
- import (
- "errors"
- "github.com/gin-gonic/gin"
- "github.com/go-playground/validator"
- "lot_interlligentControl/app/e"
- "lot_interlligentControl/app/services"
- "lot_interlligentControl/app/services/imp"
- "lot_interlligentControl/models"
- "lot_interlligentControl/unity"
- "lot_interlligentControl/utils"
- "strconv"
- )
- var shop services.Shop = &imp.Shop{}
- // AdminGetAudit
- // @Tags 管理员
- // @Summary 管理员审核状态
- // @Success 200 {object} e.R
- // @Fail 400 {object} e.R
- // @Param id query string true "id"
- // @Param state query string true "状态"
- // @Accept application/json
- // @Router /admin/auditState [put]
- func AdminGetAudit(c *gin.Context) {
- value := c.Query("id")
- value1 := c.Query("state")
- validate := validator.New()
- err := validate.Var(value, "required,numeric")
- err = validate.Var(value1, "required,numeric")
- if err != nil {
- e.ResponseWithMsg(c, e.TheParameterCannotBeEmpty, e.TheParameterCannotBeEmpty.GetMsg())
- return
- }
- uId := utils.GetUId(c)
- id, _ := strconv.Atoi(value)
- state, _ := strconv.Atoi(value1)
- auditState := shop.AuditState(uId, id, state)
- if errors.Is(auditState, e.SUCCESS) {
- e.ResponseSuccess(c, "审核成功")
- return
- }
- e.ResponseWithMsg(c, auditState, "参数错误")
- }
- // GetServiceNodeAll
- // @Tags 管理员
- // @Summary 管理员查询所有节点
- // @Success 200 {object} e.R
- // @Fail 400 {object} e.R
- // @Param req body unity.PageParams true "分页数据"
- // @Accept application/json
- // @Router /admin/serviceNode [post]
- func GetServiceNodeAll(c *gin.Context) {
- var pages unity.PageParams
- err := c.ShouldBindJSON(&pages)
- if err != nil {
- e.ResponseWithMsg(c, e.JSONParsingFailed, e.JSONParsingFailed.GetMsg())
- return
- }
- result, total, err := unity.Paginate(pages, models.ServiceNodes{})
- if err != nil {
- e.ResponseWithMsg(c, e.PaginationFailed, e.PaginationFailed.GetMsg())
- return
- }
- e.ResPonsePage(c, result, total, pages)
- }
- // GetAllShop
- // @Tags 管理员
- // @Summary 管理员查询所有店铺
- // @Success 200 {object} e.R
- // @Fail 400 {object} e.R
- // @Param req body unity.PageParams true "分页数据"
- // @Accept application/json
- // @Router /admin/shop [get]
- func GetAllShop(c *gin.Context) {
- var pages unity.PageParams
- err := c.ShouldBindJSON(&pages)
- if err != nil {
- e.ResponseWithMsg(c, e.JSONParsingFailed, e.JSONParsingFailed.GetMsg())
- return
- }
- result, total, err := unity.Paginate(pages, models.Shop{})
- if err != nil {
- e.ResponseWithMsg(c, e.PaginationFailed, e.PaginationFailed.GetMsg())
- return
- }
- e.ResPonsePage(c, result, total, pages)
- }
|