mirror of
https://github.com/flipped-aurora/gin-vue-admin.git
synced 2026-09-21 20:35:16 +00:00
Migrate all methods in the model package to the service package
This commit is contained in:
+19
-18
@@ -3,8 +3,9 @@ package v1
|
||||
import (
|
||||
"fmt"
|
||||
"gin-vue-admin/global/response"
|
||||
"gin-vue-admin/middleware"
|
||||
"gin-vue-admin/model"
|
||||
"gin-vue-admin/model/request"
|
||||
"gin-vue-admin/service"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
@@ -17,8 +18,8 @@ import (
|
||||
// @Router /menu/getMenu [post]
|
||||
func GetMenu(c *gin.Context) {
|
||||
claims, _ := c.Get("claims")
|
||||
waitUse := claims.(*middleware.CustomClaims)
|
||||
err, menus := new(model.SysMenu).GetMenuTree(waitUse.AuthorityId)
|
||||
waitUse := claims.(*request.CustomClaims)
|
||||
err, menus := service.GetMenuTree(waitUse.AuthorityId)
|
||||
if err != nil {
|
||||
response.Result(response.ERROR, gin.H{}, fmt.Sprintf("获取失败,%v", err), c)
|
||||
} else {
|
||||
@@ -35,9 +36,9 @@ func GetMenu(c *gin.Context) {
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
// @Router /menu/getMenuList [post]
|
||||
func GetMenuList(c *gin.Context) {
|
||||
var pageInfo model.PageInfo
|
||||
var pageInfo request.PageInfo
|
||||
_ = c.ShouldBindJSON(&pageInfo)
|
||||
err, menuList, total := new(model.SysBaseMenu).GetInfoList(pageInfo)
|
||||
err, menuList, total := service.GetInfoList(pageInfo)
|
||||
if err != nil {
|
||||
response.Result(response.ERROR, gin.H{}, fmt.Sprintf("获取数据失败,%v", err), c)
|
||||
} else {
|
||||
@@ -59,9 +60,9 @@ func GetMenuList(c *gin.Context) {
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
// @Router /menu/addBaseMenu [post]
|
||||
func AddBaseMenu(c *gin.Context) {
|
||||
var addMenu model.SysBaseMenu
|
||||
_ = c.ShouldBindJSON(&addMenu)
|
||||
err := addMenu.AddBaseMenu()
|
||||
var menu model.SysBaseMenu
|
||||
_ = c.ShouldBindJSON(&menu)
|
||||
err := service.AddBaseMenu(menu)
|
||||
if err != nil {
|
||||
response.Result(response.ERROR, gin.H{}, fmt.Sprintf("添加失败,%v", err), c)
|
||||
} else {
|
||||
@@ -77,7 +78,7 @@ func AddBaseMenu(c *gin.Context) {
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"返回成功"}"
|
||||
// @Router /menu/getBaseMenuTree [post]
|
||||
func GetBaseMenuTree(c *gin.Context) {
|
||||
err, menus := new(model.SysBaseMenu).GetBaseMenuTree()
|
||||
err, menus := service.GetBaseMenuTree()
|
||||
if err != nil {
|
||||
response.Result(response.ERROR, gin.H{"menus": menus}, fmt.Sprintf("获取失败,%v", err), c)
|
||||
} else {
|
||||
@@ -95,10 +96,10 @@ func GetBaseMenuTree(c *gin.Context) {
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
// @Router /menu/addMenuAuthority [post]
|
||||
func AddMenuAuthority(c *gin.Context) {
|
||||
var addMenuAuthorityInfo model.AddMenuAuthorityInfo
|
||||
var addMenuAuthorityInfo request.AddMenuAuthorityInfo
|
||||
_ = c.ShouldBindJSON(&addMenuAuthorityInfo)
|
||||
|
||||
err := new(model.SysMenu).AddMenuAuthority(addMenuAuthorityInfo.Menus, addMenuAuthorityInfo.AuthorityId)
|
||||
err := service.AddMenuAuthority(addMenuAuthorityInfo.Menus, addMenuAuthorityInfo.AuthorityId)
|
||||
if err != nil {
|
||||
response.Result(response.ERROR, gin.H{}, fmt.Sprintf("添加失败,%v", err), c)
|
||||
} else {
|
||||
@@ -115,9 +116,9 @@ func AddMenuAuthority(c *gin.Context) {
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
// @Router /menu/GetMenuAuthority [post]
|
||||
func GetMenuAuthority(c *gin.Context) {
|
||||
var authorityIdInfo model.AuthorityIdInfo
|
||||
var authorityIdInfo request.AuthorityIdInfo
|
||||
_ = c.ShouldBindJSON(&authorityIdInfo)
|
||||
err, menus := new(model.SysMenu).GetMenuAuthority(authorityIdInfo.AuthorityId)
|
||||
err, menus := service.GetMenuAuthority(authorityIdInfo.AuthorityId)
|
||||
if err != nil {
|
||||
response.Result(response.ERROR, gin.H{"menus": menus}, fmt.Sprintf("添加失败,%v", err), c)
|
||||
} else {
|
||||
@@ -134,9 +135,9 @@ func GetMenuAuthority(c *gin.Context) {
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
// @Router /menu/deleteBaseMenu [post]
|
||||
func DeleteBaseMenu(c *gin.Context) {
|
||||
var idInfo model.GetById
|
||||
var idInfo request.GetById
|
||||
_ = c.ShouldBindJSON(&idInfo)
|
||||
err := new(model.SysBaseMenu).DeleteBaseMenu(idInfo.Id)
|
||||
err := service.DeleteBaseMenu(idInfo.Id)
|
||||
if err != nil {
|
||||
response.Result(response.ERROR, gin.H{}, fmt.Sprintf("删除失败:%v", err), c)
|
||||
} else {
|
||||
@@ -156,7 +157,7 @@ func DeleteBaseMenu(c *gin.Context) {
|
||||
func UpdateBaseMenu(c *gin.Context) {
|
||||
var menu model.SysBaseMenu
|
||||
_ = c.ShouldBindJSON(&menu)
|
||||
err := menu.UpdateBaseMenu()
|
||||
err := service.UpdateBaseMenu(menu)
|
||||
if err != nil {
|
||||
response.Result(response.ERROR, gin.H{}, fmt.Sprintf("修改失败:%v", err), c)
|
||||
} else {
|
||||
@@ -173,9 +174,9 @@ func UpdateBaseMenu(c *gin.Context) {
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
// @Router /menu/getBaseMenuById [post]
|
||||
func GetBaseMenuById(c *gin.Context) {
|
||||
var idInfo model.GetById
|
||||
var idInfo request.GetById
|
||||
_ = c.ShouldBindJSON(&idInfo)
|
||||
err, menu := new(model.SysBaseMenu).GetBaseMenuById(idInfo.Id)
|
||||
err, menu := service.GetBaseMenuById(idInfo.Id)
|
||||
if err != nil {
|
||||
response.Result(response.ERROR, gin.H{}, fmt.Sprintf("查询失败:%v", err), c)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user