✨ init project
This commit is contained in:
49
plugin/announcement/initialize/api.go
Normal file
49
plugin/announcement/initialize/api.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package initialize
|
||||
|
||||
import (
|
||||
"context"
|
||||
model "git.echol.cn/loser/lckt/model/system"
|
||||
"git.echol.cn/loser/lckt/plugin/plugin-tool/utils"
|
||||
)
|
||||
|
||||
func Api(ctx context.Context) {
|
||||
entities := []model.SysApi{
|
||||
{
|
||||
Path: "/info/createInfo",
|
||||
Description: "新建公告",
|
||||
ApiGroup: "公告",
|
||||
Method: "POST",
|
||||
},
|
||||
{
|
||||
Path: "/info/deleteInfo",
|
||||
Description: "删除公告",
|
||||
ApiGroup: "公告",
|
||||
Method: "DELETE",
|
||||
},
|
||||
{
|
||||
Path: "/info/deleteInfoByIds",
|
||||
Description: "批量删除公告",
|
||||
ApiGroup: "公告",
|
||||
Method: "DELETE",
|
||||
},
|
||||
{
|
||||
Path: "/info/updateInfo",
|
||||
Description: "更新公告",
|
||||
ApiGroup: "公告",
|
||||
Method: "PUT",
|
||||
},
|
||||
{
|
||||
Path: "/info/findInfo",
|
||||
Description: "根据ID获取公告",
|
||||
ApiGroup: "公告",
|
||||
Method: "GET",
|
||||
},
|
||||
{
|
||||
Path: "/info/getInfoList",
|
||||
Description: "获取公告列表",
|
||||
ApiGroup: "公告",
|
||||
Method: "GET",
|
||||
},
|
||||
}
|
||||
utils.RegisterApis(entities...)
|
||||
}
|
||||
20
plugin/announcement/initialize/gorm.go
Normal file
20
plugin/announcement/initialize/gorm.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package initialize
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"git.echol.cn/loser/lckt/global"
|
||||
"git.echol.cn/loser/lckt/plugin/announcement/model"
|
||||
"github.com/pkg/errors"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func Gorm(ctx context.Context) {
|
||||
err := global.GVA_DB.WithContext(ctx).AutoMigrate(
|
||||
new(model.Info),
|
||||
)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "注册表失败!")
|
||||
zap.L().Error(fmt.Sprintf("%+v", err))
|
||||
}
|
||||
}
|
||||
22
plugin/announcement/initialize/menu.go
Normal file
22
plugin/announcement/initialize/menu.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package initialize
|
||||
|
||||
import (
|
||||
"context"
|
||||
model "git.echol.cn/loser/lckt/model/system"
|
||||
"git.echol.cn/loser/lckt/plugin/plugin-tool/utils"
|
||||
)
|
||||
|
||||
func Menu(ctx context.Context) {
|
||||
entities := []model.SysBaseMenu{
|
||||
{
|
||||
ParentId: 24,
|
||||
Path: "anInfo",
|
||||
Name: "anInfo",
|
||||
Hidden: false,
|
||||
Component: "plugin/announcement/view/info.vue",
|
||||
Sort: 5,
|
||||
Meta: model.Meta{Title: "公告管理", Icon: "box"},
|
||||
},
|
||||
}
|
||||
utils.RegisterMenus(entities...)
|
||||
}
|
||||
15
plugin/announcement/initialize/router.go
Normal file
15
plugin/announcement/initialize/router.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package initialize
|
||||
|
||||
import (
|
||||
"git.echol.cn/loser/lckt/global"
|
||||
"git.echol.cn/loser/lckt/middleware"
|
||||
"git.echol.cn/loser/lckt/plugin/announcement/router"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func Router(engine *gin.Engine) {
|
||||
public := engine.Group(global.GVA_CONFIG.System.RouterPrefix).Group("")
|
||||
private := engine.Group(global.GVA_CONFIG.System.RouterPrefix).Group("")
|
||||
private.Use(middleware.JWTAuth()).Use(middleware.CasbinHandler())
|
||||
router.Router.Info.Init(public, private)
|
||||
}
|
||||
17
plugin/announcement/initialize/viper.go
Normal file
17
plugin/announcement/initialize/viper.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package initialize
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.echol.cn/loser/lckt/global"
|
||||
"git.echol.cn/loser/lckt/plugin/announcement/plugin"
|
||||
"github.com/pkg/errors"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func Viper() {
|
||||
err := global.GVA_VP.UnmarshalKey("announcement", &plugin.Config)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "初始化配置文件失败!")
|
||||
zap.L().Error(fmt.Sprintf("%+v", err))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user