123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332 |
- package http
- import (
- "encoding/json"
- "io/ioutil"
- "go-common/app/admin/main/videoup/model/archive"
- "go-common/library/ecode"
- "go-common/library/log"
- bm "go-common/library/net/http/blademaster"
- "go-common/library/xstr"
- )
- // submit second_round submit.
- func submit(c *bm.Context) {
- var (
- req = c.Request
- bs []byte
- err error
- )
- if bs, err = ioutil.ReadAll(req.Body); err != nil {
- log.Error("ioutil.ReadAll() error(%v)", err)
- c.JSON(nil, ecode.RequestErr)
- return
- }
- req.Body.Close()
- // params
- var ap = &archive.ArcParam{}
- if err = json.Unmarshal(bs, ap); err != nil {
- log.Error("http submit() json.Unmarshal(%s) error(%v)", string(bs), err)
- c.JSON(nil, ecode.RequestErr)
- return
- }
- // TODO check data.
- if err = vdaSvc.Submit(c, ap); err != nil {
- log.Error("vdaSvc.Submit() error(%v)", err)
- c.JSON(nil, err)
- return
- }
- c.JSON(nil, nil)
- }
- // batchSubmit batch submit by async.
- func batchArchive(c *bm.Context) {
- var (
- req = c.Request
- bs []byte
- err error
- aps []*archive.ArcParam
- )
- if bs, err = ioutil.ReadAll(req.Body); err != nil {
- log.Error("ioutil.ReadAll() error(%v)", err)
- c.JSON(nil, ecode.RequestErr)
- return
- }
- req.Body.Close()
- // params
- if err = json.Unmarshal(bs, &aps); err != nil {
- log.Error("http submit() json.Unmarshal(%s) error(%v)", string(bs), err)
- c.JSON(nil, ecode.RequestErr)
- return
- }
- if ok := vdaSvc.CheckArchive(aps); !ok {
- c.JSON(nil, ecode.RequestErr)
- return
- }
- // TODO check data.
- if err = vdaSvc.BatchArchive(c, aps, archive.ActionArchiveSubmit); err != nil {
- log.Error("vdaSvc.BatchSubmit() error(%v)", err)
- c.JSON(nil, err)
- return
- }
- c.JSON(nil, nil)
- }
- // batchArchiveSecondRound batch submit by async.
- func batchArchiveSecondRound(c *bm.Context) {
- var (
- req = c.Request
- bs []byte
- err error
- aps []*archive.ArcParam
- )
- if bs, err = ioutil.ReadAll(req.Body); err != nil {
- log.Error("ioutil.ReadAll() error(%v)", err)
- c.JSON(nil, ecode.RequestErr)
- return
- }
- req.Body.Close()
- // params
- if err = json.Unmarshal(bs, &aps); err != nil {
- log.Error("http submit() json.Unmarshal(%s) error(%v)", string(bs), err)
- c.JSON(nil, ecode.RequestErr)
- return
- }
- if ok := vdaSvc.CheckArchive(aps); !ok {
- c.JSON(nil, ecode.RequestErr)
- return
- }
- // TODO check data.
- if err = vdaSvc.BatchArchive(c, aps, archive.ActionArchiveSecondRound); err != nil {
- log.Error("vdaSvc.BatchSubmit() error(%v)", err)
- c.JSON(nil, err)
- return
- }
- c.JSON(nil, nil)
- }
- // batchAttrs batch attr by async.
- func batchAttrs(c *bm.Context) {
- var (
- req = c.Request
- bs []byte
- err error
- aps []*archive.ArcParam
- )
- if bs, err = ioutil.ReadAll(req.Body); err != nil {
- log.Error("ioutil.ReadAll() error(%v)", err)
- c.JSON(nil, ecode.RequestErr)
- return
- }
- req.Body.Close()
- // params
- if err = json.Unmarshal(bs, &aps); err != nil {
- log.Error("http submit() json.Unmarshal(%s) error(%v)", string(bs), err)
- c.JSON(nil, ecode.RequestErr)
- return
- }
- if ok := vdaSvc.CheckArchive(aps); !ok {
- c.JSON(nil, ecode.RequestErr)
- return
- }
- // TODO check data.
- if err = vdaSvc.BatchArchive(c, aps, archive.ActionArchiveAttr); err != nil {
- log.Error("vdaSvc.BatchSubmit() error(%v)", err)
- c.JSON(nil, err)
- return
- }
- c.JSON(nil, nil)
- }
- // batchTypeIDs batch typeid by async.
- func batchTypeIDs(c *bm.Context) {
- var (
- req = c.Request
- bs []byte
- err error
- aps []*archive.ArcParam
- )
- if bs, err = ioutil.ReadAll(req.Body); err != nil {
- log.Error("ioutil.ReadAll() error(%v)", err)
- c.JSON(nil, ecode.RequestErr)
- return
- }
- req.Body.Close()
- // params
- if err = json.Unmarshal(bs, &aps); err != nil {
- log.Error("http submit() json.Unmarshal(%s) error(%v)", string(bs), err)
- c.JSON(nil, ecode.RequestErr)
- return
- }
- if ok := vdaSvc.CheckArchive(aps); !ok {
- c.JSON(nil, ecode.RequestErr)
- return
- }
- // TODO check data.
- if err = vdaSvc.BatchArchive(c, aps, archive.ActionArchiveTypeID); err != nil {
- log.Error("vdaSvc.BatchSubmit() error(%v)", err)
- c.JSON(nil, err)
- return
- }
- c.JSON(nil, nil)
- }
- // // batchZlimit batch modify zlimit.
- // func batchZlimit(c wctx.Context) {
- // var (
- // req = c.Request()
- // res = c.Result()
- // bs []byte
- // err error
- // )
- // if bs, err = ioutil.ReadAll(req.Body); err != nil {
- // log.Error("ioutil.ReadAll() error(%v)", err)
- // res["code"] = ecode.RequestErr
- // return
- // }
- // req.Body.Close()
- // // params
- // var ap = &archive.ArcParam{}
- // if err = json.Unmarshal(bs, ap); err != nil {
- // log.Error("http submit() json.Unmarshal(%s) error(%v)", string(bs), err)
- // res["code"] = ecode.RequestErr
- // return
- // }
- // if len(ap.Aids) == 0 {
- // res["code"] = ecode.RequestErr
- // return
- // }
- // if err = vdaSvc.BatchZlimit(c, ap); err != nil {
- // log.Error("vdaSvc.submit() error(%v)", err)
- // res["code"] = err
- // return
- // }
- // }
- // upAuther batch modify zlimit.
- func upAuther(c *bm.Context) {
- var (
- req = c.Request
- bs []byte
- err error
- )
- if bs, err = ioutil.ReadAll(req.Body); err != nil {
- log.Error("ioutil.ReadAll() error(%v)", err)
- c.JSON(nil, ecode.RequestErr)
- return
- }
- req.Body.Close()
- // params
- var ap = &archive.ArcParam{}
- if err = json.Unmarshal(bs, ap); err != nil {
- log.Error("http submit() json.Unmarshal(%s) error(%v)", string(bs), err)
- c.JSON(nil, ecode.RequestErr)
- return
- }
- if err = vdaSvc.UpAuther(c, ap); err != nil {
- log.Error("vdaSvc.UpAuther() error(%v)", err)
- c.JSON(nil, err)
- return
- }
- c.JSON(nil, nil)
- }
- // upAuther batch modify zlimit.
- func upAccess(c *bm.Context) {
- var (
- req = c.Request
- bs []byte
- err error
- )
- if bs, err = ioutil.ReadAll(req.Body); err != nil {
- log.Error("ioutil.ReadAll() error(%v)", err)
- c.JSON(nil, ecode.RequestErr)
- return
- }
- req.Body.Close()
- // params
- var ap = &archive.ArcParam{}
- if err = json.Unmarshal(bs, ap); err != nil {
- log.Error("http submit() json.Unmarshal(%s) error(%v)", string(bs), err)
- c.JSON(nil, ecode.RequestErr)
- return
- }
- if err = vdaSvc.UpAccess(c, ap); err != nil {
- log.Error("vdaSvc.UpAccess() error(%v)", err)
- c.JSON(nil, err)
- return
- }
- c.JSON(nil, nil)
- }
- func upArcTag(c *bm.Context) {
- pm := new(archive.TagParam)
- if err := c.Bind(pm); err != nil {
- c.JSON(nil, err)
- return
- }
- uid, _ := getUIDName(c)
- c.JSON(nil, vdaSvc.UpArcTag(c, uid, pm))
- }
- //通用批量tag接口 添加tag或者删除tag接口
- // a.支持频道回查 form_list = channel_review
- // b.支持adminBind/upBind(默认走adminBind) is_up_bind=true
- // c.支持同步隐藏tag sync_hidden_tag=true
- //todo 因为稿件服务不cache tags 也不需要发force_sync.未来计划砍掉审核库archive.tag
- func batchTag(c *bm.Context) {
- var err error
- pm := new(archive.BatchTagParam)
- if err = c.Bind(pm); err != nil {
- c.JSON(nil, ecode.RequestErr)
- return
- }
- //仅同步隐藏tag时 批量tag操作 pm.tags为空 && SyncHiddenTag = true
- if (pm.Action != "" && pm.Action != "add" && pm.Action != "delete") || (pm.Action != "" && pm.Tags == "" && !pm.SyncHiddenTag) {
- c.JSON(nil, ecode.RequestErr)
- return
- }
- if pm.Action == "" && pm.Tags == "" && pm.FromList != archive.FromListChannelReview {
- c.JSON(nil, nil)
- return
- }
- uid, _ := getUIDName(c)
- data := map[string]interface{}{}
- data["message"], err = vdaSvc.BatchUpTag(c, uid, pm)
- c.JSONMap(data, err)
- }
- func channelInfo(c *bm.Context) {
- aid := c.Request.Form.Get("aid")
- aids, err := xstr.SplitInts(aid)
- if err != nil {
- log.Error("channelInfo xstr.SplitInts(%s) error(%v)", aid, err)
- c.JSON(nil, ecode.RequestErr)
- return
- }
- //批量上线50个
- if len(aids) > 50 || len(aids) <= 0 {
- c.JSON(nil, ecode.RequestErr)
- return
- }
- data := map[string]interface{}{}
- data["data"], err = vdaSvc.GetChannelInfo(c, aids)
- if err != nil {
- data["message"] = "频道查询API异常"
- }
- c.JSONMap(data, err)
- }
- func aiTrack(c *bm.Context) {
- v := new(struct {
- Aid []int64 `form:"aid,split" validate:"required"`
- })
- if err := c.Bind(v); err != nil {
- c.JSON(nil, ecode.RequestErr)
- return
- }
- c.JSON(vdaSvc.AITrack(c, v.Aid))
- }
|