后台格式规范化 引入casbin做鉴权
This commit is contained in:
@@ -9,7 +9,7 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// @Tags FileUploadAndDownload
|
||||
// @Tags ExaFileUploadAndDownload
|
||||
// @Summary 上传文件示例
|
||||
// @Security ApiKeyAuth
|
||||
// @accept multipart/form-data
|
||||
@@ -28,7 +28,7 @@ func UploadFile(c *gin.Context) {
|
||||
servers.ReportFormat(c, false, fmt.Sprintf("接收返回值失败,%v", err), gin.H{})
|
||||
} else {
|
||||
//修改数据库后得到修改后的user并且返回供前端使用
|
||||
var file dbModel.FileUploadAndDownload
|
||||
var file dbModel.ExaFileUploadAndDownload
|
||||
file.Url = filePath
|
||||
file.Name = header.Filename
|
||||
s := strings.Split(file.Name, ".")
|
||||
@@ -44,15 +44,15 @@ func UploadFile(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// @Tags FileUploadAndDownload
|
||||
// @Tags ExaFileUploadAndDownload
|
||||
// @Summary 删除文件
|
||||
// @Security ApiKeyAuth
|
||||
// @Produce application/json
|
||||
// @Param data body dbModel.FileUploadAndDownload true "传入文件里面id即可"
|
||||
// @Param data body dbModel.ExaFileUploadAndDownload true "传入文件里面id即可"
|
||||
// @Success 200 {string} json "{"success":true,"data":{},"msg":"返回成功"}"
|
||||
// @Router /fileUploadAndDownload/deleteFile [post]
|
||||
func DeleteFile(c *gin.Context) {
|
||||
var file dbModel.FileUploadAndDownload
|
||||
var file dbModel.ExaFileUploadAndDownload
|
||||
_ = c.ShouldBind(&file)
|
||||
err, f := file.FindFile()
|
||||
if err != nil {
|
||||
@@ -72,7 +72,7 @@ func DeleteFile(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// @Tags FileUploadAndDownload
|
||||
// @Tags ExaFileUploadAndDownload
|
||||
// @Summary 分页文件列表
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
@@ -83,7 +83,7 @@ func DeleteFile(c *gin.Context) {
|
||||
func GetFileList(c *gin.Context) {
|
||||
var pageInfo modelInterface.PageInfo
|
||||
_ = c.BindJSON(&pageInfo)
|
||||
err, list, total := new(dbModel.FileUploadAndDownload).GetInfoList(pageInfo)
|
||||
err, list, total := new(dbModel.ExaFileUploadAndDownload).GetInfoList(pageInfo)
|
||||
if err != nil {
|
||||
servers.ReportFormat(c, false, fmt.Sprintf("获取数据失败,%v", err), gin.H{})
|
||||
} else {
|
@@ -4,8 +4,8 @@ import (
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"main/controller/servers"
|
||||
"main/model/dbModel"
|
||||
"main/model/modelInterface"
|
||||
"main/model/sysModel"
|
||||
)
|
||||
|
||||
type CreateApiParams struct {
|
||||
@@ -17,7 +17,7 @@ type DeleteApiParams struct {
|
||||
ID uint `json:"id"`
|
||||
}
|
||||
|
||||
// @Tags Api
|
||||
// @Tags SysApi
|
||||
// @Summary 创建基础api
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
@@ -26,7 +26,7 @@ type DeleteApiParams struct {
|
||||
// @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
// @Router /api/createApi [post]
|
||||
func CreateApi(c *gin.Context) {
|
||||
var api dbModel.Api
|
||||
var api sysModel.SysApi
|
||||
_ = c.BindJSON(&api)
|
||||
err := api.CreateApi()
|
||||
if err != nil {
|
||||
@@ -36,16 +36,16 @@ func CreateApi(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// @Tags Api
|
||||
// @Tags SysApi
|
||||
// @Summary 删除指定api
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data body dbModel.Api true "删除api"
|
||||
// @Param data body sysModel.SysApi true "删除api"
|
||||
// @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
// @Router /api/deleteApi [post]
|
||||
func DeleteApi(c *gin.Context) {
|
||||
var a dbModel.Api
|
||||
var a sysModel.SysApi
|
||||
_ = c.BindJSON(&a)
|
||||
err := a.DeleteApi()
|
||||
if err != nil {
|
||||
@@ -60,7 +60,7 @@ type AuthAndPathIn struct {
|
||||
ApiIds []uint `json:"apiIds"`
|
||||
}
|
||||
|
||||
// @Tags Api
|
||||
// @Tags SysApi
|
||||
// @Summary 创建api和角色关系
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
@@ -71,7 +71,7 @@ type AuthAndPathIn struct {
|
||||
func SetAuthAndApi(c *gin.Context) {
|
||||
var authAndPathIn AuthAndPathIn
|
||||
_ = c.BindJSON(&authAndPathIn)
|
||||
err := new(dbModel.ApiAuthority).SetAuthAndApi(authAndPathIn.AuthorityId, authAndPathIn.ApiIds)
|
||||
err := new(sysModel.SysApiAuthority).SetAuthAndApi(authAndPathIn.AuthorityId, authAndPathIn.ApiIds)
|
||||
if err != nil {
|
||||
servers.ReportFormat(c, false, fmt.Sprintf("添加失败:%v", err), gin.H{})
|
||||
} else {
|
||||
@@ -81,7 +81,7 @@ func SetAuthAndApi(c *gin.Context) {
|
||||
|
||||
//条件搜索后端看此api
|
||||
|
||||
// @Tags Api
|
||||
// @Tags SysApi
|
||||
// @Summary 分页获取API列表
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
@@ -92,12 +92,12 @@ func SetAuthAndApi(c *gin.Context) {
|
||||
func GetApiList(c *gin.Context) {
|
||||
// 此结构体仅本方法使用
|
||||
type searchParams struct {
|
||||
dbModel.Api
|
||||
sysModel.SysApi
|
||||
modelInterface.PageInfo
|
||||
}
|
||||
var sp searchParams
|
||||
_ = c.ShouldBindJSON(&sp)
|
||||
err, list, total := sp.Api.GetInfoList(sp.PageInfo)
|
||||
err, list, total := sp.SysApi.GetInfoList(sp.PageInfo)
|
||||
if err != nil {
|
||||
servers.ReportFormat(c, false, fmt.Sprintf("获取数据失败,%v", err), gin.H{})
|
||||
} else {
|
||||
@@ -111,7 +111,7 @@ func GetApiList(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// @Tags Api
|
||||
// @Tags SysApi
|
||||
// @Summary 根据id获取api
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
@@ -122,7 +122,7 @@ func GetApiList(c *gin.Context) {
|
||||
func GetApiById(c *gin.Context) {
|
||||
var idInfo GetById
|
||||
_ = c.BindJSON(&idInfo)
|
||||
err, api := new(dbModel.Api).GetApiById(idInfo.Id)
|
||||
err, api := new(sysModel.SysApi).GetApiById(idInfo.Id)
|
||||
if err != nil {
|
||||
servers.ReportFormat(c, false, fmt.Sprintf("获取数据失败,%v", err), gin.H{})
|
||||
} else {
|
||||
@@ -133,7 +133,7 @@ func GetApiById(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// @Tags Api
|
||||
// @Tags SysApi
|
||||
// @Summary 创建基础api
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
@@ -142,7 +142,7 @@ func GetApiById(c *gin.Context) {
|
||||
// @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
// @Router /api/updataApi [post]
|
||||
func UpdataApi(c *gin.Context) {
|
||||
var api dbModel.Api
|
||||
var api sysModel.SysApi
|
||||
_ = c.BindJSON(&api)
|
||||
err := api.UpdataApi()
|
||||
if err != nil {
|
||||
@@ -152,7 +152,7 @@ func UpdataApi(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// @Tags Api
|
||||
// @Tags SysApi
|
||||
// @Summary 获取所有的Api 不分页
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
@@ -160,7 +160,7 @@ func UpdataApi(c *gin.Context) {
|
||||
// @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
// @Router /api/getAllApis [post]
|
||||
func GetAllApis(c *gin.Context) {
|
||||
err, apis := new(dbModel.Api).GetAllApis()
|
||||
err, apis := new(sysModel.SysApi).GetAllApis()
|
||||
if err != nil {
|
||||
servers.ReportFormat(c, false, fmt.Sprintf("获取数据失败,%v", err), gin.H{})
|
||||
} else {
|
@@ -4,8 +4,8 @@ import (
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"main/controller/servers"
|
||||
"main/model/dbModel"
|
||||
"main/model/modelInterface"
|
||||
"main/model/sysModel"
|
||||
)
|
||||
|
||||
type CreateAuthorityPatams struct {
|
||||
@@ -22,7 +22,7 @@ type CreateAuthorityPatams struct {
|
||||
// @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
// @Router /authority/createAuthority [post]
|
||||
func CreateAuthority(c *gin.Context) {
|
||||
var auth dbModel.Authority
|
||||
var auth sysModel.SysAuthority
|
||||
_ = c.ShouldBind(&auth)
|
||||
err, authBack := auth.CreateAuthority()
|
||||
if err != nil {
|
||||
@@ -49,7 +49,7 @@ type DeleteAuthorityPatams struct {
|
||||
// @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
// @Router /authority/deleteAuthority [post]
|
||||
func DeleteAuthority(c *gin.Context) {
|
||||
var a dbModel.Authority
|
||||
var a sysModel.SysAuthority
|
||||
_ = c.BindJSON(&a)
|
||||
//删除角色之前需要判断是否有用户正在使用此角色
|
||||
err := a.DeleteAuthority()
|
||||
@@ -71,7 +71,7 @@ func DeleteAuthority(c *gin.Context) {
|
||||
func GetAuthorityList(c *gin.Context){
|
||||
var pageInfo modelInterface.PageInfo
|
||||
_ = c.BindJSON(&pageInfo)
|
||||
err, list, total := new(dbModel.Authority).GetInfoList(pageInfo)
|
||||
err, list, total := new(sysModel.SysAuthority).GetInfoList(pageInfo)
|
||||
if err != nil {
|
||||
servers.ReportFormat(c, false, fmt.Sprintf("获取数据失败,%v", err), gin.H{})
|
||||
} else {
|
||||
@@ -100,7 +100,7 @@ type GetAuthorityId struct {
|
||||
func GetAuthAndApi(c *gin.Context){
|
||||
var idInfo GetAuthorityId
|
||||
_ = c.BindJSON(&idInfo)
|
||||
err,apis := new(dbModel.ApiAuthority).GetAuthAndApi(idInfo.AuthorityId)
|
||||
err,apis := new(sysModel.SysApiAuthority).GetAuthAndApi(idInfo.AuthorityId)
|
||||
if err != nil {
|
||||
servers.ReportFormat(c, false, fmt.Sprintf("获取数据失败,%v", err), gin.H{})
|
||||
} else {
|
48
QMPlusServer/controller/api/sys_casbin.go
Normal file
48
QMPlusServer/controller/api/sys_casbin.go
Normal file
@@ -0,0 +1,48 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"main/controller/servers"
|
||||
"main/model/sysModel"
|
||||
)
|
||||
|
||||
|
||||
type CasbinInReceive struct {
|
||||
AuthorityId string `json:"authorityId"`
|
||||
Paths []string `json:paths`
|
||||
}
|
||||
|
||||
// @Tags casbin
|
||||
// @Summary 更改角色api权限
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data body api.CreateAuthorityPatams true "更改角色api权限"
|
||||
// @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
// @Router /casbin/casbinPUpdata [post]
|
||||
func CasbinPUpdata(c *gin.Context){
|
||||
var cmr CasbinInReceive
|
||||
_ = c.ShouldBind(&cmr)
|
||||
err := new(sysModel.CasbinModel).CasbinPUpdata(cmr.AuthorityId,cmr.Paths)
|
||||
if err != nil {
|
||||
servers.ReportFormat(c, false, fmt.Sprintf("添加规则失败,%v", err), gin.H{})
|
||||
} else {
|
||||
servers.ReportFormat(c, true, "添加规则成功", gin.H{})
|
||||
}
|
||||
}
|
||||
|
||||
// @Tags casbin
|
||||
// @Summary 获取权限列表
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data body api.CreateAuthorityPatams true "获取权限列表"
|
||||
// @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
// @Router /casbin/getPolicyPathByAuthorityId [post]
|
||||
func GetPolicyPathByAuthorityId(c *gin.Context){
|
||||
var cmr CasbinInReceive
|
||||
_ = c.ShouldBind(&cmr)
|
||||
paths := new(sysModel.CasbinModel).GetPolicyPathByAuthorityId(cmr.AuthorityId)
|
||||
servers.ReportFormat(c, true, "获取规则成功", gin.H{"paths":paths})
|
||||
}
|
@@ -5,7 +5,7 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"main/controller/servers"
|
||||
"main/middleware"
|
||||
"main/model/dbModel"
|
||||
"main/model/sysModel"
|
||||
"main/model/modelInterface"
|
||||
)
|
||||
|
||||
@@ -19,7 +19,7 @@ import (
|
||||
func GetMenu(c *gin.Context) {
|
||||
claims, _ := c.Get("claims")
|
||||
waitUse := claims.(*middleware.CustomClaims)
|
||||
err, menus := new(dbModel.Menu).GetMenuTree(waitUse.AuthorityId)
|
||||
err, menus := new(sysModel.SysMenu).GetMenuTree(waitUse.AuthorityId)
|
||||
if err != nil {
|
||||
servers.ReportFormat(c, false, fmt.Sprintf("获取失败:%v", err), gin.H{"menus": menus})
|
||||
} else {
|
||||
@@ -38,7 +38,7 @@ func GetMenu(c *gin.Context) {
|
||||
func GetMenuList(c *gin.Context) {
|
||||
var pageInfo modelInterface.PageInfo
|
||||
_ = c.BindJSON(&pageInfo)
|
||||
err, menuList, total := new(dbModel.BaseMenu).GetInfoList(pageInfo)
|
||||
err, menuList, total := new(sysModel.SysBaseMenu).GetInfoList(pageInfo)
|
||||
if err != nil {
|
||||
servers.ReportFormat(c, false, fmt.Sprintf("获取数据失败,%v", err), gin.H{})
|
||||
} else {
|
||||
@@ -56,11 +56,11 @@ func GetMenuList(c *gin.Context) {
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data body dbModel.BaseMenu true "新增菜单"
|
||||
// @Param data body sysModel.SysBaseMenu true "新增菜单"
|
||||
// @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
// @Router /menu/addBaseMenu [post]
|
||||
func AddBaseMenu(c *gin.Context) {
|
||||
var addMenu dbModel.BaseMenu
|
||||
var addMenu sysModel.SysBaseMenu
|
||||
_ = c.BindJSON(&addMenu)
|
||||
err := addMenu.AddBaseMenu()
|
||||
if err != nil {
|
||||
@@ -78,7 +78,7 @@ func AddBaseMenu(c *gin.Context) {
|
||||
// @Success 200 {string} json "{"success":true,"data":{},"msg":"返回成功"}"
|
||||
// @Router /menu/getBaseMenuTree [post]
|
||||
func GetBaseMenuTree(c *gin.Context) {
|
||||
err, menus := new(dbModel.BaseMenu).GetBaseMenuTree()
|
||||
err, menus := new(sysModel.SysBaseMenu).GetBaseMenuTree()
|
||||
if err != nil {
|
||||
servers.ReportFormat(c, false, fmt.Sprintf("获取失败:%v", err), gin.H{"menus": menus})
|
||||
} else {
|
||||
@@ -87,7 +87,7 @@ func GetBaseMenuTree(c *gin.Context) {
|
||||
}
|
||||
|
||||
type AddMenuAuthorityInfo struct {
|
||||
Menus []dbModel.BaseMenu
|
||||
Menus []sysModel.SysBaseMenu
|
||||
AuthorityId string
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ type AddMenuAuthorityInfo struct {
|
||||
func AddMenuAuthority(c *gin.Context) {
|
||||
var addMenuAuthorityInfo AddMenuAuthorityInfo
|
||||
_ = c.BindJSON(&addMenuAuthorityInfo)
|
||||
err := new(dbModel.Menu).AddMenuAuthority(addMenuAuthorityInfo.Menus, addMenuAuthorityInfo.AuthorityId)
|
||||
err := new(sysModel.SysMenu).AddMenuAuthority(addMenuAuthorityInfo.Menus, addMenuAuthorityInfo.AuthorityId)
|
||||
if err != nil {
|
||||
servers.ReportFormat(c, false, fmt.Sprintf("添加失败,%v", err), gin.H{})
|
||||
} else {
|
||||
@@ -125,7 +125,7 @@ type AuthorityIdInfo struct {
|
||||
func GetMenuAuthority(c *gin.Context) {
|
||||
var authorityIdInfo AuthorityIdInfo
|
||||
_ = c.BindJSON(&authorityIdInfo)
|
||||
err, menus := new(dbModel.Menu).GetMenuAuthority(authorityIdInfo.AuthorityId)
|
||||
err, menus := new(sysModel.SysMenu).GetMenuAuthority(authorityIdInfo.AuthorityId)
|
||||
if err != nil {
|
||||
servers.ReportFormat(c, false, fmt.Sprintf("获取失败:%v", err), gin.H{"menus": menus})
|
||||
} else {
|
||||
@@ -148,7 +148,7 @@ type IdInfo struct {
|
||||
func DeleteBaseMenu(c *gin.Context) {
|
||||
var idInfo IdInfo
|
||||
_ = c.BindJSON(&idInfo)
|
||||
err := new(dbModel.BaseMenu).DeleteBaseMenu(idInfo.Id)
|
||||
err := new(sysModel.SysBaseMenu).DeleteBaseMenu(idInfo.Id)
|
||||
if err != nil {
|
||||
servers.ReportFormat(c, false, fmt.Sprintf("删除失败:%v", err), gin.H{})
|
||||
} else {
|
||||
@@ -161,11 +161,11 @@ func DeleteBaseMenu(c *gin.Context) {
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data body dbModel.BaseMenu true "更新菜单"
|
||||
// @Param data body sysModel.SysBaseMenu true "更新菜单"
|
||||
// @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
// @Router /menu/updataBaseMen [post]
|
||||
func UpdataBaseMenu(c *gin.Context) {
|
||||
var menu dbModel.BaseMenu
|
||||
var menu sysModel.SysBaseMenu
|
||||
_ = c.BindJSON(&menu)
|
||||
err := menu.UpdataBaseMenu()
|
||||
if err != nil {
|
||||
@@ -190,7 +190,7 @@ type GetById struct {
|
||||
func GetBaseMenuById(c *gin.Context) {
|
||||
var idInfo GetById
|
||||
_ = c.BindJSON(&idInfo)
|
||||
err, menu := new(dbModel.BaseMenu).GetBaseMenuById(idInfo.Id)
|
||||
err, menu := new(sysModel.SysBaseMenu).GetBaseMenuById(idInfo.Id)
|
||||
if err != nil {
|
||||
servers.ReportFormat(c, false, fmt.Sprintf("查询失败:%v", err), gin.H{})
|
||||
} else {
|
@@ -7,7 +7,7 @@ import (
|
||||
uuid "github.com/satori/go.uuid"
|
||||
"main/controller/servers"
|
||||
"main/middleware"
|
||||
"main/model/dbModel"
|
||||
"main/model/sysModel"
|
||||
"main/model/modelInterface"
|
||||
"mime/multipart"
|
||||
"time"
|
||||
@@ -33,7 +33,7 @@ func Regist(c *gin.Context) {
|
||||
var R RegistAndLoginStuct
|
||||
_ = c.BindJSON(&R)
|
||||
|
||||
U := &dbModel.User{Username: R.Username, Password: R.Password}
|
||||
U := &sysModel.SysUser{Username: R.Username, Password: R.Password}
|
||||
err, user := U.Regist()
|
||||
if err != nil {
|
||||
servers.ReportFormat(c, false, fmt.Sprintf("%v", err), gin.H{
|
||||
@@ -55,7 +55,7 @@ func Regist(c *gin.Context) {
|
||||
func Login(c *gin.Context) {
|
||||
var L RegistAndLoginStuct
|
||||
_ = c.BindJSON(&L)
|
||||
U := &dbModel.User{Username: L.Username, Password: L.Password}
|
||||
U := &sysModel.SysUser{Username: L.Username, Password: L.Password}
|
||||
if err, user := U.Login(); err != nil {
|
||||
servers.ReportFormat(c, false, fmt.Sprintf("用户名密码错误或%v", err), gin.H{})
|
||||
} else {
|
||||
@@ -64,7 +64,7 @@ func Login(c *gin.Context) {
|
||||
}
|
||||
|
||||
//登录以后签发jwt
|
||||
func tokenNext(c *gin.Context, user dbModel.User) {
|
||||
func tokenNext(c *gin.Context, user sysModel.SysUser) {
|
||||
j := &middleware.JWT{
|
||||
[]byte("qmPlus"), // 唯一签名
|
||||
}
|
||||
@@ -93,7 +93,7 @@ type ChangePasswordStutrc struct {
|
||||
NewPassword string `json:"newPassword"`
|
||||
}
|
||||
|
||||
// @Tags User
|
||||
// @Tags SysUser
|
||||
// @Summary 用户修改密码
|
||||
// @Security ApiKeyAuth
|
||||
// @Produce application/json
|
||||
@@ -103,7 +103,7 @@ type ChangePasswordStutrc struct {
|
||||
func ChangePassword(c *gin.Context) {
|
||||
var params ChangePasswordStutrc
|
||||
_ = c.BindJSON(¶ms)
|
||||
U := &dbModel.User{Username: params.Username, Password: params.Password}
|
||||
U := &sysModel.SysUser{Username: params.Username, Password: params.Password}
|
||||
if err, _ := U.ChangePassword(params.NewPassword); err != nil {
|
||||
servers.ReportFormat(c, false, "修改失败,请检查用户名密码", gin.H{})
|
||||
} else {
|
||||
@@ -115,7 +115,7 @@ type UserHeaderImg struct {
|
||||
HeaderImg multipart.File `json:"headerImg"`
|
||||
}
|
||||
|
||||
// @Tags User
|
||||
// @Tags SysUser
|
||||
// @Summary 用户上传头像
|
||||
// @Security ApiKeyAuth
|
||||
// @accept multipart/form-data
|
||||
@@ -141,7 +141,7 @@ func UploadHeaderImg(c *gin.Context) {
|
||||
servers.ReportFormat(c, false, fmt.Sprintf("接收返回值失败,%v", err), gin.H{})
|
||||
} else {
|
||||
//修改数据库后得到修改后的user并且返回供前端使用
|
||||
err, user := new(dbModel.User).UploadHeaderImg(uuid, filePath)
|
||||
err, user := new(sysModel.SysUser).UploadHeaderImg(uuid, filePath)
|
||||
if err != nil {
|
||||
servers.ReportFormat(c, false, fmt.Sprintf("修改数据库链接失败,%v", err), gin.H{})
|
||||
} else {
|
||||
@@ -151,7 +151,7 @@ func UploadHeaderImg(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// @Tags User
|
||||
// @Tags SysUser
|
||||
// @Summary 分页获取用户列表
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
@@ -162,7 +162,7 @@ func UploadHeaderImg(c *gin.Context) {
|
||||
func GetUserList(c *gin.Context) {
|
||||
var pageInfo modelInterface.PageInfo
|
||||
_ = c.BindJSON(&pageInfo)
|
||||
err, list, total := new(dbModel.User).GetInfoList(pageInfo)
|
||||
err, list, total := new(sysModel.SysUser).GetInfoList(pageInfo)
|
||||
if err != nil {
|
||||
servers.ReportFormat(c, false, fmt.Sprintf("获取数据失败,%v", err), gin.H{})
|
||||
} else {
|
||||
@@ -180,7 +180,7 @@ type SetUserAuth struct {
|
||||
AuthorityId string `json:"authorityId"`
|
||||
}
|
||||
|
||||
// @Tags User
|
||||
// @Tags SysUser
|
||||
// @Summary 设置用户权限
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
@@ -191,7 +191,7 @@ type SetUserAuth struct {
|
||||
func SetUserAuthority(c *gin.Context) {
|
||||
var sua SetUserAuth
|
||||
_ = c.BindJSON(&sua)
|
||||
err := new(dbModel.User).SetUserAuthority(sua.UUID, sua.AuthorityId)
|
||||
err := new(sysModel.SysUser).SetUserAuthority(sua.UUID, sua.AuthorityId)
|
||||
if err != nil {
|
||||
servers.ReportFormat(c, false, fmt.Sprintf("修改失败,%v", err), gin.H{})
|
||||
} else {
|
@@ -4,17 +4,17 @@ import (
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"main/controller/servers"
|
||||
"main/model/dbModel"
|
||||
"main/model/sysModel"
|
||||
)
|
||||
|
||||
// @Tags workflow
|
||||
// @Summary 注册工作流
|
||||
// @Produce application/json
|
||||
// @Param data body dbModel.Workflow true "注册工作流接口"
|
||||
// @Param data body sysModel.SysWorkflow true "注册工作流接口"
|
||||
// @Success 200 {string} json "{"success":true,"data":{},"msg":"注册成功"}"
|
||||
// @Router /workflow/createWorkFlow [post]
|
||||
func CreateWorkFlow(c *gin.Context) {
|
||||
var wk dbModel.Workflow
|
||||
var wk sysModel.SysWorkflow
|
||||
_ = c.ShouldBind(&wk)
|
||||
err := wk.Create()
|
||||
if err != nil {
|
Reference in New Issue
Block a user