93 lines
3.3 KiB
Go
93 lines
3.3 KiB
Go
package locationctrl
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"91porn-server/common"
|
|
"91porn-server/common/constant"
|
|
"91porn-server/common/stderr"
|
|
"91porn-server/models/l/operatorlgmod"
|
|
"91porn-server/models/v/locmod"
|
|
"91porn-server/web/service/locationser"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
|
)
|
|
|
|
// CityList doc
|
|
// @Summary 获取城市列表
|
|
// @Description 获取城市列表
|
|
// @Tags web-视频管理
|
|
// @Accept mpfd,json
|
|
// @Produce json,html
|
|
// @Param pageNumber query int true "当前页"
|
|
// @Param pageSize query int true "每页条数"
|
|
// @Param city query string false "过滤条件:城市"
|
|
// @Success 200 {string} json "{"msg": "操作成功", "date": { "total":10, "list":[] }}"
|
|
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
|
// @Router /web/vid/location/city/list [get]
|
|
func CityList(c *gin.Context) {
|
|
req := locmod.CityPageReq{}
|
|
if err := c.ShouldBind(&req); err != nil {
|
|
common.ServeJSON(c, stderr.ErrParamError, "hotCity city List arg error "+err.Error())
|
|
return
|
|
}
|
|
page, err := locationser.CityPages(req.City, req.PageNumber, req.PageSize)
|
|
if err != nil {
|
|
common.ServeJSON(c, stderr.Failure, "city List error: "+err.Error())
|
|
return
|
|
}
|
|
common.ServeJSON(c, stderr.Success, page)
|
|
}
|
|
|
|
// CityUpdate doc
|
|
// @Summary 编辑城市
|
|
// @Description 编辑城市
|
|
// @Tags web-视频管理
|
|
// @Accept mpfd,json
|
|
// @Produce json,html
|
|
// @Param targetID formData string true "目标文档ID"
|
|
// @Param cover formData string false "封面""
|
|
// @Param fakeVisit formData int false "假播访问量"
|
|
// @Param sortKey formData int false "排序键"
|
|
// @Success 200 {string} json "{"msg": "操作成功"}"
|
|
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
|
// @Router /web/vid/location/city/update [post]
|
|
func CityUpdate(c *gin.Context) {
|
|
manager, err := common.GetAdminAct(c)
|
|
if err != nil {
|
|
common.ServeJSON(c, stderr.AdminIDErr, err.Error())
|
|
return
|
|
}
|
|
type Update struct {
|
|
Cover *string `form:"cover" json:"cover" binding:""` //封面
|
|
FakeVisit *int `form:"fakeVisit" json:"fakeVisit" binding:""` //播发假数据
|
|
SortKey *int `form:"sortKey" json:"sortKey" binding:""`
|
|
}
|
|
var arg struct {
|
|
TargetID string `form:"targetID" json:"targetID,omitempty" binding:"required"`
|
|
Update
|
|
}
|
|
if err = c.ShouldBind(&arg); err != nil {
|
|
common.ServeJSON(c, stderr.ErrParamError, "hotCity Update arg error "+err.Error())
|
|
return
|
|
}
|
|
doc := locmod.LocationDoc{
|
|
Cover: arg.Cover,
|
|
FakeVisit: arg.FakeVisit,
|
|
SortKey: arg.SortKey,
|
|
}
|
|
targetID, err := primitive.ObjectIDFromHex(arg.TargetID)
|
|
if err != nil {
|
|
common.ServeJSON(c, stderr.ErrParamError, err)
|
|
return
|
|
}
|
|
if err = locmod.UpdateToLocation(targetID, doc); err != nil {
|
|
common.ServeJSON(c, stderr.ErrDbUpdateError, err)
|
|
return
|
|
}
|
|
log, _ := json.Marshal(arg)
|
|
_ = operatorlgmod.RecordOperation(manager, constant.VideoManageCity, constant.Modify, string(log), c.Request.URL.RequestURI())
|
|
common.ServeJSON(c, stderr.Success, "")
|
|
}
|