【更新】更新restful

This commit is contained in:
PandaGoAdmin
2022-08-03 16:00:32 +08:00
parent 2cb23c0ecf
commit 6945277fdb
48 changed files with 1234 additions and 836 deletions

View File

@@ -16,17 +16,10 @@ type SysTenantsApi struct {
SysTenantsApp services.SysTenantsModel
}
// @Summary SysTenants列表数据
// @Tags SysTenants
// @Param pageSize query int false "页条数"
// @Param pageNum query int false "页码"
// @Success 200 {string} string "{"code": 200, "data": [...]}"
// @Router /system/tenant/list [get]
// @Security
func (p *SysTenantsApi) GetSysTenantsList(rc *restfulx.ReqCtx) {
data := entity.SysTenants{}
pageNum := restfulx.QueryInt(rc.GinCtx, "pageNum", 1)
pageSize := restfulx.QueryInt(rc.GinCtx, "pageSize", 10)
pageNum := restfulx.QueryInt(rc, "pageNum", 1)
pageSize := restfulx.QueryInt(rc, "pageSize", 10)
list, total := p.SysTenantsApp.FindListPage(pageNum, pageSize, data)
@@ -38,11 +31,6 @@ func (p *SysTenantsApi) GetSysTenantsList(rc *restfulx.ReqCtx) {
}
}
// @Summary SysTenants列表数据
// @Tags SysTenants
// @Success 200 {string} string "{"code": 200, "data": [...]}"
// @Router /system/tenant/lists [get]
// @Security
func (p *SysTenantsApi) GetSysTenantsAll(rc *restfulx.ReqCtx) {
list := make([]entity.SysTenants, 0)
if rc.LoginAccount.RoleKey == "admin" {
@@ -54,61 +42,27 @@ func (p *SysTenantsApi) GetSysTenantsAll(rc *restfulx.ReqCtx) {
rc.ResData = list
}
// @Summary 获取SysTenants
// @Description 获取JSON
// @Tags SysTenants
// @Param tenantId path int true "tenantId"
// @Success 200 {string} string "{"code": 200, "data": [...]}"
// @Router /system/tenant/{tenantId} [get]
// @Security
func (p *SysTenantsApi) GetSysTenants(rc *restfulx.ReqCtx) {
tenantId := restfulx.PathParamInt(rc.GinCtx, "tenantId")
tenantId := restfulx.PathParamInt(rc, "tenantId")
p.SysTenantsApp.FindOne(int64(tenantId))
}
// @Summary 添加SysTenants
// @Description 获取JSON
// @Tags SysTenants
// @Accept application/json
// @Product application/json
// @Param data body entity.SysTenants true "data"
// @Success 200 {string} string "{"code": 200, "message": "添加成功"}"
// @Success 200 {string} string "{"code": 400, "message": "添加失败"}"
// @Router /system/tenant [post]
// @Security X-TOKEN
func (p *SysTenantsApi) InsertSysTenants(rc *restfulx.ReqCtx) {
var data entity.SysTenants
restfulx.BindJsonAndValid(rc.GinCtx, &data)
restfulx.BindQuery(rc, &data)
p.SysTenantsApp.Insert(data)
}
// @Summary 修改SysTenants
// @Description 获取JSON
// @Tags SysTenants
// @Accept application/json
// @Product application/json
// @Param data body entity.SysTenants true "body"
// @Success 200 {string} string "{"code": 200, "message": "添加成功"}"
// @Success 200 {string} string "{"code": 400, "message": "添加失败"}"
// @Router /system/tenant [put]
// @Security X-TOKEN
func (p *SysTenantsApi) UpdateSysTenants(rc *restfulx.ReqCtx) {
var data entity.SysTenants
restfulx.BindJsonAndValid(rc.GinCtx, &data)
restfulx.BindQuery(rc, &data)
p.SysTenantsApp.Update(data)
}
// @Summary 删除SysTenants
// @Description 删除数据
// @Tags SysTenants
// @Param tenantId path string true "tenantId"
// @Success 200 {string} string "{"code": 200, "message": "删除成功"}"
// @Success 200 {string} string "{"code": 400, "message": "删除失败"}"
// @Router /system/tenant/{tenantId} [delete]
func (p *SysTenantsApi) DeleteSysTenants(rc *restfulx.ReqCtx) {
tenantId := rc.GinCtx.Param("tenantId")
tenantId := rc.Request.PathParameter("tenantId")
tenantIds := utils.IdsStrToIdsIntGroup(tenantId)
p.SysTenantsApp.Delete(tenantIds)
}