【优化】租户功能,框架优化

This commit is contained in:
PandaGoAdmin
2022-07-18 18:17:11 +08:00
parent d33bd39570
commit ae38e7bcef
60 changed files with 861 additions and 647 deletions

View File

@@ -22,7 +22,7 @@ type SysTenantsApi struct {
// @Param pageSize query int false "页条数"
// @Param pageNum query int false "页码"
// @Success 200 {string} string "{"code": 200, "data": [...]}"
// @Router /admin/tenant/list [get]
// @Router /system/tenant/list [get]
// @Security
func (p *SysTenantsApi) GetSysTenantsList(rc *ctx.ReqCtx) {
data := entity.SysTenants{}
@@ -39,12 +39,28 @@ func (p *SysTenantsApi) GetSysTenantsList(rc *ctx.ReqCtx) {
}
}
// @Summary SysTenants列表数据
// @Tags SysTenants
// @Success 200 {string} string "{"code": 200, "data": [...]}"
// @Router /system/tenant/lists [get]
// @Security
func (p *SysTenantsApi) GetSysTenantsAll(rc *ctx.ReqCtx) {
list := make([]entity.SysTenants, 0)
if rc.LoginAccount.RoleKey == "admin" {
data := entity.SysTenants{}
list = *p.SysTenantsApp.FindList(data)
} else {
list = append(list, *p.SysTenantsApp.FindOne(rc.LoginAccount.TenantId))
}
rc.ResData = list
}
// @Summary 获取SysTenants
// @Description 获取JSON
// @Tags SysTenants
// @Param tenantId path int true "tenantId"
// @Success 200 {string} string "{"code": 200, "data": [...]}"
// @Router /admin/tenant/{tenantId} [get]
// @Router /system/tenant/{tenantId} [get]
// @Security
func (p *SysTenantsApi) GetSysTenants(rc *ctx.ReqCtx) {
tenantId := ginx.PathParamInt(rc.GinCtx, "tenantId")
@@ -59,7 +75,7 @@ func (p *SysTenantsApi) GetSysTenants(rc *ctx.ReqCtx) {
// @Param data body entity.SysTenants true "data"
// @Success 200 {string} string "{"code": 200, "message": "添加成功"}"
// @Success 200 {string} string "{"code": 400, "message": "添加失败"}"
// @Router /admin/tenant [post]
// @Router /system/tenant [post]
// @Security X-TOKEN
func (p *SysTenantsApi) InsertSysTenants(rc *ctx.ReqCtx) {
var data entity.SysTenants
@@ -76,7 +92,7 @@ func (p *SysTenantsApi) InsertSysTenants(rc *ctx.ReqCtx) {
// @Param data body entity.SysTenants true "body"
// @Success 200 {string} string "{"code": 200, "message": "添加成功"}"
// @Success 200 {string} string "{"code": 400, "message": "添加失败"}"
// @Router /admin/tenant [put]
// @Router /system/tenant [put]
// @Security X-TOKEN
func (p *SysTenantsApi) UpdateSysTenants(rc *ctx.ReqCtx) {
var data entity.SysTenants
@@ -91,7 +107,7 @@ func (p *SysTenantsApi) UpdateSysTenants(rc *ctx.ReqCtx) {
// @Param tenantId path string true "tenantId"
// @Success 200 {string} string "{"code": 200, "message": "删除成功"}"
// @Success 200 {string} string "{"code": 400, "message": "删除失败"}"
// @Router /admin/tenant/{tenantId} [delete]
// @Router /system/tenant/{tenantId} [delete]
func (p *SysTenantsApi) DeleteSysTenants(rc *ctx.ReqCtx) {
tenantId := rc.GinCtx.Param("tenantId")
tenantIds := utils.IdsStrToIdsIntGroup(tenantId)