@@ -0,0 +1,109 @@ | |||||
package hdl | |||||
import ( | |||||
"applet/app/e" | |||||
"applet/app/enum" | |||||
"applet/app/md" | |||||
"applet/app/svc" | |||||
"applet/app/utils" | |||||
db "code.fnuoos.com/zhimeng/model.git/src" | |||||
"code.fnuoos.com/zhimeng/model.git/src/implement" | |||||
"github.com/gin-gonic/gin" | |||||
) | |||||
func MenuList(c *gin.Context) { | |||||
masterId := svc.GetMasterId(c) | |||||
engine := db.DBs[masterId] | |||||
admin := svc.GetUser(c) | |||||
qrcodeWithBatchRecordsDb := implement.NewPermissionGroupDb(engine) | |||||
groupList, err := qrcodeWithBatchRecordsDb.FindPermissionGroupV2() | |||||
if err != nil { | |||||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||||
return | |||||
} | |||||
// 1、查询出当前用户所有角色 | |||||
adminRoleDb := implement.NewAdminRoleDb(engine) | |||||
roles, err := adminRoleDb.FindAdminRole(admin.AdmId) | |||||
if err != nil { | |||||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||||
return | |||||
} | |||||
roleDb := implement.NewRoleDb(engine, 0) | |||||
var adminHasPermissionGroupIds []string | |||||
for _, v := range *roles { | |||||
list, _, err1 := roleDb.FindPermissionGroupByRole(v.RoleId) | |||||
if err1 != nil { | |||||
e.OutErr(c, e.ERR_DB_ORM, err1.Error()) | |||||
return | |||||
} | |||||
for _, v1 := range list { | |||||
adminHasPermissionGroupIds = append(adminHasPermissionGroupIds, utils.IntToStr(v1.PermissionGroup.Id)) | |||||
} | |||||
} | |||||
var tempRespMap = map[string]*md.PermissionGroupListResp{} | |||||
var tempRespMapKeys []string | |||||
for _, v := range *groupList { | |||||
var isCheck bool | |||||
if admin.IsSuperAdministrator == enum.IsSuperAdministratorTure { | |||||
isCheck = true | |||||
} else { | |||||
isCheck = false | |||||
} | |||||
if utils.InArr(utils.IntToStr(v.Id), adminHasPermissionGroupIds) { | |||||
isCheck = true | |||||
} | |||||
if v.State == enum.PermissionGroupStateForDiscard { | |||||
isCheck = false | |||||
} | |||||
tempRespMap[utils.IntToStr(v.Id)] = &md.PermissionGroupListResp{ | |||||
Id: v.Id, | |||||
Name: v.Name, | |||||
Key: v.Key, | |||||
State: v.State, | |||||
ParentId: v.ParentId, | |||||
CreateAt: v.CreateAt, | |||||
UpdateAt: v.UpdateAt, | |||||
IsCheck: isCheck, | |||||
} | |||||
tempRespMapKeys = append(tempRespMapKeys, utils.IntToStr(v.Id)) | |||||
} | |||||
for _, v := range tempRespMap { | |||||
if v.ParentId != 0 && tempRespMap[utils.IntToStr(v.ParentId)].ParentId != 0 { | |||||
tempRespMap[utils.IntToStr(v.ParentId)].SubPermissionGroupList = append(tempRespMap[utils.IntToStr(v.ParentId)].SubPermissionGroupList, *v) | |||||
} | |||||
} | |||||
for _, v := range tempRespMap { | |||||
if v.ParentId != 0 && tempRespMap[utils.IntToStr(v.ParentId)].ParentId == 0 { | |||||
tempRespMap[utils.IntToStr(v.ParentId)].SubPermissionGroupList = append(tempRespMap[utils.IntToStr(v.ParentId)].SubPermissionGroupList, *v) | |||||
} | |||||
} | |||||
var resp []*md.PermissionGroupListResp | |||||
for _, v := range tempRespMapKeys { | |||||
if tempRespMap[v].ParentId == 0 { | |||||
resp = append(resp, tempRespMap[v]) | |||||
} | |||||
} | |||||
e.OutSuc(c, map[string]interface{}{ | |||||
"list": resp, | |||||
"state": []map[string]interface{}{ | |||||
{ | |||||
"name": enum.PermissionGroupState(enum.PermissionGroupStateForNormal).String(), | |||||
"value": enum.PermissionGroupStateForNormal, | |||||
}, | |||||
{ | |||||
"name": enum.PermissionGroupState(enum.PermissionGroupStateForDiscard).String(), | |||||
"value": enum.PermissionGroupStateForDiscard, | |||||
}, | |||||
}, | |||||
}, nil) | |||||
return | |||||
} |
@@ -0,0 +1,50 @@ | |||||
package youlianghui | |||||
import ( | |||||
"applet/app/cfg" | |||||
) | |||||
type ApiService struct { | |||||
MemberId string `json:"member_id"` | |||||
Secret string `json:"secret"` | |||||
Host string `json:"host"` | |||||
} | |||||
func NewApiService(memberId, secret string) (apiService ApiService, err error) { // set方法 | |||||
apiService.MemberId = memberId | |||||
apiService.Secret = secret | |||||
apiService.Host = "https://test-api.adnet.qq.com/open/v1.1" | |||||
if cfg.Prd { | |||||
apiService.Host = "http://api.adnet.qq.com/open/v1.1" | |||||
} | |||||
return | |||||
} | |||||
// MediumAdd 创建媒体 | |||||
// func (apiService *ApiService) MediumAdd() (appId string, err error) { // set方法 | |||||
// token := GetToken(apiService.MemberId, apiService.Secret) | |||||
// url := apiService.Host + "/medium/add" | |||||
// params := map[string]interface{}{ | |||||
// "name": name, | |||||
// "type": string(adunitType), | |||||
// } | |||||
// if adunitType == enum.AdunitTypeForVideoFeeds { | |||||
// params["video_duration_min"] = 6 | |||||
// params["video_duration_max"] = 60 | |||||
// } | |||||
// postBody, err := utils.CurlPost(url, utils.SerializeStr(params), nil) | |||||
// if err != nil { | |||||
// return | |||||
// } | |||||
// var resp md.AgencyCreateAdunit | |||||
// err = json.Unmarshal(postBody, &resp) | |||||
// if err != nil { | |||||
// return | |||||
// } | |||||
// if resp.Ret != 0 { | |||||
// err = errors.New(resp.ErrMsg) | |||||
// } | |||||
// adUnitId = resp.AdUnitId | |||||
// return | |||||
// } |
@@ -0,0 +1,28 @@ | |||||
package youlianghui | |||||
import ( | |||||
"crypto/sha1" | |||||
"encoding/base64" | |||||
"fmt" | |||||
"strconv" | |||||
"strings" | |||||
"time" | |||||
) | |||||
// GetToken 获取token | |||||
func GetToken(memberId, secret string) (token string) { | |||||
timestamp := strconv.FormatInt(time.Now().Unix(), 10) // 时间戳,精确到秒 | |||||
// 计算签名 | |||||
hash := sha1.New() | |||||
hash.Write([]byte(memberId + secret + timestamp)) | |||||
sign := fmt.Sprintf("%x", hash.Sum(nil)) | |||||
// 构建列表 | |||||
listV := []string{memberId, timestamp, sign} | |||||
plain := strings.Join(listV, ",") | |||||
// 编码为Base64 | |||||
token = base64.StdEncoding.EncodeToString([]byte(plain)) | |||||
return | |||||
} |
@@ -0,0 +1,14 @@ | |||||
package md | |||||
type MediumAdd struct { | |||||
MediumName string `json:"medium_name" example:"媒体名字"` | |||||
IndustryIdV2 int `json:"industry_id_v2" example:"媒体所属新3级行业id"` | |||||
Os int `json:"os" example:"操作系统,数字含义1-Android, 2-iOS"` | |||||
DetailUrl string `json:"detail_url" example:"详情页url(支持的各个商店域名约束)"` | |||||
Affiliation string `json:"affiliation" example:"媒体隶属关系"` | |||||
PackageName string `json:"package_name" example:"主程序包名"` | |||||
FullPackageName string `json:"full_package_name" example:"完整的程序包名(当OS为Android时必填)"` | |||||
WechatAppId string `json:"wechat_app_id" example:"微信开放平台AppId(当OS为iOS时非必填)"` | |||||
PackageNameWxAppidRel string `json:"package_name_wx_appid_rel" example:"当OS为Android时选填,例如:{"com.xx.xx":"wx9b1xxx3449f","com.xx.xx.xx":"wx9b1xxx3xxx9x"}"` | |||||
WechatUniversalLink string `json:"wechat_universal_link" example:"微信开放平台Universal link"` | |||||
} |
@@ -13,4 +13,6 @@ const ( | |||||
KEY_SYS_CFG_CACHE = "sys_cfg_cache" | KEY_SYS_CFG_CACHE = "sys_cfg_cache" | ||||
CfgCacheTime = 86400 | CfgCacheTime = 86400 | ||||
AdminRolePermissionKey = "%s:advertisement_admin_role_permission:%s" // 占位符:ip, admin:id | |||||
) | ) |
@@ -0,0 +1,33 @@ | |||||
package mw | |||||
import ( | |||||
"applet/app/e" | |||||
"applet/app/enum" | |||||
"applet/app/md" | |||||
"applet/app/svc" | |||||
"applet/app/utils" | |||||
"fmt" | |||||
"github.com/gin-gonic/gin" | |||||
) | |||||
// CheckPermission 检查权限 | |||||
func CheckPermission(c *gin.Context) { | |||||
admin := svc.GetUser(c) | |||||
masterId := svc.GetMasterId(c) | |||||
// TODO::判断是否为超管 | |||||
if admin.IsSuperAdministrator == enum.IsSuperAdministratorTure { | |||||
c.Next() | |||||
} else { | |||||
rolePermissionKey := fmt.Sprintf(md.AdminRolePermissionKey, masterId, utils.AnyToString(admin.AdmId)) | |||||
isHasPermission, err := svc.CheckUserRole(c, rolePermissionKey, c.Request.RequestURI, admin.AdmId) | |||||
if err != nil { | |||||
e.OutErr(c, e.ERR, err.Error()) | |||||
return | |||||
} | |||||
if !isHasPermission { | |||||
e.OutErr(c, e.ERR_FORBIDEN, "当前用户暂未拥有该路由权限,请联系管理员") | |||||
return | |||||
} | |||||
c.Next() | |||||
} | |||||
} |
@@ -67,7 +67,10 @@ func route(r *gin.RouterGroup) { | |||||
r.POST("/registerForMedium", hdl.RegisterForMedium) | r.POST("/registerForMedium", hdl.RegisterForMedium) | ||||
r.POST("/registerForAgent", hdl.RegisterForAgent) | r.POST("/registerForAgent", hdl.RegisterForAgent) | ||||
r.Use(mw.Auth) // 以下接口需要JWT验证 | |||||
r.Use(mw.Auth) // 以下接口需要JWT验证 | |||||
rComm(r.Group("/comm")) | |||||
r.Use(mw.CheckPermission) // 检测权限 | |||||
rRole(r.Group("/role")) // 权限管理 | rRole(r.Group("/role")) // 权限管理 | ||||
rQualification(r.Group("/qualification")) // 资质认证公共数据 | rQualification(r.Group("/qualification")) // 资质认证公共数据 | ||||
rAgentQualification(r.Group("/agentQualification")) // 渠道-资质 | rAgentQualification(r.Group("/agentQualification")) // 渠道-资质 | ||||
@@ -81,12 +84,18 @@ func route(r *gin.RouterGroup) { | |||||
rIndex(r.Group("/index")) // 首页 | rIndex(r.Group("/index")) // 首页 | ||||
rFinancialDynamics(r.Group("/financialDynamics")) // 资产动态 | rFinancialDynamics(r.Group("/financialDynamics")) // 资产动态 | ||||
} | } | ||||
func rComm(r *gin.RouterGroup) { | |||||
r.POST("/getMenuList", hdl.MenuList) // 获取菜单栏列表 | |||||
} | |||||
func rIndex(r *gin.RouterGroup) { | func rIndex(r *gin.RouterGroup) { | ||||
r.GET("/base", hdl.Base) // 首页-基本信息 | r.GET("/base", hdl.Base) // 首页-基本信息 | ||||
r.GET("/total", hdl.IndexTotal) // 首页-统计数据 | r.GET("/total", hdl.IndexTotal) // 首页-统计数据 | ||||
r.POST("/app/list", hdl.IndexAppList) // 首页-应用数据 | r.POST("/app/list", hdl.IndexAppList) // 首页-应用数据 | ||||
r.POST("/app/list/table", hdl.IndexAppListTable) // 首页-应用数据-每个应用的折线图 | r.POST("/app/list/table", hdl.IndexAppListTable) // 首页-应用数据-每个应用的折线图 | ||||
} | } | ||||
func rRole(r *gin.RouterGroup) { | func rRole(r *gin.RouterGroup) { | ||||
r.GET("/roleList", hdl.RoleList) // 角色列表 | r.GET("/roleList", hdl.RoleList) // 角色列表 | ||||
r.POST("/addRole", hdl.AddRole) // 角色添加 | r.POST("/addRole", hdl.AddRole) // 角色添加 | ||||
@@ -103,9 +112,11 @@ func rRole(r *gin.RouterGroup) { | |||||
r.GET("/adminInfo", hdl.AdminInfo) // 获取管理员信息 | r.GET("/adminInfo", hdl.AdminInfo) // 获取管理员信息 | ||||
r.POST("/bindAdminRole", hdl.BindAdminRole) // 绑定角色 | r.POST("/bindAdminRole", hdl.BindAdminRole) // 绑定角色 | ||||
} | } | ||||
func rQualification(r *gin.RouterGroup) { | func rQualification(r *gin.RouterGroup) { | ||||
r.GET("/select/base", hdl.QualificationSelectBase) // 资质认证-认证选择内容 | r.GET("/select/base", hdl.QualificationSelectBase) // 资质认证-认证选择内容 | ||||
} | } | ||||
func rAgentQualification(r *gin.RouterGroup) { | func rAgentQualification(r *gin.RouterGroup) { | ||||
r.POST("/enterprise", hdl.AgentQualificationEnterprise) // 企业主体资质 | r.POST("/enterprise", hdl.AgentQualificationEnterprise) // 企业主体资质 | ||||
r.POST("/enterprise/audit", hdl.AgentQualificationEnterpriseAudit) // 企业主体资质审核 | r.POST("/enterprise/audit", hdl.AgentQualificationEnterpriseAudit) // 企业主体资质审核 | ||||
@@ -114,6 +125,7 @@ func rAgentQualification(r *gin.RouterGroup) { | |||||
r.POST("/contact", hdl.AgentQualificationContactInfo) // 联系方式 | r.POST("/contact", hdl.AgentQualificationContactInfo) // 联系方式 | ||||
r.POST("/contact/audit", hdl.AgentQualificationContactInfoAudit) // 联系方式 | r.POST("/contact/audit", hdl.AgentQualificationContactInfoAudit) // 联系方式 | ||||
} | } | ||||
func rMediumQualification(r *gin.RouterGroup) { | func rMediumQualification(r *gin.RouterGroup) { | ||||
r.POST("/enterprise", hdl.MediumQualificationEnterprise) // 企业主体资质 | r.POST("/enterprise", hdl.MediumQualificationEnterprise) // 企业主体资质 | ||||
r.POST("/enterprise/audit", hdl.MediumQualificationEnterpriseAudit) // 企业主体资质审核 | r.POST("/enterprise/audit", hdl.MediumQualificationEnterpriseAudit) // 企业主体资质审核 | ||||
@@ -122,6 +134,7 @@ func rMediumQualification(r *gin.RouterGroup) { | |||||
r.POST("/contact", hdl.MediumQualificationContactInfo) // 联系方式 | r.POST("/contact", hdl.MediumQualificationContactInfo) // 联系方式 | ||||
r.POST("/contact/audit", hdl.MediumQualificationContactInfoAudit) // 联系方式 | r.POST("/contact/audit", hdl.MediumQualificationContactInfoAudit) // 联系方式 | ||||
} | } | ||||
func rSetCenter(r *gin.RouterGroup) { | func rSetCenter(r *gin.RouterGroup) { | ||||
rBasicSetCenter := r.Group("/basic") | rBasicSetCenter := r.Group("/basic") | ||||
{ | { | ||||
@@ -160,6 +173,7 @@ func rSetCenter(r *gin.RouterGroup) { | |||||
} | } | ||||
} | } | ||||
func rMedium(r *gin.RouterGroup) { | func rMedium(r *gin.RouterGroup) { | ||||
r.POST("/applet/application/medium/list", hdl.AppletApplicationMediumList) // 应用管理-媒体列表 | r.POST("/applet/application/medium/list", hdl.AppletApplicationMediumList) // 应用管理-媒体列表 | ||||
r.POST("/applet/application/list", hdl.AppletApplicationList) // 小程序应用-列表数据 | r.POST("/applet/application/list", hdl.AppletApplicationList) // 小程序应用-列表数据 | ||||
@@ -177,11 +191,13 @@ func rMedium(r *gin.RouterGroup) { | |||||
r.POST("/agent/list", hdl.AgentList) // 代理列表 | r.POST("/agent/list", hdl.AgentList) // 代理列表 | ||||
r.POST("/agent/bind/medium/list", hdl.AgentBindMediumList) // 代理绑定媒体列表 | r.POST("/agent/bind/medium/list", hdl.AgentBindMediumList) // 代理绑定媒体列表 | ||||
} | } | ||||
func rDivisionStrategy(r *gin.RouterGroup) { | func rDivisionStrategy(r *gin.RouterGroup) { | ||||
r.POST("/list", hdl.DivisionStrategyList) // 分成策略-列表 | r.POST("/list", hdl.DivisionStrategyList) // 分成策略-列表 | ||||
r.POST("/detail", hdl.DivisionStrategyDetail) // 分成策略-详情 | r.POST("/detail", hdl.DivisionStrategyDetail) // 分成策略-详情 | ||||
r.POST("/save", hdl.DivisionStrategySave) // 分成策略-保存 | r.POST("/save", hdl.DivisionStrategySave) // 分成策略-保存 | ||||
} | } | ||||
func rDataCenter(r *gin.RouterGroup) { | func rDataCenter(r *gin.RouterGroup) { | ||||
r.POST("/original/data/list", hdl.OriginalDataList) // 数据中心-原始数据 | r.POST("/original/data/list", hdl.OriginalDataList) // 数据中心-原始数据 | ||||
r.POST("/original/data/del", hdl.OriginalDataDel) // 数据中心-原始数据-删除 | r.POST("/original/data/del", hdl.OriginalDataDel) // 数据中心-原始数据-删除 | ||||
@@ -204,6 +220,7 @@ func rDataCenter(r *gin.RouterGroup) { | |||||
r.POST("/income/data/detail", hdl.IncomeDataDetail) // 数据中心-收益报表-详情 | r.POST("/income/data/detail", hdl.IncomeDataDetail) // 数据中心-收益报表-详情 | ||||
} | } | ||||
func rSettleCenter(r *gin.RouterGroup) { | func rSettleCenter(r *gin.RouterGroup) { | ||||
r.POST("/medium/list", hdl.SettleCenterMediumList) // 结算中心-媒体列表 | r.POST("/medium/list", hdl.SettleCenterMediumList) // 结算中心-媒体列表 | ||||
r.POST("/medium/save", hdl.SettleCenterMediumSave) // 结算中心-媒体修复结算方式 | r.POST("/medium/save", hdl.SettleCenterMediumSave) // 结算中心-媒体修复结算方式 | ||||
@@ -213,6 +230,7 @@ func rSettleCenter(r *gin.RouterGroup) { | |||||
r.POST("/agent/save", hdl.SettleCenterAgentSave) // 结算中心-代理修复结算方式 | r.POST("/agent/save", hdl.SettleCenterAgentSave) // 结算中心-代理修复结算方式 | ||||
r.POST("/agent/detail", hdl.SettleCenterAgentDetail) // 结算中心-代理结算详情 | r.POST("/agent/detail", hdl.SettleCenterAgentDetail) // 结算中心-代理结算详情 | ||||
} | } | ||||
func rFinanceCenter(r *gin.RouterGroup) { | func rFinanceCenter(r *gin.RouterGroup) { | ||||
r.POST("/medium/list", hdl.FinanceCenterMediumList) // 财务中心-媒体列表 | r.POST("/medium/list", hdl.FinanceCenterMediumList) // 财务中心-媒体列表 | ||||
r.POST("/medium/detail", hdl.FinanceCenterMediumDetail) // 财务中心-媒体详情 | r.POST("/medium/detail", hdl.FinanceCenterMediumDetail) // 财务中心-媒体详情 | ||||
@@ -231,6 +249,7 @@ func rFinanceCenter(r *gin.RouterGroup) { | |||||
r.POST("/agent/pay/save", hdl.FinanceCenterAgentPaySave) // 财务中心-代理详情-确认支付 | r.POST("/agent/pay/save", hdl.FinanceCenterAgentPaySave) // 财务中心-代理详情-确认支付 | ||||
} | } | ||||
func rFinancialDynamics(r *gin.RouterGroup) { | func rFinancialDynamics(r *gin.RouterGroup) { | ||||
r.POST("/medium/total", hdl.FinancialDynamicsMediumTotal) // 预付中心-媒体预付统计 | r.POST("/medium/total", hdl.FinancialDynamicsMediumTotal) // 预付中心-媒体预付统计 | ||||
r.POST("/medium/list", hdl.FinancialDynamicsMediumList) // 预付中心-媒体预付 | r.POST("/medium/list", hdl.FinancialDynamicsMediumList) // 预付中心-媒体预付 | ||||
@@ -36,11 +36,11 @@ require ( | |||||
require ( | require ( | ||||
code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5 | 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/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.20240930064359-f120af0d8ade | |||||
github.com/jinzhu/copier v0.4.0 | github.com/jinzhu/copier v0.4.0 | ||||
) | ) | ||||
require ( | require ( | ||||
code.fnuoos.com/zhimeng/model.git v0.0.3-0.20240930064359-f120af0d8ade // indirect | |||||
filippo.io/edwards25519 v1.1.0 // indirect | filippo.io/edwards25519 v1.1.0 // indirect | ||||
github.com/KyleBanks/depth v1.2.1 // indirect | github.com/KyleBanks/depth v1.2.1 // indirect | ||||
github.com/PuerkitoBio/purell v1.1.1 // indirect | github.com/PuerkitoBio/purell v1.1.1 // indirect | ||||