【更新】更新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

@@ -14,53 +14,25 @@ type SystemApiApi struct {
ApiApp services.SysApiModel
}
// @Tags SysApi
// @Summary 创建基础api
// @Security X-TOKEN
// @accept application/json
// @Produce application/json
// @Param data body entity.SysApi true "api路径, api中文描述, api组, 方法"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}"
// @Router /system/api [post]
func (s *SystemApiApi) CreateApi(rc *restfulx.ReqCtx) {
var api entity.SysApi
restfulx.BindJsonAndValid(rc.GinCtx, &api)
restfulx.BindQuery(rc, &api)
log.Println(api)
s.ApiApp.Insert(api)
}
// @Tags SysApi
// @Summary 删除api
// @Security X-TOKEN
// @accept application/json
// @Produce application/json
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
// @Router /system/api/{id} [delete]
func (s *SystemApiApi) DeleteApi(rc *restfulx.ReqCtx) {
ids := rc.GinCtx.Param("id")
ids := rc.Request.PathParameter("id")
s.ApiApp.Delete(utils.IdsStrToIdsIntGroup(ids))
}
// @Tags SysApi
// @Summary 分页获取API列表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param path query string false "path"
// @Param description query string false "description"
// @Param method query string false "method"
// @Param apiGroup query string false "apiGroup"
// @Param pageSize query int false "页条数"
// @Param pageNum query int false "页码"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /system/api/list [get]
func (s *SystemApiApi) GetApiList(rc *restfulx.ReqCtx) {
pageNum := restfulx.QueryInt(rc.GinCtx, "pageNum", 1)
pageSize := restfulx.QueryInt(rc.GinCtx, "pageSize", 10)
path := rc.GinCtx.Query("path")
description := rc.GinCtx.Query("description")
method := rc.GinCtx.Query("method")
apiGroup := rc.GinCtx.Query("apiGroup")
pageNum := restfulx.QueryInt(rc, "pageNum", 1)
pageSize := restfulx.QueryInt(rc, "pageSize", 10)
path := rc.Request.QueryParameter("path")
description := rc.Request.QueryParameter("description")
method := rc.Request.QueryParameter("method")
apiGroup := rc.Request.QueryParameter("apiGroup")
api := entity.SysApi{Path: path, Description: description, Method: method, ApiGroup: apiGroup}
list, total := s.ApiApp.FindListPage(pageNum, pageSize, api)
rc.ResData = map[string]any{
@@ -71,55 +43,24 @@ func (s *SystemApiApi) GetApiList(rc *restfulx.ReqCtx) {
}
}
// @Tags SysApi
// @Summary 根据id获取api
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param id path int true "根据id获取api"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /system/api/{id} [get]
func (s *SystemApiApi) GetApiById(rc *restfulx.ReqCtx) {
id := restfulx.QueryInt(rc.GinCtx, "id", 0)
id := restfulx.QueryInt(rc, "id", 0)
rc.ResData = s.ApiApp.FindOne(int64(id))
}
// @Tags SysApi
// @Summary 创建基础api
// @Security X-TOKEN
// @accept application/json
// @Produce application/json
// @Param data body entity.SysApi true "api路径, api中文描述, api组, 方法"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"修改成功"}"
// @Router /api/api [put]
func (s *SystemApiApi) UpdateApi(rc *restfulx.ReqCtx) {
var api entity.SysApi
restfulx.BindJsonAndValid(rc.GinCtx, &api)
restfulx.BindQuery(rc, &api)
s.ApiApp.Update(api)
}
// @Tags SysApi
// @Summary 获取所有的Api 不分页
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /system/api/all [get]
func (s *SystemApiApi) GetAllApis(rc *restfulx.ReqCtx) {
rc.ResData = s.ApiApp.FindList(entity.SysApi{})
}
// @Tags SysApi
// @Summary 获取Api权限列表
// @Security X-TOKEN
// @accept application/json
// @Produce application/json
// @Param roleKey query string true "权限id, 权限模型列表"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /casbin/getPolicyPathByRoleId [get]
func (s *SystemApiApi) GetPolicyPathByRoleId(rc *restfulx.ReqCtx) {
roleKey := rc.GinCtx.Query("roleKey")
roleKey := rc.Request.QueryParameter("roleKey")
tenantId := strconv.Itoa(int(rc.LoginAccount.TenantId))
rc.ResData = casbin.GetPolicyPathByRoleId(tenantId, roleKey)
}

View File

@@ -12,23 +12,12 @@ type ConfigApi struct {
ConfigApp services.SysConfigModel
}
// @Summary 配置列表数据
// @Description 获取JSON
// @Tags 配置
// @Param configName query string false "configName"
// @Param configKey query string false "configKey"
// @Param configType query string false "configType"
// @Param pageSize query int false "页条数"
// @Param pageNum query int false "页码"
// @Success 200 {string} string "{"code": 200, "data": [...]}"
// @Router /system/config [get]
// @Security
func (p *ConfigApi) GetConfigList(rc *restfulx.ReqCtx) {
pageNum := restfulx.QueryInt(rc.GinCtx, "pageNum", 1)
pageSize := restfulx.QueryInt(rc.GinCtx, "pageSize", 10)
configName := rc.GinCtx.Query("configName")
configKey := rc.GinCtx.Query("configKey")
configType := rc.GinCtx.Query("configType")
pageNum := restfulx.QueryInt(rc, "pageNum", 1)
pageSize := restfulx.QueryInt(rc, "pageSize", 10)
configName := rc.Request.QueryParameter("configName")
configKey := rc.Request.QueryParameter("configKey")
configType := rc.Request.QueryParameter("configType")
config := entity.SysConfig{ConfigName: configName, ConfigKey: configKey, ConfigType: configType}
list, total := p.ConfigApp.FindListPage(pageNum, pageSize, config)
@@ -40,72 +29,31 @@ func (p *ConfigApi) GetConfigList(rc *restfulx.ReqCtx) {
}
}
// @Summary 配置列表数据ByKey
// @Description 获取JSON
// @Tags 配置
// @Param configKey query string false "configKey"
// @Success 200 {string} string "{"code": 200, "data": [...]}"
// @Router /system/config/configKey [get]
// @Security
func (p *ConfigApi) GetConfigListByKey(rc *restfulx.ReqCtx) {
configKey := rc.GinCtx.Query("configKey")
configKey := rc.Request.QueryParameter("configKey")
biz.IsTrue(configKey != "", "请传入配置Key")
rc.ResData = p.ConfigApp.FindList(entity.SysConfig{ConfigKey: configKey})
}
// @Summary 获取配置
// @Description 获取JSON
// @Tags 配置
// @Param configId path int true "configId"
// @Success 200 {string} string "{"code": 200, "data": [...]}"
// @Router /system/config/{configId} [get]
// @Security
func (p *ConfigApi) GetConfig(rc *restfulx.ReqCtx) {
id := restfulx.PathParamInt(rc.GinCtx, "configId")
id := restfulx.PathParamInt(rc, "configId")
p.ConfigApp.FindOne(int64(id))
}
// @Summary 添加配置
// @Description 获取JSON
// @Tags 配置
// @Accept application/json
// @Product application/json
// @Param data body entity.SysConfig true "data"
// @Success 200 {string} string "{"code": 200, "message": "添加成功"}"
// @Success 200 {string} string "{"code": 400, "message": "添加失败"}"
// @Router /system/config [post]
// @Security X-TOKEN
func (p *ConfigApi) InsertConfig(rc *restfulx.ReqCtx) {
var config entity.SysConfig
restfulx.BindJsonAndValid(rc.GinCtx, &config)
restfulx.BindQuery(rc, &config)
p.ConfigApp.Insert(config)
}
// @Summary 修改配置
// @Description 获取JSON
// @Tags 配置
// @Accept application/json
// @Product application/json
// @Param data body entity.SysConfig true "body"
// @Success 200 {string} string "{"code": 200, "message": "添加成功"}"
// @Success 200 {string} string "{"code": 400, "message": "添加失败"}"
// @Router /system/config [put]
// @Security X-TOKEN
func (p *ConfigApi) UpdateConfig(rc *restfulx.ReqCtx) {
var post entity.SysConfig
restfulx.BindJsonAndValid(rc.GinCtx, &post)
restfulx.BindQuery(rc, &post)
p.ConfigApp.Update(post)
}
// @Summary 删除配置
// @Description 删除数据
// @Tags 配置
// @Param configId path string true "configId 多个使用逗号分割"
// @Success 200 {string} string "{"code": 200, "message": "删除成功"}"
// @Success 200 {string} string "{"code": 400, "message": "删除失败"}"
// @Router /system/config/{configId} [delete]
func (p *ConfigApi) DeleteConfig(rc *restfulx.ReqCtx) {
configId := rc.GinCtx.Param("configId")
configId := rc.Request.PathParameter("configId")
p.ConfigApp.Delete(utils.IdsStrToIdsIntGroup(configId))
}

View File

@@ -26,7 +26,7 @@ type DeptApi struct {
// @Router /system/menu/menuTreRoleSelect/{roleId} [get]
// @Security X-TOKEN
func (m *DeptApi) GetDeptTreeRoleSelect(rc *restfulx.ReqCtx) {
roleId := restfulx.PathParamInt(rc.GinCtx, "roleId")
roleId := restfulx.PathParamInt(rc, "roleId")
var dept entity.SysDept
if !IsTenantAdmin(rc.LoginAccount.TenantId) {
dept.TenantId = rc.LoginAccount.TenantId
@@ -55,9 +55,9 @@ func (m *DeptApi) GetDeptTreeRoleSelect(rc *restfulx.ReqCtx) {
func (a *DeptApi) GetDeptList(rc *restfulx.ReqCtx) {
//pageNum := restfulx.QueryInt(rc.GinCtx, "pageNum", 1)
//pageSize := restfulx.QueryInt(rc.GinCtx, "pageSize", 10)
deptName := rc.GinCtx.Query("deptName")
status := rc.GinCtx.Query("status")
deptId := restfulx.QueryInt(rc.GinCtx, "deptId", 0)
deptName := restfulx.QueryParam(rc, "deptName")
status := restfulx.QueryParam(rc, "status")
deptId := restfulx.QueryInt(rc, "deptId", 0)
dept := entity.SysDept{DeptName: deptName, Status: status, DeptId: int64(deptId)}
if !IsTenantAdmin(rc.LoginAccount.TenantId) {
dept.TenantId = rc.LoginAccount.TenantId
@@ -94,9 +94,9 @@ func (a *DeptApi) GetOrdinaryDeptList(rc *restfulx.ReqCtx) {
// @Router /system/dept/deptTree [get]
// @Security
func (a *DeptApi) GetDeptTree(rc *restfulx.ReqCtx) {
deptName := rc.GinCtx.Query("deptName")
status := rc.GinCtx.Query("status")
deptId := restfulx.QueryInt(rc.GinCtx, "deptId", 0)
deptName := restfulx.QueryParam(rc, "deptName")
status := restfulx.QueryParam(rc, "status")
deptId := restfulx.QueryInt(rc, "deptId", 0)
dept := entity.SysDept{DeptName: deptName, Status: status, DeptId: int64(deptId)}
if !IsTenantAdmin(rc.LoginAccount.TenantId) {
dept.TenantId = rc.LoginAccount.TenantId
@@ -112,7 +112,7 @@ func (a *DeptApi) GetDeptTree(rc *restfulx.ReqCtx) {
// @Router /system/dept/{deptId} [get]
// @Security
func (a *DeptApi) GetDept(rc *restfulx.ReqCtx) {
deptId := restfulx.PathParamInt(rc.GinCtx, "deptId")
deptId := restfulx.PathParamInt(rc, "deptId")
rc.ResData = a.DeptApp.FindOne(int64(deptId))
}
@@ -128,8 +128,7 @@ func (a *DeptApi) GetDept(rc *restfulx.ReqCtx) {
// @Security Bearer
func (a *DeptApi) InsertDept(rc *restfulx.ReqCtx) {
var dept entity.SysDept
g := rc.GinCtx
restfulx.BindJsonAndValid(g, &dept)
restfulx.BindQuery(rc, &dept)
dept.TenantId = rc.LoginAccount.TenantId
dept.CreateBy = rc.LoginAccount.UserName
a.DeptApp.Insert(dept)
@@ -147,8 +146,7 @@ func (a *DeptApi) InsertDept(rc *restfulx.ReqCtx) {
// @Security Bearer
func (a *DeptApi) UpdateDept(rc *restfulx.ReqCtx) {
var dept entity.SysDept
g := rc.GinCtx
restfulx.BindJsonAndValid(g, &dept)
restfulx.BindQuery(rc, &dept)
dept.UpdateBy = rc.LoginAccount.UserName
a.DeptApp.Update(dept)
@@ -162,7 +160,7 @@ func (a *DeptApi) UpdateDept(rc *restfulx.ReqCtx) {
// @Success 200 {string} string "{"code": 400, "message": "删除失败"}"
// @Router /system/dept/{deptId} [delete]
func (a *DeptApi) DeleteDept(rc *restfulx.ReqCtx) {
deptId := rc.GinCtx.Param("deptId")
deptId := restfulx.PathParam(rc, "deptId")
deptIds := utils.IdsStrToIdsIntGroup(deptId)
deList := make([]int64, 0)

View File

@@ -27,11 +27,11 @@ type DictApi struct {
// @Router /system/dict/type/list [get]
// @Security
func (p *DictApi) GetDictTypeList(rc *restfulx.ReqCtx) {
pageNum := restfulx.QueryInt(rc.GinCtx, "pageNum", 1)
pageSize := restfulx.QueryInt(rc.GinCtx, "pageSize", 10)
status := rc.GinCtx.Query("status")
dictName := rc.GinCtx.Query("dictName")
dictType := rc.GinCtx.Query("dictType")
pageNum := restfulx.QueryInt(rc, "pageNum", 1)
pageSize := restfulx.QueryInt(rc, "pageSize", 10)
status := restfulx.QueryParam(rc, "status")
dictName := restfulx.QueryParam(rc, "dictName")
dictType := restfulx.QueryParam(rc, "dictType")
list, total := p.DictType.FindListPage(pageNum, pageSize, entity.SysDictType{Status: status, DictName: dictName, DictType: dictType})
rc.ResData = map[string]any{
@@ -50,7 +50,7 @@ func (p *DictApi) GetDictTypeList(rc *restfulx.ReqCtx) {
// @Router /system/dict/type/{dictId} [get]
// @Security
func (p *DictApi) GetDictType(rc *restfulx.ReqCtx) {
dictId := restfulx.PathParamInt(rc.GinCtx, "dictId")
dictId := restfulx.PathParamInt(rc, "dictId")
p.DictType.FindOne(int64(dictId))
}
@@ -66,7 +66,7 @@ func (p *DictApi) GetDictType(rc *restfulx.ReqCtx) {
// @Security X-TOKEN
func (p *DictApi) InsertDictType(rc *restfulx.ReqCtx) {
var dict entity.SysDictType
restfulx.BindJsonAndValid(rc.GinCtx, &dict)
restfulx.BindQuery(rc, &dict)
dict.CreateBy = rc.LoginAccount.UserName
p.DictType.Insert(dict)
@@ -84,7 +84,7 @@ func (p *DictApi) InsertDictType(rc *restfulx.ReqCtx) {
// @Security X-TOKEN
func (p *DictApi) UpdateDictType(rc *restfulx.ReqCtx) {
var dict entity.SysDictType
restfulx.BindJsonAndValid(rc.GinCtx, &dict)
restfulx.BindQuery(rc, &dict)
dict.CreateBy = rc.LoginAccount.UserName
p.DictType.Update(dict)
@@ -98,7 +98,7 @@ func (p *DictApi) UpdateDictType(rc *restfulx.ReqCtx) {
// @Success 200 {string} string "{"code": 400, "message": "删除失败"}"
// @Router /system/dict/type/{dictId} [delete]
func (p *DictApi) DeleteDictType(rc *restfulx.ReqCtx) {
dictId := rc.GinCtx.Param("dictId")
dictId := restfulx.PathParam(rc, "dictId")
dictIds := utils.IdsStrToIdsIntGroup(dictId)
deList := make([]int64, 0)
@@ -124,10 +124,10 @@ func (p *DictApi) DeleteDictType(rc *restfulx.ReqCtx) {
// @Success 200 {string} string "{"code": 400, "message": "删除失败"}"
// @Router /system/dict/type/export [get]
func (p *DictApi) ExportDictType(rc *restfulx.ReqCtx) {
filename := rc.GinCtx.Query("filename")
status := rc.GinCtx.Query("status")
dictName := rc.GinCtx.Query("dictName")
dictType := rc.GinCtx.Query("dictType")
filename := restfulx.QueryParam(rc, "filename")
status := restfulx.QueryParam(rc, "status")
dictName := restfulx.QueryParam(rc, "dictName")
dictType := restfulx.QueryParam(rc, "dictType")
list := p.DictType.FindList(entity.SysDictType{Status: status, DictName: dictName, DictType: dictType})
fileName := utils.GetFileName(global.Conf.Server.ExcelDir, filename)
@@ -145,9 +145,9 @@ func (p *DictApi) ExportDictType(rc *restfulx.ReqCtx) {
// @Router /system/dict/data/list [get]
// @Security
func (p *DictApi) GetDictDataList(rc *restfulx.ReqCtx) {
dictLabel := rc.GinCtx.Query("dictLabel")
dictType := rc.GinCtx.Query("dictType")
status := rc.GinCtx.Query("status")
dictLabel := restfulx.QueryParam(rc, "dictLabel")
dictType := restfulx.QueryParam(rc, "dictType")
status := restfulx.QueryParam(rc, "status")
rc.ResData = p.DictData.FindList(entity.SysDictData{Status: status, DictType: dictType, DictLabel: dictLabel})
}
@@ -159,7 +159,7 @@ func (p *DictApi) GetDictDataList(rc *restfulx.ReqCtx) {
// @Router /system/dict/data/type [get]
// @Security
func (p *DictApi) GetDictDataListByDictType(rc *restfulx.ReqCtx) {
dictType := rc.GinCtx.Query("dictType")
dictType := restfulx.QueryParam(rc, "dictType")
biz.IsTrue(dictType != "", "请传入字典类型")
rc.ResData = p.DictData.FindList(entity.SysDictData{DictType: dictType})
}
@@ -172,7 +172,7 @@ func (p *DictApi) GetDictDataListByDictType(rc *restfulx.ReqCtx) {
// @Router /system/dict/data/{dictCode} [get]
// @Security
func (p *DictApi) GetDictData(rc *restfulx.ReqCtx) {
dictCode := restfulx.PathParamInt(rc.GinCtx, "dictCode")
dictCode := restfulx.PathParamInt(rc, "dictCode")
p.DictData.FindOne(int64(dictCode))
}
@@ -188,8 +188,7 @@ func (p *DictApi) GetDictData(rc *restfulx.ReqCtx) {
// @Security X-TOKEN
func (p *DictApi) InsertDictData(rc *restfulx.ReqCtx) {
var data entity.SysDictData
restfulx.BindJsonAndValid(rc.GinCtx, &data)
restfulx.BindQuery(rc, &data)
data.CreateBy = rc.LoginAccount.UserName
p.DictData.Insert(data)
}
@@ -206,7 +205,7 @@ func (p *DictApi) InsertDictData(rc *restfulx.ReqCtx) {
// @Security X-TOKEN
func (p *DictApi) UpdateDictData(rc *restfulx.ReqCtx) {
var data entity.SysDictData
restfulx.BindJsonAndValid(rc.GinCtx, &data)
restfulx.BindQuery(rc, &data)
data.CreateBy = rc.LoginAccount.UserName
p.DictData.Update(data)
@@ -220,6 +219,6 @@ func (p *DictApi) UpdateDictData(rc *restfulx.ReqCtx) {
// @Success 200 {string} string "{"code": 400, "message": "删除失败"}"
// @Router /system/dict/data/{dictCode} [delete]
func (p *DictApi) DeleteDictData(rc *restfulx.ReqCtx) {
param := rc.GinCtx.Param("dictCode")
p.DictData.Delete(utils.IdsStrToIdsIntGroup(param))
dictCode := restfulx.PathParam(rc, "dictCode")
p.DictData.Delete(utils.IdsStrToIdsIntGroup(dictCode))
}

View File

@@ -3,6 +3,7 @@ package api
import (
"github.com/XM-GO/PandaKit/biz"
"github.com/XM-GO/PandaKit/restfulx"
"github.com/XM-GO/PandaKit/utils"
entity "pandax/apps/system/entity"
services "pandax/apps/system/services"
)
@@ -35,7 +36,7 @@ func (m *MenuApi) GetMenuTreeSelect(rc *restfulx.ReqCtx) {
// @Router /system/menu/menuRole [get]
// @Security X-TOKEN
func (m *MenuApi) GetMenuRole(rc *restfulx.ReqCtx) {
roleKey := rc.GinCtx.Query("roleKey")
roleKey := restfulx.QueryParam(rc, "roleKey")
biz.IsTrue(roleKey != "", "请传入角色Key")
rc.ResData = Build(*m.MenuApp.SelectMenuRole(roleKey))
}
@@ -49,7 +50,7 @@ func (m *MenuApi) GetMenuRole(rc *restfulx.ReqCtx) {
// @Router /system/menu/menuTreRoleSelect/{roleId} [get]
// @Security X-TOKEN
func (m *MenuApi) GetMenuTreeRoleSelect(rc *restfulx.ReqCtx) {
roleId := restfulx.PathParamInt(rc.GinCtx, "roleId")
roleId := restfulx.PathParamInt(rc, "roleId")
result := m.MenuApp.SelectMenuLable(entity.SysMenu{})
menuIds := make([]int64, 0)
@@ -71,7 +72,7 @@ func (m *MenuApi) GetMenuTreeRoleSelect(rc *restfulx.ReqCtx) {
// @Router /system/menu/menuPaths [get]
// @Security X-TOKEN
func (m *MenuApi) GetMenuPaths(rc *restfulx.ReqCtx) {
roleKey := rc.GinCtx.Query("roleKey")
roleKey := restfulx.QueryParam(rc, "roleKey")
biz.IsTrue(roleKey != "", "请传入角色Key")
rc.ResData = m.RoleMenuApp.GetMenuPaths(entity.SysRoleMenu{RoleName: roleKey})
}
@@ -87,8 +88,8 @@ func (m *MenuApi) GetMenuPaths(rc *restfulx.ReqCtx) {
// @Router /system/menu/menuList [get]
// @Security Bearer
func (m *MenuApi) GetMenuList(rc *restfulx.ReqCtx) {
menuName := rc.GinCtx.Query("menuName")
status := rc.GinCtx.Query("status")
menuName := restfulx.QueryParam(rc, "menuName")
status := restfulx.QueryParam(rc, "status")
menu := entity.SysMenu{MenuName: menuName, Status: status}
if menu.MenuName == "" {
@@ -107,7 +108,7 @@ func (m *MenuApi) GetMenuList(rc *restfulx.ReqCtx) {
// @Router /system/menu/{menuId} [get]
// @Security Bearer
func (m *MenuApi) GetMenu(rc *restfulx.ReqCtx) {
menuId := restfulx.PathParamInt(rc.GinCtx, "menuId")
menuId := restfulx.PathParamInt(rc, "menuId")
rc.ResData = m.MenuApp.FindOne(int64(menuId))
}
@@ -122,7 +123,7 @@ func (m *MenuApi) GetMenu(rc *restfulx.ReqCtx) {
// @Security X-TOKEN
func (m *MenuApi) InsertMenu(rc *restfulx.ReqCtx) {
var menu entity.SysMenu
restfulx.BindJsonAndValid(rc.GinCtx, &menu)
restfulx.BindQuery(rc, &menu)
menu.CreateBy = rc.LoginAccount.UserName
m.MenuApp.Insert(menu)
permis := m.RoleMenuApp.GetPermis(rc.LoginAccount.RoleId)
@@ -143,7 +144,7 @@ func (m *MenuApi) InsertMenu(rc *restfulx.ReqCtx) {
// @Security X-TOKEN
func (m *MenuApi) UpdateMenu(rc *restfulx.ReqCtx) {
var menu entity.SysMenu
restfulx.BindJsonAndValid(rc.GinCtx, &menu)
restfulx.BindQuery(rc, &menu)
menu.UpdateBy = rc.LoginAccount.UserName
m.MenuApp.Update(menu)
permis := m.RoleMenuApp.GetPermis(rc.LoginAccount.RoleId)
@@ -162,6 +163,6 @@ func (m *MenuApi) UpdateMenu(rc *restfulx.ReqCtx) {
// @Success 200 {string} string "{"code": 400, "message": "删除失败"}"
// @Router /system/menu/{menuId} [delete]
func (m *MenuApi) DeleteMenu(rc *restfulx.ReqCtx) {
menuId := restfulx.PathParamInt(rc.GinCtx, "menuId")
m.MenuApp.Delete([]int64{int64(menuId)})
menuId := restfulx.PathParam(rc, "menuId")
m.MenuApp.Delete(utils.IdsStrToIdsIntGroup(menuId))
}

View File

@@ -24,10 +24,10 @@ type NoticeApi struct {
// @Router /system/post [get]
// @Security
func (p *NoticeApi) GetNoticeList(rc *restfulx.ReqCtx) {
pageNum := restfulx.QueryInt(rc.GinCtx, "pageNum", 1)
pageSize := restfulx.QueryInt(rc.GinCtx, "pageSize", 10)
noticeType := rc.GinCtx.Query("noticeType")
title := rc.GinCtx.Query("title")
pageNum := restfulx.QueryInt(rc, "pageNum", 1)
pageSize := restfulx.QueryInt(rc, "pageSize", 10)
noticeType := restfulx.QueryParam(rc, "noticeType")
title := restfulx.QueryParam(rc, "title")
// 获取部门的子部门id
one := p.DeptApp.FindOne(rc.LoginAccount.DeptId)
@@ -57,7 +57,7 @@ func (p *NoticeApi) GetNoticeList(rc *restfulx.ReqCtx) {
// @Security X-TOKEN
func (p *NoticeApi) InsertNotice(rc *restfulx.ReqCtx) {
var notice entity.SysNotice
restfulx.BindJsonAndValid(rc.GinCtx, &notice)
restfulx.BindQuery(rc, &notice)
notice.UserName = rc.LoginAccount.UserName
p.NoticeApp.Insert(notice)
}
@@ -74,7 +74,7 @@ func (p *NoticeApi) InsertNotice(rc *restfulx.ReqCtx) {
// @Security X-TOKEN
func (p *NoticeApi) UpdateNotice(rc *restfulx.ReqCtx) {
var notice entity.SysNotice
restfulx.BindJsonAndValid(rc.GinCtx, &notice)
restfulx.BindQuery(rc, &notice)
p.NoticeApp.Update(notice)
}
@@ -87,7 +87,7 @@ func (p *NoticeApi) UpdateNotice(rc *restfulx.ReqCtx) {
// @Success 200 {string} string "{"code": 400, "message": "删除失败"}"
// @Router /system/notice/{noticeId} [delete]
func (p *NoticeApi) DeleteNotice(rc *restfulx.ReqCtx) {
noticeId := rc.GinCtx.Param("noticeId")
noticeId := restfulx.PathParam(rc, "noticeId")
noticeIds := utils.IdsStrToIdsIntGroup(noticeId)
p.NoticeApp.Delete(noticeIds)
}

View File

@@ -30,11 +30,11 @@ type PostApi struct {
// @Security
func (p *PostApi) GetPostList(rc *restfulx.ReqCtx) {
pageNum := restfulx.QueryInt(rc.GinCtx, "pageNum", 1)
pageSize := restfulx.QueryInt(rc.GinCtx, "pageSize", 10)
status := rc.GinCtx.Query("status")
postName := rc.GinCtx.Query("postName")
postCode := rc.GinCtx.Query("postCode")
pageNum := restfulx.QueryInt(rc, "pageNum", 1)
pageSize := restfulx.QueryInt(rc, "pageSize", 10)
status := restfulx.QueryParam(rc, "status")
postName := restfulx.QueryParam(rc, "postName")
postCode := restfulx.QueryParam(rc, "postCode")
post := entity.SysPost{Status: status, PostName: postName, PostCode: postCode}
if !IsTenantAdmin(rc.LoginAccount.TenantId) {
@@ -59,7 +59,7 @@ func (p *PostApi) GetPostList(rc *restfulx.ReqCtx) {
// @Router /system/post/{postId} [get]
// @Security
func (p *PostApi) GetPost(rc *restfulx.ReqCtx) {
postId := restfulx.PathParamInt(rc.GinCtx, "postId")
postId := restfulx.PathParamInt(rc, "postId")
p.PostApp.FindOne(int64(postId))
}
@@ -75,7 +75,7 @@ func (p *PostApi) GetPost(rc *restfulx.ReqCtx) {
// @Security X-TOKEN
func (p *PostApi) InsertPost(rc *restfulx.ReqCtx) {
var post entity.SysPost
restfulx.BindJsonAndValid(rc.GinCtx, &post)
restfulx.BindQuery(rc, &post)
post.TenantId = rc.LoginAccount.TenantId
post.CreateBy = rc.LoginAccount.UserName
p.PostApp.Insert(post)
@@ -93,7 +93,7 @@ func (p *PostApi) InsertPost(rc *restfulx.ReqCtx) {
// @Security X-TOKEN
func (p *PostApi) UpdatePost(rc *restfulx.ReqCtx) {
var post entity.SysPost
restfulx.BindJsonAndValid(rc.GinCtx, &post)
restfulx.BindQuery(rc, &post)
post.CreateBy = rc.LoginAccount.UserName
p.PostApp.Update(post)
@@ -107,8 +107,7 @@ func (p *PostApi) UpdatePost(rc *restfulx.ReqCtx) {
// @Success 200 {string} string "{"code": 400, "message": "删除失败"}"
// @Router /system/post/{postId} [delete]
func (p *PostApi) DeletePost(rc *restfulx.ReqCtx) {
postId := rc.GinCtx.Param("postId")
postId := restfulx.PathParam(rc, "postId")
postIds := utils.IdsStrToIdsIntGroup(postId)
deList := make([]int64, 0)

View File

@@ -32,11 +32,11 @@ type RoleApi struct {
// @Router /system/role/rolelist [get]
// @Security
func (r *RoleApi) GetRoleList(rc *restfulx.ReqCtx) {
pageNum := restfulx.QueryInt(rc.GinCtx, "pageNum", 1)
pageSize := restfulx.QueryInt(rc.GinCtx, "pageSize", 10)
status := rc.GinCtx.Query("status")
roleName := rc.GinCtx.Query("roleName")
roleKey := rc.GinCtx.Query("roleKey")
pageNum := restfulx.QueryInt(rc, "pageNum", 1)
pageSize := restfulx.QueryInt(rc, "pageSize", 10)
status := restfulx.QueryParam(rc, "status")
roleName := restfulx.QueryParam(rc, "roleName")
roleKey := restfulx.QueryParam(rc, "roleKey")
role := entity.SysRole{Status: status, RoleName: roleName, RoleKey: roleKey}
if !IsTenantAdmin(rc.LoginAccount.TenantId) {
@@ -62,7 +62,7 @@ func (r *RoleApi) GetRoleList(rc *restfulx.ReqCtx) {
// @Router /system/role [get]
// @Security X-TOKEN
func (r *RoleApi) GetRole(rc *restfulx.ReqCtx) {
roleId := restfulx.PathParamInt(rc.GinCtx, "roleId")
roleId := restfulx.PathParamInt(rc, "roleId")
role := r.RoleApp.FindOne(int64(roleId))
role.MenuIds = r.RoleApp.GetRoleMeunId(entity.SysRole{RoleId: int64(roleId)})
@@ -80,7 +80,7 @@ func (r *RoleApi) GetRole(rc *restfulx.ReqCtx) {
// @Router /system/role [post]
func (r *RoleApi) InsertRole(rc *restfulx.ReqCtx) {
var role entity.SysRole
restfulx.BindJsonAndValid(rc.GinCtx, &role)
restfulx.BindQuery(rc, &role)
role.CreateBy = rc.LoginAccount.UserName
role.TenantId = rc.LoginAccount.TenantId
insert := r.RoleApp.Insert(role)
@@ -102,7 +102,7 @@ func (r *RoleApi) InsertRole(rc *restfulx.ReqCtx) {
// @Router /system/role [put]
func (r *RoleApi) UpdateRole(rc *restfulx.ReqCtx) {
var role entity.SysRole
restfulx.BindJsonAndValid(rc.GinCtx, &role)
restfulx.BindQuery(rc, &role)
role.UpdateBy = rc.LoginAccount.UserName
// 修改角色
r.RoleApp.Update(role)
@@ -126,7 +126,7 @@ func (r *RoleApi) UpdateRole(rc *restfulx.ReqCtx) {
// @Router /system/role/changeStatus [put]
func (r *RoleApi) UpdateRoleStatus(rc *restfulx.ReqCtx) {
var role entity.SysRole
restfulx.BindJsonAndValid(rc.GinCtx, &role)
restfulx.BindQuery(rc, &role)
role.UpdateBy = rc.LoginAccount.UserName
// 修改角色
r.RoleApp.Update(role)
@@ -143,7 +143,7 @@ func (r *RoleApi) UpdateRoleStatus(rc *restfulx.ReqCtx) {
// @Router /system/role/dataScope [put]
func (r *RoleApi) UpdateRoleDataScope(rc *restfulx.ReqCtx) {
var role entity.SysRole
restfulx.BindJsonAndValid(rc.GinCtx, &role)
restfulx.BindQuery(rc, &role)
role.UpdateBy = rc.LoginAccount.UserName
// 修改角色
update := r.RoleApp.Update(role)
@@ -163,7 +163,7 @@ func (r *RoleApi) UpdateRoleDataScope(rc *restfulx.ReqCtx) {
// @Success 200 {string} string "{"code": 400, "message": "删除失败"}"
// @Router /system/role/{roleId} [delete]
func (r *RoleApi) DeleteRole(rc *restfulx.ReqCtx) {
roleId := rc.GinCtx.Param("roleId")
roleId := restfulx.PathParam(rc, "roleId")
roleIds := utils.IdsStrToIdsIntGroup(roleId)
user := entity.SysUser{}
@@ -198,10 +198,10 @@ func (r *RoleApi) DeleteRole(rc *restfulx.ReqCtx) {
// @Success 200 {string} string "{"code": 400, "message": "删除失败"}"
// @Router /system/dict/type/export [get]
func (p *RoleApi) ExportRole(rc *restfulx.ReqCtx) {
filename := rc.GinCtx.Query("filename")
status := rc.GinCtx.Query("status")
roleName := rc.GinCtx.Query("roleName")
roleKey := rc.GinCtx.Query("roleKey")
filename := restfulx.QueryParam(rc, "filename")
status := restfulx.QueryParam(rc, "status")
roleName := restfulx.QueryParam(rc, "roleName")
roleKey := restfulx.QueryParam(rc, "roleKey")
role := entity.SysRole{Status: status, RoleName: roleName, RoleKey: roleKey}
if !IsTenantAdmin(rc.LoginAccount.TenantId) {
role.TenantId = rc.LoginAccount.TenantId

View File

@@ -5,10 +5,9 @@ import (
"github.com/XM-GO/PandaKit/biz"
"github.com/XM-GO/PandaKit/restfulx"
"github.com/XM-GO/PandaKit/ws"
"github.com/gin-gonic/gin"
"github.com/emicklei/go-restful/v3"
"github.com/gorilla/websocket"
"github.com/kakuilan/kgo"
"net/http"
"runtime"
)
@@ -21,7 +20,7 @@ const (
GB = 1024 * MB
)
func (s *System) ServerInfo(g *gin.Context) {
func (s *System) ServerInfo(request *restful.Request, response *restful.Response) {
osDic := make(map[string]any, 0)
osDic["goOs"] = runtime.GOOS
osDic["arch"] = runtime.GOARCH
@@ -48,7 +47,7 @@ func (s *System) ServerInfo(g *gin.Context) {
cpuDic["used"] = fmt.Sprintf("%.2f", info.CpuUser*100)
cpuDic["free"] = fmt.Sprintf("%.2f", info.CpuFree*100)
g.JSON(http.StatusOK, gin.H{
response.WriteEntity(map[string]any{
"code": 200,
"os": osDic,
"mem": memDic,
@@ -58,8 +57,8 @@ func (s *System) ServerInfo(g *gin.Context) {
}
// 连接websocket
func (s *System) ConnectWs(g *gin.Context) {
wsConn, err := ws.Upgrader.Upgrade(g.Writer, g.Request, nil)
func (s *System) ConnectWs(request *restful.Request, response *restful.Response) {
wsConn, err := ws.Upgrader.Upgrade(response, request.Request, nil)
defer func() {
if err := recover(); &err != nil {
wsConn.WriteMessage(websocket.TextMessage, []byte(fmt.Sprintf("websocket 失败: %v", err)))
@@ -71,7 +70,7 @@ func (s *System) ConnectWs(g *gin.Context) {
panic(any(biz.NewBizErr("升级websocket失败")))
}
// 权限校验
rc := restfulx.NewReqCtx(g)
rc := restfulx.NewReqCtx(request, response)
if err = restfulx.PermissionHandler(rc); err != nil {
panic(any(biz.NewBizErr("没有权限")))
}

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)
}

View File

@@ -3,10 +3,11 @@ package api
import (
"github.com/XM-GO/PandaKit/token"
"github.com/dgrijalva/jwt-go"
"github.com/gin-gonic/gin"
"github.com/emicklei/go-restful/v3"
"github.com/kakuilan/kgo"
"github.com/mssola/user_agent"
"net/http"
"log"
"pandax/apps/system/api/form"
"pandax/apps/system/api/vo"
"pandax/apps/system/entity"
@@ -16,6 +17,7 @@ import (
"github.com/XM-GO/PandaKit/biz"
"github.com/XM-GO/PandaKit/captcha"
filek "github.com/XM-GO/PandaKit/file"
"github.com/XM-GO/PandaKit/restfulx"
"github.com/XM-GO/PandaKit/utils"
"pandax/apps/system/services"
@@ -39,9 +41,9 @@ type UserApi struct {
// @Produce application/json
// @Success 200 {string} string "{"success":true,"data":{},"msg":"登陆成功"}"
// @Router /system/user/getCaptcha [get]
func (u *UserApi) GenerateCaptcha(c *gin.Context) {
func (u *UserApi) GenerateCaptcha(request *restful.Request, response *restful.Response) {
id, image := captcha.Generate()
c.JSON(http.StatusOK, map[string]any{"base64Captcha": image, "captchaId": id})
response.WriteEntity(map[string]any{"base64Captcha": image, "captchaId": id})
}
// @Tags Base
@@ -50,7 +52,7 @@ func (u *UserApi) GenerateCaptcha(c *gin.Context) {
// @Success 200 {string} string "{"success":true,"data":{},"msg":"登陆成功"}"
// @Router /system/user/refreshToken [get]
func (u *UserApi) RefreshToken(rc *restfulx.ReqCtx) {
tokenStr := rc.GinCtx.Request.Header.Get("X-TOKEN")
tokenStr := rc.Request.Request.Header.Get("X-TOKEN")
j := token.NewJWT("", []byte(global.Conf.Jwt.Key), jwt.SigningMethodHS256)
token, err := j.RefreshToken(tokenStr)
biz.ErrIsNil(err, "刷新token失败")
@@ -65,7 +67,8 @@ func (u *UserApi) RefreshToken(rc *restfulx.ReqCtx) {
// @Router /system/user/login [post]
func (u *UserApi) Login(rc *restfulx.ReqCtx) {
var l form.Login
restfulx.BindJsonAndValid(rc.GinCtx, &l)
restfulx.BindQuery(rc, &l)
log.Println(l)
biz.IsTrue(captcha.Verify(l.CaptchaId, l.Captcha), "验证码认证失败")
login := u.UserApp.Login(entity.Login{Username: l.Username, Password: l.Password})
@@ -93,12 +96,12 @@ func (u *UserApi) Login(rc *restfulx.ReqCtx) {
}
var loginLog logEntity.LogLogin
ua := user_agent.New(rc.GinCtx.Request.UserAgent())
loginLog.Ipaddr = rc.GinCtx.ClientIP()
loginLog.LoginLocation = utils.GetRealAddressByIP(rc.GinCtx.ClientIP())
ua := user_agent.New(rc.Request.Request.UserAgent())
loginLog.Ipaddr = rc.Request.Request.RemoteAddr
loginLog.LoginLocation = utils.GetRealAddressByIP(rc.Request.Request.RemoteAddr)
loginLog.LoginTime = time.Now()
loginLog.Status = "0"
loginLog.Remark = rc.GinCtx.Request.UserAgent()
loginLog.Remark = rc.Request.Request.UserAgent()
browserName, browserVersion := ua.Browser()
loginLog.Browser = browserName + " " + browserVersion
loginLog.Os = ua.OS()
@@ -116,7 +119,7 @@ func (u *UserApi) Login(rc *restfulx.ReqCtx) {
// @Success 200 {string} string "{"success":true,"data":{},"msg":"成功"}"
// @Router /system/user/auth [get]
func (u *UserApi) Auth(rc *restfulx.ReqCtx) {
userName := rc.GinCtx.Query("username")
userName := restfulx.QueryParam(rc, "username")
biz.NotEmpty(userName, "用户名必传")
var user entity.SysUser
user.Username = userName
@@ -141,11 +144,11 @@ func (u *UserApi) Auth(rc *restfulx.ReqCtx) {
// @Router /system/user/logout [post]
func (u *UserApi) LogOut(rc *restfulx.ReqCtx) {
var loginLog logEntity.LogLogin
ua := user_agent.New(rc.GinCtx.Request.UserAgent())
loginLog.Ipaddr = rc.GinCtx.ClientIP()
ua := user_agent.New(rc.Request.Request.UserAgent())
loginLog.Ipaddr = rc.Request.Request.RemoteAddr
loginLog.LoginTime = time.Now()
loginLog.Status = "0"
loginLog.Remark = rc.GinCtx.Request.UserAgent()
loginLog.Remark = rc.Request.Request.UserAgent()
browserName, browserVersion := ua.Browser()
loginLog.Browser = browserName + " " + browserVersion
loginLog.Os = ua.OS()
@@ -168,15 +171,16 @@ func (u *UserApi) LogOut(rc *restfulx.ReqCtx) {
// @Router /system/user/sysUserList [get]
// @Security X-TOKEN
func (u *UserApi) GetSysUserList(rc *restfulx.ReqCtx) {
pageNum := restfulx.QueryInt(rc.GinCtx, "pageNum", 1)
pageSize := restfulx.QueryInt(rc.GinCtx, "pageSize", 10)
status := rc.GinCtx.Query("status")
userName := rc.GinCtx.Query("username")
phone := rc.GinCtx.Query("phone")
deptId := restfulx.QueryInt(rc.GinCtx, "deptId", 0)
pageNum := restfulx.QueryInt(rc, "pageNum", 1)
pageSize := restfulx.QueryInt(rc, "pageSize", 10)
status := restfulx.QueryParam(rc, "status")
username := restfulx.QueryParam(rc, "username")
phone := restfulx.QueryParam(rc, "phone")
deptId := restfulx.QueryInt(rc, "deptId", 0)
var user entity.SysUser
user.Status = status
user.Username = userName
user.Username = username
user.Phone = phone
user.DeptId = int64(deptId)
@@ -236,8 +240,7 @@ func (u *UserApi) GetSysUserProfile(rc *restfulx.ReqCtx) {
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
// @Router /system/user/profileAvatar [post]
func (u *UserApi) InsetSysUserAvatar(rc *restfulx.ReqCtx) {
form, err := rc.GinCtx.MultipartForm()
biz.ErrIsNil(err, "头像上传失败")
form := rc.Request.Request.MultipartForm
files := form.File["upload[]"]
guid, _ := kgo.KStr.UuidV4()
@@ -245,7 +248,7 @@ func (u *UserApi) InsetSysUserAvatar(rc *restfulx.ReqCtx) {
for _, file := range files {
global.Log.Info(file.Filename)
// 上传文件至指定目录
biz.ErrIsNil(rc.GinCtx.SaveUploadedFile(file, filPath), "保存头像失败")
biz.ErrIsNil(filek.SaveUploadedFile(file, filPath), "保存头像失败")
}
sysuser := entity.SysUser{}
sysuser.UserId = rc.LoginAccount.UserId
@@ -264,7 +267,7 @@ func (u *UserApi) InsetSysUserAvatar(rc *restfulx.ReqCtx) {
// @Router /system/user/updatePwd [post]
func (u *UserApi) SysUserUpdatePwd(rc *restfulx.ReqCtx) {
var pws entity.SysUserPwd
restfulx.BindJsonAndValid(rc.GinCtx, &pws)
restfulx.BindQuery(rc, &pws)
user := entity.SysUser{}
user.UserId = rc.LoginAccount.UserId
@@ -279,7 +282,7 @@ func (u *UserApi) SysUserUpdatePwd(rc *restfulx.ReqCtx) {
// @Router /system/user/sysUser/{userId} [get]
// @Security
func (u *UserApi) GetSysUser(rc *restfulx.ReqCtx) {
userId := restfulx.PathParamInt(rc.GinCtx, "userId")
userId := restfulx.PathParamInt(rc, "userId")
user := entity.SysUser{}
user.UserId = int64(userId)
@@ -369,7 +372,7 @@ func (u *UserApi) GetUserRolePost(rc *restfulx.ReqCtx) {
// @Router /system/user/sysUser [post]
func (u *UserApi) InsertSysUser(rc *restfulx.ReqCtx) {
var sysUser entity.SysUser
restfulx.BindJsonAndValid(rc.GinCtx, &sysUser)
restfulx.BindQuery(rc, &sysUser)
sysUser.CreateBy = rc.LoginAccount.UserName
u.UserApp.Insert(sysUser)
}
@@ -385,7 +388,7 @@ func (u *UserApi) InsertSysUser(rc *restfulx.ReqCtx) {
// @Router /system/user/sysUser [put]
func (u *UserApi) UpdateSysUser(rc *restfulx.ReqCtx) {
var sysUser entity.SysUser
restfulx.BindJsonAndValid(rc.GinCtx, &sysUser)
restfulx.BindQuery(rc, &sysUser)
sysUser.CreateBy = rc.LoginAccount.UserName
u.UserApp.Update(sysUser)
}
@@ -401,7 +404,7 @@ func (u *UserApi) UpdateSysUser(rc *restfulx.ReqCtx) {
// @Router /system/user/sysUser [put]
func (u *UserApi) UpdateSysUserStu(rc *restfulx.ReqCtx) {
var sysUser entity.SysUser
restfulx.BindJsonAndValid(rc.GinCtx, &sysUser)
restfulx.BindQuery(rc, &sysUser)
sysUser.CreateBy = rc.LoginAccount.UserName
u.UserApp.Update(sysUser)
}
@@ -414,9 +417,8 @@ func (u *UserApi) UpdateSysUserStu(rc *restfulx.ReqCtx) {
// @Success 200 {string} string "{"code": 400, "message": "删除失败"}"
// @Router /system/user/sysuser/{userId} [delete]
func (u *UserApi) DeleteSysUser(rc *restfulx.ReqCtx) {
userIds := rc.GinCtx.Param("userId")
us := utils.IdsStrToIdsIntGroup(userIds)
u.UserApp.Delete(us)
userIds := restfulx.PathParam(rc, "userId")
u.UserApp.Delete(utils.IdsStrToIdsIntGroup(userIds))
}
// @Summary 导出用户
@@ -429,14 +431,14 @@ func (u *UserApi) DeleteSysUser(rc *restfulx.ReqCtx) {
// @Success 200 {string} string "{"code": 400, "message": "删除失败"}"
// @Router /system/dict/type/export [get]
func (u *UserApi) ExportUser(rc *restfulx.ReqCtx) {
filename := rc.GinCtx.Query("filename")
status := rc.GinCtx.Query("status")
userName := rc.GinCtx.Query("username")
phone := rc.GinCtx.Query("phone")
filename := restfulx.QueryParam(rc, "filename")
status := restfulx.QueryParam(rc, "status")
username := restfulx.QueryParam(rc, "username")
phone := restfulx.QueryParam(rc, "phone")
var user entity.SysUser
user.Status = status
user.Username = userName
user.Username = username
user.Phone = phone
if !IsTenantAdmin(rc.LoginAccount.TenantId) {