增加了bus 增加了分块区滚动 增加了table 增加了分页 修改了某些分页接口 角色增删

This commit is contained in:
pixelqm
2019-09-18 22:26:53 +08:00
parent 4b09e72db5
commit dc4700c557
21 changed files with 502 additions and 39 deletions

View File

@@ -5,10 +5,11 @@ import (
"github.com/gin-gonic/gin"
"main/controller/servers"
"main/model/dbModel"
"main/model/modelInterface"
)
type CreateAuthorityPatams struct {
AuthorityId uint `json:"authorityId"`
AuthorityId string `json:"authorityId"`
AuthorityName string `json:"authorityName"`
}
@@ -22,7 +23,7 @@ type CreateAuthorityPatams struct {
// @Router /authority/createAuthority [post]
func CreateAuthority(c *gin.Context) {
var auth dbModel.Authority
_ = c.BindJSON(&auth)
_ = c.ShouldBind(&auth)
err, authBack := auth.CreateAuthority()
if err != nil {
servers.ReportFormat(c, false, fmt.Sprintf("创建失败:%v", err), gin.H{
@@ -58,3 +59,27 @@ func DeleteAuthority(c *gin.Context) {
servers.ReportFormat(c, true, "删除成功", gin.H{})
}
}
// @Tags authority
// @Summary 分页获取角色列表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body modelInterface.PageInfo true "分页获取用户列表"
// @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /authority/getAuthorityList [post]
func GetAuthorityList(c *gin.Context){
var pageInfo modelInterface.PageInfo
_ = c.BindJSON(&pageInfo)
err, list, total := new(dbModel.Authority).GetInfoList(pageInfo)
if err != nil {
servers.ReportFormat(c, false, fmt.Sprintf("获取数据失败,%v", err), gin.H{})
} else {
servers.ReportFormat(c, true, "获取数据成功", gin.H{
"authList": list,
"total": total,
"page": pageInfo.Page,
"pageSize": pageInfo.PageSize,
})
}
}

View File

@@ -3,12 +3,14 @@ package dbModel
import (
"github.com/jinzhu/gorm"
"github.com/pkg/errors"
"main/controller/servers"
"main/init/qmsql"
"main/model/modelInterface"
)
type Authority struct {
gorm.Model `json:"-"`
AuthorityId uint `json:"authorityId" gorm:"not null;unique"`
AuthorityId string `json:"authorityId" gorm:"not null;unique"`
AuthorityName string `json:"authorityName"`
}
@@ -28,3 +30,18 @@ func (a *Authority) DeleteAuthority() (err error) {
}
return err
}
// 分页获取数据 需要分页实现这个接口即可
func (a *Authority) GetInfoList(info modelInterface.PageInfo) (err error, list interface{}, total int) {
// 封装分页方法 调用即可 传入 当前的结构体和分页信息
err, db, total := servers.PagingServer(a, info)
if err != nil {
return
} else {
var authority []Authority
err = db.Find(&authority).Error
return err, authority, total
}
}

View File

@@ -11,5 +11,6 @@ func InitAuthorityRouter(Router *gin.Engine) {
{
AuthorityRouter.POST("createAuthority", api.CreateAuthority)
AuthorityRouter.POST("deleteAuthority", api.DeleteAuthority)
AuthorityRouter.POST("getAuthorityList",api.GetAuthorityList)
}
}