123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593 |
- package http
- import (
- "encoding/json"
- searchModel "go-common/app/admin/main/feed/model/search"
- "go-common/app/admin/main/feed/model/show"
- "go-common/app/admin/main/feed/util"
- "go-common/library/ecode"
- bm "go-common/library/net/http/blademaster"
- "go-common/library/time"
- )
- //Black 黑名单
- func blackList(c *bm.Context) {
- var (
- err error
- black []searchModel.Black
- )
- res := map[string]interface{}{}
- if black, err = searchSvc.BlackList(); err != nil {
- res["message"] = "获取失败:" + err.Error()
- c.JSONMap(res, ecode.RequestErr)
- return
- }
- c.JSON(black, nil)
- }
- //addBlack 添加黑名单
- func addBlack(c *bm.Context) {
- var (
- err error
- )
- res := map[string]interface{}{}
- param := new(searchModel.Black)
- if err = c.Bind(param); err != nil {
- return
- }
- uid, name := managerInfo(c)
- if err = searchSvc.AddBlack(c, param.Searchword, name, uid); err != nil {
- res["message"] = "获取失败:" + err.Error()
- c.JSONMap(res, ecode.RequestErr)
- return
- }
- c.JSON(nil, nil)
- }
- //delBlack 删除黑名单
- func delBlack(c *bm.Context) {
- var (
- err error
- )
- res := map[string]interface{}{}
- param := new(struct {
- ID int `form:"id" validate:"required"`
- })
- if err = c.Bind(param); err != nil {
- return
- }
- uid, name := managerInfo(c)
- if err = searchSvc.DelBlack(c, param.ID, name, uid); err != nil {
- res["message"] = "获取失败:" + err.Error()
- c.JSONMap(res, ecode.RequestErr)
- return
- }
- c.JSON(nil, nil)
- }
- //openAddDarkword 对外 添加黑马词
- func openAddDarkword(c *bm.Context) {
- var (
- err error
- dark searchModel.OpenDark
- )
- res := map[string]interface{}{}
- param := &struct {
- Data string `form:"data" validate:"required"`
- }{}
- if err = c.Bind(param); err != nil {
- return
- }
- if err = json.Unmarshal([]byte(param.Data), &dark); err != nil {
- res["message"] = "参数有误:" + err.Error()
- c.JSONMap(res, ecode.RequestErr)
- return
- }
- if err = searchSvc.OpenAddDarkword(c, dark); err != nil {
- res["message"] = "添加失败:" + err.Error()
- c.JSONMap(res, ecode.RequestErr)
- return
- }
- c.JSON(nil, nil)
- }
- //openBlacklist 对外 黑名单列表
- func openBlacklist(c *bm.Context) {
- var (
- err error
- black []searchModel.Black
- )
- res := map[string]interface{}{}
- if black, err = searchSvc.BlackList(); err != nil {
- res["message"] = "获取失败:" + err.Error()
- c.JSONMap(res, ecode.RequestErr)
- return
- }
- c.JSON(black, nil)
- }
- //OpenHotList 对外 黑名单列表
- func openHotList(c *bm.Context) {
- var (
- err error
- hot []searchModel.Intervene
- )
- res := map[string]interface{}{}
- if hot, err = searchSvc.OpenHotList(c); err != nil {
- res["message"] = "获取失败:" + err.Error()
- c.JSONMap(res, ecode.RequestErr)
- return
- }
- c.JSON(hot, nil)
- }
- //openDarkword 对外 获取黑马词
- func openDarkword(c *bm.Context) {
- var (
- err error
- dark []searchModel.Dark
- )
- res := map[string]interface{}{}
- if dark, err = searchSvc.GetDarkPub(c); err != nil {
- res["message"] = "获取失败:" + err.Error()
- c.JSONMap(res, ecode.RequestErr)
- return
- }
- c.JSON(dark, nil)
- }
- //openAddHotword 对外 添加搜索热词
- func openAddHotword(c *bm.Context) {
- var (
- err error
- hot searchModel.OpenHot
- )
- res := map[string]interface{}{}
- param := &struct {
- Data string `form:"data" validate:"required"`
- }{}
- if err = c.Bind(param); err != nil {
- return
- }
- if err = json.Unmarshal([]byte(param.Data), &hot); err != nil {
- res["message"] = "参数有误:" + err.Error()
- c.JSONMap(res, ecode.RequestErr)
- return
- }
- if err = searchSvc.OpenAddHotword(c, hot); err != nil {
- res["message"] = "添加失败:" + err.Error()
- c.JSONMap(res, ecode.RequestErr)
- return
- }
- c.JSON(nil, nil)
- }
- //publishHotWord publish hot word
- func publishHotWord(c *bm.Context) {
- var (
- err error
- res = map[string]interface{}{}
- )
- uid, name := managerInfo(c)
- if err = searchSvc.SetHotPub(c, name, uid); err != nil {
- res["message"] = "发布失败:" + err.Error()
- c.JSONMap(res, ecode.RequestErr)
- return
- }
- c.JSON(nil, nil)
- }
- //publishDark publish dark word
- func publishDarkWord(c *bm.Context) {
- var (
- err error
- res = map[string]interface{}{}
- )
- uid, name := managerInfo(c)
- if err = searchSvc.SetDarkPub(c, name, uid); err != nil {
- res["message"] = "发布失败:" + err.Error()
- c.JSONMap(res, ecode.RequestErr)
- return
- }
- c.JSON(nil, nil)
- }
- //addInter 添加干预
- func addInter(c *bm.Context) {
- var (
- err error
- res = map[string]interface{}{}
- )
- param := searchModel.InterveneAdd{}
- if err = c.Bind(¶m); err != nil {
- return
- }
- uid, name := managerInfo(c)
- if err = searchSvc.AddInter(c, param, name, uid); err != nil {
- res["message"] = "添加失败:" + err.Error()
- c.JSONMap(res, ecode.RequestErr)
- return
- }
- c.JSON(nil, nil)
- }
- //updateInter 更新干预
- func updateInter(c *bm.Context) {
- var (
- err error
- res = map[string]interface{}{}
- )
- param := struct {
- ID int `form:"id" validate:"required"`
- Searchword string `form:"searchword" validate:"required"`
- Rank int `form:"position" validate:"required"`
- Tag string `form:"tag"`
- Stime time.Time `form:"stime" validate:"required"`
- Etime time.Time `form:"etime" validate:"required"`
- }{}
- if err = c.Bind(¶m); err != nil {
- return
- }
- inter := searchModel.InterveneAdd{
- Searchword: param.Searchword,
- Rank: param.Rank,
- Tag: param.Tag,
- Stime: param.Stime,
- Etime: param.Etime,
- }
- uid, name := managerInfo(c)
- if err = searchSvc.UpdateInter(c, inter, param.ID, name, uid); err != nil {
- res["message"] = "更新失败:" + err.Error()
- c.JSONMap(res, ecode.RequestErr)
- return
- }
- c.JSON(nil, nil)
- }
- //deleteHot 删除热词
- func deleteHot(c *bm.Context) {
- var (
- err error
- res = map[string]interface{}{}
- )
- param := struct {
- ID int `form:"id" validate:"required"`
- Type uint8 `form:"type" validate:"required"`
- }{}
- if err = c.Bind(¶m); err != nil {
- return
- }
- uid, name := managerInfo(c)
- if err = searchSvc.DeleteHot(c, param.ID, param.Type, name, uid); err != nil {
- res["message"] = "删除失败:" + err.Error()
- c.JSONMap(res, ecode.RequestErr)
- return
- }
- c.JSON(nil, nil)
- }
- //deleteDark 删除黑马词
- func deleteDark(c *bm.Context) {
- var (
- err error
- res = map[string]interface{}{}
- )
- param := struct {
- ID int `form:"id" validate:"required"`
- }{}
- if err = c.Bind(¶m); err != nil {
- return
- }
- uid, name := managerInfo(c)
- if err = searchSvc.DeleteDark(c, param.ID, name, uid); err != nil {
- res["message"] = "删除失败:" + err.Error()
- c.JSONMap(res, ecode.RequestErr)
- return
- }
- c.JSON(nil, nil)
- }
- //updateSearch 更新搜索推过来的词
- func updateSearch(c *bm.Context) {
- var (
- err error
- res = map[string]interface{}{}
- )
- param := struct {
- ID int `form:"id" validate:"required"`
- Tag string `form:"tag"`
- }{}
- if err = c.Bind(¶m); err != nil {
- return
- }
- uid, name := managerInfo(c)
- if err = searchSvc.UpdateSearch(c, param.Tag, param.ID, name, uid); err != nil {
- res["message"] = "更新失败:" + err.Error()
- c.JSONMap(res, ecode.RequestErr)
- return
- }
- c.JSON(nil, nil)
- }
- //HotList 搜索热词
- func HotList(c *bm.Context) {
- var (
- err error
- hotout searchModel.HotwordOut
- )
- res := map[string]interface{}{}
- param := struct {
- Date string `form:"date" validate:"required"`
- }{}
- if err = c.Bind(¶m); err != nil {
- return
- }
- if hotout, err = searchSvc.HotList(c, param.Date); err != nil {
- res["message"] = "获取热词失败:" + err.Error()
- c.JSONMap(res, ecode.RequestErr)
- return
- }
- c.JSON(hotout, nil)
- }
- //darkList 黑马词
- func darkList(c *bm.Context) {
- var (
- err error
- darkout searchModel.DarkwordOut
- )
- res := map[string]interface{}{}
- param := struct {
- Date string `form:"date" validate:"required"`
- }{}
- if err = c.Bind(¶m); err != nil {
- return
- }
- if darkout, err = searchSvc.DarkList(c, param.Date); err != nil {
- res["message"] = "获取黑马词失败:" + err.Error()
- c.JSONMap(res, ecode.RequestErr)
- return
- }
- c.JSON(darkout, nil)
- }
- func searchWebCardList(c *bm.Context) {
- var (
- err error
- pager *show.SearchWebCardPager
- )
- res := map[string]interface{}{}
- req := &show.SearchWebCardLP{}
- if err = c.Bind(req); err != nil {
- return
- }
- if pager, err = searchSvc.SearchWebCardList(req); err != nil {
- res["message"] = "列表获取失败 " + err.Error()
- c.JSONMap(res, ecode.RequestErr)
- return
- }
- c.JSON(pager, nil)
- }
- func addSearchWebCard(c *bm.Context) {
- var (
- err error
- )
- res := map[string]interface{}{}
- req := &show.SearchWebCardAP{}
- if err = c.Bind(req); err != nil {
- return
- }
- uid, name := util.UserInfo(c)
- if name == "" {
- c.JSONMap(map[string]interface{}{"message": "请重新登录"}, ecode.Unauthorized)
- c.Abort()
- return
- }
- req.Person = name
- if err = searchSvc.AddSearchWebCard(c, req, name, uid); err != nil {
- res["message"] = "卡片创建失败 " + err.Error()
- c.JSONMap(res, ecode.RequestErr)
- return
- }
- c.JSON(nil, nil)
- }
- func upSearchWebCard(c *bm.Context) {
- var (
- err error
- )
- res := map[string]interface{}{}
- req := &show.SearchWebCardUP{}
- if err = c.Bind(req); err != nil {
- return
- }
- uid, name := util.UserInfo(c)
- if name == "" {
- c.JSONMap(map[string]interface{}{"message": "请重新登录"}, ecode.Unauthorized)
- c.Abort()
- return
- }
- if req.ID <= 0 {
- c.JSONMap(map[string]interface{}{"message": "ID 参数不合法"}, ecode.RequestErr)
- c.Abort()
- return
- }
- if err = searchSvc.UpdateSearchWebCard(c, req, name, uid); err != nil {
- res["message"] = "卡片创建失败 " + err.Error()
- c.JSONMap(res, ecode.RequestErr)
- return
- }
- c.JSON(nil, nil)
- }
- func delSearchWebCard(c *bm.Context) {
- var (
- err error
- )
- res := map[string]interface{}{}
- req := &struct {
- ID int64 `form:"id" validate:"required"`
- }{}
- if err = c.Bind(req); err != nil {
- return
- }
- uid, name := util.UserInfo(c)
- if name == "" {
- c.JSONMap(map[string]interface{}{"message": "请重新登录"}, ecode.Unauthorized)
- c.Abort()
- return
- }
- if req.ID <= 0 {
- c.JSONMap(map[string]interface{}{"message": "ID 参数不合法"}, ecode.RequestErr)
- c.Abort()
- return
- }
- if err = searchSvc.DeleteSearchWebCard(req.ID, name, uid); err != nil {
- res["message"] = "卡片创建失败 " + err.Error()
- c.JSONMap(res, ecode.RequestErr)
- return
- }
- c.JSON(nil, nil)
- }
- func searchWebList(c *bm.Context) {
- var (
- err error
- pager *show.SearchWebPager
- )
- res := map[string]interface{}{}
- req := &show.SearchWebLP{}
- if err = c.Bind(req); err != nil {
- return
- }
- if pager, err = searchSvc.SearchWebList(req); err != nil {
- res["message"] = "列表获取失败 " + err.Error()
- c.JSONMap(res, ecode.RequestErr)
- return
- }
- c.JSON(pager, nil)
- }
- func openSearchWeb(c *bm.Context) {
- var (
- err error
- pager []*show.SearchWeb
- )
- res := map[string]interface{}{}
- if pager, err = searchSvc.OpenSearchWebList(); err != nil {
- res["message"] = "列表获取失败 " + err.Error()
- c.JSONMap(res, ecode.RequestErr)
- return
- }
- c.JSON(pager, nil)
- }
- func addSearchWeb(c *bm.Context) {
- var (
- err error
- )
- res := map[string]interface{}{}
- req := &show.SearchWebAP{}
- if err = c.Bind(req); err != nil {
- return
- }
- uid, name := util.UserInfo(c)
- if name == "" {
- c.JSONMap(map[string]interface{}{"message": "请重新登录"}, ecode.Unauthorized)
- c.Abort()
- return
- }
- req.Person = name
- if err = searchSvc.AddSearchWeb(c, req, name, uid); err != nil {
- res["message"] = "卡片创建失败 " + err.Error()
- c.JSONMap(res, ecode.RequestErr)
- return
- }
- c.JSON(nil, nil)
- }
- func upSearchWeb(c *bm.Context) {
- var (
- err error
- )
- res := map[string]interface{}{}
- req := &show.SearchWebUP{}
- if err = c.Bind(req); err != nil {
- return
- }
- uid, name := util.UserInfo(c)
- if name == "" {
- c.JSONMap(map[string]interface{}{"message": "请重新登录"}, ecode.Unauthorized)
- c.Abort()
- return
- }
- if req.ID <= 0 {
- c.JSONMap(map[string]interface{}{"message": "ID 参数不合法"}, ecode.RequestErr)
- c.Abort()
- return
- }
- if err = searchSvc.UpdateSearchWeb(c, req, name, uid); err != nil {
- res["message"] = "卡片创建失败 " + err.Error()
- c.JSONMap(res, ecode.RequestErr)
- return
- }
- c.JSON(nil, nil)
- }
- func delSearchWeb(c *bm.Context) {
- var (
- err error
- )
- res := map[string]interface{}{}
- req := &struct {
- ID int64 `form:"id" validate:"required"`
- }{}
- if err = c.Bind(req); err != nil {
- return
- }
- uid, name := util.UserInfo(c)
- if name == "" {
- c.JSONMap(map[string]interface{}{"message": "请重新登录"}, ecode.Unauthorized)
- c.Abort()
- return
- }
- if req.ID <= 0 {
- c.JSONMap(map[string]interface{}{"message": "ID 参数不合法"}, ecode.RequestErr)
- c.Abort()
- return
- }
- if err = searchSvc.DeleteSearchWeb(req.ID, name, uid); err != nil {
- res["message"] = "卡片删除失败 " + err.Error()
- c.JSONMap(res, ecode.RequestErr)
- return
- }
- c.JSON(nil, nil)
- }
- func optSearchWeb(c *bm.Context) {
- var (
- err error
- )
- res := map[string]interface{}{}
- req := &struct {
- ID int64 `form:"id" validate:"required"`
- Opt string `form:"opt" validate:"required"`
- }{}
- if err = c.Bind(req); err != nil {
- return
- }
- uid, name := util.UserInfo(c)
- if name == "" {
- c.JSONMap(map[string]interface{}{"message": "请重新登录"}, ecode.Unauthorized)
- c.Abort()
- return
- }
- if err = searchSvc.OptionSearchWeb(req.ID, req.Opt, name, uid); err != nil {
- res["message"] = "修改失败 " + err.Error()
- c.JSONMap(res, ecode.RequestErr)
- return
- }
- c.JSON(nil, nil)
- }
|