init: init refactor
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
Name: system-api
|
||||
Host: 0.0.0.0
|
||||
Port: 9003
|
||||
|
||||
Auth:
|
||||
AccessSecret: 9149f2eb-d517-4a50-a03a-231dbcf0d872
|
||||
AccessExpire: 7200
|
||||
|
||||
DB:
|
||||
DataSource: root:root@tcp(192.168.100.127:3307)/sundynix_micro_go?charset=utf8mb4&parseTime=True&loc=Local
|
||||
|
||||
# system-rpc 服务配置
|
||||
SystemRpc:
|
||||
Etcd:
|
||||
Hosts:
|
||||
- 192.168.100.127:2379
|
||||
Key: system.rpc
|
||||
@@ -0,0 +1,21 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package config
|
||||
|
||||
import (
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
"github.com/zeromicro/go-zero/zrpc"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
rest.RestConf
|
||||
Auth struct {
|
||||
AccessSecret string
|
||||
AccessExpire int64
|
||||
}
|
||||
SystemRpc zrpc.RpcClientConf
|
||||
DB struct {
|
||||
DataSource string
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package client
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/system/api/internal/logic/client"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 创建客户端
|
||||
func CreateClientHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.ClientReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := client.NewCreateClientLogic(r.Context(), svcCtx)
|
||||
err := l.CreateClient(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package client
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/system/api/internal/logic/client"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 删除客户端
|
||||
func DeleteClientHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.IdsReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := client.NewDeleteClientLogic(r.Context(), svcCtx)
|
||||
err := l.DeleteClient(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package client
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/system/api/internal/logic/client"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 客户端列表
|
||||
func GetClientListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.ClientListReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := client.NewGetClientListLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetClientList(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.OkWithData(w, resp)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package client
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/system/api/internal/logic/client"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 更新客户端
|
||||
func UpdateClientHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.ClientUpdateReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := client.NewUpdateClientLogic(r.Context(), svcCtx)
|
||||
err := l.UpdateClient(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package dict
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/system/api/internal/logic/dict"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 创建字典
|
||||
func CreateDictHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.DictReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := dict.NewCreateDictLogic(r.Context(), svcCtx)
|
||||
err := l.CreateDict(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package dict
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/system/api/internal/logic/dict"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 删除字典
|
||||
func DeleteDictHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.IdsReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := dict.NewDeleteDictLogic(r.Context(), svcCtx)
|
||||
err := l.DeleteDict(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package dict
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/system/api/internal/logic/dict"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 字典列表
|
||||
func GetDictListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.DictListReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := dict.NewGetDictListLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetDictList(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.OkWithData(w, resp)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package dict
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/system/api/internal/logic/dict"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 更新字典
|
||||
func UpdateDictHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.DictUpdateReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := dict.NewUpdateDictLogic(r.Context(), svcCtx)
|
||||
err := l.UpdateDict(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package menu
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/system/api/internal/logic/menu"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 创建菜单
|
||||
func CreateMenuHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.MenuReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := menu.NewCreateMenuLogic(r.Context(), svcCtx)
|
||||
err := l.CreateMenu(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package menu
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/system/api/internal/logic/menu"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 删除菜单
|
||||
func DeleteMenuHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.IdsReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := menu.NewDeleteMenuLogic(r.Context(), svcCtx)
|
||||
err := l.DeleteMenu(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package menu
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/system/api/internal/logic/menu"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 根据角色获取菜单
|
||||
func GetMenuByRoleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.IdReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := menu.NewGetMenuByRoleLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetMenuByRole(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.OkWithData(w, resp)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package menu
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"sundynix-micro-go/app/system/api/internal/logic/menu"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 菜单列表(树形)
|
||||
func GetMenuListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
l := menu.NewGetMenuListLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetMenuList()
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.OkWithData(w, resp)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package menu
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/system/api/internal/logic/menu"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 更新菜单
|
||||
func UpdateMenuHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.MenuUpdateReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := menu.NewUpdateMenuLogic(r.Context(), svcCtx)
|
||||
err := l.UpdateMenu(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package operationRecord
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/system/api/internal/logic/operationRecord"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 删除操作日志
|
||||
func DeleteOperationRecordHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.IdsReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := operationRecord.NewDeleteOperationRecordLogic(r.Context(), svcCtx)
|
||||
err := l.DeleteOperationRecord(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package operationRecord
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
operationrecord "sundynix-micro-go/app/system/api/internal/logic/operationRecord"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 操作日志列表
|
||||
func GetOperationRecordListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.OperationRecordListReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := operationrecord.NewGetOperationRecordListLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetOperationRecordList(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.OkWithData(w, resp)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package role
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/system/api/internal/logic/role"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 创建角色
|
||||
func CreateRoleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.RoleReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := role.NewCreateRoleLogic(r.Context(), svcCtx)
|
||||
err := l.CreateRole(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package role
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/system/api/internal/logic/role"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 删除角色
|
||||
func DeleteRoleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.IdsReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := role.NewDeleteRoleLogic(r.Context(), svcCtx)
|
||||
err := l.DeleteRole(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package role
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/system/api/internal/logic/role"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 角色列表
|
||||
func GetRoleListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.RoleListReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := role.NewGetRoleListLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetRoleList(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.OkWithData(w, resp)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package role
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/system/api/internal/logic/role"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 更新角色
|
||||
func UpdateRoleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.RoleUpdateReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := role.NewUpdateRoleLogic(r.Context(), svcCtx)
|
||||
err := l.UpdateRole(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
// Code generated by goctl. DO NOT EDIT.
|
||||
// goctl 1.10.1
|
||||
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
client "sundynix-micro-go/app/system/api/internal/handler/client"
|
||||
dict "sundynix-micro-go/app/system/api/internal/handler/dict"
|
||||
menu "sundynix-micro-go/app/system/api/internal/handler/menu"
|
||||
operationRecord "sundynix-micro-go/app/system/api/internal/handler/operationRecord"
|
||||
role "sundynix-micro-go/app/system/api/internal/handler/role"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
)
|
||||
|
||||
func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
// 创建客户端
|
||||
Method: http.MethodPost,
|
||||
Path: "/client/create",
|
||||
Handler: client.CreateClientHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 删除客户端
|
||||
Method: http.MethodDelete,
|
||||
Path: "/client/delete",
|
||||
Handler: client.DeleteClientHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 客户端列表
|
||||
Method: http.MethodPost,
|
||||
Path: "/client/list",
|
||||
Handler: client.GetClientListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 更新客户端
|
||||
Method: http.MethodPut,
|
||||
Path: "/client/update",
|
||||
Handler: client.UpdateClientHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
rest.WithPrefix("/api/sys"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
// 创建字典
|
||||
Method: http.MethodPost,
|
||||
Path: "/dict/create",
|
||||
Handler: dict.CreateDictHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 删除字典
|
||||
Method: http.MethodDelete,
|
||||
Path: "/dict/delete",
|
||||
Handler: dict.DeleteDictHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 字典列表
|
||||
Method: http.MethodPost,
|
||||
Path: "/dict/list",
|
||||
Handler: dict.GetDictListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 更新字典
|
||||
Method: http.MethodPut,
|
||||
Path: "/dict/update",
|
||||
Handler: dict.UpdateDictHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
rest.WithPrefix("/api/sys"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
// 根据角色获取菜单
|
||||
Method: http.MethodPost,
|
||||
Path: "/menu/byRole",
|
||||
Handler: menu.GetMenuByRoleHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 创建菜单
|
||||
Method: http.MethodPost,
|
||||
Path: "/menu/create",
|
||||
Handler: menu.CreateMenuHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 删除菜单
|
||||
Method: http.MethodDelete,
|
||||
Path: "/menu/delete",
|
||||
Handler: menu.DeleteMenuHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 菜单列表(树形)
|
||||
Method: http.MethodGet,
|
||||
Path: "/menu/list",
|
||||
Handler: menu.GetMenuListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 更新菜单
|
||||
Method: http.MethodPut,
|
||||
Path: "/menu/update",
|
||||
Handler: menu.UpdateMenuHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
rest.WithPrefix("/api/sys"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
// 删除操作日志
|
||||
Method: http.MethodDelete,
|
||||
Path: "/log/delete",
|
||||
Handler: operationRecord.DeleteOperationRecordHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 操作日志列表
|
||||
Method: http.MethodPost,
|
||||
Path: "/log/list",
|
||||
Handler: operationRecord.GetOperationRecordListHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
rest.WithPrefix("/api/sys"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
// 创建角色
|
||||
Method: http.MethodPost,
|
||||
Path: "/role/create",
|
||||
Handler: role.CreateRoleHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 删除角色
|
||||
Method: http.MethodDelete,
|
||||
Path: "/role/delete",
|
||||
Handler: role.DeleteRoleHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 角色列表
|
||||
Method: http.MethodPost,
|
||||
Path: "/role/list",
|
||||
Handler: role.GetRoleListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 更新角色
|
||||
Method: http.MethodPut,
|
||||
Path: "/role/update",
|
||||
Handler: role.UpdateRoleHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
rest.WithPrefix("/api/sys"),
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
sysModel "sundynix-micro-go/app/system/model"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type CreateClientLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewCreateClientLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateClientLogic {
|
||||
return &CreateClientLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *CreateClientLogic) CreateClient(req *types.ClientReq) error {
|
||||
client := sysModel.SundynixClient{
|
||||
ClientID: req.ClientId,
|
||||
Name: req.Name,
|
||||
GrantType: req.GrantType,
|
||||
AdditionalInfo: req.AdditionalInfo,
|
||||
ActiveTimeout: req.ActiveTimeout,
|
||||
}
|
||||
if err := l.svcCtx.DB.Create(&client).Error; err != nil {
|
||||
l.Errorf("创建客户端失败: %v", err)
|
||||
return fmt.Errorf("创建客户端失败")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
sysModel "sundynix-micro-go/app/system/model"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type DeleteClientLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewDeleteClientLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteClientLogic {
|
||||
return &DeleteClientLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *DeleteClientLogic) DeleteClient(req *types.IdsReq) error {
|
||||
if err := l.svcCtx.DB.Where("id IN ?", req.Ids).Delete(&sysModel.SundynixClient{}).Error; err != nil {
|
||||
l.Errorf("删除客户端失败: %v", err)
|
||||
return fmt.Errorf("删除客户端失败")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
sysModel "sundynix-micro-go/app/system/model"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetClientListLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetClientListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetClientListLogic {
|
||||
return &GetClientListLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetClientListLogic) GetClientList(req *types.ClientListReq) (resp interface{}, err error) {
|
||||
var clients []sysModel.SundynixClient
|
||||
var total int64
|
||||
|
||||
db := l.svcCtx.DB.Model(&sysModel.SundynixClient{})
|
||||
if req.Name != "" {
|
||||
db = db.Where("name LIKE ?", "%"+req.Name+"%")
|
||||
}
|
||||
|
||||
if err := db.Count(&total).Error; err != nil {
|
||||
l.Errorf("查询客户端总数失败: %v", err)
|
||||
return nil, fmt.Errorf("查询失败")
|
||||
}
|
||||
|
||||
current := req.Current
|
||||
pageSize := req.PageSize
|
||||
if current <= 0 {
|
||||
current = 1
|
||||
}
|
||||
if pageSize <= 0 {
|
||||
pageSize = 10
|
||||
}
|
||||
|
||||
offset := (current - 1) * pageSize
|
||||
if err := db.Offset(offset).Limit(pageSize).Find(&clients).Error; err != nil {
|
||||
l.Errorf("查询客户端列表失败: %v", err)
|
||||
return nil, fmt.Errorf("查询失败")
|
||||
}
|
||||
|
||||
return map[string]interface{}{
|
||||
"list": clients,
|
||||
"total": total,
|
||||
"current": current,
|
||||
"size": pageSize,
|
||||
}, nil
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
sysModel "sundynix-micro-go/app/system/model"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type UpdateClientLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewUpdateClientLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateClientLogic {
|
||||
return &UpdateClientLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *UpdateClientLogic) UpdateClient(req *types.ClientUpdateReq) error {
|
||||
updates := map[string]interface{}{}
|
||||
if req.ClientId != "" {
|
||||
updates["client_id"] = req.ClientId
|
||||
}
|
||||
if req.Name != "" {
|
||||
updates["name"] = req.Name
|
||||
}
|
||||
if req.GrantType != "" {
|
||||
updates["grant_type"] = req.GrantType
|
||||
}
|
||||
if req.AdditionalInfo != "" {
|
||||
updates["additional_info"] = req.AdditionalInfo
|
||||
}
|
||||
if req.ActiveTimeout > 0 {
|
||||
updates["active_timeout"] = req.ActiveTimeout
|
||||
}
|
||||
|
||||
if err := l.svcCtx.DB.Model(&sysModel.SundynixClient{}).Where("id = ?", req.Id).Updates(updates).Error; err != nil {
|
||||
l.Errorf("更新客户端失败: %v", err)
|
||||
return fmt.Errorf("更新客户端失败")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
package dict
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
sysModel "sundynix-micro-go/app/system/model"
|
||||
)
|
||||
|
||||
type CreateDictLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewCreateDictLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateDictLogic {
|
||||
return &CreateDictLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *CreateDictLogic) CreateDict(req *types.DictReq) error {
|
||||
dict := sysModel.SundynixDict{Type: req.Type, Label: req.Label, Value: req.Value, Sort: req.Sort, Desc: req.Desc}
|
||||
if err := l.svcCtx.DB.Create(&dict).Error; err != nil {
|
||||
return fmt.Errorf("创建字典失败")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
package dict
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
sysModel "sundynix-micro-go/app/system/model"
|
||||
)
|
||||
|
||||
type DeleteDictLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewDeleteDictLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteDictLogic {
|
||||
return &DeleteDictLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *DeleteDictLogic) DeleteDict(req *types.IdsReq) error {
|
||||
if err := l.svcCtx.DB.Where("id IN ?", req.Ids).Delete(&sysModel.SundynixDict{}).Error; err != nil {
|
||||
return fmt.Errorf("删除字典失败")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
package dict
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
sysModel "sundynix-micro-go/app/system/model"
|
||||
)
|
||||
|
||||
type GetDictListLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetDictListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetDictListLogic {
|
||||
return &GetDictListLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *GetDictListLogic) GetDictList(req *types.DictListReq) (resp interface{}, err error) {
|
||||
var dicts []sysModel.SundynixDict
|
||||
var total int64
|
||||
db := l.svcCtx.DB.Model(&sysModel.SundynixDict{})
|
||||
if req.Type != "" {
|
||||
db = db.Where("type = ?", req.Type)
|
||||
}
|
||||
db.Count(&total)
|
||||
current, pageSize := req.Current, req.PageSize
|
||||
if current <= 0 {
|
||||
current = 1
|
||||
}
|
||||
if pageSize <= 0 {
|
||||
pageSize = 10
|
||||
}
|
||||
if err := db.Offset((current - 1) * pageSize).Limit(pageSize).Order("sort").Find(&dicts).Error; err != nil {
|
||||
return nil, fmt.Errorf("查询字典列表失败")
|
||||
}
|
||||
return map[string]interface{}{"list": dicts, "total": total, "current": current, "size": pageSize}, nil
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
package dict
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
sysModel "sundynix-micro-go/app/system/model"
|
||||
)
|
||||
|
||||
type UpdateDictLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewUpdateDictLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateDictLogic {
|
||||
return &UpdateDictLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *UpdateDictLogic) UpdateDict(req *types.DictUpdateReq) error {
|
||||
updates := map[string]interface{}{}
|
||||
if req.Type != "" {
|
||||
updates["type"] = req.Type
|
||||
}
|
||||
if req.Label != "" {
|
||||
updates["label"] = req.Label
|
||||
}
|
||||
if req.Value != "" {
|
||||
updates["value"] = req.Value
|
||||
}
|
||||
if req.Sort > 0 {
|
||||
updates["sort"] = req.Sort
|
||||
}
|
||||
if req.Desc != "" {
|
||||
updates["desc"] = req.Desc
|
||||
}
|
||||
if len(updates) > 0 {
|
||||
if err := l.svcCtx.DB.Model(&sysModel.SundynixDict{}).Where("id = ?", req.Id).Updates(updates).Error; err != nil {
|
||||
return fmt.Errorf("更新字典失败")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
package menu
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
sysModel "sundynix-micro-go/app/system/model"
|
||||
)
|
||||
|
||||
type CreateMenuLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewCreateMenuLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateMenuLogic {
|
||||
return &CreateMenuLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *CreateMenuLogic) CreateMenu(req *types.MenuReq) error {
|
||||
menu := sysModel.SundynixMenu{
|
||||
ParentID: req.ParentId, Category: req.Category, Name: req.Name, Title: req.Title,
|
||||
Code: req.Code, Path: req.Path, Permission: req.Permission, Locale: req.Locale,
|
||||
Icon: req.Icon, Sort: req.Sort,
|
||||
}
|
||||
if menu.ParentID == "" {
|
||||
menu.ParentID = "0"
|
||||
}
|
||||
if err := l.svcCtx.DB.Create(&menu).Error; err != nil {
|
||||
return fmt.Errorf("创建菜单失败")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
package menu
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
sysModel "sundynix-micro-go/app/system/model"
|
||||
)
|
||||
|
||||
type DeleteMenuLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewDeleteMenuLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteMenuLogic {
|
||||
return &DeleteMenuLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *DeleteMenuLogic) DeleteMenu(req *types.IdsReq) error {
|
||||
if err := l.svcCtx.DB.Where("id IN ?", req.Ids).Delete(&sysModel.SundynixMenu{}).Error; err != nil {
|
||||
return fmt.Errorf("删除菜单失败")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
package menu
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
sysModel "sundynix-micro-go/app/system/model"
|
||||
)
|
||||
|
||||
type GetMenuByRoleLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetMenuByRoleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetMenuByRoleLogic {
|
||||
return &GetMenuByRoleLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *GetMenuByRoleLogic) GetMenuByRole(req *types.IdReq) (resp interface{}, err error) {
|
||||
var role sysModel.SundynixRole
|
||||
if err := l.svcCtx.DB.Preload("Menus").Where("id = ?", req.Id).First(&role).Error; err != nil {
|
||||
return nil, fmt.Errorf("查询角色菜单失败")
|
||||
}
|
||||
return role.Menus, nil
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
package menu
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
sysModel "sundynix-micro-go/app/system/model"
|
||||
)
|
||||
|
||||
type GetMenuListLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetMenuListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetMenuListLogic {
|
||||
return &GetMenuListLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *GetMenuListLogic) GetMenuList() (resp interface{}, err error) {
|
||||
var menus []sysModel.SundynixMenu
|
||||
if err := l.svcCtx.DB.Order("sort").Find(&menus).Error; err != nil {
|
||||
return nil, fmt.Errorf("查询菜单列表失败")
|
||||
}
|
||||
// 构建树形结构
|
||||
menuMap := make(map[string]*sysModel.SundynixMenu)
|
||||
for i := range menus {
|
||||
menus[i].Children = []*sysModel.SundynixMenu{}
|
||||
menuMap[menus[i].ID] = &menus[i]
|
||||
}
|
||||
var tree []*sysModel.SundynixMenu
|
||||
for _, m := range menuMap {
|
||||
if m.ParentID == "0" || m.ParentID == "" {
|
||||
tree = append(tree, m)
|
||||
} else if parent, ok := menuMap[m.ParentID]; ok {
|
||||
parent.Children = append(parent.Children, m)
|
||||
} else {
|
||||
tree = append(tree, m)
|
||||
}
|
||||
}
|
||||
return tree, nil
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
package menu
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
sysModel "sundynix-micro-go/app/system/model"
|
||||
)
|
||||
|
||||
type UpdateMenuLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewUpdateMenuLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateMenuLogic {
|
||||
return &UpdateMenuLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *UpdateMenuLogic) UpdateMenu(req *types.MenuUpdateReq) error {
|
||||
updates := map[string]interface{}{}
|
||||
if req.ParentId != "" {
|
||||
updates["parent_id"] = req.ParentId
|
||||
}
|
||||
if req.Name != "" {
|
||||
updates["name"] = req.Name
|
||||
}
|
||||
if req.Title != "" {
|
||||
updates["title"] = req.Title
|
||||
}
|
||||
if req.Code != "" {
|
||||
updates["code"] = req.Code
|
||||
}
|
||||
if req.Path != "" {
|
||||
updates["path"] = req.Path
|
||||
}
|
||||
if req.Permission != "" {
|
||||
updates["permission"] = req.Permission
|
||||
}
|
||||
if req.Locale != "" {
|
||||
updates["locale"] = req.Locale
|
||||
}
|
||||
if req.Icon != "" {
|
||||
updates["icon"] = req.Icon
|
||||
}
|
||||
if req.Sort > 0 {
|
||||
updates["sort"] = req.Sort
|
||||
}
|
||||
if req.Category > 0 {
|
||||
updates["category"] = req.Category
|
||||
}
|
||||
if len(updates) > 0 {
|
||||
if err := l.svcCtx.DB.Model(&sysModel.SundynixMenu{}).Where("id = ?", req.Id).Updates(updates).Error; err != nil {
|
||||
return fmt.Errorf("更新菜单失败")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
package operationRecord
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
sysModel "sundynix-micro-go/app/system/model"
|
||||
)
|
||||
|
||||
type DeleteOperationRecordLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewDeleteOperationRecordLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteOperationRecordLogic {
|
||||
return &DeleteOperationRecordLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *DeleteOperationRecordLogic) DeleteOperationRecord(req *types.IdsReq) error {
|
||||
if err := l.svcCtx.DB.Where("id IN ?", req.Ids).Delete(&sysModel.SundynixOperationRecord{}).Error; err != nil {
|
||||
return fmt.Errorf("删除操作日志失败")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
package operationRecord
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
sysModel "sundynix-micro-go/app/system/model"
|
||||
)
|
||||
|
||||
type GetOperationRecordListLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetOperationRecordListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetOperationRecordListLogic {
|
||||
return &GetOperationRecordListLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *GetOperationRecordListLogic) GetOperationRecordList(req *types.OperationRecordListReq) (resp interface{}, err error) {
|
||||
var records []sysModel.SundynixOperationRecord
|
||||
var total int64
|
||||
db := l.svcCtx.DB.Model(&sysModel.SundynixOperationRecord{})
|
||||
if req.Method != "" {
|
||||
db = db.Where("method = ?", req.Method)
|
||||
}
|
||||
if req.Path != "" {
|
||||
db = db.Where("path LIKE ?", "%"+req.Path+"%")
|
||||
}
|
||||
if req.Status > 0 {
|
||||
db = db.Where("status = ?", req.Status)
|
||||
}
|
||||
db.Count(&total)
|
||||
current, pageSize := req.Current, req.PageSize
|
||||
if current <= 0 {
|
||||
current = 1
|
||||
}
|
||||
if pageSize <= 0 {
|
||||
pageSize = 10
|
||||
}
|
||||
if err := db.Offset((current - 1) * pageSize).Limit(pageSize).Order("created_at DESC").Find(&records).Error; err != nil {
|
||||
return nil, fmt.Errorf("查询操作日志失败")
|
||||
}
|
||||
return map[string]interface{}{"list": records, "total": total, "current": current, "size": pageSize}, nil
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package role
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
sysModel "sundynix-micro-go/app/system/model"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type CreateRoleLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewCreateRoleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateRoleLogic {
|
||||
return &CreateRoleLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *CreateRoleLogic) CreateRole(req *types.RoleReq) error {
|
||||
role := sysModel.SundynixRole{Name: req.Name, Code: req.Code, Sort: req.Sort}
|
||||
if err := l.svcCtx.DB.Create(&role).Error; err != nil {
|
||||
return fmt.Errorf("创建角色失败")
|
||||
}
|
||||
// 关联菜单
|
||||
if len(req.MenuIds) > 0 {
|
||||
for _, menuID := range req.MenuIds {
|
||||
l.svcCtx.DB.Create(&sysModel.SundynixRoleMenu{RoleID: role.ID, MenuID: menuID})
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
package role
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
sysModel "sundynix-micro-go/app/system/model"
|
||||
)
|
||||
|
||||
type DeleteRoleLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewDeleteRoleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteRoleLogic {
|
||||
return &DeleteRoleLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *DeleteRoleLogic) DeleteRole(req *types.IdsReq) error {
|
||||
if err := l.svcCtx.DB.Where("id IN ?", req.Ids).Delete(&sysModel.SundynixRole{}).Error; err != nil {
|
||||
return fmt.Errorf("删除角色失败")
|
||||
}
|
||||
// 清理角色菜单关联
|
||||
l.svcCtx.DB.Where("role_id IN ?", req.Ids).Delete(&sysModel.SundynixRoleMenu{})
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
package role
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
sysModel "sundynix-micro-go/app/system/model"
|
||||
)
|
||||
|
||||
type GetRoleListLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetRoleListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetRoleListLogic {
|
||||
return &GetRoleListLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *GetRoleListLogic) GetRoleList(req *types.RoleListReq) (resp interface{}, err error) {
|
||||
var roles []sysModel.SundynixRole
|
||||
var total int64
|
||||
db := l.svcCtx.DB.Model(&sysModel.SundynixRole{})
|
||||
if req.Name != "" {
|
||||
db = db.Where("name LIKE ?", "%"+req.Name+"%")
|
||||
}
|
||||
db.Count(&total)
|
||||
current, pageSize := req.Current, req.PageSize
|
||||
if current <= 0 {
|
||||
current = 1
|
||||
}
|
||||
if pageSize <= 0 {
|
||||
pageSize = 10
|
||||
}
|
||||
if err := db.Preload("Menus").Offset((current - 1) * pageSize).Limit(pageSize).Order("sort").Find(&roles).Error; err != nil {
|
||||
return nil, fmt.Errorf("查询角色列表失败")
|
||||
}
|
||||
return map[string]interface{}{"list": roles, "total": total, "current": current, "size": pageSize}, nil
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
package role
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
sysModel "sundynix-micro-go/app/system/model"
|
||||
)
|
||||
|
||||
type UpdateRoleLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewUpdateRoleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateRoleLogic {
|
||||
return &UpdateRoleLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *UpdateRoleLogic) UpdateRole(req *types.RoleUpdateReq) error {
|
||||
updates := map[string]interface{}{}
|
||||
if req.Name != "" {
|
||||
updates["name"] = req.Name
|
||||
}
|
||||
if req.Code != "" {
|
||||
updates["code"] = req.Code
|
||||
}
|
||||
if req.Sort > 0 {
|
||||
updates["sort"] = req.Sort
|
||||
}
|
||||
if len(updates) > 0 {
|
||||
if err := l.svcCtx.DB.Model(&sysModel.SundynixRole{}).Where("id = ?", req.Id).Updates(updates).Error; err != nil {
|
||||
return fmt.Errorf("更新角色失败")
|
||||
}
|
||||
}
|
||||
// 更新菜单关联
|
||||
if len(req.MenuIds) > 0 {
|
||||
l.svcCtx.DB.Where("role_id = ?", req.Id).Delete(&sysModel.SundynixRoleMenu{})
|
||||
for _, menuID := range req.MenuIds {
|
||||
l.svcCtx.DB.Create(&sysModel.SundynixRoleMenu{RoleID: req.Id, MenuID: menuID})
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package svc
|
||||
|
||||
import (
|
||||
"sundynix-micro-go/app/system/api/internal/config"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"gorm.io/driver/mysql"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type ServiceContext struct {
|
||||
Config config.Config
|
||||
DB *gorm.DB
|
||||
}
|
||||
|
||||
func NewServiceContext(c config.Config) *ServiceContext {
|
||||
db, err := gorm.Open(mysql.Open(c.DB.DataSource), &gorm.Config{})
|
||||
if err != nil {
|
||||
logx.Errorf("连接数据库失败: %v", err)
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return &ServiceContext{
|
||||
Config: c,
|
||||
DB: db,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
// Code generated by goctl. DO NOT EDIT.
|
||||
// goctl 1.10.1
|
||||
|
||||
package types
|
||||
|
||||
type ClientListReq struct {
|
||||
Current int `json:"current,optional"`
|
||||
PageSize int `json:"pageSize,optional"`
|
||||
Name string `json:"name,optional"`
|
||||
}
|
||||
|
||||
type ClientReq struct {
|
||||
ClientId string `json:"clientId"`
|
||||
Name string `json:"name"`
|
||||
GrantType string `json:"grantType,optional"`
|
||||
AdditionalInfo string `json:"additionalInfo,optional"`
|
||||
ActiveTimeout int64 `json:"activeTimeout,optional"`
|
||||
}
|
||||
|
||||
type ClientUpdateReq struct {
|
||||
Id string `json:"id"`
|
||||
ClientId string `json:"clientId,optional"`
|
||||
Name string `json:"name,optional"`
|
||||
GrantType string `json:"grantType,optional"`
|
||||
AdditionalInfo string `json:"additionalInfo,optional"`
|
||||
ActiveTimeout int64 `json:"activeTimeout,optional"`
|
||||
}
|
||||
|
||||
type DictListReq struct {
|
||||
Current int `json:"current,optional"`
|
||||
PageSize int `json:"pageSize,optional"`
|
||||
Type string `json:"type,optional"`
|
||||
}
|
||||
|
||||
type DictReq struct {
|
||||
Type string `json:"type"`
|
||||
Label string `json:"label"`
|
||||
Value string `json:"value"`
|
||||
Sort int `json:"sort,optional"`
|
||||
Desc string `json:"desc,optional"`
|
||||
}
|
||||
|
||||
type DictUpdateReq struct {
|
||||
Id string `json:"id"`
|
||||
Type string `json:"type,optional"`
|
||||
Label string `json:"label,optional"`
|
||||
Value string `json:"value,optional"`
|
||||
Sort int `json:"sort,optional"`
|
||||
Desc string `json:"desc,optional"`
|
||||
}
|
||||
|
||||
type IdReq struct {
|
||||
Id string `json:"id"`
|
||||
}
|
||||
|
||||
type IdsReq struct {
|
||||
Ids []string `json:"ids"`
|
||||
}
|
||||
|
||||
type MenuReq struct {
|
||||
ParentId string `json:"parentId,optional"`
|
||||
Category int `json:"category,optional"`
|
||||
Name string `json:"name"`
|
||||
Title string `json:"title,optional"`
|
||||
Code string `json:"code,optional"`
|
||||
Path string `json:"path,optional"`
|
||||
Permission string `json:"permission,optional"`
|
||||
Locale string `json:"locale,optional"`
|
||||
Icon string `json:"icon,optional"`
|
||||
Sort int `json:"sort,optional"`
|
||||
}
|
||||
|
||||
type MenuUpdateReq struct {
|
||||
Id string `json:"id"`
|
||||
ParentId string `json:"parentId,optional"`
|
||||
Category int `json:"category,optional"`
|
||||
Name string `json:"name,optional"`
|
||||
Title string `json:"title,optional"`
|
||||
Code string `json:"code,optional"`
|
||||
Path string `json:"path,optional"`
|
||||
Permission string `json:"permission,optional"`
|
||||
Locale string `json:"locale,optional"`
|
||||
Icon string `json:"icon,optional"`
|
||||
Sort int `json:"sort,optional"`
|
||||
}
|
||||
|
||||
type OperationRecordListReq struct {
|
||||
Current int `json:"current,optional"`
|
||||
PageSize int `json:"pageSize,optional"`
|
||||
Method string `json:"method,optional"`
|
||||
Path string `json:"path,optional"`
|
||||
Status int `json:"status,optional"`
|
||||
}
|
||||
|
||||
type PageReq struct {
|
||||
Current int `json:"current,optional"`
|
||||
PageSize int `json:"pageSize,optional"`
|
||||
Keyword string `json:"keyword,optional"`
|
||||
}
|
||||
|
||||
type RoleListReq struct {
|
||||
Current int `json:"current,optional"`
|
||||
PageSize int `json:"pageSize,optional"`
|
||||
Name string `json:"name,optional"`
|
||||
}
|
||||
|
||||
type RoleReq struct {
|
||||
Name string `json:"name"`
|
||||
Code string `json:"code"`
|
||||
Sort int `json:"sort,optional"`
|
||||
MenuIds []string `json:"menuIds,optional"`
|
||||
}
|
||||
|
||||
type RoleUpdateReq struct {
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name,optional"`
|
||||
Code string `json:"code,optional"`
|
||||
Sort int `json:"sort,optional"`
|
||||
MenuIds []string `json:"menuIds,optional"`
|
||||
}
|
||||
@@ -0,0 +1,231 @@
|
||||
syntax = "v1"
|
||||
|
||||
info (
|
||||
title: "系统服务API"
|
||||
desc: "客户端管理、角色管理、菜单管理、操作日志等HTTP接口"
|
||||
author: "sundynix"
|
||||
version: "v1.0.0"
|
||||
)
|
||||
|
||||
type (
|
||||
// ---------- 通用 ----------
|
||||
IdReq {
|
||||
Id string `json:"id"`
|
||||
}
|
||||
IdsReq {
|
||||
Ids []string `json:"ids"`
|
||||
}
|
||||
PageReq {
|
||||
Current int `json:"current,optional"`
|
||||
PageSize int `json:"pageSize,optional"`
|
||||
Keyword string `json:"keyword,optional"`
|
||||
}
|
||||
// ---------- 客户端 ----------
|
||||
ClientReq {
|
||||
ClientId string `json:"clientId"`
|
||||
Name string `json:"name"`
|
||||
GrantType string `json:"grantType,optional"`
|
||||
AdditionalInfo string `json:"additionalInfo,optional"`
|
||||
ActiveTimeout int64 `json:"activeTimeout,optional"`
|
||||
}
|
||||
ClientUpdateReq {
|
||||
Id string `json:"id"`
|
||||
ClientId string `json:"clientId,optional"`
|
||||
Name string `json:"name,optional"`
|
||||
GrantType string `json:"grantType,optional"`
|
||||
AdditionalInfo string `json:"additionalInfo,optional"`
|
||||
ActiveTimeout int64 `json:"activeTimeout,optional"`
|
||||
}
|
||||
ClientListReq {
|
||||
Current int `json:"current,optional"`
|
||||
PageSize int `json:"pageSize,optional"`
|
||||
Name string `json:"name,optional"`
|
||||
}
|
||||
// ---------- 角色 ----------
|
||||
RoleReq {
|
||||
Name string `json:"name"`
|
||||
Code string `json:"code"`
|
||||
Sort int `json:"sort,optional"`
|
||||
MenuIds []string `json:"menuIds,optional"`
|
||||
}
|
||||
RoleUpdateReq {
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name,optional"`
|
||||
Code string `json:"code,optional"`
|
||||
Sort int `json:"sort,optional"`
|
||||
MenuIds []string `json:"menuIds,optional"`
|
||||
}
|
||||
RoleListReq {
|
||||
Current int `json:"current,optional"`
|
||||
PageSize int `json:"pageSize,optional"`
|
||||
Name string `json:"name,optional"`
|
||||
}
|
||||
// ---------- 菜单 ----------
|
||||
MenuReq {
|
||||
ParentId string `json:"parentId,optional"`
|
||||
Category int `json:"category,optional"`
|
||||
Name string `json:"name"`
|
||||
Title string `json:"title,optional"`
|
||||
Code string `json:"code,optional"`
|
||||
Path string `json:"path,optional"`
|
||||
Permission string `json:"permission,optional"`
|
||||
Locale string `json:"locale,optional"`
|
||||
Icon string `json:"icon,optional"`
|
||||
Sort int `json:"sort,optional"`
|
||||
}
|
||||
MenuUpdateReq {
|
||||
Id string `json:"id"`
|
||||
ParentId string `json:"parentId,optional"`
|
||||
Category int `json:"category,optional"`
|
||||
Name string `json:"name,optional"`
|
||||
Title string `json:"title,optional"`
|
||||
Code string `json:"code,optional"`
|
||||
Path string `json:"path,optional"`
|
||||
Permission string `json:"permission,optional"`
|
||||
Locale string `json:"locale,optional"`
|
||||
Icon string `json:"icon,optional"`
|
||||
Sort int `json:"sort,optional"`
|
||||
}
|
||||
// ---------- 操作日志 ----------
|
||||
OperationRecordListReq {
|
||||
Current int `json:"current,optional"`
|
||||
PageSize int `json:"pageSize,optional"`
|
||||
Method string `json:"method,optional"`
|
||||
Path string `json:"path,optional"`
|
||||
Status int `json:"status,optional"`
|
||||
}
|
||||
// ---------- 字典 ----------
|
||||
DictReq {
|
||||
Type string `json:"type"`
|
||||
Label string `json:"label"`
|
||||
Value string `json:"value"`
|
||||
Sort int `json:"sort,optional"`
|
||||
Desc string `json:"desc,optional"`
|
||||
}
|
||||
DictUpdateReq {
|
||||
Id string `json:"id"`
|
||||
Type string `json:"type,optional"`
|
||||
Label string `json:"label,optional"`
|
||||
Value string `json:"value,optional"`
|
||||
Sort int `json:"sort,optional"`
|
||||
Desc string `json:"desc,optional"`
|
||||
}
|
||||
DictListReq {
|
||||
Current int `json:"current,optional"`
|
||||
PageSize int `json:"pageSize,optional"`
|
||||
Type string `json:"type,optional"`
|
||||
}
|
||||
)
|
||||
|
||||
// ========== 需要鉴权的接口 ==========
|
||||
@server (
|
||||
prefix: /api/sys
|
||||
group: client
|
||||
jwt: Auth
|
||||
)
|
||||
service system-api {
|
||||
@doc "创建客户端"
|
||||
@handler CreateClient
|
||||
post /client/create (ClientReq)
|
||||
|
||||
@doc "更新客户端"
|
||||
@handler UpdateClient
|
||||
put /client/update (ClientUpdateReq)
|
||||
|
||||
@doc "删除客户端"
|
||||
@handler DeleteClient
|
||||
delete /client/delete (IdsReq)
|
||||
|
||||
@doc "客户端列表"
|
||||
@handler GetClientList
|
||||
post /client/list (ClientListReq)
|
||||
}
|
||||
|
||||
@server (
|
||||
prefix: /api/sys
|
||||
group: role
|
||||
jwt: Auth
|
||||
)
|
||||
service system-api {
|
||||
@doc "创建角色"
|
||||
@handler CreateRole
|
||||
post /role/create (RoleReq)
|
||||
|
||||
@doc "更新角色"
|
||||
@handler UpdateRole
|
||||
put /role/update (RoleUpdateReq)
|
||||
|
||||
@doc "删除角色"
|
||||
@handler DeleteRole
|
||||
delete /role/delete (IdsReq)
|
||||
|
||||
@doc "角色列表"
|
||||
@handler GetRoleList
|
||||
post /role/list (RoleListReq)
|
||||
}
|
||||
|
||||
@server (
|
||||
prefix: /api/sys
|
||||
group: menu
|
||||
jwt: Auth
|
||||
)
|
||||
service system-api {
|
||||
@doc "创建菜单"
|
||||
@handler CreateMenu
|
||||
post /menu/create (MenuReq)
|
||||
|
||||
@doc "更新菜单"
|
||||
@handler UpdateMenu
|
||||
put /menu/update (MenuUpdateReq)
|
||||
|
||||
@doc "删除菜单"
|
||||
@handler DeleteMenu
|
||||
delete /menu/delete (IdsReq)
|
||||
|
||||
@doc "菜单列表(树形)"
|
||||
@handler GetMenuList
|
||||
get /menu/list
|
||||
|
||||
@doc "根据角色获取菜单"
|
||||
@handler GetMenuByRole
|
||||
post /menu/byRole (IdReq)
|
||||
}
|
||||
|
||||
@server (
|
||||
prefix: /api/sys
|
||||
group: operationRecord
|
||||
jwt: Auth
|
||||
)
|
||||
service system-api {
|
||||
@doc "操作日志列表"
|
||||
@handler GetOperationRecordList
|
||||
post /log/list (OperationRecordListReq)
|
||||
|
||||
@doc "删除操作日志"
|
||||
@handler DeleteOperationRecord
|
||||
delete /log/delete (IdsReq)
|
||||
}
|
||||
|
||||
@server (
|
||||
prefix: /api/sys
|
||||
group: dict
|
||||
jwt: Auth
|
||||
)
|
||||
service system-api {
|
||||
@doc "创建字典"
|
||||
@handler CreateDict
|
||||
post /dict/create (DictReq)
|
||||
|
||||
@doc "更新字典"
|
||||
@handler UpdateDict
|
||||
put /dict/update (DictUpdateReq)
|
||||
|
||||
@doc "删除字典"
|
||||
@handler DeleteDict
|
||||
delete /dict/delete (IdsReq)
|
||||
|
||||
@doc "字典列表"
|
||||
@handler GetDictList
|
||||
post /dict/list (DictListReq)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
|
||||
"sundynix-micro-go/app/system/api/internal/config"
|
||||
"sundynix-micro-go/app/system/api/internal/handler"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/conf"
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
)
|
||||
|
||||
var configFile = flag.String("f", "etc/system-api.yaml", "the config file")
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
var c config.Config
|
||||
conf.MustLoad(*configFile, &c)
|
||||
|
||||
server := rest.MustNewServer(c.RestConf)
|
||||
defer server.Stop()
|
||||
|
||||
ctx := svc.NewServiceContext(c)
|
||||
handler.RegisterHandlers(server, ctx)
|
||||
|
||||
fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port)
|
||||
server.Start()
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"sundynix-micro-go/common/model"
|
||||
"time"
|
||||
)
|
||||
|
||||
// SundynixClient 客户端表
|
||||
type SundynixClient struct {
|
||||
model.BaseModel
|
||||
ClientID string `gorm:"size:20;column:client_id" json:"clientId"`
|
||||
Name string `gorm:"size:50;column:name" json:"name"`
|
||||
GrantType string `gorm:"size:50;column:grant_type" json:"grantType"`
|
||||
AdditionalInfo string `gorm:"type:text;column:additional_info" json:"additionalInfo"`
|
||||
ActiveTimeout int64 `gorm:"column:active_timeout" json:"activeTimeout"`
|
||||
}
|
||||
|
||||
func (SundynixClient) TableName() string {
|
||||
return "sundynix_client"
|
||||
}
|
||||
|
||||
// SundynixRole 角色表
|
||||
type SundynixRole struct {
|
||||
model.BaseModel
|
||||
Name string `gorm:"size:20;column:name" json:"name"`
|
||||
Code string `gorm:"size:20;column:code" json:"code"`
|
||||
Sort int `gorm:"column:sort" json:"sort"`
|
||||
Menus []*SundynixMenu `gorm:"many2many:sundynix_role_menu;" json:"menus"`
|
||||
}
|
||||
|
||||
func (SundynixRole) TableName() string {
|
||||
return "sundynix_role"
|
||||
}
|
||||
|
||||
// SundynixMenu 菜单表
|
||||
type SundynixMenu struct {
|
||||
model.BaseModel
|
||||
ParentID string `gorm:"size:100;default:'0';column:parent_id" json:"parentId"`
|
||||
Category int `gorm:"column:category" json:"category"`
|
||||
Name string `gorm:"size:20;column:name" json:"name"`
|
||||
Title string `gorm:"size:20;column:title" json:"title"`
|
||||
Code string `gorm:"size:50;column:code" json:"code"`
|
||||
Path string `gorm:"size:100;column:path" json:"path"`
|
||||
Permission string `gorm:"size:20;column:permission" json:"permission"`
|
||||
Locale string `gorm:"size:50;column:locale" json:"locale"`
|
||||
Icon string `gorm:"size:20;column:icon" json:"icon"`
|
||||
Sort int `gorm:"column:sort" json:"sort"`
|
||||
Children []*SundynixMenu `gorm:"-" json:"children"`
|
||||
}
|
||||
|
||||
func (SundynixMenu) TableName() string {
|
||||
return "sundynix_menu"
|
||||
}
|
||||
|
||||
// SundynixRoleMenu 角色菜单关联表
|
||||
type SundynixRoleMenu struct {
|
||||
RoleID string `gorm:"size:50;primaryKey;column:role_id" json:"roleId"`
|
||||
MenuID string `gorm:"size:50;primaryKey;column:menu_id" json:"menuId"`
|
||||
}
|
||||
|
||||
func (SundynixRoleMenu) TableName() string {
|
||||
return "sundynix_role_menu"
|
||||
}
|
||||
|
||||
// SundynixUserRole 用户角色关联表
|
||||
type SundynixUserRole struct {
|
||||
UserID string `gorm:"size:50;primaryKey;column:user_id" json:"userId"`
|
||||
RoleID string `gorm:"size:50;primaryKey;column:role_id" json:"roleId"`
|
||||
}
|
||||
|
||||
func (SundynixUserRole) TableName() string {
|
||||
return "sundynix_user_role"
|
||||
}
|
||||
|
||||
// SundynixOperationRecord 操作记录表
|
||||
type SundynixOperationRecord struct {
|
||||
model.BaseModel
|
||||
IP string `gorm:"column:ip;comment:请求ip" json:"ip"`
|
||||
Method string `gorm:"column:method;comment:请求方法" json:"method"`
|
||||
Path string `gorm:"column:path;comment:请求路径" json:"path"`
|
||||
Status int `gorm:"column:status;comment:请求状态" json:"status"`
|
||||
Latency time.Duration `gorm:"column:latency;comment:延迟" json:"latency"`
|
||||
Agent string `gorm:"type:text;column:agent;comment:代理" json:"agent"`
|
||||
ErrorMessage string `gorm:"column:error_message;comment:错误信息" json:"errorMessage"`
|
||||
Body string `gorm:"type:text;column:body;comment:请求Body" json:"body"`
|
||||
Resp string `gorm:"type:text;column:resp;comment:响应Body" json:"resp"`
|
||||
UserID string `gorm:"column:user_id;comment:用户id" json:"userId"`
|
||||
}
|
||||
|
||||
func (SundynixOperationRecord) TableName() string {
|
||||
return "sundynix_operation_record"
|
||||
}
|
||||
|
||||
// SundynixDict 字典表(新增)
|
||||
type SundynixDict struct {
|
||||
model.BaseModel
|
||||
Type string `gorm:"size:50;column:type;comment:字典类型" json:"type"`
|
||||
Label string `gorm:"size:100;column:label;comment:字典标签" json:"label"`
|
||||
Value string `gorm:"size:100;column:value;comment:字典值" json:"value"`
|
||||
Sort int `gorm:"column:sort;default:0;comment:排序" json:"sort"`
|
||||
Desc string `gorm:"size:200;column:desc;comment:描述" json:"desc"`
|
||||
}
|
||||
|
||||
func (SundynixDict) TableName() string {
|
||||
return "sundynix_dict"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
Name: system.rpc
|
||||
ListenOn: 0.0.0.0:9103
|
||||
Etcd:
|
||||
Hosts:
|
||||
- 192.168.100.127:2379
|
||||
Key: system.rpc
|
||||
|
||||
# MySQL
|
||||
DB:
|
||||
DataSource: root:root@tcp(192.168.100.127:3307)/sundynix_micro_go?charset=utf8mb4&parseTime=True&loc=Local
|
||||
Executable
+10
@@ -0,0 +1,10 @@
|
||||
package config
|
||||
|
||||
import "github.com/zeromicro/go-zero/zrpc"
|
||||
|
||||
type Config struct {
|
||||
zrpc.RpcServerConf
|
||||
DB struct {
|
||||
DataSource string
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
sysModel "sundynix-micro-go/app/system/model"
|
||||
"sundynix-micro-go/app/system/rpc/internal/svc"
|
||||
"sundynix-micro-go/app/system/rpc/system"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type GetClientByIdLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewGetClientByIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetClientByIdLogic {
|
||||
return &GetClientByIdLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// 获取客户端信息
|
||||
func (l *GetClientByIdLogic) GetClientById(in *system.GetClientByIdReq) (*system.GetClientByIdResp, error) {
|
||||
var client sysModel.SundynixClient
|
||||
err := l.svcCtx.DB.Where("client_id = ?", in.ClientId).First(&client).Error
|
||||
if err != nil {
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
return nil, status.Error(codes.NotFound, "客户端不存在")
|
||||
}
|
||||
l.Errorf("查询客户端失败: %v", err)
|
||||
return nil, status.Error(codes.Internal, "查询客户端失败")
|
||||
}
|
||||
|
||||
return &system.GetClientByIdResp{
|
||||
Client: &system.ClientInfo{
|
||||
Id: client.ID,
|
||||
ClientId: client.ClientID,
|
||||
Name: client.Name,
|
||||
GrantType: client.GrantType,
|
||||
AdditionalInfo: client.AdditionalInfo,
|
||||
ActiveTimeout: client.ActiveTimeout,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
sysModel "sundynix-micro-go/app/system/model"
|
||||
"sundynix-micro-go/app/system/rpc/internal/svc"
|
||||
"sundynix-micro-go/app/system/rpc/system"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
type GetMenusByRoleIdLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewGetMenusByRoleIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetMenusByRoleIdLogic {
|
||||
return &GetMenusByRoleIdLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// 获取角色菜单列表
|
||||
func (l *GetMenusByRoleIdLogic) GetMenusByRoleId(in *system.GetMenusByRoleIdReq) (*system.GetMenusByRoleIdResp, error) {
|
||||
// 查询角色菜单关联
|
||||
var roleMenus []sysModel.SundynixRoleMenu
|
||||
if err := l.svcCtx.DB.Where("role_id = ?", in.RoleId).Find(&roleMenus).Error; err != nil {
|
||||
l.Errorf("查询角色菜单失败: %v", err)
|
||||
return nil, status.Error(codes.Internal, "查询角色菜单失败")
|
||||
}
|
||||
|
||||
if len(roleMenus) == 0 {
|
||||
return &system.GetMenusByRoleIdResp{Menus: []*system.MenuInfo{}}, nil
|
||||
}
|
||||
|
||||
menuIds := make([]string, 0, len(roleMenus))
|
||||
for _, rm := range roleMenus {
|
||||
menuIds = append(menuIds, rm.MenuID)
|
||||
}
|
||||
|
||||
// 查询菜单信息
|
||||
var menus []sysModel.SundynixMenu
|
||||
if err := l.svcCtx.DB.Where("id IN ?", menuIds).Order("sort").Find(&menus).Error; err != nil {
|
||||
l.Errorf("查询菜单信息失败: %v", err)
|
||||
return nil, status.Error(codes.Internal, "查询菜单信息失败")
|
||||
}
|
||||
|
||||
// 构建树形结构
|
||||
menuMap := make(map[string]*system.MenuInfo)
|
||||
var rootMenus []*system.MenuInfo
|
||||
|
||||
for _, m := range menus {
|
||||
menuInfo := &system.MenuInfo{
|
||||
Id: m.ID,
|
||||
ParentId: m.ParentID,
|
||||
Category: int32(m.Category),
|
||||
Name: m.Name,
|
||||
Title: m.Title,
|
||||
Code: m.Code,
|
||||
Path: m.Path,
|
||||
Permission: m.Permission,
|
||||
Locale: m.Locale,
|
||||
Icon: m.Icon,
|
||||
Sort: int32(m.Sort),
|
||||
Children: []*system.MenuInfo{},
|
||||
}
|
||||
menuMap[m.ID] = menuInfo
|
||||
}
|
||||
|
||||
for _, menuInfo := range menuMap {
|
||||
if menuInfo.ParentId == "0" || menuInfo.ParentId == "" {
|
||||
rootMenus = append(rootMenus, menuInfo)
|
||||
} else {
|
||||
if parent, ok := menuMap[menuInfo.ParentId]; ok {
|
||||
parent.Children = append(parent.Children, menuInfo)
|
||||
} else {
|
||||
rootMenus = append(rootMenus, menuInfo)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return &system.GetMenusByRoleIdResp{Menus: rootMenus}, nil
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
sysModel "sundynix-micro-go/app/system/model"
|
||||
"sundynix-micro-go/app/system/rpc/internal/svc"
|
||||
"sundynix-micro-go/app/system/rpc/system"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
type GetRolesByUserIdLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewGetRolesByUserIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetRolesByUserIdLogic {
|
||||
return &GetRolesByUserIdLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// 获取用户角色列表
|
||||
func (l *GetRolesByUserIdLogic) GetRolesByUserId(in *system.GetRolesByUserIdReq) (*system.GetRolesByUserIdResp, error) {
|
||||
// 查询用户角色关联
|
||||
var userRoles []sysModel.SundynixUserRole
|
||||
if err := l.svcCtx.DB.Where("user_id = ?", in.UserId).Find(&userRoles).Error; err != nil {
|
||||
l.Errorf("查询用户角色失败: %v", err)
|
||||
return nil, status.Error(codes.Internal, "查询用户角色失败")
|
||||
}
|
||||
|
||||
if len(userRoles) == 0 {
|
||||
return &system.GetRolesByUserIdResp{Roles: []*system.RoleInfo{}}, nil
|
||||
}
|
||||
|
||||
roleIds := make([]string, 0, len(userRoles))
|
||||
for _, ur := range userRoles {
|
||||
roleIds = append(roleIds, ur.RoleID)
|
||||
}
|
||||
|
||||
var roles []sysModel.SundynixRole
|
||||
if err := l.svcCtx.DB.Where("id IN ?", roleIds).Find(&roles).Error; err != nil {
|
||||
l.Errorf("查询角色信息失败: %v", err)
|
||||
return nil, status.Error(codes.Internal, "查询角色信息失败")
|
||||
}
|
||||
|
||||
roleInfos := make([]*system.RoleInfo, 0, len(roles))
|
||||
for _, r := range roles {
|
||||
roleInfos = append(roleInfos, &system.RoleInfo{
|
||||
Id: r.ID,
|
||||
Name: r.Name,
|
||||
Code: r.Code,
|
||||
Sort: int32(r.Sort),
|
||||
})
|
||||
}
|
||||
|
||||
return &system.GetRolesByUserIdResp{Roles: roleInfos}, nil
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
// Code generated by goctl. DO NOT EDIT.
|
||||
// goctl 1.10.1
|
||||
// Source: system.proto
|
||||
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/system/rpc/internal/logic"
|
||||
"sundynix-micro-go/app/system/rpc/internal/svc"
|
||||
"sundynix-micro-go/app/system/rpc/system"
|
||||
)
|
||||
|
||||
type SystemServiceServer struct {
|
||||
svcCtx *svc.ServiceContext
|
||||
system.UnimplementedSystemServiceServer
|
||||
}
|
||||
|
||||
func NewSystemServiceServer(svcCtx *svc.ServiceContext) *SystemServiceServer {
|
||||
return &SystemServiceServer{
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
// 获取用户角色列表
|
||||
func (s *SystemServiceServer) GetRolesByUserId(ctx context.Context, in *system.GetRolesByUserIdReq) (*system.GetRolesByUserIdResp, error) {
|
||||
l := logic.NewGetRolesByUserIdLogic(ctx, s.svcCtx)
|
||||
return l.GetRolesByUserId(in)
|
||||
}
|
||||
|
||||
// 获取角色菜单列表
|
||||
func (s *SystemServiceServer) GetMenusByRoleId(ctx context.Context, in *system.GetMenusByRoleIdReq) (*system.GetMenusByRoleIdResp, error) {
|
||||
l := logic.NewGetMenusByRoleIdLogic(ctx, s.svcCtx)
|
||||
return l.GetMenusByRoleId(in)
|
||||
}
|
||||
|
||||
// 获取客户端信息
|
||||
func (s *SystemServiceServer) GetClientById(ctx context.Context, in *system.GetClientByIdReq) (*system.GetClientByIdResp, error) {
|
||||
l := logic.NewGetClientByIdLogic(ctx, s.svcCtx)
|
||||
return l.GetClientById(in)
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package svc
|
||||
|
||||
import (
|
||||
sysModel "sundynix-micro-go/app/system/model"
|
||||
"sundynix-micro-go/app/system/rpc/internal/config"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"gorm.io/driver/mysql"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type ServiceContext struct {
|
||||
Config config.Config
|
||||
DB *gorm.DB
|
||||
}
|
||||
|
||||
func NewServiceContext(c config.Config) *ServiceContext {
|
||||
db, err := gorm.Open(mysql.Open(c.DB.DataSource), &gorm.Config{})
|
||||
if err != nil {
|
||||
logx.Errorf("连接数据库失败: %v", err)
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// 自动迁移
|
||||
if err := db.AutoMigrate(
|
||||
&sysModel.SundynixClient{},
|
||||
&sysModel.SundynixRole{},
|
||||
&sysModel.SundynixMenu{},
|
||||
&sysModel.SundynixRoleMenu{},
|
||||
&sysModel.SundynixOperationRecord{},
|
||||
&sysModel.SundynixDict{},
|
||||
); err != nil {
|
||||
logx.Errorf("数据库迁移失败: %v", err)
|
||||
}
|
||||
|
||||
return &ServiceContext{
|
||||
Config: c,
|
||||
DB: db,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package system;
|
||||
|
||||
option go_package = "./system";
|
||||
|
||||
// ---------- 通用消息 ----------
|
||||
|
||||
message CommonResp {
|
||||
int64 code = 1;
|
||||
string msg = 2;
|
||||
}
|
||||
|
||||
// ---------- 角色信息 ----------
|
||||
|
||||
message RoleInfo {
|
||||
string id = 1;
|
||||
string name = 2;
|
||||
string code = 3;
|
||||
int32 sort = 4;
|
||||
}
|
||||
|
||||
// ---------- 菜单信息 ----------
|
||||
|
||||
message MenuInfo {
|
||||
string id = 1;
|
||||
string parentId = 2;
|
||||
int32 category = 3;
|
||||
string name = 4;
|
||||
string title = 5;
|
||||
string code = 6;
|
||||
string path = 7;
|
||||
string permission = 8;
|
||||
string locale = 9;
|
||||
string icon = 10;
|
||||
int32 sort = 11;
|
||||
repeated MenuInfo children = 12;
|
||||
}
|
||||
|
||||
// ---------- 客户端信息 ----------
|
||||
|
||||
message ClientInfo {
|
||||
string id = 1;
|
||||
string clientId = 2;
|
||||
string name = 3;
|
||||
string grantType = 4;
|
||||
string additionalInfo = 5;
|
||||
int64 activeTimeout = 6;
|
||||
}
|
||||
|
||||
// ---------- 请求/响应 ----------
|
||||
|
||||
message GetRolesByUserIdReq {
|
||||
string userId = 1;
|
||||
}
|
||||
|
||||
message GetRolesByUserIdResp {
|
||||
repeated RoleInfo roles = 1;
|
||||
}
|
||||
|
||||
message GetMenusByRoleIdReq {
|
||||
string roleId = 1;
|
||||
}
|
||||
|
||||
message GetMenusByRoleIdResp {
|
||||
repeated MenuInfo menus = 1;
|
||||
}
|
||||
|
||||
message GetClientByIdReq {
|
||||
string clientId = 1;
|
||||
}
|
||||
|
||||
message GetClientByIdResp {
|
||||
ClientInfo client = 1;
|
||||
}
|
||||
|
||||
// ---------- 服务定义 ----------
|
||||
|
||||
service SystemService {
|
||||
// 获取用户角色列表
|
||||
rpc GetRolesByUserId(GetRolesByUserIdReq) returns (GetRolesByUserIdResp);
|
||||
// 获取角色菜单列表
|
||||
rpc GetMenusByRoleId(GetMenusByRoleIdReq) returns (GetMenusByRoleIdResp);
|
||||
// 获取客户端信息
|
||||
rpc GetClientById(GetClientByIdReq) returns (GetClientByIdResp);
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
|
||||
"sundynix-micro-go/app/system/rpc/internal/config"
|
||||
"sundynix-micro-go/app/system/rpc/internal/server"
|
||||
"sundynix-micro-go/app/system/rpc/internal/svc"
|
||||
"sundynix-micro-go/app/system/rpc/system"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/conf"
|
||||
"github.com/zeromicro/go-zero/core/service"
|
||||
"github.com/zeromicro/go-zero/zrpc"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/reflection"
|
||||
)
|
||||
|
||||
var configFile = flag.String("f", "etc/system.yaml", "the config file")
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
var c config.Config
|
||||
conf.MustLoad(*configFile, &c)
|
||||
ctx := svc.NewServiceContext(c)
|
||||
|
||||
s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
|
||||
system.RegisterSystemServiceServer(grpcServer, server.NewSystemServiceServer(ctx))
|
||||
|
||||
if c.Mode == service.DevMode || c.Mode == service.TestMode {
|
||||
reflection.Register(grpcServer)
|
||||
}
|
||||
})
|
||||
defer s.Stop()
|
||||
|
||||
fmt.Printf("Starting rpc server at %s...\n", c.ListenOn)
|
||||
s.Start()
|
||||
}
|
||||
@@ -0,0 +1,745 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.11
|
||||
// protoc v7.34.1
|
||||
// source: pb/system.proto
|
||||
|
||||
package system
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
unsafe "unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type CommonResp struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Code int64 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"`
|
||||
Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *CommonResp) Reset() {
|
||||
*x = CommonResp{}
|
||||
mi := &file_pb_system_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *CommonResp) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*CommonResp) ProtoMessage() {}
|
||||
|
||||
func (x *CommonResp) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_pb_system_proto_msgTypes[0]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use CommonResp.ProtoReflect.Descriptor instead.
|
||||
func (*CommonResp) Descriptor() ([]byte, []int) {
|
||||
return file_pb_system_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *CommonResp) GetCode() int64 {
|
||||
if x != nil {
|
||||
return x.Code
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *CommonResp) GetMsg() string {
|
||||
if x != nil {
|
||||
return x.Msg
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type RoleInfo struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
|
||||
Code string `protobuf:"bytes,3,opt,name=code,proto3" json:"code,omitempty"`
|
||||
Sort int32 `protobuf:"varint,4,opt,name=sort,proto3" json:"sort,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *RoleInfo) Reset() {
|
||||
*x = RoleInfo{}
|
||||
mi := &file_pb_system_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *RoleInfo) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*RoleInfo) ProtoMessage() {}
|
||||
|
||||
func (x *RoleInfo) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_pb_system_proto_msgTypes[1]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use RoleInfo.ProtoReflect.Descriptor instead.
|
||||
func (*RoleInfo) Descriptor() ([]byte, []int) {
|
||||
return file_pb_system_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *RoleInfo) GetId() string {
|
||||
if x != nil {
|
||||
return x.Id
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *RoleInfo) GetName() string {
|
||||
if x != nil {
|
||||
return x.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *RoleInfo) GetCode() string {
|
||||
if x != nil {
|
||||
return x.Code
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *RoleInfo) GetSort() int32 {
|
||||
if x != nil {
|
||||
return x.Sort
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type MenuInfo struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
ParentId string `protobuf:"bytes,2,opt,name=parentId,proto3" json:"parentId,omitempty"`
|
||||
Category int32 `protobuf:"varint,3,opt,name=category,proto3" json:"category,omitempty"`
|
||||
Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"`
|
||||
Title string `protobuf:"bytes,5,opt,name=title,proto3" json:"title,omitempty"`
|
||||
Code string `protobuf:"bytes,6,opt,name=code,proto3" json:"code,omitempty"`
|
||||
Path string `protobuf:"bytes,7,opt,name=path,proto3" json:"path,omitempty"`
|
||||
Permission string `protobuf:"bytes,8,opt,name=permission,proto3" json:"permission,omitempty"`
|
||||
Locale string `protobuf:"bytes,9,opt,name=locale,proto3" json:"locale,omitempty"`
|
||||
Icon string `protobuf:"bytes,10,opt,name=icon,proto3" json:"icon,omitempty"`
|
||||
Sort int32 `protobuf:"varint,11,opt,name=sort,proto3" json:"sort,omitempty"`
|
||||
Children []*MenuInfo `protobuf:"bytes,12,rep,name=children,proto3" json:"children,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *MenuInfo) Reset() {
|
||||
*x = MenuInfo{}
|
||||
mi := &file_pb_system_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *MenuInfo) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*MenuInfo) ProtoMessage() {}
|
||||
|
||||
func (x *MenuInfo) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_pb_system_proto_msgTypes[2]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use MenuInfo.ProtoReflect.Descriptor instead.
|
||||
func (*MenuInfo) Descriptor() ([]byte, []int) {
|
||||
return file_pb_system_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *MenuInfo) GetId() string {
|
||||
if x != nil {
|
||||
return x.Id
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *MenuInfo) GetParentId() string {
|
||||
if x != nil {
|
||||
return x.ParentId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *MenuInfo) GetCategory() int32 {
|
||||
if x != nil {
|
||||
return x.Category
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *MenuInfo) GetName() string {
|
||||
if x != nil {
|
||||
return x.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *MenuInfo) GetTitle() string {
|
||||
if x != nil {
|
||||
return x.Title
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *MenuInfo) GetCode() string {
|
||||
if x != nil {
|
||||
return x.Code
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *MenuInfo) GetPath() string {
|
||||
if x != nil {
|
||||
return x.Path
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *MenuInfo) GetPermission() string {
|
||||
if x != nil {
|
||||
return x.Permission
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *MenuInfo) GetLocale() string {
|
||||
if x != nil {
|
||||
return x.Locale
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *MenuInfo) GetIcon() string {
|
||||
if x != nil {
|
||||
return x.Icon
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *MenuInfo) GetSort() int32 {
|
||||
if x != nil {
|
||||
return x.Sort
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *MenuInfo) GetChildren() []*MenuInfo {
|
||||
if x != nil {
|
||||
return x.Children
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type ClientInfo struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
ClientId string `protobuf:"bytes,2,opt,name=clientId,proto3" json:"clientId,omitempty"`
|
||||
Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"`
|
||||
GrantType string `protobuf:"bytes,4,opt,name=grantType,proto3" json:"grantType,omitempty"`
|
||||
AdditionalInfo string `protobuf:"bytes,5,opt,name=additionalInfo,proto3" json:"additionalInfo,omitempty"`
|
||||
ActiveTimeout int64 `protobuf:"varint,6,opt,name=activeTimeout,proto3" json:"activeTimeout,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ClientInfo) Reset() {
|
||||
*x = ClientInfo{}
|
||||
mi := &file_pb_system_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ClientInfo) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ClientInfo) ProtoMessage() {}
|
||||
|
||||
func (x *ClientInfo) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_pb_system_proto_msgTypes[3]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ClientInfo.ProtoReflect.Descriptor instead.
|
||||
func (*ClientInfo) Descriptor() ([]byte, []int) {
|
||||
return file_pb_system_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *ClientInfo) GetId() string {
|
||||
if x != nil {
|
||||
return x.Id
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ClientInfo) GetClientId() string {
|
||||
if x != nil {
|
||||
return x.ClientId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ClientInfo) GetName() string {
|
||||
if x != nil {
|
||||
return x.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ClientInfo) GetGrantType() string {
|
||||
if x != nil {
|
||||
return x.GrantType
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ClientInfo) GetAdditionalInfo() string {
|
||||
if x != nil {
|
||||
return x.AdditionalInfo
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ClientInfo) GetActiveTimeout() int64 {
|
||||
if x != nil {
|
||||
return x.ActiveTimeout
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type GetRolesByUserIdReq struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
UserId string `protobuf:"bytes,1,opt,name=userId,proto3" json:"userId,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *GetRolesByUserIdReq) Reset() {
|
||||
*x = GetRolesByUserIdReq{}
|
||||
mi := &file_pb_system_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *GetRolesByUserIdReq) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetRolesByUserIdReq) ProtoMessage() {}
|
||||
|
||||
func (x *GetRolesByUserIdReq) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_pb_system_proto_msgTypes[4]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetRolesByUserIdReq.ProtoReflect.Descriptor instead.
|
||||
func (*GetRolesByUserIdReq) Descriptor() ([]byte, []int) {
|
||||
return file_pb_system_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
func (x *GetRolesByUserIdReq) GetUserId() string {
|
||||
if x != nil {
|
||||
return x.UserId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type GetRolesByUserIdResp struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Roles []*RoleInfo `protobuf:"bytes,1,rep,name=roles,proto3" json:"roles,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *GetRolesByUserIdResp) Reset() {
|
||||
*x = GetRolesByUserIdResp{}
|
||||
mi := &file_pb_system_proto_msgTypes[5]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *GetRolesByUserIdResp) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetRolesByUserIdResp) ProtoMessage() {}
|
||||
|
||||
func (x *GetRolesByUserIdResp) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_pb_system_proto_msgTypes[5]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetRolesByUserIdResp.ProtoReflect.Descriptor instead.
|
||||
func (*GetRolesByUserIdResp) Descriptor() ([]byte, []int) {
|
||||
return file_pb_system_proto_rawDescGZIP(), []int{5}
|
||||
}
|
||||
|
||||
func (x *GetRolesByUserIdResp) GetRoles() []*RoleInfo {
|
||||
if x != nil {
|
||||
return x.Roles
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type GetMenusByRoleIdReq struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
RoleId string `protobuf:"bytes,1,opt,name=roleId,proto3" json:"roleId,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *GetMenusByRoleIdReq) Reset() {
|
||||
*x = GetMenusByRoleIdReq{}
|
||||
mi := &file_pb_system_proto_msgTypes[6]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *GetMenusByRoleIdReq) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetMenusByRoleIdReq) ProtoMessage() {}
|
||||
|
||||
func (x *GetMenusByRoleIdReq) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_pb_system_proto_msgTypes[6]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetMenusByRoleIdReq.ProtoReflect.Descriptor instead.
|
||||
func (*GetMenusByRoleIdReq) Descriptor() ([]byte, []int) {
|
||||
return file_pb_system_proto_rawDescGZIP(), []int{6}
|
||||
}
|
||||
|
||||
func (x *GetMenusByRoleIdReq) GetRoleId() string {
|
||||
if x != nil {
|
||||
return x.RoleId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type GetMenusByRoleIdResp struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Menus []*MenuInfo `protobuf:"bytes,1,rep,name=menus,proto3" json:"menus,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *GetMenusByRoleIdResp) Reset() {
|
||||
*x = GetMenusByRoleIdResp{}
|
||||
mi := &file_pb_system_proto_msgTypes[7]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *GetMenusByRoleIdResp) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetMenusByRoleIdResp) ProtoMessage() {}
|
||||
|
||||
func (x *GetMenusByRoleIdResp) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_pb_system_proto_msgTypes[7]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetMenusByRoleIdResp.ProtoReflect.Descriptor instead.
|
||||
func (*GetMenusByRoleIdResp) Descriptor() ([]byte, []int) {
|
||||
return file_pb_system_proto_rawDescGZIP(), []int{7}
|
||||
}
|
||||
|
||||
func (x *GetMenusByRoleIdResp) GetMenus() []*MenuInfo {
|
||||
if x != nil {
|
||||
return x.Menus
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type GetClientByIdReq struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
ClientId string `protobuf:"bytes,1,opt,name=clientId,proto3" json:"clientId,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *GetClientByIdReq) Reset() {
|
||||
*x = GetClientByIdReq{}
|
||||
mi := &file_pb_system_proto_msgTypes[8]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *GetClientByIdReq) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetClientByIdReq) ProtoMessage() {}
|
||||
|
||||
func (x *GetClientByIdReq) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_pb_system_proto_msgTypes[8]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetClientByIdReq.ProtoReflect.Descriptor instead.
|
||||
func (*GetClientByIdReq) Descriptor() ([]byte, []int) {
|
||||
return file_pb_system_proto_rawDescGZIP(), []int{8}
|
||||
}
|
||||
|
||||
func (x *GetClientByIdReq) GetClientId() string {
|
||||
if x != nil {
|
||||
return x.ClientId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type GetClientByIdResp struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Client *ClientInfo `protobuf:"bytes,1,opt,name=client,proto3" json:"client,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *GetClientByIdResp) Reset() {
|
||||
*x = GetClientByIdResp{}
|
||||
mi := &file_pb_system_proto_msgTypes[9]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *GetClientByIdResp) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetClientByIdResp) ProtoMessage() {}
|
||||
|
||||
func (x *GetClientByIdResp) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_pb_system_proto_msgTypes[9]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetClientByIdResp.ProtoReflect.Descriptor instead.
|
||||
func (*GetClientByIdResp) Descriptor() ([]byte, []int) {
|
||||
return file_pb_system_proto_rawDescGZIP(), []int{9}
|
||||
}
|
||||
|
||||
func (x *GetClientByIdResp) GetClient() *ClientInfo {
|
||||
if x != nil {
|
||||
return x.Client
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var File_pb_system_proto protoreflect.FileDescriptor
|
||||
|
||||
const file_pb_system_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"\x0fpb/system.proto\x12\x06system\"2\n" +
|
||||
"\n" +
|
||||
"CommonResp\x12\x12\n" +
|
||||
"\x04code\x18\x01 \x01(\x03R\x04code\x12\x10\n" +
|
||||
"\x03msg\x18\x02 \x01(\tR\x03msg\"V\n" +
|
||||
"\bRoleInfo\x12\x0e\n" +
|
||||
"\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n" +
|
||||
"\x04name\x18\x02 \x01(\tR\x04name\x12\x12\n" +
|
||||
"\x04code\x18\x03 \x01(\tR\x04code\x12\x12\n" +
|
||||
"\x04sort\x18\x04 \x01(\x05R\x04sort\"\xb2\x02\n" +
|
||||
"\bMenuInfo\x12\x0e\n" +
|
||||
"\x02id\x18\x01 \x01(\tR\x02id\x12\x1a\n" +
|
||||
"\bparentId\x18\x02 \x01(\tR\bparentId\x12\x1a\n" +
|
||||
"\bcategory\x18\x03 \x01(\x05R\bcategory\x12\x12\n" +
|
||||
"\x04name\x18\x04 \x01(\tR\x04name\x12\x14\n" +
|
||||
"\x05title\x18\x05 \x01(\tR\x05title\x12\x12\n" +
|
||||
"\x04code\x18\x06 \x01(\tR\x04code\x12\x12\n" +
|
||||
"\x04path\x18\a \x01(\tR\x04path\x12\x1e\n" +
|
||||
"\n" +
|
||||
"permission\x18\b \x01(\tR\n" +
|
||||
"permission\x12\x16\n" +
|
||||
"\x06locale\x18\t \x01(\tR\x06locale\x12\x12\n" +
|
||||
"\x04icon\x18\n" +
|
||||
" \x01(\tR\x04icon\x12\x12\n" +
|
||||
"\x04sort\x18\v \x01(\x05R\x04sort\x12,\n" +
|
||||
"\bchildren\x18\f \x03(\v2\x10.system.MenuInfoR\bchildren\"\xb8\x01\n" +
|
||||
"\n" +
|
||||
"ClientInfo\x12\x0e\n" +
|
||||
"\x02id\x18\x01 \x01(\tR\x02id\x12\x1a\n" +
|
||||
"\bclientId\x18\x02 \x01(\tR\bclientId\x12\x12\n" +
|
||||
"\x04name\x18\x03 \x01(\tR\x04name\x12\x1c\n" +
|
||||
"\tgrantType\x18\x04 \x01(\tR\tgrantType\x12&\n" +
|
||||
"\x0eadditionalInfo\x18\x05 \x01(\tR\x0eadditionalInfo\x12$\n" +
|
||||
"\ractiveTimeout\x18\x06 \x01(\x03R\ractiveTimeout\"-\n" +
|
||||
"\x13GetRolesByUserIdReq\x12\x16\n" +
|
||||
"\x06userId\x18\x01 \x01(\tR\x06userId\">\n" +
|
||||
"\x14GetRolesByUserIdResp\x12&\n" +
|
||||
"\x05roles\x18\x01 \x03(\v2\x10.system.RoleInfoR\x05roles\"-\n" +
|
||||
"\x13GetMenusByRoleIdReq\x12\x16\n" +
|
||||
"\x06roleId\x18\x01 \x01(\tR\x06roleId\">\n" +
|
||||
"\x14GetMenusByRoleIdResp\x12&\n" +
|
||||
"\x05menus\x18\x01 \x03(\v2\x10.system.MenuInfoR\x05menus\".\n" +
|
||||
"\x10GetClientByIdReq\x12\x1a\n" +
|
||||
"\bclientId\x18\x01 \x01(\tR\bclientId\"?\n" +
|
||||
"\x11GetClientByIdResp\x12*\n" +
|
||||
"\x06client\x18\x01 \x01(\v2\x12.system.ClientInfoR\x06client2\xf3\x01\n" +
|
||||
"\rSystemService\x12M\n" +
|
||||
"\x10GetRolesByUserId\x12\x1b.system.GetRolesByUserIdReq\x1a\x1c.system.GetRolesByUserIdResp\x12M\n" +
|
||||
"\x10GetMenusByRoleId\x12\x1b.system.GetMenusByRoleIdReq\x1a\x1c.system.GetMenusByRoleIdResp\x12D\n" +
|
||||
"\rGetClientById\x12\x18.system.GetClientByIdReq\x1a\x19.system.GetClientByIdRespB\n" +
|
||||
"Z\b./systemb\x06proto3"
|
||||
|
||||
var (
|
||||
file_pb_system_proto_rawDescOnce sync.Once
|
||||
file_pb_system_proto_rawDescData []byte
|
||||
)
|
||||
|
||||
func file_pb_system_proto_rawDescGZIP() []byte {
|
||||
file_pb_system_proto_rawDescOnce.Do(func() {
|
||||
file_pb_system_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_pb_system_proto_rawDesc), len(file_pb_system_proto_rawDesc)))
|
||||
})
|
||||
return file_pb_system_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_pb_system_proto_msgTypes = make([]protoimpl.MessageInfo, 10)
|
||||
var file_pb_system_proto_goTypes = []any{
|
||||
(*CommonResp)(nil), // 0: system.CommonResp
|
||||
(*RoleInfo)(nil), // 1: system.RoleInfo
|
||||
(*MenuInfo)(nil), // 2: system.MenuInfo
|
||||
(*ClientInfo)(nil), // 3: system.ClientInfo
|
||||
(*GetRolesByUserIdReq)(nil), // 4: system.GetRolesByUserIdReq
|
||||
(*GetRolesByUserIdResp)(nil), // 5: system.GetRolesByUserIdResp
|
||||
(*GetMenusByRoleIdReq)(nil), // 6: system.GetMenusByRoleIdReq
|
||||
(*GetMenusByRoleIdResp)(nil), // 7: system.GetMenusByRoleIdResp
|
||||
(*GetClientByIdReq)(nil), // 8: system.GetClientByIdReq
|
||||
(*GetClientByIdResp)(nil), // 9: system.GetClientByIdResp
|
||||
}
|
||||
var file_pb_system_proto_depIdxs = []int32{
|
||||
2, // 0: system.MenuInfo.children:type_name -> system.MenuInfo
|
||||
1, // 1: system.GetRolesByUserIdResp.roles:type_name -> system.RoleInfo
|
||||
2, // 2: system.GetMenusByRoleIdResp.menus:type_name -> system.MenuInfo
|
||||
3, // 3: system.GetClientByIdResp.client:type_name -> system.ClientInfo
|
||||
4, // 4: system.SystemService.GetRolesByUserId:input_type -> system.GetRolesByUserIdReq
|
||||
6, // 5: system.SystemService.GetMenusByRoleId:input_type -> system.GetMenusByRoleIdReq
|
||||
8, // 6: system.SystemService.GetClientById:input_type -> system.GetClientByIdReq
|
||||
5, // 7: system.SystemService.GetRolesByUserId:output_type -> system.GetRolesByUserIdResp
|
||||
7, // 8: system.SystemService.GetMenusByRoleId:output_type -> system.GetMenusByRoleIdResp
|
||||
9, // 9: system.SystemService.GetClientById:output_type -> system.GetClientByIdResp
|
||||
7, // [7:10] is the sub-list for method output_type
|
||||
4, // [4:7] is the sub-list for method input_type
|
||||
4, // [4:4] is the sub-list for extension type_name
|
||||
4, // [4:4] is the sub-list for extension extendee
|
||||
0, // [0:4] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_pb_system_proto_init() }
|
||||
func file_pb_system_proto_init() {
|
||||
if File_pb_system_proto != nil {
|
||||
return
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_pb_system_proto_rawDesc), len(file_pb_system_proto_rawDesc)),
|
||||
NumEnums: 0,
|
||||
NumMessages: 10,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_pb_system_proto_goTypes,
|
||||
DependencyIndexes: file_pb_system_proto_depIdxs,
|
||||
MessageInfos: file_pb_system_proto_msgTypes,
|
||||
}.Build()
|
||||
File_pb_system_proto = out.File
|
||||
file_pb_system_proto_goTypes = nil
|
||||
file_pb_system_proto_depIdxs = nil
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.6.1
|
||||
// - protoc v7.34.1
|
||||
// source: pb/system.proto
|
||||
|
||||
package system
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.64.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
SystemService_GetRolesByUserId_FullMethodName = "/system.SystemService/GetRolesByUserId"
|
||||
SystemService_GetMenusByRoleId_FullMethodName = "/system.SystemService/GetMenusByRoleId"
|
||||
SystemService_GetClientById_FullMethodName = "/system.SystemService/GetClientById"
|
||||
)
|
||||
|
||||
// SystemServiceClient is the client API for SystemService service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type SystemServiceClient interface {
|
||||
// 获取用户角色列表
|
||||
GetRolesByUserId(ctx context.Context, in *GetRolesByUserIdReq, opts ...grpc.CallOption) (*GetRolesByUserIdResp, error)
|
||||
// 获取角色菜单列表
|
||||
GetMenusByRoleId(ctx context.Context, in *GetMenusByRoleIdReq, opts ...grpc.CallOption) (*GetMenusByRoleIdResp, error)
|
||||
// 获取客户端信息
|
||||
GetClientById(ctx context.Context, in *GetClientByIdReq, opts ...grpc.CallOption) (*GetClientByIdResp, error)
|
||||
}
|
||||
|
||||
type systemServiceClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewSystemServiceClient(cc grpc.ClientConnInterface) SystemServiceClient {
|
||||
return &systemServiceClient{cc}
|
||||
}
|
||||
|
||||
func (c *systemServiceClient) GetRolesByUserId(ctx context.Context, in *GetRolesByUserIdReq, opts ...grpc.CallOption) (*GetRolesByUserIdResp, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(GetRolesByUserIdResp)
|
||||
err := c.cc.Invoke(ctx, SystemService_GetRolesByUserId_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *systemServiceClient) GetMenusByRoleId(ctx context.Context, in *GetMenusByRoleIdReq, opts ...grpc.CallOption) (*GetMenusByRoleIdResp, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(GetMenusByRoleIdResp)
|
||||
err := c.cc.Invoke(ctx, SystemService_GetMenusByRoleId_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *systemServiceClient) GetClientById(ctx context.Context, in *GetClientByIdReq, opts ...grpc.CallOption) (*GetClientByIdResp, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(GetClientByIdResp)
|
||||
err := c.cc.Invoke(ctx, SystemService_GetClientById_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// SystemServiceServer is the server API for SystemService service.
|
||||
// All implementations must embed UnimplementedSystemServiceServer
|
||||
// for forward compatibility.
|
||||
type SystemServiceServer interface {
|
||||
// 获取用户角色列表
|
||||
GetRolesByUserId(context.Context, *GetRolesByUserIdReq) (*GetRolesByUserIdResp, error)
|
||||
// 获取角色菜单列表
|
||||
GetMenusByRoleId(context.Context, *GetMenusByRoleIdReq) (*GetMenusByRoleIdResp, error)
|
||||
// 获取客户端信息
|
||||
GetClientById(context.Context, *GetClientByIdReq) (*GetClientByIdResp, error)
|
||||
mustEmbedUnimplementedSystemServiceServer()
|
||||
}
|
||||
|
||||
// UnimplementedSystemServiceServer must be embedded to have
|
||||
// forward compatible implementations.
|
||||
//
|
||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedSystemServiceServer struct{}
|
||||
|
||||
func (UnimplementedSystemServiceServer) GetRolesByUserId(context.Context, *GetRolesByUserIdReq) (*GetRolesByUserIdResp, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method GetRolesByUserId not implemented")
|
||||
}
|
||||
func (UnimplementedSystemServiceServer) GetMenusByRoleId(context.Context, *GetMenusByRoleIdReq) (*GetMenusByRoleIdResp, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method GetMenusByRoleId not implemented")
|
||||
}
|
||||
func (UnimplementedSystemServiceServer) GetClientById(context.Context, *GetClientByIdReq) (*GetClientByIdResp, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method GetClientById not implemented")
|
||||
}
|
||||
func (UnimplementedSystemServiceServer) mustEmbedUnimplementedSystemServiceServer() {}
|
||||
func (UnimplementedSystemServiceServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafeSystemServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to SystemServiceServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeSystemServiceServer interface {
|
||||
mustEmbedUnimplementedSystemServiceServer()
|
||||
}
|
||||
|
||||
func RegisterSystemServiceServer(s grpc.ServiceRegistrar, srv SystemServiceServer) {
|
||||
// If the following call panics, it indicates UnimplementedSystemServiceServer was
|
||||
// embedded by pointer and is nil. This will cause panics if an
|
||||
// unimplemented method is ever invoked, so we test this at initialization
|
||||
// time to prevent it from happening at runtime later due to I/O.
|
||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||
t.testEmbeddedByValue()
|
||||
}
|
||||
s.RegisterService(&SystemService_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _SystemService_GetRolesByUserId_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetRolesByUserIdReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SystemServiceServer).GetRolesByUserId(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: SystemService_GetRolesByUserId_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SystemServiceServer).GetRolesByUserId(ctx, req.(*GetRolesByUserIdReq))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SystemService_GetMenusByRoleId_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetMenusByRoleIdReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SystemServiceServer).GetMenusByRoleId(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: SystemService_GetMenusByRoleId_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SystemServiceServer).GetMenusByRoleId(ctx, req.(*GetMenusByRoleIdReq))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SystemService_GetClientById_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetClientByIdReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SystemServiceServer).GetClientById(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: SystemService_GetClientById_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SystemServiceServer).GetClientById(ctx, req.(*GetClientByIdReq))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// SystemService_ServiceDesc is the grpc.ServiceDesc for SystemService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var SystemService_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "system.SystemService",
|
||||
HandlerType: (*SystemServiceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "GetRolesByUserId",
|
||||
Handler: _SystemService_GetRolesByUserId_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetMenusByRoleId",
|
||||
Handler: _SystemService_GetMenusByRoleId_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetClientById",
|
||||
Handler: _SystemService_GetClientById_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "pb/system.proto",
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
// Code generated by goctl. DO NOT EDIT.
|
||||
// goctl 1.10.1
|
||||
// Source: system.proto
|
||||
|
||||
package systemservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/system/rpc/system"
|
||||
|
||||
"github.com/zeromicro/go-zero/zrpc"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type (
|
||||
ClientInfo = system.ClientInfo
|
||||
CommonResp = system.CommonResp
|
||||
GetClientByIdReq = system.GetClientByIdReq
|
||||
GetClientByIdResp = system.GetClientByIdResp
|
||||
GetMenusByRoleIdReq = system.GetMenusByRoleIdReq
|
||||
GetMenusByRoleIdResp = system.GetMenusByRoleIdResp
|
||||
GetRolesByUserIdReq = system.GetRolesByUserIdReq
|
||||
GetRolesByUserIdResp = system.GetRolesByUserIdResp
|
||||
MenuInfo = system.MenuInfo
|
||||
RoleInfo = system.RoleInfo
|
||||
|
||||
SystemService interface {
|
||||
// 获取用户角色列表
|
||||
GetRolesByUserId(ctx context.Context, in *GetRolesByUserIdReq, opts ...grpc.CallOption) (*GetRolesByUserIdResp, error)
|
||||
// 获取角色菜单列表
|
||||
GetMenusByRoleId(ctx context.Context, in *GetMenusByRoleIdReq, opts ...grpc.CallOption) (*GetMenusByRoleIdResp, error)
|
||||
// 获取客户端信息
|
||||
GetClientById(ctx context.Context, in *GetClientByIdReq, opts ...grpc.CallOption) (*GetClientByIdResp, error)
|
||||
}
|
||||
|
||||
defaultSystemService struct {
|
||||
cli zrpc.Client
|
||||
}
|
||||
)
|
||||
|
||||
func NewSystemService(cli zrpc.Client) SystemService {
|
||||
return &defaultSystemService{
|
||||
cli: cli,
|
||||
}
|
||||
}
|
||||
|
||||
// 获取用户角色列表
|
||||
func (m *defaultSystemService) GetRolesByUserId(ctx context.Context, in *GetRolesByUserIdReq, opts ...grpc.CallOption) (*GetRolesByUserIdResp, error) {
|
||||
client := system.NewSystemServiceClient(m.cli.Conn())
|
||||
return client.GetRolesByUserId(ctx, in, opts...)
|
||||
}
|
||||
|
||||
// 获取角色菜单列表
|
||||
func (m *defaultSystemService) GetMenusByRoleId(ctx context.Context, in *GetMenusByRoleIdReq, opts ...grpc.CallOption) (*GetMenusByRoleIdResp, error) {
|
||||
client := system.NewSystemServiceClient(m.cli.Conn())
|
||||
return client.GetMenusByRoleId(ctx, in, opts...)
|
||||
}
|
||||
|
||||
// 获取客户端信息
|
||||
func (m *defaultSystemService) GetClientById(ctx context.Context, in *GetClientByIdReq, opts ...grpc.CallOption) (*GetClientByIdResp, error) {
|
||||
client := system.NewSystemServiceClient(m.cli.Conn())
|
||||
return client.GetClientById(ctx, in, opts...)
|
||||
}
|
||||
Reference in New Issue
Block a user