@@ -0,0 +1,92 @@
|
||||
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, "")
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
package locationctrl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/pageopt"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/commod"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/models/v/locmod"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
// HotCityList doc
|
||||
// @Summary 获取热门城市列表
|
||||
// @Description 获取热门城市列表
|
||||
// @Tags web-视频管理-HotCity
|
||||
// @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/hotCity/list [get]
|
||||
func HotCityList(c *gin.Context) {
|
||||
type Query struct {
|
||||
City *string `form:"city" json:"city" bson:"city,omitempty"` //角色类型
|
||||
}
|
||||
var arg struct {
|
||||
commod.Page
|
||||
Query
|
||||
}
|
||||
if err := c.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "hotCity List arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
match := &pageopt.AssignMatch{
|
||||
Key: "city",
|
||||
Val: arg.City,
|
||||
}
|
||||
sort := bson.D{{Key: "createdAt", Value: -1}}
|
||||
skip := int64((arg.PageNumber - 1) * arg.PageSize)
|
||||
limit := int64(arg.PageSize)
|
||||
page, err := locmod.HotCityPages(sort, skip, limit, match)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.Failure, "hotCity List error: "+err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, stderr.Success, page)
|
||||
}
|
||||
|
||||
// HotCityUpdate doc
|
||||
// @Summary 编辑热门城市
|
||||
// @Description 编辑热门城市
|
||||
// @Tags web-视频管理-HotCity
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param targetID formData string true "目标文档ID"
|
||||
// @Param sortKey formData int false "排序键"
|
||||
// @Param enable formData bool false "使能"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/vid/location/hotCity/update [post]
|
||||
func HotCityUpdate(c *gin.Context) {
|
||||
manager, err := common.GetAdminAct(c)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
type Update struct {
|
||||
SortKey *int `form:"sortKey" json:"sortKey" binding:""`
|
||||
Enable *bool `form:"enable" json:"enable" binding:""`
|
||||
Province *string `form:"province" json:"province" 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
|
||||
}
|
||||
cityDoc := locmod.HotCityDoc{
|
||||
SortKey: arg.SortKey,
|
||||
Enable: arg.Enable,
|
||||
Province: arg.Province,
|
||||
}
|
||||
targetID, err := primitive.ObjectIDFromHex(arg.TargetID)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
if err = locmod.UpdateTo(targetID, cityDoc); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrDbUpdateError, err)
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(arg)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.VideoManageHotCity, constant.Modify, string(log), c.Request.URL.RequestURI())
|
||||
common.ServeJSON(c, stderr.Success, "")
|
||||
}
|
||||
|
||||
// HotCityAdd doc
|
||||
// @Summary 新增热门城市
|
||||
// @Description 新增热门城市
|
||||
// @Tags web-视频管理-HotCity
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param city formData string true "城市"
|
||||
// @Param sortKey formData int true "排序"
|
||||
// @Param enable formData bool true "使能"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/vid/location/hotCity/add [post]
|
||||
func HotCityAdd(c *gin.Context) {
|
||||
manager, err := common.GetAdminAct(c)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var arg struct {
|
||||
City *string `form:"city" json:"city" binding:"required"` //城市
|
||||
Province *string `form:"province" json:"province" binding:"required"` //省份
|
||||
SortKey *int `form:"sortKey" json:"sortKey" binding:"required"` //排序
|
||||
Enable *bool `form:"enable" json:"enable" binding:"required"` //使能
|
||||
}
|
||||
if err := c.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "tone Add arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
doc := locmod.HotCityDoc{
|
||||
City: arg.City,
|
||||
Province: arg.Province,
|
||||
SortKey: arg.SortKey,
|
||||
Enable: arg.Enable,
|
||||
}
|
||||
if err = locmod.Insert(doc); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrDbInsertError, err)
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(arg)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.VideoManageHotCity, constant.Add, string(log), c.Request.URL.RequestURI())
|
||||
common.ServeJSON(c, stderr.Success, "")
|
||||
}
|
||||
|
||||
// HotCityDelete doc
|
||||
// @Summary 批量删除热门城市
|
||||
// @Description 批量删除热门城市
|
||||
// @Tags web-视频管理-HotCity
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param idArray formData array true "ID数组"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/vid/location/hotCity/delete [delete]
|
||||
func HotCityDelete(c *gin.Context) {
|
||||
manager, err := common.GetAdminAct(c)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var arg struct {
|
||||
IDArray []string `form:"idArray" json:"idArray" binding:"required"`
|
||||
}
|
||||
if err = c.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "hotCity Delete arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
idArray, err := common.IDArray(arg.IDArray)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
if err = locmod.DeleteMany(idArray); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrDbDeleteError, err)
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(arg)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.VideoManageHotCity, constant.Delete, string(log), c.Request.URL.RequestURI())
|
||||
common.ServeJSON(c, stderr.Success, "")
|
||||
}
|
||||
Reference in New Issue
Block a user