Browse Source

更新

master
huangjiajun 2 months ago
parent
commit
7f1d01e166
3 changed files with 16 additions and 12 deletions
  1. +6
    -9
      app/hdl/hdl_role.go
  2. +8
    -0
      app/md/admin.go
  3. +2
    -3
      app/svc/svc_medium_agent.go

+ 6
- 9
app/hdl/hdl_role.go View File

@@ -657,7 +657,7 @@ func AdminInfo(c *gin.Context) {
return
}
func RoleMediumList(c *gin.Context) {
var req md.AppletApplicationMediumListReq
var req md.AdminBindMediumListReq
err := c.ShouldBindJSON(&req)
if err != nil {
err = validate.HandleValidateErr(err)
@@ -667,8 +667,7 @@ func RoleMediumList(c *gin.Context) {
}
engine := svc.MasterDb(c)
NewMediumDb := implement.NewMediumDb(engine)
appId := svc.GetMediumIdStr(c, req.Name, req.Account)
user := svc.GetUser(c)
appId := svc.GetMediumIdStr(c, 0, req.Name, req.Account)
list, total, _ := NewMediumDb.FindSuperAdminByMediumId(appId, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
data := make([]md.AdminBindMediumListData, 0)
if len(list) > 0 {
@@ -687,7 +686,7 @@ func RoleMediumList(c *gin.Context) {
tmp.Name = GetMediumList.CompanyAbbreviation
}
}
count, _ := engine.Where("medium_id=? and admin_id=?", v.MediumId, user.AdmId).Count(&model.AdminBindMedium{})
count, _ := engine.Where("medium_id=? and admin_id=?", v.MediumId, req.AdminId).Count(&model.AdminBindMedium{})
if count > 0 {
tmp.IsBind = "1"
}
@@ -710,15 +709,14 @@ func RoleBindMedium(c *gin.Context) {
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))
data := NewAdminBindMediumDb.GetAdminByMediumId(utils.StrToInt(req.AdminId), utils.StrToInt(req.MediumId))
if data != nil {
e.OutErr(c, 400, e.NewErr(400, "已绑定该媒体"))
return
}
tmp := model.AdminBindMedium{
AdminId: user.AdmId,
AdminId: utils.StrToInt(req.AdminId),
MediumId: utils.StrToInt(req.MediumId),
CreateAt: time.Now(),
UpdateAt: time.Now(),
@@ -736,8 +734,7 @@ func RoleDelMedium(c *gin.Context) {
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{})
svc.MasterDb(c).Where("medium_id=? and admin_id=?", req.MediumId, req.AdminId).Delete(&model.AdminBindMedium{})
e.OutSuc(c, "success", nil)
return
}

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

@@ -13,4 +13,12 @@ type AdminBindMediumListRes struct {

type AdminBindMediumListSaveReq struct {
MediumId string `json:"medium_id"`
AdminId string `json:"admin_id"`
}
type AdminBindMediumListReq struct {
Limit string `json:"limit"`
Page string `json:"page" `
Name string `json:"name" example:"媒体名称"`
Account string `json:"account" example:"媒体账号"`
AdminId string `json:"admin_id"`
}

+ 2
- 3
app/svc/svc_medium_agent.go View File

@@ -300,12 +300,11 @@ func GetAgentInfo(c *gin.Context, mediumId int) map[string]string {
return res
}

func GetMediumIdStr(c *gin.Context, name, account string) string {
user := GetUser(c)
func GetMediumIdStr(c *gin.Context, admId int, name, account string) string {
appId := GetMediumByAccountId(c, name, account)
appIds := []string{"-1"}
NewAdminBindMediumDb := implement2.NewAdminBindMediumDb(MasterDb(c))
list := NewAdminBindMediumDb.FindAll(user.AdmId)
list := NewAdminBindMediumDb.FindAll(admId)
ids := make([]string, 0)
for _, v := range list {
appIds = append(appIds, utils.IntToStr(v.MediumId))


Loading…
Cancel
Save