From aadde4c368481293d37f6d4b54799e135597adb6 Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Mon, 9 Dec 2024 14:34:35 +0800 Subject: [PATCH 01/12] update --- app/hdl/member_center/hdl_tag__management.go | 15 +++++++++++++-- go.mod | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/hdl/member_center/hdl_tag__management.go b/app/hdl/member_center/hdl_tag__management.go index 89bc7e1..f1d7878 100644 --- a/app/hdl/member_center/hdl_tag__management.go +++ b/app/hdl/member_center/hdl_tag__management.go @@ -7,6 +7,7 @@ import ( "applet/app/utils" "code.fnuoos.com/EggPlanet/egg_models.git/src/implement" "code.fnuoos.com/EggPlanet/egg_models.git/src/model" + "errors" "github.com/gin-gonic/gin" "time" ) @@ -126,7 +127,7 @@ func UpdateTag(c *gin.Context) { Memo: req.Memo, } - forceColumns := []string{"tag_name", "memo", "is_punish"} + forceColumns := []string{"tag_name", "memo"} tagDb := implement.NewUserTagDb(db.Db) affected, err := tagDb.UserTagUpdate(tagID, tag, forceColumns...) @@ -160,7 +161,17 @@ func DeleteTag(c *gin.Context) { session := db.Db.NewSession() defer session.Close() - _, err := tagDb.UserTagDeleteBySession(session, req.TagID) + isUsed, err := recordsDb.UserTagRecordsIsUsedBySession(session, utils.StrToInt(req.TagID)) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + if isUsed { + e.OutErr(c, e.ERR, errors.New("该标签已被使用,无法删除").Error()) + return + } + + _, err = tagDb.UserTagDeleteBySession(session, req.TagID) if err != nil { session.Rollback() e.OutErr(c, e.ERR_DB_ORM, err.Error()) diff --git a/go.mod b/go.mod index 34c8776..94ffe78 100644 --- a/go.mod +++ b/go.mod @@ -33,7 +33,7 @@ require ( ) require ( - code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241207095049-e0ad89412565 + code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241209061118-ae1be0db6a70 code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241205075006-9c0bf995c788 code.fnuoos.com/go_rely_warehouse/zyos_go_es.git v1.0.1-0.20241118083738-0f22da9ba0be code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5 From 5b7b0755f859a8e46ee32a4161b01755c79d08e0 Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Mon, 9 Dec 2024 17:48:56 +0800 Subject: [PATCH 02/12] update --- app/enum/enum_role.go | 19 + app/hdl/hdl_role.go | 652 ++++++++++++++++++++++++++++++++++ app/md/md_role.go | 18 +- app/router/router.go | 18 + app/svc/svc_role.go | 24 ++ docs/docs.go | 791 ++++++++++++++++++++++++++++++++++++++++++ docs/swagger.json | 791 ++++++++++++++++++++++++++++++++++++++++++ docs/swagger.yaml | 523 ++++++++++++++++++++++++++++ go.mod | 2 +- 9 files changed, 2824 insertions(+), 14 deletions(-) create mode 100644 app/enum/enum_role.go create mode 100644 app/hdl/hdl_role.go diff --git a/app/enum/enum_role.go b/app/enum/enum_role.go new file mode 100644 index 0000000..bd8763c --- /dev/null +++ b/app/enum/enum_role.go @@ -0,0 +1,19 @@ +package enum + +type RoleState int32 + +const ( + RoleStateForNormal = 1 + RoleStateForFreeze = 2 +) + +func (gt RoleState) String() string { + switch gt { + case RoleStateForNormal: + return "正常" + case RoleStateForFreeze: + return "冻结" + default: + return "未知" + } +} diff --git a/app/hdl/hdl_role.go b/app/hdl/hdl_role.go new file mode 100644 index 0000000..80cb578 --- /dev/null +++ b/app/hdl/hdl_role.go @@ -0,0 +1,652 @@ +package hdl + +import ( + "applet/app/db" + "applet/app/e" + "applet/app/enum" + "applet/app/lib/validate" + "applet/app/md" + "applet/app/svc" + "applet/app/utils" + "code.fnuoos.com/EggPlanet/egg_models.git/src/implement" + "code.fnuoos.com/EggPlanet/egg_models.git/src/model" + "github.com/gin-gonic/gin" + "time" +) + +// PermissionGroupList +// @Summary 权限组列表 +// @Tags 权限管理 +// @Description 权限管理-权限组列表 +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @Accept json +// @Produce json +// @param adm_id query string true "管理员id" +// @Success 200 {string} "具体看返回内容" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/role/permissionGroupList [GET] +func PermissionGroupList(c *gin.Context) { + roleId := c.DefaultQuery("role_id", "") + engine := db.Db + qrcodeWithBatchRecordsDb := implement.NewPermissionGroupDb(engine) + groupList, err := qrcodeWithBatchRecordsDb.FindPermissionGroup() + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + + roleDb := implement.NewRoleDb(engine, utils.StrToInt(roleId)) + list, _, err := roleDb.FindPermissionGroupByRole(utils.StrToInt(roleId)) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + var isHasPermissionGroupId []string + for _, v := range list { + isHasPermissionGroupId = append(isHasPermissionGroupId, utils.IntToStr(v.PermissionGroup.Id)) + } + + var tempRespMap = map[string]*md.PermissionGroupListResp{} + var tempRespMapKeys []string + for _, v := range *groupList { + isCheck := false + if utils.InArr(utils.IntToStr(v.Id), isHasPermissionGroupId) { + isCheck = true + } + 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 +} + +// RoleList +// @Summary 角色列表 +// @Tags 权限管理 +// @Description 权限管理-角色列表 +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @Accept json +// @Produce json +// @Success 200 {string} "具体看返回内容" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/role/roleList [GET] +func RoleList(c *gin.Context) { + engine := db.Db + roleDb := implement.NewRoleDb(engine, 0) + roleList, err := roleDb.FindRole() + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + + adminRoleDb := implement.NewAdminRoleDb(engine) + adminDb := implement.NewAdminDb(engine) + var result []*md.RoleListResp + for _, v := range *roleList { + var temp md.RoleListResp + temp.Data = v + adminRoles, err1 := adminRoleDb.FindAdminRoleByRoleId(v.Id) + if err1 != nil { + e.OutErr(c, e.ERR_DB_ORM, err1.Error()) + return + } + for _, adminRole := range *adminRoles { + admin, err2 := adminDb.GetAdmin(adminRole.AdmId) + if err2 != nil { + e.OutErr(c, e.ERR_DB_ORM, err2.Error()) + return + } + temp.AdminList = append(temp.AdminList, struct { + Name string `json:"name"` + }{ + Name: admin.Username, + }) + } + result = append(result, &temp) + } + e.OutSuc(c, map[string]interface{}{ + "list": result, + "state": []map[string]interface{}{ + { + "name": enum.RoleState(enum.RoleStateForNormal).String(), + "value": enum.RoleStateForNormal, + }, + { + "name": enum.RoleState(enum.RoleStateForFreeze).String(), + "value": enum.RoleStateForFreeze, + }, + }, + }, nil) + return +} + +// AddRole +// @Summary 添加角色 +// @Tags 权限管理 +// @Description 权限管理-添加角色 +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @Accept json +// @Produce json +// @Param args body md.AddRoleReq true "请求参数" +// @Success 200 {string} "success" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/role/addRole [POST] +func AddRole(c *gin.Context) { + var req md.AddRoleReq + err := c.ShouldBindJSON(&req) + if err != nil { + err = validate.HandleValidateErr(err) + err1 := err.(e.E) + e.OutErr(c, err1.Code, err1.Error()) + return + } + engine := db.Db + roleDb := implement.NewRoleDb(engine, 0) + now := time.Now() + _, err = roleDb.RoleInsert(&model.Role{ + Name: req.Name, + State: enum.RoleStateForNormal, + Memo: req.Memo, + CreateAt: now.Format("2006-01-02 15:04:05"), + UpdateAt: now.Format("2006-01-02 15:04:05"), + }) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + + e.OutSuc(c, "success", nil) + return +} + +// UpdateRole +// @Summary 修改角色 +// @Tags 权限管理 +// @Description 权限管理-修改角色 +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @Accept json +// @Produce json +// @Param args body md.UpdateRoleReq true "请求参数" +// @Success 200 {string} "success" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/role/updateRole [POST] +func UpdateRole(c *gin.Context) { + var req md.UpdateRoleReq + err := c.ShouldBindJSON(&req) + if err != nil { + err = validate.HandleValidateErr(err) + err1 := err.(e.E) + e.OutErr(c, err1.Code, err1.Error()) + return + } + engine := db.Db + roleDb := implement.NewRoleDb(engine, req.RoleId) + role, err := roleDb.GetRole() + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + if role == nil { + e.OutErr(c, e.ERR_NO_DATA, "未查询到相应记录") + return + } + role.Name = req.Name + role.Memo = req.Memo + _, err = roleDb.UpdateRole(role, "name", "memo") + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + e.OutSuc(c, "success", nil) + return +} + +// RoleBindPermissionGroup +// @Summary 角色绑定权限组 +// @Tags 权限管理 +// @Description 权限管理-角色绑定权限组 +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @Accept json +// @Produce json +// @Param args body md.RoleBindPermissionGroupReq true "请求参数" +// @Success 200 {string} "success" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/role/roleBindPermissionGroup [POST] +func RoleBindPermissionGroup(c *gin.Context) { + var req md.RoleBindPermissionGroupReq + err := c.ShouldBindJSON(&req) + if err != nil { + err = validate.HandleValidateErr(err) + err1 := err.(e.E) + e.OutErr(c, err1.Code, err1.Error()) + return + } + err = svc.RoleBindPermissionGroup(c, req) + if err != nil { + e.OutErr(c, e.ERR, err.Error()) + return + } + + e.OutSuc(c, "success", nil) + return +} + +// UpdateRoleState +// @Summary 修改角色状态 +// @Tags 权限管理 +// @Description 权限管理-修改角色状态 +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @Accept json +// @Produce json +// @Param args body md.UpdateRoleStateReq true "请求参数" +// @Success 200 {string} "success" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/role/updateRoleState [POST] +func UpdateRoleState(c *gin.Context) { + var req md.UpdateRoleStateReq + err := c.ShouldBindJSON(&req) + if err != nil { + err = validate.HandleValidateErr(err) + err1 := err.(e.E) + e.OutErr(c, err1.Code, err1.Error()) + return + } + engine := db.Db + roleDb := implement.NewRoleDb(engine, req.RoleId) + role, err := roleDb.GetRole() + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + if role == nil { + e.OutErr(c, e.ERR_NO_DATA, "未查询到相应记录") + return + } + role.State = req.State + _, err = roleDb.UpdateRole(role, "state") + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + e.OutSuc(c, "success", nil) + return +} + +// DeleteRole +// @Summary 删除角色 +// @Tags 权限管理 +// @Description 权限管理-删除角色 +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @Accept json +// @Produce json +// @Param args body md.UpdateRoleStateReq true "请求参数" +// @Success 200 {string} "success" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/role/deleteRole/{$id} [DELETE] +func DeleteRole(c *gin.Context) { + id := c.Param("id") + engine := db.Db + roleDb := implement.NewRoleDb(engine, utils.StrToInt(id)) + role, err := roleDb.GetRole() + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + if role == nil { + e.OutErr(c, e.ERR_NO_DATA, "未查询到相应记录") + return + } + + err = svc.DeleteRole(c, utils.StrToInt(id)) + if err != nil { + e.OutErr(c, e.ERR, err.Error()) + return + } + + e.OutSuc(c, "success", nil) + return +} + +// AdminList +// @Summary 管理员列表 +// @Tags 权限管理 +// @Description 权限管理-管理员列表 +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @Accept json +// @Produce json +// @Param args body md.AdminListReq true "请求参数" +// @Success 200 {string} "具体看返回内容" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/role/adminList [POST] +func AdminList(c *gin.Context) { + var req md.AdminListReq + err := c.ShouldBindJSON(&req) + if err != nil { + err = validate.HandleValidateErr(err) + err1 := err.(e.E) + e.OutErr(c, err1.Code, err1.Error()) + return + } + if req.Limit == 0 { + req.Limit = 10 + } + if req.Page == 0 { + req.Page = 10 + } + engine := db.Db + adminDb := implement.NewAdminDb(engine) + adminList, total, err := adminDb.FindAdmin(req.UserName, req.State, req.Page, req.Limit) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + var result []md.AdminListResp + for _, v := range adminList { + permissionGroupList, _, err1 := adminDb.FindAdminRolePermissionGroup(v.AdmId) + if err1 != nil { + e.OutErr(c, e.ERR_DB_ORM, err1.Error()) + return + } + var roleList []string + for _, v1 := range permissionGroupList { + roleList = append(roleList, v1.Role.Name) + } + + result = append(result, md.AdminListResp{ + AdmId: v.AdmId, + Username: v.Username, + State: v.State, + IsSuperAdministrator: v.IsSuperAdministrator, + Memo: v.Memo, + CreateAt: v.CreateAt, + UpdateAt: v.UpdateAt, + RoleList: roleList, + }) + } + + e.OutSuc(c, map[string]interface{}{ + "list": result, + "total": total, + "state": []map[string]interface{}{ + { + "name": enum.RoleState(enum.RoleStateForNormal).String(), + "value": enum.RoleStateForNormal, + }, + { + "name": enum.RoleState(enum.RoleStateForFreeze).String(), + "value": enum.RoleStateForFreeze, + }, + }, + }, nil) + return +} + +// UpdateAdminState +// @Summary 修改管理员状态 +// @Tags 权限管理 +// @Description 权限管理-修改管理员状态 +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @Accept json +// @Produce json +// @Param args body md.UpdateAdminStateReq true "请求参数" +// @Success 200 {string} "success" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/role/updateAdminState [POST] +func UpdateAdminState(c *gin.Context) { + var req md.UpdateAdminStateReq + err := c.ShouldBindJSON(&req) + if err != nil { + err = validate.HandleValidateErr(err) + err1 := err.(e.E) + e.OutErr(c, err1.Code, err1.Error()) + return + } + + engine := db.Db + admDb := implement.NewAdminDb(engine) + admin, err := admDb.GetAdmin(req.AdmId) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + if admin == nil { + e.OutErr(c, e.ERR_NO_DATA, "未查询到相应记录") + return + } + admin.State = req.State + _, err = admDb.UpdateAdmin(admin, "state") + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + e.OutSuc(c, "success", nil) + return +} + +// UpdateAdmin +// @Summary 修改管理员信息 +// @Tags 权限管理 +// @Description 权限管理-修改管理员信息 +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @Accept json +// @Produce json +// @Param args body md.UpdateAdminReq true "请求参数" +// @Success 200 {string} "success" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/role/updateAdmin [POST] +func UpdateAdmin(c *gin.Context) { + var req md.UpdateAdminReq + err := c.ShouldBindJSON(&req) + if err != nil { + err = validate.HandleValidateErr(err) + err1 := err.(e.E) + e.OutErr(c, err1.Code, err1.Error()) + return + } + engine := db.Db + admDb := implement.NewAdminDb(engine) + admin, err := admDb.GetAdmin(req.AdmId) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + if admin == nil { + e.OutErr(c, e.ERR_NO_DATA, "未查询到相应记录") + return + } + admin.Username = req.Username + admin.Memo = req.Memo + 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 + } + e.OutSuc(c, "success", nil) + return +} + +// AddAdmin +// @Summary 新增管理员 +// @Tags 权限管理 +// @Description 权限管理-新增管理员 +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @Accept json +// @Produce json +// @Param args body md.AddAdminReq true "请求参数" +// @Success 200 {string} "success" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/role/addAdmin [POST] +func AddAdmin(c *gin.Context) { + var req md.AddAdminReq + err := c.ShouldBindJSON(&req) + if err != nil { + err = validate.HandleValidateErr(err) + err1 := err.(e.E) + e.OutErr(c, err1.Code, err1.Error()) + return + } + engine := db.Db + admDb := implement.NewAdminDb(engine) + isHasAdmin, err := admDb.GetAdminByUserName(req.Username) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + if isHasAdmin != nil { + e.OutErr(c, e.ERR, "当前用户名已存在,请勿重复添加") + return + } + + admId, err := admDb.CreateAdminId() + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + admin := model.Admin{ + + AdmId: admId, + Username: req.Username, + Password: utils.Md5(req.Password), + State: enum.AdminStateForNormal, + IsSuperAdministrator: 0, + Memo: req.Memo, + CreateAt: time.Now().Format("2006-01-02 15:04:05"), + UpdateAt: time.Now().Format("2006-01-02 15:04:05"), + } + _, err = admDb.AdminInsert(&admin) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + e.OutSuc(c, "success", nil) + return +} + +// DeleteAdmin +// @Summary 删除管理员 +// @Tags 权限管理 +// @Description 权限管理-删除管理员 +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @Accept json +// @Produce json +// @Success 200 {string} "success" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/role/deleteAdmin/{$adm_id} [DELETE] +func DeleteAdmin(c *gin.Context) { + admId := c.Param("adm_id") + err := svc.AdminDelete([]int{utils.StrToInt(admId)}) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + e.OutSuc(c, "success", nil) + return +} + +// BindAdminRole +// @Summary 管理员绑定角色 +// @Tags 权限管理 +// @Description 权限管理-管理员绑定角色 +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @Accept json +// @Produce json +// @Param args body md.BindAdminRoleReq true "请求参数" +// @Success 200 {string} "success" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/role/bindAdminRole [POST] +func BindAdminRole(c *gin.Context) { + var req md.BindAdminRoleReq + err := c.ShouldBindJSON(&req) + if err != nil { + err = validate.HandleValidateErr(err) + err1 := err.(e.E) + e.OutErr(c, err1.Code, err1.Error()) + return + } + err = svc.BindAdminRole(c, req) + if err != nil { + e.OutErr(c, e.ERR, err.Error()) + return + } + e.OutSuc(c, "success", nil) + return +} + +// AdminInfo +// @Summary 管理员信息 +// @Tags 权限管理 +// @Description 权限管理-管理员信息 +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @Accept json +// @Produce json +// @param adm_id query string true "管理员id" +// @Success 200 {string} "具体看返回内容" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/role/adminInfo [GET] +func AdminInfo(c *gin.Context) { + admId := c.DefaultQuery("adm_id", "") + engine := db.Db + admDb := implement.NewAdminDb(engine) + admin, err := admDb.GetAdmin(utils.StrToInt(admId)) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + admin.Password = "" + e.OutSuc(c, map[string]interface{}{ + "info": admin, + "state": []map[string]interface{}{ + { + "name": enum.RoleState(enum.RoleStateForNormal).String(), + "value": enum.RoleStateForNormal, + }, + { + "name": enum.RoleState(enum.RoleStateForFreeze).String(), + "value": enum.RoleStateForFreeze, + }, + }, + }, nil) + return +} diff --git a/app/md/md_role.go b/app/md/md_role.go index 5e8c173..a3b3338 100644 --- a/app/md/md_role.go +++ b/app/md/md_role.go @@ -17,22 +17,14 @@ type UpdateRoleStateReq struct { } type AddRoleReq struct { - Name string `json:"name" binding:"required" label:"名称"` - Memo string `json:"memo" binding:"required" label:"备注"` - Logo string `json:"logo" label:"左边图标"` - Label string `json:"label" label:"身份标签"` - SeoLogo string `json:"seo_logo" label:"seo"` - SeoTitle string `json:"seo_title" label:"seo"` + Name string `json:"name" binding:"required" label:"名称"` + Memo string `json:"memo" binding:"required" label:"备注"` } type UpdateRoleReq struct { - RoleId int `json:"role_id" binding:"required" label:"id"` - Name string `json:"name" binding:"required" label:"名称"` - Memo string `json:"memo" binding:"required" label:"备注"` - Logo string `json:"logo" label:"左边图标"` - Label string `json:"label" label:"身份标签"` - SeoLogo string `json:"seo_logo" label:"seo"` - SeoTitle string `json:"seo_title" label:"seo"` + RoleId int `json:"role_id" binding:"required" label:"id"` + Name string `json:"name" binding:"required" label:"名称"` + Memo string `json:"memo" binding:"required" label:"备注"` } type RoleBindPermissionGroupReq struct { diff --git a/app/router/router.go b/app/router/router.go index 57ec947..c4008cd 100644 --- a/app/router/router.go +++ b/app/router/router.go @@ -88,6 +88,7 @@ func route(r *gin.RouterGroup) { r.GET("/config", hdl.Config) rIm(r.Group("/im")) r.Use(mw.CheckPermission) // 检测权限 + rRole(r.Group("/role")) rInstitutionalManagement(r.Group("/institutionalManagement")) rMarketingApplications(r.Group("/marketingApplications")) rMemberCenter(r.Group("/memberCenter")) @@ -402,6 +403,23 @@ func rFriendCircleSettings(r *gin.RouterGroup) { } } +func rRole(r *gin.RouterGroup) { + r.GET("/roleList", hdl.RoleList) // 角色列表 + r.POST("/addRole", hdl.AddRole) // 角色添加 + r.POST("/roleBindPermissionGroup", hdl.RoleBindPermissionGroup) // 角色绑定权限组 + r.POST("/updateRoleState", hdl.UpdateRoleState) // 修改角色状态 + r.POST("/updateRole", hdl.UpdateRole) // 修改角色状态 + r.DELETE("/deleteRole/:id", hdl.DeleteRole) // 删除角色 + r.GET("/permissionGroupList", hdl.PermissionGroupList) // 权限组列表 + r.POST("/adminList", hdl.AdminList) // 管理员列表 + r.POST("/updateAdminState", hdl.UpdateAdminState) // 修改管理员状态 + r.POST("/updateAdmin", hdl.UpdateAdmin) // 修改管理员信息 + r.POST("/addAdmin", hdl.AddAdmin) // 新增管理员 + r.DELETE("/deleteAdmin/:adm_id", hdl.DeleteAdmin) // 删除管理员 + r.GET("/adminInfo", hdl.AdminInfo) // 获取管理员信息 + r.POST("/bindAdminRole", hdl.BindAdminRole) // 绑定角色 +} + func rComm(r *gin.RouterGroup) { r.POST("/getMenuList", comm.MenuList) // 获取菜单栏列表 r.POST("/getOssUrl", comm.GetOssUrl) // 获取阿里云上传PutObject所需的签名URL diff --git a/app/svc/svc_role.go b/app/svc/svc_role.go index 79bafd1..0f96f68 100644 --- a/app/svc/svc_role.go +++ b/app/svc/svc_role.go @@ -194,3 +194,27 @@ func BindAdminRole(c *gin.Context, req md.BindAdminRoleReq) (err error) { return session.Commit() } + +func AdminDelete(admIds []int) (err error) { + engine := db.Db + session := engine.NewSession() + defer session.Close() + session.Begin() + //1、删除 `admin` + adminDb := implement.NewAdminDb(engine) + _, err = adminDb.AdminDeleteBySession(session, admIds) + if err != nil { + _ = session.Rollback() + return + } + + //2、删除 `admin_role` + adminRoleDb := implement.NewAdminRoleDb(engine) + _, err = adminRoleDb.AdminDeleteBySessionForAdmId(session, admIds) + if err != nil { + _ = session.Rollback() + return + } + + return session.Commit() +} diff --git a/docs/docs.go b/docs/docs.go index d6a53dc..d3c249b 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -6785,6 +6785,642 @@ const docTemplate = `{ } } }, + "/api/role/addAdmin": { + "post": { + "description": "权限管理-新增管理员", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "权限管理" + ], + "summary": "新增管理员", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "请求参数", + "name": "args", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/md.AddAdminReq" + } + } + ], + "responses": { + "200": { + "description": "success", + "schema": { + "type": "string" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/role/addRole": { + "post": { + "description": "权限管理-添加角色", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "权限管理" + ], + "summary": "添加角色", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "请求参数", + "name": "args", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/md.AddRoleReq" + } + } + ], + "responses": { + "200": { + "description": "success", + "schema": { + "type": "string" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/role/adminInfo": { + "get": { + "description": "权限管理-管理员信息", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "权限管理" + ], + "summary": "管理员信息", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "管理员id", + "name": "adm_id", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "具体看返回内容", + "schema": { + "type": "string" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/role/adminList": { + "post": { + "description": "权限管理-管理员列表", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "权限管理" + ], + "summary": "管理员列表", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "请求参数", + "name": "args", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/md.AdminListReq" + } + } + ], + "responses": { + "200": { + "description": "具体看返回内容", + "schema": { + "type": "string" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/role/bindAdminRole": { + "post": { + "description": "权限管理-管理员绑定角色", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "权限管理" + ], + "summary": "管理员绑定角色", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "请求参数", + "name": "args", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/md.BindAdminRoleReq" + } + } + ], + "responses": { + "200": { + "description": "success", + "schema": { + "type": "string" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/role/deleteAdmin/{$adm_id}": { + "delete": { + "description": "权限管理-删除管理员", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "权限管理" + ], + "summary": "删除管理员", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "success", + "schema": { + "type": "string" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/role/deleteRole/{$id}": { + "delete": { + "description": "权限管理-删除角色", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "权限管理" + ], + "summary": "删除角色", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "请求参数", + "name": "args", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/md.UpdateRoleStateReq" + } + } + ], + "responses": { + "200": { + "description": "success", + "schema": { + "type": "string" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/role/permissionGroupList": { + "get": { + "description": "权限管理-权限组列表", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "权限管理" + ], + "summary": "权限组列表", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "管理员id", + "name": "adm_id", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "具体看返回内容", + "schema": { + "type": "string" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/role/roleBindPermissionGroup": { + "post": { + "description": "权限管理-角色绑定权限组", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "权限管理" + ], + "summary": "角色绑定权限组", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "请求参数", + "name": "args", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/md.RoleBindPermissionGroupReq" + } + } + ], + "responses": { + "200": { + "description": "success", + "schema": { + "type": "string" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/role/roleList": { + "get": { + "description": "权限管理-角色列表", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "权限管理" + ], + "summary": "角色列表", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "具体看返回内容", + "schema": { + "type": "string" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/role/updateAdmin": { + "post": { + "description": "权限管理-修改管理员信息", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "权限管理" + ], + "summary": "修改管理员信息", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "请求参数", + "name": "args", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/md.UpdateAdminReq" + } + } + ], + "responses": { + "200": { + "description": "success", + "schema": { + "type": "string" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/role/updateAdminState": { + "post": { + "description": "权限管理-修改管理员状态", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "权限管理" + ], + "summary": "修改管理员状态", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "请求参数", + "name": "args", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/md.UpdateAdminStateReq" + } + } + ], + "responses": { + "200": { + "description": "success", + "schema": { + "type": "string" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/role/updateRole": { + "post": { + "description": "权限管理-修改角色", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "权限管理" + ], + "summary": "修改角色", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "请求参数", + "name": "args", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/md.UpdateRoleReq" + } + } + ], + "responses": { + "200": { + "description": "success", + "schema": { + "type": "string" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/role/updateRoleState": { + "post": { + "description": "权限管理-修改角色状态", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "权限管理" + ], + "summary": "修改角色状态", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "请求参数", + "name": "args", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/md.UpdateRoleStateReq" + } + } + ], + "responses": { + "200": { + "description": "success", + "schema": { + "type": "string" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, "/api/settCenter/oss/aliYun/getBasic": { "get": { "description": "对象存储设置(获取)", @@ -8090,6 +8726,24 @@ const docTemplate = `{ } } }, + "md.AddAdminReq": { + "type": "object", + "required": [ + "password", + "username" + ], + "properties": { + "memo": { + "type": "string" + }, + "password": { + "type": "string" + }, + "username": { + "type": "string" + } + } + }, "md.AddBlackListReq": { "type": "object", "properties": { @@ -8263,6 +8917,21 @@ const docTemplate = `{ } } }, + "md.AddRoleReq": { + "type": "object", + "required": [ + "memo", + "name" + ], + "properties": { + "memo": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, "md.AddTagReq": { "type": "object", "properties": { @@ -8280,6 +8949,23 @@ const docTemplate = `{ } } }, + "md.AdminListReq": { + "type": "object", + "properties": { + "limit": { + "type": "integer" + }, + "page": { + "type": "integer" + }, + "state": { + "type": "integer" + }, + "username": { + "type": "string" + } + } + }, "md.AdvertisingBase": { "type": "object", "properties": { @@ -8898,6 +9584,23 @@ const docTemplate = `{ } } }, + "md.BindAdminRoleReq": { + "type": "object", + "required": [ + "adm_id" + ], + "properties": { + "adm_id": { + "type": "integer" + }, + "role_ids": { + "type": "array", + "items": { + "type": "integer" + } + } + } + }, "md.CloudBundleBaseResp": { "type": "object", "properties": { @@ -12279,6 +12982,23 @@ const docTemplate = `{ } } }, + "md.RoleBindPermissionGroupReq": { + "type": "object", + "required": [ + "role_id" + ], + "properties": { + "permission_ids": { + "type": "array", + "items": { + "type": "integer" + } + }, + "role_id": { + "type": "integer" + } + } + }, "md.SelectData": { "type": "object", "properties": { @@ -12700,6 +13420,43 @@ const docTemplate = `{ } } }, + "md.UpdateAdminReq": { + "type": "object", + "required": [ + "adm_id", + "password", + "username" + ], + "properties": { + "adm_id": { + "type": "integer" + }, + "memo": { + "type": "string" + }, + "password": { + "type": "string" + }, + "username": { + "type": "string" + } + } + }, + "md.UpdateAdminStateReq": { + "type": "object", + "required": [ + "adm_id", + "state" + ], + "properties": { + "adm_id": { + "type": "integer" + }, + "state": { + "type": "integer" + } + } + }, "md.UpdateContributionValueBasicSettingReq": { "type": "object", "properties": { @@ -12968,6 +13725,40 @@ const docTemplate = `{ } } }, + "md.UpdateRoleReq": { + "type": "object", + "required": [ + "memo", + "name", + "role_id" + ], + "properties": { + "memo": { + "type": "string" + }, + "name": { + "type": "string" + }, + "role_id": { + "type": "integer" + } + } + }, + "md.UpdateRoleStateReq": { + "type": "object", + "required": [ + "role_id", + "state" + ], + "properties": { + "role_id": { + "type": "integer" + }, + "state": { + "type": "integer" + } + } + }, "md.UpdateTagReq": { "type": "object", "properties": { diff --git a/docs/swagger.json b/docs/swagger.json index d872bcb..288dba2 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -6778,6 +6778,642 @@ } } }, + "/api/role/addAdmin": { + "post": { + "description": "权限管理-新增管理员", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "权限管理" + ], + "summary": "新增管理员", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "请求参数", + "name": "args", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/md.AddAdminReq" + } + } + ], + "responses": { + "200": { + "description": "success", + "schema": { + "type": "string" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/role/addRole": { + "post": { + "description": "权限管理-添加角色", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "权限管理" + ], + "summary": "添加角色", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "请求参数", + "name": "args", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/md.AddRoleReq" + } + } + ], + "responses": { + "200": { + "description": "success", + "schema": { + "type": "string" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/role/adminInfo": { + "get": { + "description": "权限管理-管理员信息", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "权限管理" + ], + "summary": "管理员信息", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "管理员id", + "name": "adm_id", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "具体看返回内容", + "schema": { + "type": "string" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/role/adminList": { + "post": { + "description": "权限管理-管理员列表", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "权限管理" + ], + "summary": "管理员列表", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "请求参数", + "name": "args", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/md.AdminListReq" + } + } + ], + "responses": { + "200": { + "description": "具体看返回内容", + "schema": { + "type": "string" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/role/bindAdminRole": { + "post": { + "description": "权限管理-管理员绑定角色", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "权限管理" + ], + "summary": "管理员绑定角色", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "请求参数", + "name": "args", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/md.BindAdminRoleReq" + } + } + ], + "responses": { + "200": { + "description": "success", + "schema": { + "type": "string" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/role/deleteAdmin/{$adm_id}": { + "delete": { + "description": "权限管理-删除管理员", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "权限管理" + ], + "summary": "删除管理员", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "success", + "schema": { + "type": "string" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/role/deleteRole/{$id}": { + "delete": { + "description": "权限管理-删除角色", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "权限管理" + ], + "summary": "删除角色", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "请求参数", + "name": "args", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/md.UpdateRoleStateReq" + } + } + ], + "responses": { + "200": { + "description": "success", + "schema": { + "type": "string" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/role/permissionGroupList": { + "get": { + "description": "权限管理-权限组列表", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "权限管理" + ], + "summary": "权限组列表", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "管理员id", + "name": "adm_id", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "具体看返回内容", + "schema": { + "type": "string" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/role/roleBindPermissionGroup": { + "post": { + "description": "权限管理-角色绑定权限组", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "权限管理" + ], + "summary": "角色绑定权限组", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "请求参数", + "name": "args", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/md.RoleBindPermissionGroupReq" + } + } + ], + "responses": { + "200": { + "description": "success", + "schema": { + "type": "string" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/role/roleList": { + "get": { + "description": "权限管理-角色列表", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "权限管理" + ], + "summary": "角色列表", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "具体看返回内容", + "schema": { + "type": "string" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/role/updateAdmin": { + "post": { + "description": "权限管理-修改管理员信息", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "权限管理" + ], + "summary": "修改管理员信息", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "请求参数", + "name": "args", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/md.UpdateAdminReq" + } + } + ], + "responses": { + "200": { + "description": "success", + "schema": { + "type": "string" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/role/updateAdminState": { + "post": { + "description": "权限管理-修改管理员状态", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "权限管理" + ], + "summary": "修改管理员状态", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "请求参数", + "name": "args", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/md.UpdateAdminStateReq" + } + } + ], + "responses": { + "200": { + "description": "success", + "schema": { + "type": "string" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/role/updateRole": { + "post": { + "description": "权限管理-修改角色", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "权限管理" + ], + "summary": "修改角色", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "请求参数", + "name": "args", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/md.UpdateRoleReq" + } + } + ], + "responses": { + "200": { + "description": "success", + "schema": { + "type": "string" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/role/updateRoleState": { + "post": { + "description": "权限管理-修改角色状态", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "权限管理" + ], + "summary": "修改角色状态", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "请求参数", + "name": "args", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/md.UpdateRoleStateReq" + } + } + ], + "responses": { + "200": { + "description": "success", + "schema": { + "type": "string" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, "/api/settCenter/oss/aliYun/getBasic": { "get": { "description": "对象存储设置(获取)", @@ -8083,6 +8719,24 @@ } } }, + "md.AddAdminReq": { + "type": "object", + "required": [ + "password", + "username" + ], + "properties": { + "memo": { + "type": "string" + }, + "password": { + "type": "string" + }, + "username": { + "type": "string" + } + } + }, "md.AddBlackListReq": { "type": "object", "properties": { @@ -8256,6 +8910,21 @@ } } }, + "md.AddRoleReq": { + "type": "object", + "required": [ + "memo", + "name" + ], + "properties": { + "memo": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, "md.AddTagReq": { "type": "object", "properties": { @@ -8273,6 +8942,23 @@ } } }, + "md.AdminListReq": { + "type": "object", + "properties": { + "limit": { + "type": "integer" + }, + "page": { + "type": "integer" + }, + "state": { + "type": "integer" + }, + "username": { + "type": "string" + } + } + }, "md.AdvertisingBase": { "type": "object", "properties": { @@ -8891,6 +9577,23 @@ } } }, + "md.BindAdminRoleReq": { + "type": "object", + "required": [ + "adm_id" + ], + "properties": { + "adm_id": { + "type": "integer" + }, + "role_ids": { + "type": "array", + "items": { + "type": "integer" + } + } + } + }, "md.CloudBundleBaseResp": { "type": "object", "properties": { @@ -12272,6 +12975,23 @@ } } }, + "md.RoleBindPermissionGroupReq": { + "type": "object", + "required": [ + "role_id" + ], + "properties": { + "permission_ids": { + "type": "array", + "items": { + "type": "integer" + } + }, + "role_id": { + "type": "integer" + } + } + }, "md.SelectData": { "type": "object", "properties": { @@ -12693,6 +13413,43 @@ } } }, + "md.UpdateAdminReq": { + "type": "object", + "required": [ + "adm_id", + "password", + "username" + ], + "properties": { + "adm_id": { + "type": "integer" + }, + "memo": { + "type": "string" + }, + "password": { + "type": "string" + }, + "username": { + "type": "string" + } + } + }, + "md.UpdateAdminStateReq": { + "type": "object", + "required": [ + "adm_id", + "state" + ], + "properties": { + "adm_id": { + "type": "integer" + }, + "state": { + "type": "integer" + } + } + }, "md.UpdateContributionValueBasicSettingReq": { "type": "object", "properties": { @@ -12961,6 +13718,40 @@ } } }, + "md.UpdateRoleReq": { + "type": "object", + "required": [ + "memo", + "name", + "role_id" + ], + "properties": { + "memo": { + "type": "string" + }, + "name": { + "type": "string" + }, + "role_id": { + "type": "integer" + } + } + }, + "md.UpdateRoleStateReq": { + "type": "object", + "required": [ + "role_id", + "state" + ], + "properties": { + "role_id": { + "type": "integer" + }, + "state": { + "type": "integer" + } + } + }, "md.UpdateTagReq": { "type": "object", "properties": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 2fcc85a..a335579 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -349,6 +349,18 @@ definitions: example: 手机号 type: string type: object + md.AddAdminReq: + properties: + memo: + type: string + password: + type: string + username: + type: string + required: + - password + - username + type: object md.AddBlackListReq: properties: memo: @@ -472,6 +484,16 @@ definitions: description: 金额 type: string type: object + md.AddRoleReq: + properties: + memo: + type: string + name: + type: string + required: + - memo + - name + type: object md.AddTagReq: properties: is_punish: @@ -484,6 +506,17 @@ definitions: description: 标签名称 type: string type: object + md.AdminListReq: + properties: + limit: + type: integer + page: + type: integer + state: + type: integer + username: + type: string + type: object md.AdvertisingBase: properties: android_ad_is_open: @@ -910,6 +943,17 @@ definitions: description: 发送模式(1:所有用户 2:指定用户) type: integer type: object + md.BindAdminRoleReq: + properties: + adm_id: + type: integer + role_ids: + items: + type: integer + type: array + required: + - adm_id + type: object md.CloudBundleBaseResp: properties: android_logo: @@ -3259,6 +3303,17 @@ definitions: description: 奖励值 type: string type: object + md.RoleBindPermissionGroupReq: + properties: + permission_ids: + items: + type: integer + type: array + role_id: + type: integer + required: + - role_id + type: object md.SelectData: properties: direction: @@ -3553,6 +3608,31 @@ definitions: uid: type: integer type: object + md.UpdateAdminReq: + properties: + adm_id: + type: integer + memo: + type: string + password: + type: string + username: + type: string + required: + - adm_id + - password + - username + type: object + md.UpdateAdminStateReq: + properties: + adm_id: + type: integer + state: + type: integer + required: + - adm_id + - state + type: object md.UpdateContributionValueBasicSettingReq: properties: hand_out_red_package: @@ -3732,6 +3812,29 @@ definitions: description: xx天未活跃,处罚滑落 type: integer type: object + md.UpdateRoleReq: + properties: + memo: + type: string + name: + type: string + role_id: + type: integer + required: + - memo + - name + - role_id + type: object + md.UpdateRoleStateReq: + properties: + role_id: + type: integer + state: + type: integer + required: + - role_id + - state + type: object md.UpdateTagReq: properties: memo: @@ -9330,6 +9433,426 @@ paths: summary: 消息中心-基本配置-推送记录添加-发送(不做编辑了) tags: - 消息中心 + /api/role/addAdmin: + post: + consumes: + - application/json + description: 权限管理-新增管理员 + parameters: + - description: 验证参数Bearer和token空格拼接 + in: header + name: Authorization + required: true + type: string + - description: 请求参数 + in: body + name: args + required: true + schema: + $ref: '#/definitions/md.AddAdminReq' + produces: + - application/json + responses: + "200": + description: success + schema: + type: string + "400": + description: 具体错误 + schema: + $ref: '#/definitions/md.Response' + summary: 新增管理员 + tags: + - 权限管理 + /api/role/addRole: + post: + consumes: + - application/json + description: 权限管理-添加角色 + parameters: + - description: 验证参数Bearer和token空格拼接 + in: header + name: Authorization + required: true + type: string + - description: 请求参数 + in: body + name: args + required: true + schema: + $ref: '#/definitions/md.AddRoleReq' + produces: + - application/json + responses: + "200": + description: success + schema: + type: string + "400": + description: 具体错误 + schema: + $ref: '#/definitions/md.Response' + summary: 添加角色 + tags: + - 权限管理 + /api/role/adminInfo: + get: + consumes: + - application/json + description: 权限管理-管理员信息 + parameters: + - description: 验证参数Bearer和token空格拼接 + in: header + name: Authorization + required: true + type: string + - description: 管理员id + in: query + name: adm_id + required: true + type: string + produces: + - application/json + responses: + "200": + description: 具体看返回内容 + schema: + type: string + "400": + description: 具体错误 + schema: + $ref: '#/definitions/md.Response' + summary: 管理员信息 + tags: + - 权限管理 + /api/role/adminList: + post: + consumes: + - application/json + description: 权限管理-管理员列表 + parameters: + - description: 验证参数Bearer和token空格拼接 + in: header + name: Authorization + required: true + type: string + - description: 请求参数 + in: body + name: args + required: true + schema: + $ref: '#/definitions/md.AdminListReq' + produces: + - application/json + responses: + "200": + description: 具体看返回内容 + schema: + type: string + "400": + description: 具体错误 + schema: + $ref: '#/definitions/md.Response' + summary: 管理员列表 + tags: + - 权限管理 + /api/role/bindAdminRole: + post: + consumes: + - application/json + description: 权限管理-管理员绑定角色 + parameters: + - description: 验证参数Bearer和token空格拼接 + in: header + name: Authorization + required: true + type: string + - description: 请求参数 + in: body + name: args + required: true + schema: + $ref: '#/definitions/md.BindAdminRoleReq' + produces: + - application/json + responses: + "200": + description: success + schema: + type: string + "400": + description: 具体错误 + schema: + $ref: '#/definitions/md.Response' + summary: 管理员绑定角色 + tags: + - 权限管理 + /api/role/deleteAdmin/{$adm_id}: + delete: + consumes: + - application/json + description: 权限管理-删除管理员 + parameters: + - description: 验证参数Bearer和token空格拼接 + in: header + name: Authorization + required: true + type: string + produces: + - application/json + responses: + "200": + description: success + schema: + type: string + "400": + description: 具体错误 + schema: + $ref: '#/definitions/md.Response' + summary: 删除管理员 + tags: + - 权限管理 + /api/role/deleteRole/{$id}: + delete: + consumes: + - application/json + description: 权限管理-删除角色 + parameters: + - description: 验证参数Bearer和token空格拼接 + in: header + name: Authorization + required: true + type: string + - description: 请求参数 + in: body + name: args + required: true + schema: + $ref: '#/definitions/md.UpdateRoleStateReq' + produces: + - application/json + responses: + "200": + description: success + schema: + type: string + "400": + description: 具体错误 + schema: + $ref: '#/definitions/md.Response' + summary: 删除角色 + tags: + - 权限管理 + /api/role/permissionGroupList: + get: + consumes: + - application/json + description: 权限管理-权限组列表 + parameters: + - description: 验证参数Bearer和token空格拼接 + in: header + name: Authorization + required: true + type: string + - description: 管理员id + in: query + name: adm_id + required: true + type: string + produces: + - application/json + responses: + "200": + description: 具体看返回内容 + schema: + type: string + "400": + description: 具体错误 + schema: + $ref: '#/definitions/md.Response' + summary: 权限组列表 + tags: + - 权限管理 + /api/role/roleBindPermissionGroup: + post: + consumes: + - application/json + description: 权限管理-角色绑定权限组 + parameters: + - description: 验证参数Bearer和token空格拼接 + in: header + name: Authorization + required: true + type: string + - description: 请求参数 + in: body + name: args + required: true + schema: + $ref: '#/definitions/md.RoleBindPermissionGroupReq' + produces: + - application/json + responses: + "200": + description: success + schema: + type: string + "400": + description: 具体错误 + schema: + $ref: '#/definitions/md.Response' + summary: 角色绑定权限组 + tags: + - 权限管理 + /api/role/roleList: + get: + consumes: + - application/json + description: 权限管理-角色列表 + parameters: + - description: 验证参数Bearer和token空格拼接 + in: header + name: Authorization + required: true + type: string + produces: + - application/json + responses: + "200": + description: 具体看返回内容 + schema: + type: string + "400": + description: 具体错误 + schema: + $ref: '#/definitions/md.Response' + summary: 角色列表 + tags: + - 权限管理 + /api/role/updateAdmin: + post: + consumes: + - application/json + description: 权限管理-修改管理员信息 + parameters: + - description: 验证参数Bearer和token空格拼接 + in: header + name: Authorization + required: true + type: string + - description: 请求参数 + in: body + name: args + required: true + schema: + $ref: '#/definitions/md.UpdateAdminReq' + produces: + - application/json + responses: + "200": + description: success + schema: + type: string + "400": + description: 具体错误 + schema: + $ref: '#/definitions/md.Response' + summary: 修改管理员信息 + tags: + - 权限管理 + /api/role/updateAdminState: + post: + consumes: + - application/json + description: 权限管理-修改管理员状态 + parameters: + - description: 验证参数Bearer和token空格拼接 + in: header + name: Authorization + required: true + type: string + - description: 请求参数 + in: body + name: args + required: true + schema: + $ref: '#/definitions/md.UpdateAdminStateReq' + produces: + - application/json + responses: + "200": + description: success + schema: + type: string + "400": + description: 具体错误 + schema: + $ref: '#/definitions/md.Response' + summary: 修改管理员状态 + tags: + - 权限管理 + /api/role/updateRole: + post: + consumes: + - application/json + description: 权限管理-修改角色 + parameters: + - description: 验证参数Bearer和token空格拼接 + in: header + name: Authorization + required: true + type: string + - description: 请求参数 + in: body + name: args + required: true + schema: + $ref: '#/definitions/md.UpdateRoleReq' + produces: + - application/json + responses: + "200": + description: success + schema: + type: string + "400": + description: 具体错误 + schema: + $ref: '#/definitions/md.Response' + summary: 修改角色 + tags: + - 权限管理 + /api/role/updateRoleState: + post: + consumes: + - application/json + description: 权限管理-修改角色状态 + parameters: + - description: 验证参数Bearer和token空格拼接 + in: header + name: Authorization + required: true + type: string + - description: 请求参数 + in: body + name: args + required: true + schema: + $ref: '#/definitions/md.UpdateRoleStateReq' + produces: + - application/json + responses: + "200": + description: success + schema: + type: string + "400": + description: 具体错误 + schema: + $ref: '#/definitions/md.Response' + summary: 修改角色状态 + tags: + - 权限管理 /api/settCenter/oss/aliYun/getBasic: get: consumes: diff --git a/go.mod b/go.mod index 94ffe78..75c22fc 100644 --- a/go.mod +++ b/go.mod @@ -33,7 +33,7 @@ require ( ) require ( - code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241209061118-ae1be0db6a70 + code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241209094543-8aafc254a593 code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241205075006-9c0bf995c788 code.fnuoos.com/go_rely_warehouse/zyos_go_es.git v1.0.1-0.20241118083738-0f22da9ba0be code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5 From cff192c47132f9404b153dc810dd1fb665e19e5f Mon Sep 17 00:00:00 2001 From: dengbiao Date: Mon, 9 Dec 2024 19:46:36 +0800 Subject: [PATCH 03/12] update --- app/hdl/member_center/hdl_user_management.go | 12 ++++---- app/svc/member_center/svc_user_management.go | 30 ++++++++++++++------ 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/app/hdl/member_center/hdl_user_management.go b/app/hdl/member_center/hdl_user_management.go index 157ea91..9950bf6 100644 --- a/app/hdl/member_center/hdl_user_management.go +++ b/app/hdl/member_center/hdl_user_management.go @@ -75,13 +75,13 @@ func UserManagementGetUserList(c *gin.Context) { }, } - users, total, err3 := svc.UserManagementGetUsers(db.Db, req) + users, total, err3 := svc.UserManagementGetUsers(req) if err3 != nil { e.OutErr(c, e.ERR_DB_ORM, err3.Error()) return } - userIDs := make([]int64, len(*users)) - for i, user := range *users { + userIDs := make([]int64, len(users)) + for i, user := range users { userIDs[i] = user.Id } @@ -102,9 +102,9 @@ func UserManagementGetUserList(c *gin.Context) { return } - userMap := make(map[int64]int, len(*users)) - list := make([]md.UserManagementGetUserListNode, len(*users)) - for i, user := range *users { + userMap := make(map[int64]int, len(users)) + list := make([]md.UserManagementGetUserListNode, len(users)) + for i, user := range users { list[i] = md.UserManagementGetUserListNode{ ID: user.Id, Sex: user.Sex, diff --git a/app/svc/member_center/svc_user_management.go b/app/svc/member_center/svc_user_management.go index e8976f7..b349dd4 100644 --- a/app/svc/member_center/svc_user_management.go +++ b/app/svc/member_center/svc_user_management.go @@ -6,14 +6,31 @@ import ( "applet/app/utils" "code.fnuoos.com/EggPlanet/egg_models.git/src/implement" "code.fnuoos.com/EggPlanet/egg_models.git/src/model" + "fmt" "strings" "time" "xorm.io/xorm" ) -func UserManagementGetUsers(engine *xorm.Engine, req *md.UserManagementGetUserListReq) (*[]md.UserInfo, int64, error) { - users := make([]md.UserInfo, 0) - session := engine.Table("user").Alias("a").Distinct("a.id"). +func UserManagementGetUsers(req *md.UserManagementGetUserListReq) ([]*md.UserInfo, int64, error) { + users := make([]*md.UserInfo, 0) + pageSess := userManagementGetUsersBindQuery(db.Db, req) + countSess := userManagementGetUsersBindQuery(db.Db, req) + total, err := countSess.Distinct("a.id").Count(&md.UserInfo{}) + if err != nil { + fmt.Println(err.Error()) + return nil, 0, err + } + + err = pageSess.Distinct("a.*").Limit(req.Limit, (req.Page-1)*req.Limit).Asc("a.id").Find(&users) + if err != nil { + return nil, 0, err + } + return users, total, nil +} + +func userManagementGetUsersBindQuery(engine *xorm.Engine, req *md.UserManagementGetUserListReq) *xorm.Session { + session := engine.Table("user").Alias("a"). Join("LEFT OUTER", []string{"user", "b"}, "a.parent_uid = b.id"). Join("LEFT OUTER", "user_tag_records", "user_tag_records.uid = a.id") if req.ID != 0 { @@ -67,13 +84,8 @@ func UserManagementGetUsers(engine *xorm.Engine, req *md.UserManagementGetUserLi if req.LoginBefore != "" && req.LoginAfter != "" { session = session.Where("a.update_at > ? and a.update_at < ?", req.LoginBefore, req.LoginAfter) } - total, err := session.Limit(req.Limit, (req.Page-1)*req.Limit).Asc("a.id").FindAndCount(&users) - if err != nil { - return nil, 0, err - } - return &users, total, nil + return session } - func UserManagementUpdateUserInfo(engine *xorm.Engine, req *md.UserManagementUpdateUserInfoReq) (int64, error) { session := engine.NewSession() defer session.Close() From 6df15acfbd84eaa0e4f81e7428d5d29964ea4b07 Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Tue, 10 Dec 2024 10:53:08 +0800 Subject: [PATCH 04/12] update --- .../member_center/hdl_level__management.go | 40 ++-- app/hdl/member_center/hdl_tag__management.go | 25 +- app/hdl/notice/hdl_aliyun_sms.go | 214 ++++++++++++++++++ app/hdl/notice/hdl_notice.go | 214 ++++++++++++++++++ app/md/md_notice.go | 189 ++++++++++++++++ app/router/router.go | 12 +- app/svc/member_center/svc_level_management.go | 31 +++ app/svc/member_center/svc_tag__management.go | 38 ++++ 8 files changed, 710 insertions(+), 53 deletions(-) create mode 100644 app/svc/member_center/svc_tag__management.go diff --git a/app/hdl/member_center/hdl_level__management.go b/app/hdl/member_center/hdl_level__management.go index db81d6d..50b389e 100644 --- a/app/hdl/member_center/hdl_level__management.go +++ b/app/hdl/member_center/hdl_level__management.go @@ -30,35 +30,12 @@ func GetLevelList(c *gin.Context) { page := c.DefaultQuery("page", "1") limit := c.DefaultQuery("limit", "10") - levelDb := implement.NewUserLevelDb(db.Db) - levels, total, err := levelDb.UserLevelAllByAscByPage(utils.StrToInt(page), utils.StrToInt(limit)) + list, total, err := svc.LevelManagementGetLevelList(page, limit) if err != nil { e.OutErr(c, e.ERR_DB_ORM, err.Error()) return } - sql := "SElECT count(distinct id) as total, level FROM `user` GROUP BY level" - results, err := db.QueryNativeString(db.Db, sql) - if err != nil { - e.OutErr(c, e.ERR_DB_ORM, err.Error()) - return - } - var countMap = map[int]string{} - for _, res := range results { - countMap[utils.StrToInt(res["level"])] = res["total"] - } - - list := make([]md2.LevelListNode, len(levels)) - for i, level := range levels { - list[i].LevelWeight = level.LevelWeight - list[i].LevelID = level.Id - list[i].LevelName = level.LevelName - list[i].Count = countMap[level.Id] - list[i].CreateAt = level.CreateAt - list[i].IsUse = level.IsUse - list[i].Memo = level.Memo - } - resp := md2.GetLevelListResp{ List: list, Paginate: md2.Paginate{ @@ -165,6 +142,21 @@ func UpdateLevel(c *gin.Context) { forceColumns = append(forceColumns, "level_weight") } if req.IsUse == "0" || req.IsUse == "1" { + // 判断当前该等级有没有被使用 + userDb := implement.NewUserDb(db.Db) + has, err := userDb.UserExistByParams(map[string]interface{}{ + "key": "level", + "value": req.IsUse, + }) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + if has { + e.OutErr(c, e.ERR, errors.New("该等级下存在会员,无法关闭该会员等级,请移除对应等级下会员或将会员移动到其他等级").Error()) + return + } + level.LevelWeight = utils.StrToInt(req.IsUse) forceColumns = append(forceColumns, "is_use") } diff --git a/app/hdl/member_center/hdl_tag__management.go b/app/hdl/member_center/hdl_tag__management.go index f1d7878..d05a0e8 100644 --- a/app/hdl/member_center/hdl_tag__management.go +++ b/app/hdl/member_center/hdl_tag__management.go @@ -4,6 +4,7 @@ import ( "applet/app/db" "applet/app/e" md2 "applet/app/md/member_center" + svc "applet/app/svc/member_center" "applet/app/utils" "code.fnuoos.com/EggPlanet/egg_models.git/src/implement" "code.fnuoos.com/EggPlanet/egg_models.git/src/model" @@ -28,33 +29,11 @@ func GetTagList(c *gin.Context) { page := c.DefaultQuery("page", "1") limit := c.DefaultQuery("limit", "10") - sql := "SElECT count(distinct uid) as total, tag_id FROM `user_tag_records` GROUP BY tag_id" - results, err := db.QueryNativeString(db.Db, sql) + list, total, err := svc.TagManagementGetList(page, limit) if err != nil { e.OutErr(c, e.ERR_DB_ORM, err.Error()) return } - var countMap = map[int64]string{} - for _, res := range results { - countMap[utils.StrToInt64(res["tag_id"])] = res["total"] - } - - tagDb := implement.NewUserTagDb(db.Db) - tags, total, err := tagDb.UserTagAllByAscByPage(utils.StrToInt(page), utils.StrToInt(limit)) - if err != nil { - e.OutErr(c, e.ERR_DB_ORM, err.Error()) - return - } - - list := make([]md2.TagListNode, len(*tags)) - for i, tag := range *tags { - list[i].Name = tag.TagName - list[i].Count = countMap[int64(tag.Id)] - list[i].CreateAt = tag.CreateAt - list[i].Memo = tag.Memo - list[i].TagID = utils.IntToStr(tag.Id) - list[i].IsPunish = tag.IsPunish - } resp := md2.GetTagListResp{ List: list, diff --git a/app/hdl/notice/hdl_aliyun_sms.go b/app/hdl/notice/hdl_aliyun_sms.go index f652422..fcf7523 100644 --- a/app/hdl/notice/hdl_aliyun_sms.go +++ b/app/hdl/notice/hdl_aliyun_sms.go @@ -1,7 +1,14 @@ package notice import ( + "applet/app/db" + "applet/app/e" + "applet/app/md" + svc2 "applet/app/svc" + svc "applet/app/svc/member_center" "applet/app/svc/notice" + "applet/app/utils" + "code.fnuoos.com/EggPlanet/egg_models.git/src/implement" "github.com/gin-gonic/gin" ) @@ -124,3 +131,210 @@ func AliyunSmsPushList(c *gin.Context) { func AliyunSmsPushSave(c *gin.Context) { notice.AliyunSmsPushSave(c) } + +// AliyunSmsGetUserList +// @Summary 消息中心-短信推送记录-获取用户信息 +// @Tags 消息中心 +// @Description 获取用户信息 +// @Accept json +// @Produce json +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @Param req body md.JPushGetUserListReq true "(分页信息必填)" +// @Success 200 {Object} md.JPushGetUserListResp "具体数据" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/notice/aliyunSms/getUserList [post] +func AliyunSmsGetUserList(c *gin.Context) { + var req *md.AliyunSmsUserListReq + if err := c.ShouldBindJSON(&req); err != nil { + e.OutErr(c, e.ERR_INVALID_ARGS, err.Error()) + return + } + + levelDb := implement.NewUserLevelDb(db.Db) + levels, err1 := levelDb.UserLevelAllByAsc() + if err1 != nil { + e.OutErr(c, e.ERR_DB_ORM, err1.Error()) + return + } + levelsList := make([]map[string]interface{}, 0) + levelsMap := make(map[int]string) + for _, level := range levels { + levelsList = append(levelsList, map[string]interface{}{ + "id": level.Id, + "name": level.LevelName, + }) + levelsMap[level.Id] = level.LevelName + } + + tagDb := implement.NewUserTagDb(db.Db) + tags, err2 := tagDb.UserTagAllByAsc() + if err2 != nil { + e.OutErr(c, e.ERR_DB_ORM, err2.Error()) + return + } + tagsList := make([]map[string]interface{}, 0) + tagsMap := make(map[int]string) + for _, tag := range tags { + tagsList = append(tagsList, map[string]interface{}{ + "id": tag.Id, + "name": tag.TagName, + }) + tagsMap[tag.Id] = tag.TagName + } + + stateList := []map[string]interface{}{ + { + "name": "正常", + "value": "1", + }, + { + "name": "冻结", + "value": "2", + }, + } + userMemberRequest := req.ToUserMemberRequest() + users, total, err3 := svc.UserManagementGetUsers(userMemberRequest) + if err3 != nil { + e.OutErr(c, e.ERR_DB_ORM, err3.Error()) + return + } + userIDs := make([]int64, len(users)) + for i, user := range users { + userIDs[i] = user.Id + } + + recordsDb := implement.NewUserTagRecordsDb(db.Db) + records, err := recordsDb.UserTagRecordsFindByParams(map[string]interface{}{ + "key": "uid", + "value": userIDs, + }) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + + var levelCounts []md.LevelCount + err4 := db.Db.Table("user").Select("level, Count(*) AS count").GroupBy("level").Find(&levelCounts) + if err4 != nil { + e.OutErr(c, e.ERR_DB_ORM, err4.Error()) + return + } + + userMap := make(map[int64]int, len(users)) + list := make([]md.GetUserListNode, len(users)) + for i, user := range users { + list[i] = md.GetUserListNode{ + ID: user.Id, + Sex: user.Sex, + Avatar: svc2.GetOssUrl(user.Avatar), + Nickname: user.Nickname, + Phone: user.Phone, + IsRealName: user.IsRealName, + InviteCode: user.SystemInviteCode, + ParentID: user.ParentUid, + ParentInviteCode: user.ParentSystemInviteCode, + ParentPhone: user.Phone, + RegisterTime: user.CreateAt, + Memo: user.Memo, + Wechat: user.UnionId, + RegisterType: user.RegisterType, + State: user.State, + LastLoginAt: user.UpdateAt, + } + var tempTagList []md.TagNode + list[i].Tag = tempTagList + userMap[user.Id] = i + level, ok := levelsMap[user.Level] + if ok { + list[i].LevelName = level + } + } + + for _, record := range *records { + tempTagNode := md.TagNode{ + TagID: record.TagId, + TagName: tagsMap[record.TagId], + } + list[userMap[record.Uid]].Tag = append(list[userMap[record.Uid]].Tag, tempTagNode) + } + + resp := md.AliyunSmsGetUserListResp{ + LevelsList: levelsList, + TagsList: tagsList, + StateList: stateList, + List: list, + Paginate: md.Paginate{ + Limit: req.Limit, + Page: req.Page, + Total: total, + }, + } + e.OutSuc(c, resp, nil) +} + +// AliyunSmsTagList +// @Summary 消息中心-短信推送记录-标签管理(获取) +// @Tags 消息中心 +// @Description 标签管理(获取) +// @Accept json +// @Produce json +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @Param limit query int true "每页大小" +// @Param page query int true "页数" +// @Success 200 {object} md.AliyunSmsGetTagListResp "具体数据" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/notice/aliyunSms/getTagList [get] +func AliyunSmsTagList(c *gin.Context) { + page := c.DefaultQuery("page", "1") + limit := c.DefaultQuery("limit", "10") + + list, total, err := svc.TagManagementGetList(page, limit) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + + resp := md.AliyunSmsGetTagListResp{ + List: list, + Paginate: md.Paginate{ + Limit: utils.StrToInt(limit), + Page: utils.StrToInt(page), + Total: total, + }, + } + e.OutSuc(c, resp, nil) +} + +// AliyunSmsGetLevelList +// @Summary 消息中心-短信推送记录-等级管理(获取) +// @Tags 消息中心 +// @Description 等级管理(获取) +// @Accept json +// @Produce json +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @Param limit query int true "每页大小" +// @Param page query int true "页数" +// @Success 200 {object} md.AliyunSmsGetLevelListResp "具体数据" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/notice/aliyunSms/getLevelList [get] +func AliyunSmsGetLevelList(c *gin.Context) { + page := c.DefaultQuery("page", "1") + limit := c.DefaultQuery("limit", "10") + + list, total, err := svc.LevelManagementGetLevelList(page, limit) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + + resp := md.AliyunSmsGetLevelListResp{ + List: list, + Paginate: md.Paginate{ + Limit: utils.StrToInt(limit), + Page: utils.StrToInt(page), + Total: total, + }, + } + + e.OutSuc(c, resp, nil) +} diff --git a/app/hdl/notice/hdl_notice.go b/app/hdl/notice/hdl_notice.go index 6f7b9d3..1ff1985 100644 --- a/app/hdl/notice/hdl_notice.go +++ b/app/hdl/notice/hdl_notice.go @@ -1,7 +1,14 @@ package notice import ( + "applet/app/db" + "applet/app/e" + "applet/app/md" + svc2 "applet/app/svc" + svc "applet/app/svc/member_center" "applet/app/svc/notice" + "applet/app/utils" + "code.fnuoos.com/EggPlanet/egg_models.git/src/implement" "github.com/gin-gonic/gin" ) @@ -79,3 +86,210 @@ func PushList(c *gin.Context) { func PushSave(c *gin.Context) { notice.PushSave(c) } + +// JPushGetUserList +// @Summary 消息中心-基本配置-获取用户信息 +// @Tags 消息中心 +// @Description 获取用户信息 +// @Accept json +// @Produce json +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @Param req body md.JPushGetUserListReq true "(分页信息必填)" +// @Success 200 {Object} md.JPushGetUserListResp "具体数据" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/notice/jPush/getUserList [post] +func JPushGetUserList(c *gin.Context) { + var req *md.JPushGetUserListReq + if err := c.ShouldBindJSON(&req); err != nil { + e.OutErr(c, e.ERR_INVALID_ARGS, err.Error()) + return + } + + levelDb := implement.NewUserLevelDb(db.Db) + levels, err1 := levelDb.UserLevelAllByAsc() + if err1 != nil { + e.OutErr(c, e.ERR_DB_ORM, err1.Error()) + return + } + levelsList := make([]map[string]interface{}, 0) + levelsMap := make(map[int]string) + for _, level := range levels { + levelsList = append(levelsList, map[string]interface{}{ + "id": level.Id, + "name": level.LevelName, + }) + levelsMap[level.Id] = level.LevelName + } + + tagDb := implement.NewUserTagDb(db.Db) + tags, err2 := tagDb.UserTagAllByAsc() + if err2 != nil { + e.OutErr(c, e.ERR_DB_ORM, err2.Error()) + return + } + tagsList := make([]map[string]interface{}, 0) + tagsMap := make(map[int]string) + for _, tag := range tags { + tagsList = append(tagsList, map[string]interface{}{ + "id": tag.Id, + "name": tag.TagName, + }) + tagsMap[tag.Id] = tag.TagName + } + + stateList := []map[string]interface{}{ + { + "name": "正常", + "value": "1", + }, + { + "name": "冻结", + "value": "2", + }, + } + userMemberRequest := req.ToUserMemberRequest() + users, total, err3 := svc.UserManagementGetUsers(userMemberRequest) + if err3 != nil { + e.OutErr(c, e.ERR_DB_ORM, err3.Error()) + return + } + userIDs := make([]int64, len(users)) + for i, user := range users { + userIDs[i] = user.Id + } + + recordsDb := implement.NewUserTagRecordsDb(db.Db) + records, err := recordsDb.UserTagRecordsFindByParams(map[string]interface{}{ + "key": "uid", + "value": userIDs, + }) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + + var levelCounts []md.LevelCount + err4 := db.Db.Table("user").Select("level, Count(*) AS count").GroupBy("level").Find(&levelCounts) + if err4 != nil { + e.OutErr(c, e.ERR_DB_ORM, err4.Error()) + return + } + + userMap := make(map[int64]int, len(users)) + list := make([]md.GetUserListNode, len(users)) + for i, user := range users { + list[i] = md.GetUserListNode{ + ID: user.Id, + Sex: user.Sex, + Avatar: svc2.GetOssUrl(user.Avatar), + Nickname: user.Nickname, + Phone: user.Phone, + IsRealName: user.IsRealName, + InviteCode: user.SystemInviteCode, + ParentID: user.ParentUid, + ParentInviteCode: user.ParentSystemInviteCode, + ParentPhone: user.Phone, + RegisterTime: user.CreateAt, + Memo: user.Memo, + Wechat: user.UnionId, + RegisterType: user.RegisterType, + State: user.State, + LastLoginAt: user.UpdateAt, + } + var tempTagList []md.TagNode + list[i].Tag = tempTagList + userMap[user.Id] = i + level, ok := levelsMap[user.Level] + if ok { + list[i].LevelName = level + } + } + + for _, record := range *records { + tempTagNode := md.TagNode{ + TagID: record.TagId, + TagName: tagsMap[record.TagId], + } + list[userMap[record.Uid]].Tag = append(list[userMap[record.Uid]].Tag, tempTagNode) + } + + resp := md.JPushGetUserListResp{ + LevelsList: levelsList, + TagsList: tagsList, + StateList: stateList, + List: list, + Paginate: md.Paginate{ + Limit: req.Limit, + Page: req.Page, + Total: total, + }, + } + e.OutSuc(c, resp, nil) +} + +// JPushGetTagList +// @Summary 消息中心-基本配置-标签管理(获取) +// @Tags 消息中心 +// @Description 标签管理(获取) +// @Accept json +// @Produce json +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @Param limit query int true "每页大小" +// @Param page query int true "页数" +// @Success 200 {object} md.JPushGetTagListResp "具体数据" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/notice/jPush/getTagList [get] +func JPushGetTagList(c *gin.Context) { + page := c.DefaultQuery("page", "1") + limit := c.DefaultQuery("limit", "10") + + list, total, err := svc.TagManagementGetList(page, limit) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + + resp := md.JPushGetTagListResp{ + List: list, + Paginate: md.Paginate{ + Limit: utils.StrToInt(limit), + Page: utils.StrToInt(page), + Total: total, + }, + } + e.OutSuc(c, resp, nil) +} + +// JPushGetLevelList +// @Summary 消息中心-基本配置-等级管理(获取) +// @Tags 消息中心 +// @Description 等级管理(获取) +// @Accept json +// @Produce json +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @Param limit query int true "每页大小" +// @Param page query int true "页数" +// @Success 200 {object} md.JPushGetLevelListResp "具体数据" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/notice/jPush/getLevelList [get] +func JPushGetLevelList(c *gin.Context) { + page := c.DefaultQuery("page", "1") + limit := c.DefaultQuery("limit", "10") + + list, total, err := svc.LevelManagementGetLevelList(page, limit) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + + resp := md.JPushGetLevelListResp{ + List: list, + Paginate: md.Paginate{ + Limit: utils.StrToInt(limit), + Page: utils.StrToInt(page), + Total: total, + }, + } + + e.OutSuc(c, resp, nil) +} diff --git a/app/md/md_notice.go b/app/md/md_notice.go index 6ba5834..81522fc 100644 --- a/app/md/md_notice.go +++ b/app/md/md_notice.go @@ -1,5 +1,10 @@ package md +import ( + md "applet/app/md/member_center" + "code.fnuoos.com/EggPlanet/egg_models.git/src/model" +) + type NoticeListReq struct { Page string `json:"page,required"` // 页数 Limit string `json:"limit,required"` // 每页大小 @@ -118,3 +123,187 @@ type NoticeAliyunSmsPushSaveReq struct { TagList []string `json:"tag_list"` Level []string `json:"level"` } + +type Paginate struct { + Limit int `json:"limit"` // 每页大小 + Page int `json:"page"` // 页数 + Total int64 `json:"total"` // 总数据量 +} + +type JPushGetUserListResp struct { + LevelsList []map[string]interface{} `json:"levels_list"` // 等级列表 + TagsList []map[string]interface{} `json:"tags_list"` // 标签列表 + StateList []map[string]interface{} `json:"state_list"` // 状态列表 + List []GetUserListNode `json:"list"` + Paginate Paginate `json:"paginate"` // 分页信息 +} + +type TagNode struct { + TagID int `json:"tag_id"` // 标签 ID + TagName string `json:"tag_name"` // 标签名称 +} +type LevelCount struct { + Level int `xorm:"level"` + Count int `xorm:"count"` +} + +type GetUserListNode struct { + ID int64 `json:"id"` // 会员 ID + Tag []TagNode `json:"tag"` // 会员标签 + Sex int `json:"sex"` // 性别(0:未知 1:男 2:女) + Avatar string `json:"avatar"` // 头像 + Nickname string `json:"nickname"` // 昵称 + Phone string `json:"phone"` // 手机号 + IsRealName int `json:"is_real_name"` // 是否实名 0.未实名,1.已实名 + LevelName string `json:"level_name"` // 会员等级 + InviteCode string `json:"invite_code" example:"会员邀请码"` + ParentID int64 `json:"parent_id"` // 推荐人 ID + ParentInviteCode string `json:"parent_invite_code" example:"推荐人邀请码"` + ParentPhone string `json:"parent_phone" example:"推荐人手机号"` + RegisterTime string `json:"register_time"` // 注册时间 + Memo string `json:"memo"` // 备注 + Wechat string `json:"wechat"` // 微信号 + RegisterType int `json:"register_type"` // 注册类型 + State int `json:"state"` // 状态 + LastLoginAt string `json:"last_login_at"` // 最后登录时间 +} + +type JPushGetUserListReq struct { + ID int64 `json:"id"` // 会员 ID + Nickname string `json:"nickname" example:"会员昵称"` + RecommendID int64 `json:"recommend_id"` // 推荐人 ID + Tag int `json:"tag"` // 标签 id + Phone string `json:"phone" example:"会员手机号"` + InviteCode string `json:"invite_code" example:"会员邀请码"` + ParentInviteCode string `json:"parent_invite_code" example:"上级邀请码"` + ParentPhone string `json:"parent_phone" example:"上级手机号"` + Sex int `json:"sex"` // 性别(0:未知 1:男 2:女) + UnionId string `json:"union_id" example:"微信号"` + Level int `json:"level"` // 会员等级 + RegisterType int `json:"register_type"` // 注册类型(1:APP注册、2:H5注册) + State int `json:"state"` // 状态 + Effective int `json:"effective"` // 有效会员 + IsRealName int `json:"is_real_name"` // 是否实名 0.未实名,1.已实名 + Memo string `json:"memo"` // 备注 + RegisterBefore string `json:"register_before"` // 注册时间起点 + RegisterAfter string `json:"register_after"` // 注册时间终点 + LoginBefore string `json:"login_before"` // 最近登录开始时间 + LoginAfter string `json:"login_after"` // 最近登录结束时间 + Page int `json:"page,required"` + Limit int `json:"limit,required"` +} + +type UserInfo struct { + model.User `xorm:"extends"` + TagID int `xorm:"tag_id"` + ParentPhone string `xorm:"parent_phone"` + ParentSystemInviteCode string `xorm:"parent_system_invite_code"` + ParentCustomInviteCode string `xorm:"parent_custom_invite_code"` +} + +type JPushGetTagListResp struct { + List []md.TagListNode `json:"list"` + Paginate Paginate `json:"paginate"` +} + +type JPushGetLevelListResp struct { + List []md.LevelListNode `json:"list"` + Paginate Paginate `json:"paginate"` +} + +type AliyunSmsGetUserListResp struct { + LevelsList []map[string]interface{} `json:"levels_list"` // 等级列表 + TagsList []map[string]interface{} `json:"tags_list"` // 标签列表 + StateList []map[string]interface{} `json:"state_list"` // 状态列表 + List []GetUserListNode `json:"list"` + Paginate Paginate `json:"paginate"` // 分页信息 +} + +type AliyunSmsUserListReq struct { + ID int64 `json:"id"` // 会员 ID + Nickname string `json:"nickname" example:"会员昵称"` + RecommendID int64 `json:"recommend_id"` // 推荐人 ID + Tag int `json:"tag"` // 标签 id + Phone string `json:"phone" example:"会员手机号"` + InviteCode string `json:"invite_code" example:"会员邀请码"` + ParentInviteCode string `json:"parent_invite_code" example:"上级邀请码"` + ParentPhone string `json:"parent_phone" example:"上级手机号"` + Sex int `json:"sex"` // 性别(0:未知 1:男 2:女) + UnionId string `json:"union_id" example:"微信号"` + Level int `json:"level"` // 会员等级 + RegisterType int `json:"register_type"` // 注册类型(1:APP注册、2:H5注册) + State int `json:"state"` // 状态 + Effective int `json:"effective"` // 有效会员 + IsRealName int `json:"is_real_name"` // 是否实名 0.未实名,1.已实名 + Memo string `json:"memo"` // 备注 + RegisterBefore string `json:"register_before"` // 注册时间起点 + RegisterAfter string `json:"register_after"` // 注册时间终点 + LoginBefore string `json:"login_before"` // 最近登录开始时间 + LoginAfter string `json:"login_after"` // 最近登录结束时间 + Page int `json:"page,required"` + Limit int `json:"limit,required"` +} + +type AliyunSmsGetTagListResp struct { + List []md.TagListNode `json:"list"` + Paginate Paginate `json:"paginate"` +} + +type AliyunSmsGetLevelListResp struct { + List []md.LevelListNode `json:"list"` + Paginate Paginate `json:"paginate"` +} + +func (req JPushGetUserListReq) ToUserMemberRequest() *md.UserManagementGetUserListReq { + return &md.UserManagementGetUserListReq{ + ID: req.ID, + Nickname: req.Nickname, + RecommendID: req.RecommendID, + Tag: req.Tag, + Phone: req.Phone, + InviteCode: req.InviteCode, + ParentInviteCode: req.ParentInviteCode, + ParentPhone: req.ParentPhone, + Sex: req.Sex, + UnionId: req.UnionId, + Level: req.Level, + RegisterType: req.RegisterType, + State: req.State, + Effective: req.Effective, + IsRealName: req.IsRealName, + Memo: req.Memo, + RegisterBefore: req.RegisterBefore, + RegisterAfter: req.RegisterAfter, + LoginBefore: req.LoginBefore, + LoginAfter: req.LoginAfter, + Page: req.Page, + Limit: req.Limit, + } +} + +func (req AliyunSmsUserListReq) ToUserMemberRequest() *md.UserManagementGetUserListReq { + return &md.UserManagementGetUserListReq{ + ID: req.ID, + Nickname: req.Nickname, + RecommendID: req.RecommendID, + Tag: req.Tag, + Phone: req.Phone, + InviteCode: req.InviteCode, + ParentInviteCode: req.ParentInviteCode, + ParentPhone: req.ParentPhone, + Sex: req.Sex, + UnionId: req.UnionId, + Level: req.Level, + RegisterType: req.RegisterType, + State: req.State, + Effective: req.Effective, + IsRealName: req.IsRealName, + Memo: req.Memo, + RegisterBefore: req.RegisterBefore, + RegisterAfter: req.RegisterAfter, + LoginBefore: req.LoginBefore, + LoginAfter: req.LoginAfter, + Page: req.Page, + Limit: req.Limit, + } +} diff --git a/app/router/router.go b/app/router/router.go index c4008cd..c2eab05 100644 --- a/app/router/router.go +++ b/app/router/router.go @@ -147,17 +147,17 @@ func rNotice(r *gin.RouterGroup) { rJpush := r.Group("/jPush") //极光 { rJpush.POST("/push/list", notice.PushList) - rJpush.POST("/getUserList", member_center.UserManagementGetUserList) - rJpush.GET("/getTagList", member_center.GetTagList) - rJpush.GET("/getLevelList", member_center.GetLevelList) + rJpush.POST("/getUserList", notice.JPushGetUserList) + rJpush.GET("/getTagList", notice.JPushGetTagList) + rJpush.GET("/getLevelList", notice.JPushGetLevelList) rJpush.POST("/push/save", notice.PushSave) } rAliyunSms := r.Group("/aliyunSms") //阿里云短信 { rAliyunSms.POST("/file/phone", notice.AliyunSmsFilePhone) - rAliyunSms.POST("/getUserList", member_center.UserManagementGetUserList) - rAliyunSms.GET("/getTagList", member_center.GetTagList) - rAliyunSms.GET("/getLevelList", member_center.GetLevelList) + rAliyunSms.POST("/getUserList", notice.AliyunSmsGetUserList) + rAliyunSms.GET("/getTagList", notice.AliyunSmsTagList) + rAliyunSms.GET("/getLevelList", notice.AliyunSmsGetLevelList) rAliyunSms.GET("/sale/base", notice.AliyunSmsSaleBase) rAliyunSms.POST("/sale/save", notice.AliyunSmsSaleSave) rAliyunSms.POST("/push/list", notice.AliyunSmsPushList) diff --git a/app/svc/member_center/svc_level_management.go b/app/svc/member_center/svc_level_management.go index 4a19be4..a160868 100644 --- a/app/svc/member_center/svc_level_management.go +++ b/app/svc/member_center/svc_level_management.go @@ -45,3 +45,34 @@ func BatchAddLevelTask(session *xorm.Session, tasks []md.LevelTaskNode, levelId return nil } + +func LevelManagementGetLevelList(page, limit string) ([]md.LevelListNode, int64, error) { + levelDb := implement.NewUserLevelDb(db.Db) + levels, total, err := levelDb.UserLevelAllByAscByPage(utils.StrToInt(page), utils.StrToInt(limit)) + if err != nil { + return nil, 0, err + } + + sql := "SElECT count(distinct id) as total, level FROM `user` GROUP BY level" + results, err := db.QueryNativeString(db.Db, sql) + if err != nil { + return nil, 0, err + } + var countMap = map[int]string{} + for _, res := range results { + countMap[utils.StrToInt(res["level"])] = res["total"] + } + + list := make([]md.LevelListNode, len(levels)) + for i, level := range levels { + list[i].LevelWeight = level.LevelWeight + list[i].LevelID = level.Id + list[i].LevelName = level.LevelName + list[i].Count = countMap[level.Id] + list[i].CreateAt = level.CreateAt + list[i].IsUse = level.IsUse + list[i].Memo = level.Memo + } + + return list, total, nil +} diff --git a/app/svc/member_center/svc_tag__management.go b/app/svc/member_center/svc_tag__management.go new file mode 100644 index 0000000..b37183e --- /dev/null +++ b/app/svc/member_center/svc_tag__management.go @@ -0,0 +1,38 @@ +package svc + +import ( + "applet/app/db" + md "applet/app/md/member_center" + "applet/app/utils" + "code.fnuoos.com/EggPlanet/egg_models.git/src/implement" +) + +func TagManagementGetList(page, limit string) ([]md.TagListNode, int64, error) { + sql := "SElECT count(distinct uid) as total, tag_id FROM `user_tag_records` GROUP BY tag_id" + results, err := db.QueryNativeString(db.Db, sql) + if err != nil { + return nil, 0, err + } + var countMap = map[int64]string{} + for _, res := range results { + countMap[utils.StrToInt64(res["tag_id"])] = res["total"] + } + + tagDb := implement.NewUserTagDb(db.Db) + tags, total, err := tagDb.UserTagAllByAscByPage(utils.StrToInt(page), utils.StrToInt(limit)) + if err != nil { + return nil, 0, err + } + + list := make([]md.TagListNode, len(*tags)) + for i, tag := range *tags { + list[i].Name = tag.TagName + list[i].Count = countMap[int64(tag.Id)] + list[i].CreateAt = tag.CreateAt + list[i].Memo = tag.Memo + list[i].TagID = utils.IntToStr(tag.Id) + list[i].IsPunish = tag.IsPunish + } + + return list, total, nil +} From 891c11608f88d016820582f39713870fb735b02b Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Tue, 10 Dec 2024 10:56:51 +0800 Subject: [PATCH 05/12] update swag --- docs/docs.go | 466 ++++++++++++++++++++++++++++++++++++++++++++++ docs/swagger.json | 466 ++++++++++++++++++++++++++++++++++++++++++++++ docs/swagger.yaml | 317 +++++++++++++++++++++++++++++++ 3 files changed, 1249 insertions(+) diff --git a/docs/docs.go b/docs/docs.go index d3c249b..247c566 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -6371,6 +6371,157 @@ const docTemplate = `{ } } }, + "/api/notice/aliyunSms/getLevelList": { + "get": { + "description": "等级管理(获取)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "消息中心" + ], + "summary": "消息中心-短信推送记录-等级管理(获取)", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "integer", + "description": "每页大小", + "name": "limit", + "in": "query", + "required": true + }, + { + "type": "integer", + "description": "页数", + "name": "page", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "具体数据", + "schema": { + "$ref": "#/definitions/md.AliyunSmsGetLevelListResp" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/notice/aliyunSms/getTagList": { + "get": { + "description": "标签管理(获取)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "消息中心" + ], + "summary": "消息中心-短信推送记录-标签管理(获取)", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "integer", + "description": "每页大小", + "name": "limit", + "in": "query", + "required": true + }, + { + "type": "integer", + "description": "页数", + "name": "page", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "具体数据", + "schema": { + "$ref": "#/definitions/md.AliyunSmsGetTagListResp" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/notice/aliyunSms/getUserList": { + "post": { + "description": "获取用户信息", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "消息中心" + ], + "summary": "消息中心-短信推送记录-获取用户信息", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "(分页信息必填)", + "name": "req", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/md.JPushGetUserListReq" + } + } + ], + "responses": { + "200": { + "description": "具体数据", + "schema": { + "type": "Object" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, "/api/notice/aliyunSms/push/list": { "post": { "description": "短信推送记录-推送记录列表", @@ -6691,6 +6842,157 @@ const docTemplate = `{ } } }, + "/api/notice/jPush/getLevelList": { + "get": { + "description": "等级管理(获取)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "消息中心" + ], + "summary": "消息中心-基本配置-等级管理(获取)", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "integer", + "description": "每页大小", + "name": "limit", + "in": "query", + "required": true + }, + { + "type": "integer", + "description": "页数", + "name": "page", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "具体数据", + "schema": { + "$ref": "#/definitions/md.JPushGetLevelListResp" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/notice/jPush/getTagList": { + "get": { + "description": "标签管理(获取)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "消息中心" + ], + "summary": "消息中心-基本配置-标签管理(获取)", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "integer", + "description": "每页大小", + "name": "limit", + "in": "query", + "required": true + }, + { + "type": "integer", + "description": "页数", + "name": "page", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "具体数据", + "schema": { + "$ref": "#/definitions/md.JPushGetTagListResp" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/notice/jPush/getUserList": { + "post": { + "description": "获取用户信息", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "消息中心" + ], + "summary": "消息中心-基本配置-获取用户信息", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "(分页信息必填)", + "name": "req", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/md.JPushGetUserListReq" + } + } + ], + "responses": { + "200": { + "description": "具体数据", + "schema": { + "type": "Object" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, "/api/notice/jPush/push/list": { "post": { "description": "基本配置-推送记录列表", @@ -8231,6 +8533,23 @@ const docTemplate = `{ } }, "definitions": { + "applet_app_md.Paginate": { + "type": "object", + "properties": { + "limit": { + "description": "每页大小", + "type": "integer" + }, + "page": { + "description": "页数", + "type": "integer" + }, + "total": { + "description": "总数据量", + "type": "integer" + } + } + }, "applet_app_md_financial_center.Paginate": { "type": "object", "properties": { @@ -9223,6 +9542,34 @@ const docTemplate = `{ } } }, + "md.AliyunSmsGetLevelListResp": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/md.LevelListNode" + } + }, + "paginate": { + "$ref": "#/definitions/applet_app_md.Paginate" + } + } + }, + "md.AliyunSmsGetTagListResp": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/md.TagListNode" + } + }, + "paginate": { + "$ref": "#/definitions/applet_app_md.Paginate" + } + } + }, "md.ArticleCateDelReq": { "type": "object", "properties": { @@ -11847,6 +12194,125 @@ const docTemplate = `{ } } }, + "md.JPushGetLevelListResp": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/md.LevelListNode" + } + }, + "paginate": { + "$ref": "#/definitions/applet_app_md.Paginate" + } + } + }, + "md.JPushGetTagListResp": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/md.TagListNode" + } + }, + "paginate": { + "$ref": "#/definitions/applet_app_md.Paginate" + } + } + }, + "md.JPushGetUserListReq": { + "type": "object", + "properties": { + "effective": { + "description": "有效会员", + "type": "integer" + }, + "id": { + "description": "会员 ID", + "type": "integer" + }, + "invite_code": { + "type": "string", + "example": "会员邀请码" + }, + "is_real_name": { + "description": "是否实名 0.未实名,1.已实名", + "type": "integer" + }, + "level": { + "description": "会员等级", + "type": "integer" + }, + "limit": { + "type": "integer" + }, + "login_after": { + "description": "最近登录结束时间", + "type": "string" + }, + "login_before": { + "description": "最近登录开始时间", + "type": "string" + }, + "memo": { + "description": "备注", + "type": "string" + }, + "nickname": { + "type": "string", + "example": "会员昵称" + }, + "page": { + "type": "integer" + }, + "parent_invite_code": { + "type": "string", + "example": "上级邀请码" + }, + "parent_phone": { + "type": "string", + "example": "上级手机号" + }, + "phone": { + "type": "string", + "example": "会员手机号" + }, + "recommend_id": { + "description": "推荐人 ID", + "type": "integer" + }, + "register_after": { + "description": "注册时间终点", + "type": "string" + }, + "register_before": { + "description": "注册时间起点", + "type": "string" + }, + "register_type": { + "description": "注册类型(1:APP注册、2:H5注册)", + "type": "integer" + }, + "sex": { + "description": "性别(0:未知 1:男 2:女)", + "type": "integer" + }, + "state": { + "description": "状态", + "type": "integer" + }, + "tag": { + "description": "标签 id", + "type": "integer" + }, + "union_id": { + "type": "string", + "example": "微信号" + } + } + }, "md.LevelListNode": { "type": "object", "properties": { diff --git a/docs/swagger.json b/docs/swagger.json index 288dba2..39ccd10 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -6364,6 +6364,157 @@ } } }, + "/api/notice/aliyunSms/getLevelList": { + "get": { + "description": "等级管理(获取)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "消息中心" + ], + "summary": "消息中心-短信推送记录-等级管理(获取)", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "integer", + "description": "每页大小", + "name": "limit", + "in": "query", + "required": true + }, + { + "type": "integer", + "description": "页数", + "name": "page", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "具体数据", + "schema": { + "$ref": "#/definitions/md.AliyunSmsGetLevelListResp" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/notice/aliyunSms/getTagList": { + "get": { + "description": "标签管理(获取)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "消息中心" + ], + "summary": "消息中心-短信推送记录-标签管理(获取)", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "integer", + "description": "每页大小", + "name": "limit", + "in": "query", + "required": true + }, + { + "type": "integer", + "description": "页数", + "name": "page", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "具体数据", + "schema": { + "$ref": "#/definitions/md.AliyunSmsGetTagListResp" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/notice/aliyunSms/getUserList": { + "post": { + "description": "获取用户信息", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "消息中心" + ], + "summary": "消息中心-短信推送记录-获取用户信息", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "(分页信息必填)", + "name": "req", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/md.JPushGetUserListReq" + } + } + ], + "responses": { + "200": { + "description": "具体数据", + "schema": { + "type": "Object" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, "/api/notice/aliyunSms/push/list": { "post": { "description": "短信推送记录-推送记录列表", @@ -6684,6 +6835,157 @@ } } }, + "/api/notice/jPush/getLevelList": { + "get": { + "description": "等级管理(获取)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "消息中心" + ], + "summary": "消息中心-基本配置-等级管理(获取)", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "integer", + "description": "每页大小", + "name": "limit", + "in": "query", + "required": true + }, + { + "type": "integer", + "description": "页数", + "name": "page", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "具体数据", + "schema": { + "$ref": "#/definitions/md.JPushGetLevelListResp" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/notice/jPush/getTagList": { + "get": { + "description": "标签管理(获取)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "消息中心" + ], + "summary": "消息中心-基本配置-标签管理(获取)", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "integer", + "description": "每页大小", + "name": "limit", + "in": "query", + "required": true + }, + { + "type": "integer", + "description": "页数", + "name": "page", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "具体数据", + "schema": { + "$ref": "#/definitions/md.JPushGetTagListResp" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/notice/jPush/getUserList": { + "post": { + "description": "获取用户信息", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "消息中心" + ], + "summary": "消息中心-基本配置-获取用户信息", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "(分页信息必填)", + "name": "req", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/md.JPushGetUserListReq" + } + } + ], + "responses": { + "200": { + "description": "具体数据", + "schema": { + "type": "Object" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, "/api/notice/jPush/push/list": { "post": { "description": "基本配置-推送记录列表", @@ -8224,6 +8526,23 @@ } }, "definitions": { + "applet_app_md.Paginate": { + "type": "object", + "properties": { + "limit": { + "description": "每页大小", + "type": "integer" + }, + "page": { + "description": "页数", + "type": "integer" + }, + "total": { + "description": "总数据量", + "type": "integer" + } + } + }, "applet_app_md_financial_center.Paginate": { "type": "object", "properties": { @@ -9216,6 +9535,34 @@ } } }, + "md.AliyunSmsGetLevelListResp": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/md.LevelListNode" + } + }, + "paginate": { + "$ref": "#/definitions/applet_app_md.Paginate" + } + } + }, + "md.AliyunSmsGetTagListResp": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/md.TagListNode" + } + }, + "paginate": { + "$ref": "#/definitions/applet_app_md.Paginate" + } + } + }, "md.ArticleCateDelReq": { "type": "object", "properties": { @@ -11840,6 +12187,125 @@ } } }, + "md.JPushGetLevelListResp": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/md.LevelListNode" + } + }, + "paginate": { + "$ref": "#/definitions/applet_app_md.Paginate" + } + } + }, + "md.JPushGetTagListResp": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/md.TagListNode" + } + }, + "paginate": { + "$ref": "#/definitions/applet_app_md.Paginate" + } + } + }, + "md.JPushGetUserListReq": { + "type": "object", + "properties": { + "effective": { + "description": "有效会员", + "type": "integer" + }, + "id": { + "description": "会员 ID", + "type": "integer" + }, + "invite_code": { + "type": "string", + "example": "会员邀请码" + }, + "is_real_name": { + "description": "是否实名 0.未实名,1.已实名", + "type": "integer" + }, + "level": { + "description": "会员等级", + "type": "integer" + }, + "limit": { + "type": "integer" + }, + "login_after": { + "description": "最近登录结束时间", + "type": "string" + }, + "login_before": { + "description": "最近登录开始时间", + "type": "string" + }, + "memo": { + "description": "备注", + "type": "string" + }, + "nickname": { + "type": "string", + "example": "会员昵称" + }, + "page": { + "type": "integer" + }, + "parent_invite_code": { + "type": "string", + "example": "上级邀请码" + }, + "parent_phone": { + "type": "string", + "example": "上级手机号" + }, + "phone": { + "type": "string", + "example": "会员手机号" + }, + "recommend_id": { + "description": "推荐人 ID", + "type": "integer" + }, + "register_after": { + "description": "注册时间终点", + "type": "string" + }, + "register_before": { + "description": "注册时间起点", + "type": "string" + }, + "register_type": { + "description": "注册类型(1:APP注册、2:H5注册)", + "type": "integer" + }, + "sex": { + "description": "性别(0:未知 1:男 2:女)", + "type": "integer" + }, + "state": { + "description": "状态", + "type": "integer" + }, + "tag": { + "description": "标签 id", + "type": "integer" + }, + "union_id": { + "type": "string", + "example": "微信号" + } + } + }, "md.LevelListNode": { "type": "object", "properties": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index a335579..75ab192 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -1,4 +1,16 @@ definitions: + applet_app_md.Paginate: + properties: + limit: + description: 每页大小 + type: integer + page: + description: 页数 + type: integer + total: + description: 总数据量 + type: integer + type: object applet_app_md_financial_center.Paginate: properties: limit: @@ -693,6 +705,24 @@ definitions: example: 名称 type: string type: object + md.AliyunSmsGetLevelListResp: + properties: + list: + items: + $ref: '#/definitions/md.LevelListNode' + type: array + paginate: + $ref: '#/definitions/applet_app_md.Paginate' + type: object + md.AliyunSmsGetTagListResp: + properties: + list: + items: + $ref: '#/definitions/md.TagListNode' + type: array + paginate: + $ref: '#/definitions/applet_app_md.Paginate' + type: object md.ArticleCateDelReq: properties: id: @@ -2501,6 +2531,91 @@ definitions: content_image_url: type: string type: object + md.JPushGetLevelListResp: + properties: + list: + items: + $ref: '#/definitions/md.LevelListNode' + type: array + paginate: + $ref: '#/definitions/applet_app_md.Paginate' + type: object + md.JPushGetTagListResp: + properties: + list: + items: + $ref: '#/definitions/md.TagListNode' + type: array + paginate: + $ref: '#/definitions/applet_app_md.Paginate' + type: object + md.JPushGetUserListReq: + properties: + effective: + description: 有效会员 + type: integer + id: + description: 会员 ID + type: integer + invite_code: + example: 会员邀请码 + type: string + is_real_name: + description: 是否实名 0.未实名,1.已实名 + type: integer + level: + description: 会员等级 + type: integer + limit: + type: integer + login_after: + description: 最近登录结束时间 + type: string + login_before: + description: 最近登录开始时间 + type: string + memo: + description: 备注 + type: string + nickname: + example: 会员昵称 + type: string + page: + type: integer + parent_invite_code: + example: 上级邀请码 + type: string + parent_phone: + example: 上级手机号 + type: string + phone: + example: 会员手机号 + type: string + recommend_id: + description: 推荐人 ID + type: integer + register_after: + description: 注册时间终点 + type: string + register_before: + description: 注册时间起点 + type: string + register_type: + description: 注册类型(1:APP注册、2:H5注册) + type: integer + sex: + description: 性别(0:未知 1:男 2:女) + type: integer + state: + description: 状态 + type: integer + tag: + description: 标签 id + type: integer + union_id: + example: 微信号 + type: string + type: object md.LevelListNode: properties: count: @@ -9160,6 +9275,107 @@ paths: summary: 消息中心-短信推送记录-通知模板 tags: - 消息中心 + /api/notice/aliyunSms/getLevelList: + get: + consumes: + - application/json + description: 等级管理(获取) + parameters: + - description: 验证参数Bearer和token空格拼接 + in: header + name: Authorization + required: true + type: string + - description: 每页大小 + in: query + name: limit + required: true + type: integer + - description: 页数 + in: query + name: page + required: true + type: integer + produces: + - application/json + responses: + "200": + description: 具体数据 + schema: + $ref: '#/definitions/md.AliyunSmsGetLevelListResp' + "400": + description: 具体错误 + schema: + $ref: '#/definitions/md.Response' + summary: 消息中心-短信推送记录-等级管理(获取) + tags: + - 消息中心 + /api/notice/aliyunSms/getTagList: + get: + consumes: + - application/json + description: 标签管理(获取) + parameters: + - description: 验证参数Bearer和token空格拼接 + in: header + name: Authorization + required: true + type: string + - description: 每页大小 + in: query + name: limit + required: true + type: integer + - description: 页数 + in: query + name: page + required: true + type: integer + produces: + - application/json + responses: + "200": + description: 具体数据 + schema: + $ref: '#/definitions/md.AliyunSmsGetTagListResp' + "400": + description: 具体错误 + schema: + $ref: '#/definitions/md.Response' + summary: 消息中心-短信推送记录-标签管理(获取) + tags: + - 消息中心 + /api/notice/aliyunSms/getUserList: + post: + consumes: + - application/json + description: 获取用户信息 + parameters: + - description: 验证参数Bearer和token空格拼接 + in: header + name: Authorization + required: true + type: string + - description: (分页信息必填) + in: body + name: req + required: true + schema: + $ref: '#/definitions/md.JPushGetUserListReq' + produces: + - application/json + responses: + "200": + description: 具体数据 + schema: + type: Object + "400": + description: 具体错误 + schema: + $ref: '#/definitions/md.Response' + summary: 消息中心-短信推送记录-获取用户信息 + tags: + - 消息中心 /api/notice/aliyunSms/push/list: post: consumes: @@ -9371,6 +9587,107 @@ paths: summary: 消息中心-基本配置-通知模板添加编辑 tags: - 消息中心 + /api/notice/jPush/getLevelList: + get: + consumes: + - application/json + description: 等级管理(获取) + parameters: + - description: 验证参数Bearer和token空格拼接 + in: header + name: Authorization + required: true + type: string + - description: 每页大小 + in: query + name: limit + required: true + type: integer + - description: 页数 + in: query + name: page + required: true + type: integer + produces: + - application/json + responses: + "200": + description: 具体数据 + schema: + $ref: '#/definitions/md.JPushGetLevelListResp' + "400": + description: 具体错误 + schema: + $ref: '#/definitions/md.Response' + summary: 消息中心-基本配置-等级管理(获取) + tags: + - 消息中心 + /api/notice/jPush/getTagList: + get: + consumes: + - application/json + description: 标签管理(获取) + parameters: + - description: 验证参数Bearer和token空格拼接 + in: header + name: Authorization + required: true + type: string + - description: 每页大小 + in: query + name: limit + required: true + type: integer + - description: 页数 + in: query + name: page + required: true + type: integer + produces: + - application/json + responses: + "200": + description: 具体数据 + schema: + $ref: '#/definitions/md.JPushGetTagListResp' + "400": + description: 具体错误 + schema: + $ref: '#/definitions/md.Response' + summary: 消息中心-基本配置-标签管理(获取) + tags: + - 消息中心 + /api/notice/jPush/getUserList: + post: + consumes: + - application/json + description: 获取用户信息 + parameters: + - description: 验证参数Bearer和token空格拼接 + in: header + name: Authorization + required: true + type: string + - description: (分页信息必填) + in: body + name: req + required: true + schema: + $ref: '#/definitions/md.JPushGetUserListReq' + produces: + - application/json + responses: + "200": + description: 具体数据 + schema: + type: Object + "400": + description: 具体错误 + schema: + $ref: '#/definitions/md.Response' + summary: 消息中心-基本配置-获取用户信息 + tags: + - 消息中心 /api/notice/jPush/push/list: post: consumes: From 313928950f61f21d5ef9d5e860c17377bfca0d0d Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Tue, 10 Dec 2024 15:19:53 +0800 Subject: [PATCH 06/12] update --- app/hdl/comm/hdl_comm.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/hdl/comm/hdl_comm.go b/app/hdl/comm/hdl_comm.go index 1589179..ad4ef3d 100644 --- a/app/hdl/comm/hdl_comm.go +++ b/app/hdl/comm/hdl_comm.go @@ -17,11 +17,21 @@ import ( "strings" ) +// MenuList +// @Summary 通用请求-权限列表-菜单栏列表(获取) +// @Tags 权限列表 +// @Description 菜单栏列表(获取) +// @Accept json +// @Produce json +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @Success 200 {object} "具体路由" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/comm/getMenuList [POST] func MenuList(c *gin.Context) { engine := db.Db admin := svc.GetUser(c) qrcodeWithBatchRecordsDb := implement.NewPermissionGroupDb(engine) - groupList, err := qrcodeWithBatchRecordsDb.FindPermissionGroupV2() + groupList, err := qrcodeWithBatchRecordsDb.FindPermissionGroup() if err != nil { e.OutErr(c, e.ERR_DB_ORM, err.Error()) return From 347b025c86be727373c5efa99dd780a20cc4a254 Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Tue, 10 Dec 2024 15:46:44 +0800 Subject: [PATCH 07/12] update --- app/hdl/comm/hdl_comm.go | 2 +- docs/docs.go | 39 +++++++++++++++++++++++++++++++++++++++ docs/swagger.json | 39 +++++++++++++++++++++++++++++++++++++++ docs/swagger.yaml | 26 ++++++++++++++++++++++++++ 4 files changed, 105 insertions(+), 1 deletion(-) diff --git a/app/hdl/comm/hdl_comm.go b/app/hdl/comm/hdl_comm.go index ad4ef3d..93eb8b5 100644 --- a/app/hdl/comm/hdl_comm.go +++ b/app/hdl/comm/hdl_comm.go @@ -24,7 +24,7 @@ import ( // @Accept json // @Produce json // @param Authorization header string true "验证参数Bearer和token空格拼接" -// @Success 200 {object} "具体路由" +// @Success 200 {object} map[string]interface{} "具体路由" // @Failure 400 {object} md.Response "具体错误" // @Router /api/comm/getMenuList [POST] func MenuList(c *gin.Context) { diff --git a/docs/docs.go b/docs/docs.go index 247c566..791b423 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -1333,6 +1333,45 @@ const docTemplate = `{ } } }, + "/api/comm/getMenuList": { + "post": { + "description": "菜单栏列表(获取)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "权限列表" + ], + "summary": "通用请求-权限列表-菜单栏列表(获取)", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "具体路由", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, "/api/comm/getOssUrl": { "post": { "description": "上传许可链接(获取)", diff --git a/docs/swagger.json b/docs/swagger.json index 39ccd10..0616b50 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -1326,6 +1326,45 @@ } } }, + "/api/comm/getMenuList": { + "post": { + "description": "菜单栏列表(获取)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "权限列表" + ], + "summary": "通用请求-权限列表-菜单栏列表(获取)", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "具体路由", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, "/api/comm/getOssUrl": { "post": { "description": "上传许可链接(获取)", diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 75ab192..432ef6b 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -5944,6 +5944,32 @@ paths: summary: 通用请求-获取管理员信息 tags: - 通用请求 + /api/comm/getMenuList: + post: + consumes: + - application/json + description: 菜单栏列表(获取) + parameters: + - description: 验证参数Bearer和token空格拼接 + in: header + name: Authorization + required: true + type: string + produces: + - application/json + responses: + "200": + description: 具体路由 + schema: + additionalProperties: true + type: object + "400": + description: 具体错误 + schema: + $ref: '#/definitions/md.Response' + summary: 通用请求-权限列表-菜单栏列表(获取) + tags: + - 权限列表 /api/comm/getOssUrl: post: consumes: From 5e221b010a4303ce17b93e399bd21d8300414d5a Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Tue, 10 Dec 2024 17:13:05 +0800 Subject: [PATCH 08/12] update --- app/hdl/hdl_role.go | 2 +- app/md/md_module.go | 2 -- app/svc/svc_role.go | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app/hdl/hdl_role.go b/app/hdl/hdl_role.go index 80cb578..6c66448 100644 --- a/app/hdl/hdl_role.go +++ b/app/hdl/hdl_role.go @@ -260,7 +260,7 @@ func RoleBindPermissionGroup(c *gin.Context) { e.OutErr(c, err1.Code, err1.Error()) return } - err = svc.RoleBindPermissionGroup(c, req) + err = svc.RoleBindPermissionGroup(req) if err != nil { e.OutErr(c, e.ERR, err.Error()) return diff --git a/app/md/md_module.go b/app/md/md_module.go index 3e7913c..46f1541 100644 --- a/app/md/md_module.go +++ b/app/md/md_module.go @@ -6,7 +6,6 @@ var Module = map[string]string{ "3": "bottom_bar", "4": "invitation_download_landing_page", "5": "invitation_poster", - "6": "about_us", "7": "down_channel", "8": "contribution", "9": "egg_score", @@ -23,7 +22,6 @@ var ModuleList = []map[string]interface{}{ {"name": "底部导航", "mod_name": "bottom_bar", "value": "3"}, {"name": "邀请下载落地页", "mod_name": "invitation_download_landing_page", "value": "4"}, {"name": "邀请海报", "mod_name": "invitation_poster", "value": "5"}, - {"name": "关于我们", "mod_name": "about_us", "value": "6"}, {"name": "下载渠道", "mod_name": "down_channel", "value": "7"}, {"name": "贡献值", "mod_name": "contribution", "value": "8"}, {"name": "蛋蛋分", "mod_name": "egg_score", "value": "9"}, diff --git a/app/svc/svc_role.go b/app/svc/svc_role.go index 0f96f68..87ad38f 100644 --- a/app/svc/svc_role.go +++ b/app/svc/svc_role.go @@ -101,7 +101,7 @@ func DeleteRole(c *gin.Context, roleId int) (err error) { return session.Commit() } -func RoleBindPermissionGroup(c *gin.Context, req md.RoleBindPermissionGroupReq) (err error) { +func RoleBindPermissionGroup(req md.RoleBindPermissionGroupReq) (err error) { engine := db.Db session := engine.NewSession() defer session.Close() From a296597f31c90b452752915f0b254d4530f29427 Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Tue, 10 Dec 2024 17:15:31 +0800 Subject: [PATCH 09/12] rollback module 6 --- app/md/md_module.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/md/md_module.go b/app/md/md_module.go index 46f1541..3e7913c 100644 --- a/app/md/md_module.go +++ b/app/md/md_module.go @@ -6,6 +6,7 @@ var Module = map[string]string{ "3": "bottom_bar", "4": "invitation_download_landing_page", "5": "invitation_poster", + "6": "about_us", "7": "down_channel", "8": "contribution", "9": "egg_score", @@ -22,6 +23,7 @@ var ModuleList = []map[string]interface{}{ {"name": "底部导航", "mod_name": "bottom_bar", "value": "3"}, {"name": "邀请下载落地页", "mod_name": "invitation_download_landing_page", "value": "4"}, {"name": "邀请海报", "mod_name": "invitation_poster", "value": "5"}, + {"name": "关于我们", "mod_name": "about_us", "value": "6"}, {"name": "下载渠道", "mod_name": "down_channel", "value": "7"}, {"name": "贡献值", "mod_name": "contribution", "value": "8"}, {"name": "蛋蛋分", "mod_name": "egg_score", "value": "9"}, From 0e8cf7840a071d0a8ad471c0d20f689d5db3f1bf Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Tue, 10 Dec 2024 18:24:55 +0800 Subject: [PATCH 10/12] update --- app/hdl/hdl_home_page.go | 12 ++++-- app/hdl/member_center/hdl_tag__management.go | 39 +++++++++++++++++--- app/md/member_center/md_tag_management.go | 7 ++-- docs/docs.go | 4 ++ docs/swagger.json | 4 ++ docs/swagger.yaml | 3 ++ go.mod | 2 +- 7 files changed, 57 insertions(+), 14 deletions(-) diff --git a/app/hdl/hdl_home_page.go b/app/hdl/hdl_home_page.go index 7bb653e..f80313d 100644 --- a/app/hdl/hdl_home_page.go +++ b/app/hdl/hdl_home_page.go @@ -146,7 +146,8 @@ func GetGrowData(c *gin.Context) { return } kind := req.Kind - + var yData []interface{} + var xData []interface{} now := time.Now() dataDb := implement.NewPlatformGrowDataDb(db.Db) m, has, err := dataDb.PlatformGrowDataGetLastOne() @@ -155,11 +156,14 @@ func GetGrowData(c *gin.Context) { return } if !has { - e.OutErr(c, e.ERR_NO_DATA, "未查询到数据") + resp := md.GetPriceCurveResp{ + XData: xData, + YData: yData, + } + e.OutSuc(c, resp, nil) return } - var yData []interface{} - var xData []interface{} + switch kind { case "1": // 日 diff --git a/app/hdl/member_center/hdl_tag__management.go b/app/hdl/member_center/hdl_tag__management.go index d05a0e8..b40b72c 100644 --- a/app/hdl/member_center/hdl_tag__management.go +++ b/app/hdl/member_center/hdl_tag__management.go @@ -99,16 +99,43 @@ func UpdateTag(c *gin.Context) { return } tagID := utils.StrToInt(req.TagID) - + tagDb := implement.NewUserTagDb(db.Db) + oldTag, err := tagDb.UserTagGetOneByParams(map[string]interface{}{"key": "id", "value": tagID}) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + if oldTag == nil { + e.OutErr(c, e.ERR_NO_DATA, errors.New("标签不存在").Error()) + return + } + if req.IsPunish != "" && oldTag.IsPunish != utils.StrToInt(req.IsPunish) { + // 标签在被使用情况下不允许修改是否为处罚标签 + recordsDb := implement.NewUserTagRecordsDb(db.Db) + exist, err := recordsDb.UserTagRecordsExist(0, tagID) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + if exist { + e.OutErr(c, e.ERR, errors.New("该标签已被使用,无法修改是否为处罚标签").Error()) + return + } + } tag := &model.UserTag{ - Id: tagID, - TagName: req.Name, - Memo: req.Memo, + Id: tagID, } - forceColumns := []string{"tag_name", "memo"} + if req.Name != "" { + tag.TagName = req.Name + } + + if req.Memo != "" { + tag.Memo = req.Memo + } + + forceColumns := []string{"tag_name", "memo", "is_punish"} - tagDb := implement.NewUserTagDb(db.Db) affected, err := tagDb.UserTagUpdate(tagID, tag, forceColumns...) if err != nil { e.OutErr(c, e.ERR_DB_ORM, err.Error()) diff --git a/app/md/member_center/md_tag_management.go b/app/md/member_center/md_tag_management.go index 8a05c2b..fd6bc13 100644 --- a/app/md/member_center/md_tag_management.go +++ b/app/md/member_center/md_tag_management.go @@ -21,9 +21,10 @@ type AddTagReq struct { } type UpdateTagReq struct { - TagID string `json:"tag_id,required"` // 标签 ID - Name string `json:"name,required"` // 标签名称 - Memo string `json:"memo,required"` // 备注 + TagID string `json:"tag_id,required"` // 标签 ID + Name string `json:"name,required"` // 标签名称 + Memo string `json:"memo,required"` // 备注 + IsPunish string `json:"is_punish"` // 是否是惩罚标签 } type DeleteTagReq struct { diff --git a/docs/docs.go b/docs/docs.go index 791b423..a1f96bf 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -14267,6 +14267,10 @@ const docTemplate = `{ "md.UpdateTagReq": { "type": "object", "properties": { + "is_punish": { + "description": "是否是惩罚标签", + "type": "string" + }, "memo": { "description": "备注", "type": "string" diff --git a/docs/swagger.json b/docs/swagger.json index 0616b50..7a3e0b4 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -14260,6 +14260,10 @@ "md.UpdateTagReq": { "type": "object", "properties": { + "is_punish": { + "description": "是否是惩罚标签", + "type": "string" + }, "memo": { "description": "备注", "type": "string" diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 432ef6b..e56a533 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -3952,6 +3952,9 @@ definitions: type: object md.UpdateTagReq: properties: + is_punish: + description: 是否是惩罚标签 + type: string memo: description: 备注 type: string diff --git a/go.mod b/go.mod index 75c22fc..5cb737f 100644 --- a/go.mod +++ b/go.mod @@ -33,7 +33,7 @@ require ( ) require ( - code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241209094543-8aafc254a593 + code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241210101917-218ac8890613 code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241205075006-9c0bf995c788 code.fnuoos.com/go_rely_warehouse/zyos_go_es.git v1.0.1-0.20241118083738-0f22da9ba0be code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5 From 783367d16f4f8fab28a7cd26284abd4aff22eddc Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Tue, 10 Dec 2024 19:27:22 +0800 Subject: [PATCH 11/12] update --- app/hdl/member_center/hdl_level__management.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/hdl/member_center/hdl_level__management.go b/app/hdl/member_center/hdl_level__management.go index 50b389e..9ee0727 100644 --- a/app/hdl/member_center/hdl_level__management.go +++ b/app/hdl/member_center/hdl_level__management.go @@ -254,10 +254,12 @@ func AddLevel(c *gin.Context) { } // 2. 创建任务信息 - err = svc.BatchAddLevelTask(session, req.UserLevelTasks, id) - if err != nil { - e.OutErr(c, e.ERR_DB_ORM, err.Error()) - return + if len(req.UserLevelTasks) > 0 { + err = svc.BatchAddLevelTask(session, req.UserLevelTasks, id) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } } err = session.Commit() From 4aa10f2534a42c46979864602f2f2e0fb761d841 Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Tue, 10 Dec 2024 19:40:11 +0800 Subject: [PATCH 12/12] update --- app/hdl/member_center/hdl_level__management.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/hdl/member_center/hdl_level__management.go b/app/hdl/member_center/hdl_level__management.go index 9ee0727..ada68d3 100644 --- a/app/hdl/member_center/hdl_level__management.go +++ b/app/hdl/member_center/hdl_level__management.go @@ -193,10 +193,12 @@ func UpdateLevel(c *gin.Context) { } // 2.2 添加更新后的任务 - err = svc.BatchAddLevelTask(session, req.UserLevelTasks, utils.StrToInt(req.LevelID)) - if err != nil { - e.OutErr(c, e.ERR_DB_ORM, err.Error()) - return + if len(req.UserLevelTasks) > 0 { + err = svc.BatchAddLevelTask(session, req.UserLevelTasks, utils.StrToInt(req.LevelID)) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } } err = session.Commit()