|
|
@@ -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 |
|
|
|
} |