Browse Source

更新

master
huangjiajun 4 weeks ago
parent
commit
eac921c929
5 changed files with 136 additions and 1 deletions
  1. +86
    -0
      app/hdl/hdl_role.go
  2. +16
    -0
      app/md/admin.go
  3. +3
    -0
      app/router/router.go
  4. +30
    -0
      app/svc/svc_medium_agent.go
  5. +1
    -1
      go.mod

+ 86
- 0
app/hdl/hdl_role.go View File

@@ -10,6 +10,7 @@ import (
db "code.fnuoos.com/zhimeng/model.git/src"
"code.fnuoos.com/zhimeng/model.git/src/implement"
"code.fnuoos.com/zhimeng/model.git/src/model"
implement2 "code.fnuoos.com/zhimeng/model.git/src/super/implement"
"github.com/gin-gonic/gin"
"time"
)
@@ -655,3 +656,88 @@ func AdminInfo(c *gin.Context) {
}, nil)
return
}
func RoleMediumList(c *gin.Context) {
var req md.AppletApplicationMediumListReq
err := c.ShouldBindJSON(&req)
if err != nil {
err = validate.HandleValidateErr(err)
err1 := err.(e.E)
e.OutErr(c, err1.Code, err1.Error())
return
}
engine := svc.MasterDb(c)
NewMediumDb := implement.NewMediumDb(engine)
appId := svc.GetMediumIdStr(c, req.Name, req.Account)
user := svc.GetUser(c)
list, total, _ := NewMediumDb.FindSuperAdminByMediumId(appId, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
data := make([]md.AdminBindMediumListData, 0)
if len(list) > 0 {
for _, v := range list {
var tmp = md.AdminBindMediumListData{
MediumId: utils.IntToStr(v.MediumId),
Name: v.Memo,
IsBind: "0",
Account: v.Username,
}
NewMediumListDb := implement2.NewMediumListDb(db.Db)
GetMediumList, _ := NewMediumListDb.GetMediumList(v.MediumId)
if GetMediumList != nil {
tmp.Name = GetMediumList.CompanyName
if GetMediumList.CompanyAbbreviation != "" {
tmp.Name = GetMediumList.CompanyAbbreviation
}
}
count, _ := engine.Where("medium_id=? and admin_id=?", v.MediumId, user.AdmId).Count(&model.AdminBindMedium{})
if count > 0 {
tmp.IsBind = "1"
}
data = append(data, tmp)
}
}
res := md.AdminBindMediumListRes{
List: data,
Total: total,
}
e.OutSuc(c, res, nil)
return
}
func RoleBindMedium(c *gin.Context) {
var req md.AdminBindMediumListSaveReq
err := c.ShouldBindJSON(&req)
if err != nil {
err = validate.HandleValidateErr(err)
err1 := err.(e.E)
e.OutErr(c, err1.Code, err1.Error())
return
}
user := svc.GetUser(c)
NewAdminBindMediumDb := implement.NewAdminBindMediumDb(svc.MasterDb(c))
data := NewAdminBindMediumDb.GetAdminByMediumId(user.AdmId, utils.StrToInt(req.MediumId))
if data != nil {
e.OutErr(c, 400, e.NewErr(400, "已绑定该媒体"))
return
}
tmp := model.AdminBindMedium{
AdminId: user.AdmId,
MediumId: utils.StrToInt(req.MediumId),
CreateAt: time.Now(),
UpdateAt: time.Now(),
}
svc.MasterDb(c).Insert(&tmp)
e.OutSuc(c, "success", nil)
return
}
func RoleDelMedium(c *gin.Context) {
var req md.AdminBindMediumListSaveReq
err := c.ShouldBindJSON(&req)
if err != nil {
err = validate.HandleValidateErr(err)
err1 := err.(e.E)
e.OutErr(c, err1.Code, err1.Error())
return
}
user := svc.GetUser(c)
svc.MasterDb(c).Where("medium_id=? and admin_id=?", req.MediumId, user.AdmId).Delete(&model.AdminBindMedium{})
e.OutSuc(c, "success", nil)
return
}

+ 16
- 0
app/md/admin.go View File

@@ -0,0 +1,16 @@
package md

type AdminBindMediumListData struct {
MediumId string `json:"medium_id" example:"媒体id"`
Name string `json:"name" example:""`
Account string `json:"account" example:""`
IsBind string `json:"is_bind"`
}
type AdminBindMediumListRes struct {
List []AdminBindMediumListData `json:"list"`
Total int64 `json:"total"`
}

type AdminBindMediumListSaveReq struct {
MediumId string `json:"medium_id"`
}

+ 3
- 0
app/router/router.go View File

@@ -122,6 +122,9 @@ func rRole(r *gin.RouterGroup) {
r.DELETE("/deleteAdmin/:adm_id", hdl.DeleteAdmin) // 删除管理员
r.GET("/adminInfo", hdl.AdminInfo) // 获取管理员信息
r.POST("/bindAdminRole", hdl.BindAdminRole) // 绑定角色
r.POST("/mediumList", hdl.RoleMediumList) // 管理员列表-媒体列表
r.POST("/bindMedium", hdl.RoleBindMedium) // 管理员列表-关联媒体
r.POST("/mediumDel", hdl.RoleDelMedium) // 管理员列表-删除关联媒体
}

func rAgentQualification(r *gin.RouterGroup) {


+ 30
- 0
app/svc/svc_medium_agent.go View File

@@ -299,3 +299,33 @@ func GetAgentInfo(c *gin.Context, mediumId int) map[string]string {
}
return res
}

func GetMediumIdStr(c *gin.Context, name, account string) string {
user := GetUser(c)
appId := GetMediumByAccountId(c, name, account)
appIds := []string{"-1"}
NewAdminBindMediumDb := implement2.NewAdminBindMediumDb(MasterDb(c))
list := NewAdminBindMediumDb.FindAll(user.AdmId)
ids := make([]string, 0)
for _, v := range list {
appIds = append(appIds, utils.IntToStr(v.MediumId))
ids = append(ids, utils.IntToStr(v.MediumId))
}
if len(list) == 0 { //为空就查全部
appIds = []string{}
}
if appId != "" { //不为空就判断 有没有在列表里面
appIds = []string{"-1"}
ex := strings.Split(appId, ",")
for _, v := range ex {
if utils.InArr(v, ids) || len(list) == 0 {
appIds = append(appIds, v)
}
}
}
str := ""
if len(appIds) > 0 {
str = strings.Join(appIds, ",")
}
return str
}

+ 1
- 1
go.mod View File

@@ -36,7 +36,7 @@ require (
require (
code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5
code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git v1.1.21-0.20240830072333-a1980ffb256e
code.fnuoos.com/zhimeng/model.git v0.0.3-0.20241024100823-8521ffcf1077
code.fnuoos.com/zhimeng/model.git v0.0.3-0.20241024113302-5f350a1a0c09
github.com/jinzhu/copier v0.4.0
)



Loading…
Cancel
Save