@@ -402,6 +402,7 @@ func AdminList(c *gin.Context) { | |||
result = append(result, md.AdminListResp{ | |||
AdmId: v.AdmId, | |||
ShowTime: v.ShowTime, | |||
Username: v.Username, | |||
State: v.State, | |||
IsSuperAdministrator: v.IsSuperAdministrator, | |||
@@ -504,8 +505,11 @@ func UpdateAdmin(c *gin.Context) { | |||
} | |||
admin.Username = req.Username | |||
admin.Memo = req.Memo | |||
admin.Password = utils.Md5(req.Password) | |||
_, err = admDb.UpdateAdmin(admin, "username", "memo", "password") | |||
admin.ShowTime = req.ShowTime | |||
if req.Password != "" { | |||
admin.Password = utils.Md5(req.Password) | |||
} | |||
_, err = admDb.UpdateAdmin(admin, "username", "memo", "password", "show_time") | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
@@ -552,6 +556,8 @@ func AddAdmin(c *gin.Context) { | |||
return | |||
} | |||
admin := model.Admin{ | |||
ShowTime: req.ShowTime, | |||
AdmId: admId, | |||
Username: req.Username, | |||
Password: utils.Md5(req.Password), | |||
@@ -738,3 +744,86 @@ func RoleDelMedium(c *gin.Context) { | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
func RoleAgentList(c *gin.Context) { | |||
var req md.AdminBindMediumListReq | |||
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, 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 { | |||
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, req.AdminId).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 RoleBindAgent(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 | |||
} | |||
NewAdminBindMediumDb := implement.NewAdminBindMediumDb(svc.MasterDb(c)) | |||
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: utils.StrToInt(req.AdminId), | |||
MediumId: utils.StrToInt(req.MediumId), | |||
CreateAt: time.Now(), | |||
UpdateAt: time.Now(), | |||
} | |||
svc.MasterDb(c).Insert(&tmp) | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
func RoleDelAgent(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 | |||
} | |||
svc.MasterDb(c).Where("medium_id=? and admin_id=?", req.MediumId, req.AdminId).Delete(&model.AdminBindMedium{}) | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} |
@@ -67,6 +67,7 @@ type AdminListResp struct { | |||
Memo string `json:"memo"` | |||
CreateAt string `json:"create_at"` | |||
UpdateAt string `json:"update_at"` | |||
ShowTime string `json:"show_time"` | |||
RoleList []string `json:"role_list"` | |||
} | |||
@@ -79,6 +80,7 @@ type AddAdminReq struct { | |||
Username string `json:"username" binding:"required" label:"名称"` | |||
Password string `json:"password" binding:"required" label:"密码"` | |||
Memo string `json:"memo" label:"备注"` | |||
ShowTime string `json:"show_time"` | |||
} | |||
type UpdateAdminReq struct { | |||
@@ -86,6 +88,7 @@ type UpdateAdminReq struct { | |||
Username string `json:"username" binding:"required" label:"名称"` | |||
Password string `json:"password" binding:"required" label:"密码"` | |||
Memo string `json:"memo" label:"备注"` | |||
ShowTime string `json:"show_time"` | |||
} | |||
type BindAdminRoleReq struct { | |||
@@ -149,6 +149,9 @@ func rRole(r *gin.RouterGroup) { | |||
r.POST("/mediumList", hdl.RoleMediumList) // 管理员列表-媒体列表 | |||
r.POST("/bindMedium", hdl.RoleBindMedium) // 管理员列表-关联媒体 | |||
r.POST("/mediumDel", hdl.RoleDelMedium) // 管理员列表-删除关联媒体 | |||
r.POST("/bindAgent", hdl.RoleBindAgent) // 管理员列表-关联代理 | |||
r.POST("/agentList", hdl.RoleAgentList) // 管理员列表-媒体列表 | |||
r.POST("/agentDel", hdl.RoleDelAgent) // 管理员列表-删除代理媒体 | |||
} | |||
func rAgentQualification(r *gin.RouterGroup) { | |||
@@ -417,8 +417,20 @@ func DataCenterSelectData(c *gin.Context) { | |||
ids = append(ids, utils.IntToStr(v.MediumId)) | |||
} | |||
for _, v := range appList { | |||
if utils.InArr(utils.IntToStr(v.MediumId), ids) == false && user.IsSuperAdministrator != 1 { | |||
continue | |||
if user.IsSuperAdministrator != 1 { | |||
if utils.InArr(utils.IntToStr(v.MediumId), ids) == false && len(ids) > 0 { | |||
continue | |||
} | |||
if len(ids) == 0 { | |||
if user.ShowTime == "" { | |||
continue | |||
} else { | |||
showTime := utils.TimeStdParseUnix(user.ShowTime + " 00:00:00") | |||
if v.CreateAt.Unix() < showTime { | |||
continue | |||
} | |||
} | |||
} | |||
} | |||
_, ok := appMap[v.Platform] | |||
if ok == false { | |||
@@ -396,14 +396,29 @@ func GetAppletIdByAdminId(c *gin.Context, admId int, name, platform, appIdStr st | |||
appIds = append(appIds, utils.IntToStr(v.MediumId)) | |||
ids = append(ids, utils.IntToStr(v.MediumId)) | |||
} | |||
isAll := 0 | |||
if len(list) == 0 { //为空就查全部 | |||
isAll = 1 | |||
appIds = []string{} | |||
NewAppletApplicationDb := implement2.NewAppletApplicationDb(MasterDb(c)) | |||
appList, _ := NewAppletApplicationDb.FindAllAppletApplicationList() | |||
user := GetUser(c) | |||
for _, v := range appList { | |||
if user.IsSuperAdministrator != 1 && user.ShowTime != "" { | |||
showTime := utils.TimeStdParseUnix(user.ShowTime + " 00:00:00") | |||
if v.CreateAt.Unix() >= showTime { | |||
appIds = append(appIds, utils.IntToStr(v.MediumId)) | |||
ids = append(ids, utils.IntToStr(v.MediumId)) | |||
isAll = 0 | |||
} | |||
} | |||
} | |||
} | |||
if appId != "" { //不为空就判断 有没有在列表里面 | |||
appIds = []string{"-1"} | |||
ex := strings.Split(appId, ",") | |||
for _, v := range ex { | |||
if utils.InArr(v, ids) || len(list) == 0 { | |||
if utils.InArr(v, ids) || (len(list) == 0 && isAll == 1) { | |||
appIds = append(appIds, v) | |||
} | |||
} | |||
@@ -35,7 +35,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.20241030074222-64103a1c8c40 | |||
code.fnuoos.com/zhimeng/model.git v0.0.3-0.20241104033828-ce3223d3e794 | |||
github.com/360EntSecGroup-Skylar/excelize v1.4.1 | |||
github.com/gin-contrib/cors v1.7.2 | |||
github.com/jinzhu/copier v0.4.0 | |||