feat: 添加api接口,几乎完善。
parent
53ee858140
commit
1173086e2f
@ -0,0 +1,57 @@
|
||||
// api
|
||||
//
|
||||
// Description: api service
|
||||
//
|
||||
// Schemes: http, https
|
||||
// Host: localhost:0
|
||||
// BasePath: /
|
||||
// Version: 0.0.1
|
||||
// SecurityDefinitions:
|
||||
// Token:
|
||||
// type: apiKey
|
||||
// name: Authorization
|
||||
// in: header
|
||||
// Security:
|
||||
// - Token: []
|
||||
// Consumes:
|
||||
// - application/json
|
||||
//
|
||||
// Produces:
|
||||
// - application/json
|
||||
//
|
||||
// swagger:meta
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"git.noahlan.cn/noahlan/ntool-biz/core/i18n"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/config"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/handler"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/conf"
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
)
|
||||
|
||||
var configFile = flag.String("f", "api/etc/api-dev.yaml", "the config file")
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
var c config.Config
|
||||
conf.MustLoad(*configFile, &c, conf.UseEnv())
|
||||
|
||||
server := rest.MustNewServer(c.RestConf, rest.WithCors(c.CORSConf.Address))
|
||||
defer server.Stop()
|
||||
|
||||
// i18n
|
||||
server.Use(i18n.WithI18nMiddleware())
|
||||
|
||||
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,70 @@
|
||||
Name: api.api
|
||||
Host: 0.0.0.0
|
||||
Port: 19999
|
||||
Timeout: 30000
|
||||
|
||||
Auth:
|
||||
AccessSecret: "FZpng2gdo1ZrUndoWC7AqjpCVdoXkabi" # the same as core
|
||||
AccessExpire: 259200
|
||||
|
||||
CORSConf:
|
||||
Address: '*'
|
||||
|
||||
Log:
|
||||
ServiceName: apiApiLogger
|
||||
Mode: console
|
||||
Path: ./logs/api/api
|
||||
Encoding: plain # json or plain
|
||||
Level: debug
|
||||
Stat: false
|
||||
Compress: false
|
||||
KeepDays: 7
|
||||
StackCoolDownMillis: 100
|
||||
|
||||
Prometheus:
|
||||
Host: 0.0.0.0
|
||||
Port: 4000
|
||||
Path: /metrics
|
||||
|
||||
CoreRpc:
|
||||
NonBlock: true
|
||||
Etcd:
|
||||
Hosts:
|
||||
- 192.168.1.155:2379
|
||||
Key: n-admin.core.rpc
|
||||
|
||||
RedisConf:
|
||||
Addr: 192.168.1.155:6379
|
||||
Type: node
|
||||
|
||||
Captcha:
|
||||
KeyLen: 4
|
||||
ImgWidth: 240
|
||||
ImgHeight: 80
|
||||
Driver: string
|
||||
|
||||
# 多语言配置
|
||||
I18n:
|
||||
Default: zh
|
||||
RootPath: dal/i18n/locale
|
||||
SortedParameterPrefix: p
|
||||
|
||||
# Casbin
|
||||
CasbinConf:
|
||||
ModelText: |
|
||||
[request_definition]
|
||||
r = sub, obj, act
|
||||
[policy_definition]
|
||||
p = sub, obj, act
|
||||
[role_definition]
|
||||
g = _, _
|
||||
[policy_effect]
|
||||
e = some(where (p.eft == allow))
|
||||
[matchers]
|
||||
m = r.sub == p.sub && keyMatch2(r.obj, p.obj) && r.act == p.act
|
||||
|
||||
RegisterConf:
|
||||
DefaultPassword: "gvXYlSc8"
|
||||
Description: "此用户很懒,什么都没留下。"
|
||||
|
||||
|
@ -0,0 +1,32 @@
|
||||
Name: api.api
|
||||
Host: 0.0.0.0
|
||||
Port: 0
|
||||
Timeout: 30000
|
||||
|
||||
Auth:
|
||||
AccessSecret: # the same as core
|
||||
AccessExpire: 259200
|
||||
|
||||
CORSConf:
|
||||
Address: '*'
|
||||
|
||||
Log:
|
||||
ServiceName: apiApiLogger
|
||||
Mode: console
|
||||
Path: ./logs/api/api
|
||||
Encoding: plain # json or plain
|
||||
Level: debug
|
||||
Stat: false
|
||||
Compress: false
|
||||
KeepDays: 7
|
||||
StackCoolDownMillis: 100
|
||||
|
||||
Prometheus:
|
||||
Host: 0.0.0.0
|
||||
Port: 4000
|
||||
Path: /metrics
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,27 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"git.noahlan.cn/noahlan/ntool-biz/core/captcha"
|
||||
nconfig "git.noahlan.cn/noahlan/ntool-biz/core/config"
|
||||
"git.noahlan.cn/noahlan/ntool-biz/core/i18n"
|
||||
"github.com/zeromicro/go-zero/zrpc"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
rest.RestConf
|
||||
Auth nconfig.AuthConf
|
||||
CORSConf nconfig.CORSConf
|
||||
RedisConf nconfig.RedisConf
|
||||
Captcha captcha.Config `json:",optional"`
|
||||
I18n i18n.Config `json:",optional"`
|
||||
|
||||
RegisterConf RegisterConf
|
||||
|
||||
CoreRpc zrpc.RpcClientConf
|
||||
}
|
||||
|
||||
type RegisterConf struct {
|
||||
DefaultPassword string `json:",default=a123456"`
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/auth"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
)
|
||||
|
||||
// swagger:route post /api/auth/login auth Login
|
||||
//
|
||||
// Log in | 密码登录
|
||||
//
|
||||
// Log in | 密码登录
|
||||
//
|
||||
// Parameters:
|
||||
// + name: body
|
||||
// require: true
|
||||
// in: body
|
||||
// type: LoginReq
|
||||
//
|
||||
// Responses:
|
||||
// 200: LoginResp
|
||||
|
||||
func LoginHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
const transErr = true
|
||||
var req types.LoginReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := auth.NewLoginLogic(r, r.Context(), svcCtx)
|
||||
resp, err := l.Login(&req)
|
||||
|
||||
statusz.ResponseHandler(r, w, transErr, resp, err)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/auth"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
)
|
||||
|
||||
// swagger:route post /api/auth/register auth Register
|
||||
//
|
||||
// Register | 注册
|
||||
//
|
||||
// Register | 注册
|
||||
//
|
||||
// Parameters:
|
||||
// + name: body
|
||||
// require: true
|
||||
// in: body
|
||||
// type: RegisterReq
|
||||
//
|
||||
// Responses:
|
||||
// 200: BaseID
|
||||
|
||||
func RegisterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
const transErr = true
|
||||
var req types.RegisterReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := auth.NewRegisterLogic(r, r.Context(), svcCtx)
|
||||
resp, err := l.Register(&req)
|
||||
|
||||
statusz.ResponseHandler(r, w, transErr, resp, err)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package base
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/base"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
)
|
||||
|
||||
// swagger:route get /api/base/initDatabase base InitDatabase
|
||||
//
|
||||
// Initialize database | 初始化数据库
|
||||
//
|
||||
// Initialize database | 初始化数据库
|
||||
//
|
||||
|
||||
func InitDatabaseHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
const transErr = true
|
||||
|
||||
l := base.NewInitDatabaseLogic(r, r.Context(), svcCtx)
|
||||
err := l.InitDatabase()
|
||||
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package captcha
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/captcha"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
)
|
||||
|
||||
// swagger:route get /api/captcha captcha GetCaptcha
|
||||
//
|
||||
// Get Captcha | 获取验证码
|
||||
//
|
||||
// Get Captcha | 获取验证码
|
||||
//
|
||||
// Responses:
|
||||
// 200: CaptchaInfo
|
||||
|
||||
func GetCaptchaHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
const transErr = true
|
||||
|
||||
l := captcha.NewGetCaptchaLogic(r, r.Context(), svcCtx)
|
||||
resp, err := l.GetCaptcha()
|
||||
|
||||
statusz.ResponseHandler(r, w, transErr, resp, err)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package captcha
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/captcha"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
)
|
||||
|
||||
// swagger:route post /api/captcha/validate captcha ValidateCaptcha
|
||||
//
|
||||
// Validating captcha | 验证验证码正确性
|
||||
//
|
||||
// Validating captcha | 验证验证码正确性
|
||||
//
|
||||
// Parameters:
|
||||
// + name: body
|
||||
// require: true
|
||||
// in: body
|
||||
// type: ValidateCaptchaReq
|
||||
//
|
||||
|
||||
func ValidateCaptchaHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
const transErr = true
|
||||
var req types.ValidateCaptchaReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := captcha.NewValidateCaptchaLogic(r, r.Context(), svcCtx)
|
||||
err := l.ValidateCaptcha(&req)
|
||||
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package department_admin
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/department_admin"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
)
|
||||
|
||||
// swagger:route post /api/admin/department/create department_admin CreateDepartmentAdmin
|
||||
//
|
||||
// Create department | 创建部门
|
||||
//
|
||||
// Create department | 创建部门
|
||||
//
|
||||
// Parameters:
|
||||
// + name: body
|
||||
// require: true
|
||||
// in: body
|
||||
// type: DepartmentInfo
|
||||
//
|
||||
// Responses:
|
||||
// 200: BaseID
|
||||
|
||||
func CreateDepartmentAdminHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
const transErr = true
|
||||
var req types.DepartmentInfo
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := department_admin.NewCreateDepartmentAdminLogic(r, r.Context(), svcCtx)
|
||||
resp, err := l.CreateDepartmentAdmin(&req)
|
||||
|
||||
statusz.ResponseHandler(r, w, transErr, resp, err)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package department_admin
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/department_admin"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
)
|
||||
|
||||
// swagger:route delete /api/admin/department department_admin DeleteDepartmentAdmin
|
||||
//
|
||||
// Delete department | 删除部门
|
||||
//
|
||||
// Delete department | 删除部门
|
||||
//
|
||||
// Parameters:
|
||||
// + name: body
|
||||
// require: true
|
||||
// in: body
|
||||
// type: BaseIDs
|
||||
//
|
||||
|
||||
func DeleteDepartmentAdminHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
const transErr = true
|
||||
var req types.BaseIDs
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := department_admin.NewDeleteDepartmentAdminLogic(r, r.Context(), svcCtx)
|
||||
err := l.DeleteDepartmentAdmin(&req)
|
||||
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package department_admin
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/department_admin"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
)
|
||||
|
||||
// swagger:route get /api/admin/department department_admin GetDepartmentAdmin
|
||||
//
|
||||
// Get department | 获取部门
|
||||
//
|
||||
// Get department | 获取部门
|
||||
//
|
||||
// Responses:
|
||||
// 200: DepartmentInfo
|
||||
|
||||
func GetDepartmentAdminHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
const transErr = true
|
||||
var req types.DepartmentReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := department_admin.NewGetDepartmentAdminLogic(r, r.Context(), svcCtx)
|
||||
resp, err := l.GetDepartmentAdmin(&req)
|
||||
|
||||
statusz.ResponseHandler(r, w, transErr, resp, err)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package department_admin
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/department_admin"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
)
|
||||
|
||||
// swagger:route get /api/admin/department/list department_admin GetDepartmentListAdmin
|
||||
//
|
||||
// Get department list | 获取部门列表
|
||||
//
|
||||
// Get department list | 获取部门列表
|
||||
//
|
||||
// Responses:
|
||||
// 200: DepartmentListResp
|
||||
|
||||
func GetDepartmentListAdminHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
const transErr = true
|
||||
var req types.DepartmentReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := department_admin.NewGetDepartmentListAdminLogic(r, r.Context(), svcCtx)
|
||||
resp, err := l.GetDepartmentListAdmin(&req)
|
||||
|
||||
statusz.ResponseHandler(r, w, transErr, resp, err)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package department_admin
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/department_admin"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
)
|
||||
|
||||
// swagger:route post /api/admin/department/update department_admin UpdateDepartmentAdmin
|
||||
//
|
||||
// Update department info | 更新部门信息
|
||||
//
|
||||
// Update department info | 更新部门信息
|
||||
//
|
||||
// Parameters:
|
||||
// + name: body
|
||||
// require: true
|
||||
// in: body
|
||||
// type: DepartmentInfo
|
||||
//
|
||||
|
||||
func UpdateDepartmentAdminHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
const transErr = true
|
||||
var req types.DepartmentInfo
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := department_admin.NewUpdateDepartmentAdminLogic(r, r.Context(), svcCtx)
|
||||
err := l.UpdateDepartmentAdmin(&req)
|
||||
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package dictionary_admin
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/dictionary_admin"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
)
|
||||
|
||||
// swagger:route post /api/admin/dictionary/create dictionary_admin CreateDictionaryAdmin
|
||||
//
|
||||
// Create dictionary | 创建字典
|
||||
//
|
||||
// Create dictionary | 创建字典
|
||||
//
|
||||
// Parameters:
|
||||
// + name: body
|
||||
// require: true
|
||||
// in: body
|
||||
// type: DictionaryInfo
|
||||
//
|
||||
// Responses:
|
||||
// 200: BaseID
|
||||
|
||||
func CreateDictionaryAdminHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
const transErr = true
|
||||
var req types.DictionaryInfo
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := dictionary_admin.NewCreateDictionaryAdminLogic(r, r.Context(), svcCtx)
|
||||
resp, err := l.CreateDictionaryAdmin(&req)
|
||||
|
||||
statusz.ResponseHandler(r, w, transErr, resp, err)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package dictionary_admin
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/dictionary_admin"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
)
|
||||
|
||||
// swagger:route delete /api/admin/dictionary dictionary_admin DeleteDictionaryAdmin
|
||||
//
|
||||
// Delete dictionary | 删除字典
|
||||
//
|
||||
// Delete dictionary | 删除字典
|
||||
//
|
||||
// Parameters:
|
||||
// + name: body
|
||||
// require: true
|
||||
// in: body
|
||||
// type: BaseIDs
|
||||
//
|
||||
|
||||
func DeleteDictionaryAdminHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
const transErr = true
|
||||
var req types.BaseIDs
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := dictionary_admin.NewDeleteDictionaryAdminLogic(r, r.Context(), svcCtx)
|
||||
err := l.DeleteDictionaryAdmin(&req)
|
||||
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package detail
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/dictionary_admin/detail"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
)
|
||||
|
||||
// swagger:route post /api/admin/dictionary/detail/create dictionary_admin/detail CreateDictionaryDetailAdmin
|
||||
//
|
||||
// Create dictionary Detail | 创建字典项
|
||||
//
|
||||
// Create dictionary Detail | 创建字典项
|
||||
//
|
||||
// Parameters:
|
||||
// + name: body
|
||||
// require: true
|
||||
// in: body
|
||||
// type: DictionaryDetailInfo
|
||||
//
|
||||
// Responses:
|
||||
// 200: BaseID
|
||||
|
||||
func CreateDictionaryDetailAdminHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
const transErr = true
|
||||
var req types.DictionaryDetailInfo
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := detail.NewCreateDictionaryDetailAdminLogic(r, r.Context(), svcCtx)
|
||||
resp, err := l.CreateDictionaryDetailAdmin(&req)
|
||||
|
||||
statusz.ResponseHandler(r, w, transErr, resp, err)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package detail
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/dictionary_admin/detail"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
)
|
||||
|
||||
// swagger:route delete /api/admin/dictionary/detail dictionary_admin/detail DeleteDictionaryDetailAdmin
|
||||
//
|
||||
// Delete dictionary | 删除字典项(批量)
|
||||
//
|
||||
// Delete dictionary | 删除字典项(批量)
|
||||
//
|
||||
|
||||
func DeleteDictionaryDetailAdminHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
const transErr = true
|
||||
var req types.DeleteDictionaryDetailReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := detail.NewDeleteDictionaryDetailAdminLogic(r, r.Context(), svcCtx)
|
||||
err := l.DeleteDictionaryDetailAdmin(&req)
|
||||
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package detail
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/dictionary_admin/detail"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
)
|
||||
|
||||
// swagger:route get /api/admin/dictionary/detail dictionary_admin/detail GetDictionaryDetailAdmin
|
||||
//
|
||||
// Get dictionary | 获取字典项
|
||||
//
|
||||
// Get dictionary | 获取字典项
|
||||
//
|
||||
// Responses:
|
||||
// 200: DictionaryDetailInfo
|
||||
|
||||
func GetDictionaryDetailAdminHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
const transErr = true
|
||||
var req types.DictionaryDetailReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := detail.NewGetDictionaryDetailAdminLogic(r, r.Context(), svcCtx)
|
||||
resp, err := l.GetDictionaryDetailAdmin(&req)
|
||||
|
||||
statusz.ResponseHandler(r, w, transErr, resp, err)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package detail
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/dictionary_admin/detail"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
)
|
||||
|
||||
// swagger:route get /api/admin/dictionary/detail/list dictionary_admin/detail GetDictionaryDetailListAdmin
|
||||
//
|
||||
// Get dictionary list | 获取字典项列表
|
||||
//
|
||||
// Get dictionary list | 获取字典项列表
|
||||
//
|
||||
// Responses:
|
||||
// 200: DictionaryDetailListResp
|
||||
|
||||
func GetDictionaryDetailListAdminHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
const transErr = true
|
||||
var req types.DictionaryDetailReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := detail.NewGetDictionaryDetailListAdminLogic(r, r.Context(), svcCtx)
|
||||
resp, err := l.GetDictionaryDetailListAdmin(&req)
|
||||
|
||||
statusz.ResponseHandler(r, w, transErr, resp, err)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package detail
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/dictionary_admin/detail"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
)
|
||||
|
||||
// swagger:route post /api/admin/dictionary/detail/update dictionary_admin/detail UpdateDictionaryDetailAdmin
|
||||
//
|
||||
// Update dictionary info | 更新字典项信息
|
||||
//
|
||||
// Update dictionary info | 更新字典项信息
|
||||
//
|
||||
// Parameters:
|
||||
// + name: body
|
||||
// require: true
|
||||
// in: body
|
||||
// type: DictionaryDetailInfo
|
||||
//
|
||||
|
||||
func UpdateDictionaryDetailAdminHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
const transErr = true
|
||||
var req types.DictionaryDetailInfo
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := detail.NewUpdateDictionaryDetailAdminLogic(r, r.Context(), svcCtx)
|
||||
err := l.UpdateDictionaryDetailAdmin(&req)
|
||||
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package dictionary_admin
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/dictionary_admin"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
)
|
||||
|
||||
// swagger:route get /api/admin/dictionary dictionary_admin GetDictionaryAdmin
|
||||
//
|
||||
// Get dictionary | 获取字典
|
||||
//
|
||||
// Get dictionary | 获取字典
|
||||
//
|
||||
// Responses:
|
||||
// 200: DictionaryInfo
|
||||
|
||||
func GetDictionaryAdminHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
const transErr = true
|
||||
var req types.DictionaryReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := dictionary_admin.NewGetDictionaryAdminLogic(r, r.Context(), svcCtx)
|
||||
resp, err := l.GetDictionaryAdmin(&req)
|
||||
|
||||
statusz.ResponseHandler(r, w, transErr, resp, err)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package dictionary_admin
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/dictionary_admin"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
)
|
||||
|
||||
// swagger:route get /api/admin/dictionary/list dictionary_admin GetDictionaryListAdmin
|
||||
//
|
||||
// Get dictionary list | 获取字典列表
|
||||
//
|
||||
// Get dictionary list | 获取字典列表
|
||||
//
|
||||
// Responses:
|
||||
// 200: DictionaryListResp
|
||||
|
||||
func GetDictionaryListAdminHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
const transErr = true
|
||||
var req types.DictionaryReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := dictionary_admin.NewGetDictionaryListAdminLogic(r, r.Context(), svcCtx)
|
||||
resp, err := l.GetDictionaryListAdmin(&req)
|
||||
|
||||
statusz.ResponseHandler(r, w, transErr, resp, err)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package dictionary_admin
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/dictionary_admin"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
)
|
||||
|
||||
// swagger:route post /api/admin/dictionary/update dictionary_admin UpdateDictionaryAdmin
|
||||
//
|
||||
// Update dictionary info | 更新字典信息
|
||||
//
|
||||
// Update dictionary info | 更新字典信息
|
||||
//
|
||||
// Parameters:
|
||||
// + name: body
|
||||
// require: true
|
||||
// in: body
|
||||
// type: DictionaryInfo
|
||||
//
|
||||
|
||||
func UpdateDictionaryAdminHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
const transErr = true
|
||||
var req types.DictionaryInfo
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := dictionary_admin.NewUpdateDictionaryAdminLogic(r, r.Context(), svcCtx)
|
||||
err := l.UpdateDictionaryAdmin(&req)
|
||||
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package district
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/district"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
)
|
||||
|
||||
// swagger:route get /api/district/children district GetDistrictChildren
|
||||
//
|
||||
// get district children | 获取子级地址列表
|
||||
//
|
||||
// get district children | 获取子级地址列表
|
||||
//
|
||||
// Responses:
|
||||
// 200: []*DistrictInfo
|
||||
|
||||
func GetDistrictChildrenHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
const transErr = true
|
||||
var req types.GetDistrictChildrenReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := district.NewGetDistrictChildrenLogic(r, r.Context(), svcCtx)
|
||||
resp, err := l.GetDistrictChildren(&req)
|
||||
|
||||
statusz.ResponseHandler(r, w, transErr, resp, err)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package district
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/district"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
)
|
||||
|
||||
// swagger:route get /api/district/list district GetDistrictList
|
||||
//
|
||||
// get district list | 获取地址列表
|
||||
//
|
||||
// get district list | 获取地址列表
|
||||
//
|
||||
// Responses:
|
||||
// 200: []*DistrictInfo
|
||||
|
||||
func GetDistrictListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
const transErr = true
|
||||
var req types.GetDistrictListReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := district.NewGetDistrictListLogic(r, r.Context(), svcCtx)
|
||||
resp, err := l.GetDistrictList(&req)
|
||||
|
||||
statusz.ResponseHandler(r, w, transErr, resp, err)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package district
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/district"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
)
|
||||
|
||||
// swagger:route get /api/district/name district GetDistrictName
|
||||
//
|
||||
// get district name list | 获取地址名
|
||||
//
|
||||
// get district name list | 获取地址名
|
||||
//
|
||||
// Responses:
|
||||
// 200: GetDistrictNameResp
|
||||
|
||||
func GetDistrictNameHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
const transErr = true
|
||||
var req types.GetDistrictNameReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := district.NewGetDistrictNameLogic(r, r.Context(), svcCtx)
|
||||
resp, err := l.GetDistrictName(&req)
|
||||
|
||||
statusz.ResponseHandler(r, w, transErr, resp, err)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package district
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/district"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
)
|
||||
|
||||
// swagger:route get /api/district/tree district GetDistrictTree
|
||||
//
|
||||
// get district tree | 获取地址树,整棵树
|
||||
//
|
||||
// get district tree | 获取地址树,整棵树
|
||||
//
|
||||
// Responses:
|
||||
// 200: DistrictTree
|
||||
|
||||
func GetDistrictTreeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
const transErr = true
|
||||
var req types.DistrictReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := district.NewGetDistrictTreeLogic(r, r.Context(), svcCtx)
|
||||
resp, err := l.GetDistrictTree(&req)
|
||||
|
||||
statusz.ResponseHandler(r, w, transErr, resp, err)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package oauthprovider_admin
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/oauthprovider_admin"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
)
|
||||
|
||||
// swagger:route post /api/admin/oauth_provider/create oauthprovider_admin CreateOauthProviderAdmin
|
||||
//
|
||||
// Create oauth provider information | 创建第三方信息
|
||||
//
|
||||
// Create oauth provider information | 创建第三方信息
|
||||
//
|
||||
// Parameters:
|
||||
// + name: body
|
||||
// require: true
|
||||
// in: body
|
||||
// type: OauthProviderInfo
|
||||
//
|
||||
|
||||
func CreateOauthProviderAdminHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
const transErr = true
|
||||
var req types.OauthProviderInfo
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := oauthprovider_admin.NewCreateOauthProviderAdminLogic(r, r.Context(), svcCtx)
|
||||
err := l.CreateOauthProviderAdmin(&req)
|
||||
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package oauthprovider_admin
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/oauthprovider_admin"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
)
|
||||
|
||||
// swagger:route post /api/admin/oauth_provider/delete oauthprovider_admin DeleteOauthProviderAdmin
|
||||
//
|
||||
// Delete oauth provider information | 删除第三方信息
|
||||
//
|
||||
// Delete oauth provider information | 删除第三方信息
|
||||
//
|
||||
// Parameters:
|
||||
// + name: body
|
||||
// require: true
|
||||
// in: body
|
||||
// type: BaseIDs
|
||||
//
|
||||
|
||||
func DeleteOauthProviderAdminHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
const transErr = true
|
||||
var req types.BaseIDs
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := oauthprovider_admin.NewDeleteOauthProviderAdminLogic(r, r.Context(), svcCtx)
|
||||
err := l.DeleteOauthProviderAdmin(&req)
|
||||
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package oauthprovider_admin
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/oauthprovider_admin"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
)
|
||||
|
||||
// swagger:route get /api/admin/oauth_provider oauthprovider_admin GetOauthProviderAdmin
|
||||
//
|
||||
// Get oauth provider by Params | 根据条件获取第三方信息
|
||||
//
|
||||
// Get oauth provider by Params | 根据条件获取第三方信息
|
||||
//
|
||||
// Responses:
|
||||
// 200: OauthProviderInfo
|
||||
|
||||
func GetOauthProviderAdminHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
const transErr = true
|
||||
var req types.OauthProviderReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := oauthprovider_admin.NewGetOauthProviderAdminLogic(r, r.Context(), svcCtx)
|
||||
resp, err := l.GetOauthProviderAdmin(&req)
|
||||
|
||||
statusz.ResponseHandler(r, w, transErr, resp, err)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package oauthprovider_admin
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/oauthprovider_admin"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
)
|
||||
|
||||
// swagger:route get /api/admin/oauth_provider/list oauthprovider_admin GetOauthProviderListAdmin
|
||||
//
|
||||
// Get oauth provider list | 获取第三方信息列表
|
||||
//
|
||||
// Get oauth provider list | 获取第三方信息列表
|
||||
//
|
||||
// Responses:
|
||||
// 200: OauthProviderListResp
|
||||
|
||||
func GetOauthProviderListAdminHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
const transErr = true
|
||||
var req types.OauthProviderReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := oauthprovider_admin.NewGetOauthProviderListAdminLogic(r, r.Context(), svcCtx)
|
||||
resp, err := l.GetOauthProviderListAdmin(&req)
|
||||
|
||||
statusz.ResponseHandler(r, w, transErr, resp, err)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package oauthprovider_admin
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/oauthprovider_admin"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
)
|
||||
|
||||
// swagger:route post /api/admin/oauth_provider/update oauthprovider_admin UpdateOauthProviderAdmin
|
||||
//
|
||||
// Update oauth provider information | 更新第三方信息
|
||||
//
|
||||
// Update oauth provider information | 更新第三方信息
|
||||
//
|
||||
// Parameters:
|
||||
// + name: body
|
||||
// require: true
|
||||
// in: body
|
||||
// type: OauthProviderInfo
|
||||
//
|
||||
|
||||
func UpdateOauthProviderAdminHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
const transErr = true
|
||||
var req types.OauthProviderInfo
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := oauthprovider_admin.NewUpdateOauthProviderAdminLogic(r, r.Context(), svcCtx)
|
||||
err := l.UpdateOauthProviderAdmin(&req)
|
||||
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package role_admin
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/role_admin"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
)
|
||||
|
||||
// swagger:route post /api/admin/role/create role_admin CreateRoleAdmin
|
||||
//
|
||||
// Create role information | 创建角色
|
||||
//
|
||||
// Create role information | 创建角色
|
||||
//
|
||||
// Parameters:
|
||||
// + name: body
|
||||
// require: true
|
||||
// in: body
|
||||
// type: RoleInfo
|
||||
//
|
||||
|
||||
func CreateRoleAdminHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
const transErr = true
|
||||
var req types.RoleInfo
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := role_admin.NewCreateRoleAdminLogic(r, r.Context(), svcCtx)
|
||||
err := l.CreateRoleAdmin(&req)
|
||||
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package role_admin
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/role_admin"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
)
|
||||
|
||||
// swagger:route delete /api/admin/role role_admin DeleteRoleAdmin
|
||||
//
|
||||
// Delete role information | 删除角色信息
|
||||
//
|
||||
// Delete role information | 删除角色信息
|
||||
//
|
||||
// Parameters:
|
||||
// + name: body
|
||||
// require: true
|
||||
// in: body
|
||||
// type: BaseIDs
|
||||
//
|
||||
|
||||
func DeleteRoleAdminHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
const transErr = true
|
||||
var req types.BaseIDs
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := role_admin.NewDeleteRoleAdminLogic(r, r.Context(), svcCtx)
|
||||
err := l.DeleteRoleAdmin(&req)
|
||||
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package role_admin
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/role_admin"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
)
|
||||
|
||||
// swagger:route get /api/admin/role role_admin GetRoleAdmin
|
||||
//
|
||||
// Get Role | 根据条件获取角色
|
||||
//
|
||||
// Get Role | 根据条件获取角色
|
||||
//
|
||||
// Responses:
|
||||
// 200: RoleInfo
|
||||
|
||||
func GetRoleAdminHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
const transErr = true
|
||||
var req types.RoleReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := role_admin.NewGetRoleAdminLogic(r, r.Context(), svcCtx)
|
||||
resp, err := l.GetRoleAdmin(&req)
|
||||
|
||||
statusz.ResponseHandler(r, w, transErr, resp, err)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package role_admin
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/role_admin"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
)
|
||||
|
||||
// swagger:route get /api/admin/role/list role_admin GetRoleListAdmin
|
||||
//
|
||||
// Get role list | 获取角色列表
|
||||
//
|
||||
// Get role list | 获取角色列表
|
||||
//
|
||||
// Responses:
|
||||
// 200: RoleListResp
|
||||
|
||||
func GetRoleListAdminHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
const transErr = true
|
||||
var req types.RoleReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := role_admin.NewGetRoleListAdminLogic(r, r.Context(), svcCtx)
|
||||
resp, err := l.GetRoleListAdmin(&req)
|
||||
|
||||
statusz.ResponseHandler(r, w, transErr, resp, err)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package role_admin
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/role_admin"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
)
|
||||
|
||||
// swagger:route post /api/admin/role/update role_admin UpdateRoleAdmin
|
||||
//
|
||||
// Update role information | 更新角色
|
||||
//
|
||||
// Update role information | 更新角色
|
||||
//
|
||||
// Parameters:
|
||||
// + name: body
|
||||
// require: true
|
||||
// in: body
|
||||
// type: RoleInfo
|
||||
//
|
||||
|
||||
func UpdateRoleAdminHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
const transErr = true
|
||||
var req types.RoleInfo
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := role_admin.NewUpdateRoleAdminLogic(r, r.Context(), svcCtx)
|
||||
err := l.UpdateRoleAdmin(&req)
|
||||
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,363 @@
|
||||
// Code generated by goctl. DO NOT EDIT.
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
auth "git.noahlan.cn/n-admin/n-admin-server/api/internal/handler/auth"
|
||||
base "git.noahlan.cn/n-admin/n-admin-server/api/internal/handler/base"
|
||||
captcha "git.noahlan.cn/n-admin/n-admin-server/api/internal/handler/captcha"
|
||||
department_admin "git.noahlan.cn/n-admin/n-admin-server/api/internal/handler/department_admin"
|
||||
dictionary_admin "git.noahlan.cn/n-admin/n-admin-server/api/internal/handler/dictionary_admin"
|
||||
dictionary_admindetail "git.noahlan.cn/n-admin/n-admin-server/api/internal/handler/dictionary_admin/detail"
|
||||
district "git.noahlan.cn/n-admin/n-admin-server/api/internal/handler/district"
|
||||
oauthprovider_admin "git.noahlan.cn/n-admin/n-admin-server/api/internal/handler/oauthprovider_admin"
|
||||
role_admin "git.noahlan.cn/n-admin/n-admin-server/api/internal/handler/role_admin"
|
||||
token_admin "git.noahlan.cn/n-admin/n-admin-server/api/internal/handler/token_admin"
|
||||
user "git.noahlan.cn/n-admin/n-admin-server/api/internal/handler/user"
|
||||
user_admin "git.noahlan.cn/n-admin/n-admin-server/api/internal/handler/user_admin"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
)
|
||||
|
||||
func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/initDatabase",
|
||||
Handler: base.InitDatabaseHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithPrefix("/api/base"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/oauth/login",
|
||||
Handler: auth.OauthLoginHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/oauth/login/byCode",
|
||||
Handler: auth.OauthLoginByCodeHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/oauth/login/byPhone",
|
||||
Handler: auth.OauthLoginByPhoneHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/oauth/login/callback",
|
||||
Handler: auth.OauthCallbackHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/login",
|
||||
Handler: auth.LoginHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/login/byCode",
|
||||
Handler: auth.LoginByCodeHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/register",
|
||||
Handler: auth.RegisterHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithPrefix("/api/auth"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
rest.WithMiddlewares(
|
||||
[]rest.Middleware{serverCtx.Authority},
|
||||
[]rest.Route{
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/create",
|
||||
Handler: user_admin.CreateUserAdminHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/update",
|
||||
Handler: user_admin.UpdateUserAdminHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/list",
|
||||
Handler: user_admin.GetUserListAdminHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/",
|
||||
Handler: user_admin.GetUserAdminHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodDelete,
|
||||
Path: "/",
|
||||
Handler: user_admin.DeleteUserAdminHandler(serverCtx),
|
||||
},
|
||||
}...,
|
||||
),
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
rest.WithPrefix("/api/admin/user"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
rest.WithMiddlewares(
|
||||
[]rest.Middleware{serverCtx.Authority},
|
||||
[]rest.Route{
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/",
|
||||
Handler: user.GetCurrentUserHandler(serverCtx),
|
||||
},
|
||||
}...,
|
||||
),
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
rest.WithPrefix("/api/user"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
rest.WithMiddlewares(
|
||||
[]rest.Middleware{serverCtx.Authority},
|
||||
[]rest.Route{
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/create",
|
||||
Handler: role_admin.CreateRoleAdminHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/update",
|
||||
Handler: role_admin.UpdateRoleAdminHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodDelete,
|
||||
Path: "/",
|
||||
Handler: role_admin.DeleteRoleAdminHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/list",
|
||||
Handler: role_admin.GetRoleListAdminHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/",
|
||||
Handler: role_admin.GetRoleAdminHandler(serverCtx),
|
||||
},
|
||||
}...,
|
||||
),
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
rest.WithPrefix("/api/admin/role"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
rest.WithMiddlewares(
|
||||
[]rest.Middleware{serverCtx.Authority},
|
||||
[]rest.Route{
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/list",
|
||||
Handler: token_admin.GetTokenListAdminHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/disable",
|
||||
Handler: token_admin.DisableTokenAdminHandler(serverCtx),
|
||||
},
|
||||
}...,
|
||||
),
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
rest.WithPrefix("/api/admin/token"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/",
|
||||
Handler: captcha.GetCaptchaHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/validate",
|
||||
Handler: captcha.ValidateCaptchaHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithPrefix("/api/captcha"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/tree",
|
||||
Handler: district.GetDistrictTreeHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/list",
|
||||
Handler: district.GetDistrictListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/children",
|
||||
Handler: district.GetDistrictChildrenHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/name",
|
||||
Handler: district.GetDistrictNameHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithPrefix("/api/district"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
rest.WithMiddlewares(
|
||||
[]rest.Middleware{serverCtx.Authority},
|
||||
[]rest.Route{
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/create",
|
||||
Handler: oauthprovider_admin.CreateOauthProviderAdminHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/update",
|
||||
Handler: oauthprovider_admin.UpdateOauthProviderAdminHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/delete",
|
||||
Handler: oauthprovider_admin.DeleteOauthProviderAdminHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/list",
|
||||
Handler: oauthprovider_admin.GetOauthProviderListAdminHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/",
|
||||
Handler: oauthprovider_admin.GetOauthProviderAdminHandler(serverCtx),
|
||||
},
|
||||
}...,
|
||||
),
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
rest.WithPrefix("/api/admin/oauth_provider"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
rest.WithMiddlewares(
|
||||
[]rest.Middleware{serverCtx.Authority},
|
||||
[]rest.Route{
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/create",
|
||||
Handler: department_admin.CreateDepartmentAdminHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/update",
|
||||
Handler: department_admin.UpdateDepartmentAdminHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/list",
|
||||
Handler: department_admin.GetDepartmentListAdminHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/",
|
||||
Handler: department_admin.GetDepartmentAdminHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodDelete,
|
||||
Path: "/",
|
||||
Handler: department_admin.DeleteDepartmentAdminHandler(serverCtx),
|
||||
},
|
||||
}...,
|
||||
),
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
rest.WithPrefix("/api/admin/department"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
rest.WithMiddlewares(
|
||||
[]rest.Middleware{serverCtx.Authority},
|
||||
[]rest.Route{
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/create",
|
||||
Handler: dictionary_admin.CreateDictionaryAdminHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/update",
|
||||
Handler: dictionary_admin.UpdateDictionaryAdminHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/list",
|
||||
Handler: dictionary_admin.GetDictionaryListAdminHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/",
|
||||
Handler: dictionary_admin.GetDictionaryAdminHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodDelete,
|
||||
Path: "/",
|
||||
Handler: dictionary_admin.DeleteDictionaryAdminHandler(serverCtx),
|
||||
},
|
||||
}...,
|
||||
),
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
rest.WithPrefix("/api/admin/dictionary"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
rest.WithMiddlewares(
|
||||
[]rest.Middleware{serverCtx.Authority},
|
||||
[]rest.Route{
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/create",
|
||||
Handler: dictionary_admindetail.CreateDictionaryDetailAdminHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/update",
|
||||
Handler: dictionary_admindetail.UpdateDictionaryDetailAdminHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/list",
|
||||
Handler: dictionary_admindetail.GetDictionaryDetailListAdminHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/",
|
||||
Handler: dictionary_admindetail.GetDictionaryDetailAdminHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodDelete,
|
||||
Path: "/",
|
||||
Handler: dictionary_admindetail.DeleteDictionaryDetailAdminHandler(serverCtx),
|
||||
},
|
||||
}...,
|
||||
),
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
rest.WithPrefix("/api/admin/dictionary/detail"),
|
||||
)
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package token_admin
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/token_admin"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
)
|
||||
|
||||
// swagger:route post /api/admin/token/disable token_admin DisableTokenAdmin
|
||||
//
|
||||
// Disable token | 禁用凭证(强制下线)
|
||||
//
|
||||
// Disable token | 禁用凭证(强制下线)
|
||||
//
|
||||
// Parameters:
|
||||
// + name: body
|
||||
// require: true
|
||||
// in: body
|
||||
// type: BaseID
|
||||
//
|
||||
|
||||
func DisableTokenAdminHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
const transErr = true
|
||||
var req types.BaseID
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := token_admin.NewDisableTokenAdminLogic(r, r.Context(), svcCtx)
|
||||
err := l.DisableTokenAdmin(&req)
|
||||
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package token_admin
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/token_admin"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
)
|
||||
|
||||
// swagger:route get /api/admin/token/list token_admin GetTokenListAdmin
|
||||
//
|
||||
// Get token list | 获取凭证列表
|
||||
//
|
||||
// Get token list | 获取凭证列表
|
||||
//
|
||||
// Responses:
|
||||
// 200: TokenListResp
|
||||
|
||||
func GetTokenListAdminHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
const transErr = true
|
||||
var req types.TokenReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := token_admin.NewGetTokenListAdminLogic(r, r.Context(), svcCtx)
|
||||
resp, err := l.GetTokenListAdmin(&req)
|
||||
|
||||
statusz.ResponseHandler(r, w, transErr, resp, err)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/user"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
)
|
||||
|
||||
// swagger:route get /api/user user GetCurrentUser
|
||||
//
|
||||
// Get Current User | 获取当前登录用户信息
|
||||
//
|
||||
// Get Current User | 获取当前登录用户信息
|
||||
//
|
||||
// Responses:
|
||||
// 200: UserInfo
|
||||
|
||||
func GetCurrentUserHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
const transErr = true
|
||||
|
||||
l := user.NewGetCurrentUserLogic(r, r.Context(), svcCtx)
|
||||
resp, err := l.GetCurrentUser()
|
||||
|
||||
statusz.ResponseHandler(r, w, transErr, resp, err)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package user_admin
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/user_admin"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
)
|
||||
|
||||
// swagger:route post /api/admin/user/create user_admin CreateUserAdmin
|
||||
//
|
||||
// Create user | 创建用户
|
||||
//
|
||||
// Create user | 创建用户
|
||||
//
|
||||
// Parameters:
|
||||
// + name: body
|
||||
// require: true
|
||||
// in: body
|
||||
// type: UserInfo
|
||||
//
|
||||
// Responses:
|
||||
// 200: BaseID
|
||||
|
||||
func CreateUserAdminHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
const transErr = true
|
||||
var req types.UserInfo
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := user_admin.NewCreateUserAdminLogic(r, r.Context(), svcCtx)
|
||||
resp, err := l.CreateUserAdmin(&req)
|
||||
|
||||
statusz.ResponseHandler(r, w, transErr, resp, err)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package user_admin
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/user_admin"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
)
|
||||
|
||||
// swagger:route delete /api/admin/user user_admin DeleteUserAdmin
|
||||
//
|
||||
// Delete user | 删除用户
|
||||
//
|
||||
// Delete user | 删除用户
|
||||
//
|
||||
// Parameters:
|
||||
// + name: body
|
||||
// require: true
|
||||
// in: body
|
||||
// type: BaseIDs
|
||||
//
|
||||
|
||||
func DeleteUserAdminHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
const transErr = true
|
||||
var req types.BaseIDs
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := user_admin.NewDeleteUserAdminLogic(r, r.Context(), svcCtx)
|
||||
err := l.DeleteUserAdmin(&req)
|
||||
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package user_admin
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/user_admin"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
)
|
||||
|
||||
// swagger:route get /api/admin/user user_admin GetUserAdmin
|
||||
//
|
||||
// Get user | 获取用户
|
||||
//
|
||||
// Get user | 获取用户
|
||||
//
|
||||
// Responses:
|
||||
// 200: UserInfo
|
||||
|
||||
func GetUserAdminHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
const transErr = true
|
||||
var req types.UserReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := user_admin.NewGetUserAdminLogic(r, r.Context(), svcCtx)
|
||||
resp, err := l.GetUserAdmin(&req)
|
||||
|
||||
statusz.ResponseHandler(r, w, transErr, resp, err)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package user_admin
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/user_admin"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
)
|
||||
|
||||
// swagger:route get /api/admin/user/list user_admin GetUserListAdmin
|
||||
//
|
||||
// Get user list | 获取用户列表
|
||||
//
|
||||
// Get user list | 获取用户列表
|
||||
//
|
||||
// Responses:
|
||||
// 200: UserListResp
|
||||
|
||||
func GetUserListAdminHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
const transErr = true
|
||||
var req types.UserReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := user_admin.NewGetUserListAdminLogic(r, r.Context(), svcCtx)
|
||||
resp, err := l.GetUserListAdmin(&req)
|
||||
|
||||
statusz.ResponseHandler(r, w, transErr, resp, err)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package user_admin
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/user_admin"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
)
|
||||
|
||||
// swagger:route post /api/admin/user/update user_admin UpdateUserAdmin
|
||||
//
|
||||
// Update user | 更新用户信息
|
||||
//
|
||||
// Update user | 更新用户信息
|
||||
//
|
||||
// Parameters:
|
||||
// + name: body
|
||||
// require: true
|
||||
// in: body
|
||||
// type: UserInfo
|
||||
//
|
||||
|
||||
func UpdateUserAdminHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
const transErr = true
|
||||
var req types.UserInfo
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := user_admin.NewUpdateUserAdminLogic(r, r.Context(), svcCtx)
|
||||
err := l.UpdateUserAdmin(&req)
|
||||
|
||||
statusz.ResponseHandler(r, w, transErr, nil, err)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,116 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/dal/errx"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/types/core"
|
||||
"git.noahlan.cn/noahlan/ntool-biz/core/nstatus"
|
||||
"git.noahlan.cn/noahlan/ntool-biz/core/nstatus/msg"
|
||||
"git.noahlan.cn/noahlan/ntool/nstd/tea"
|
||||
"git.noahlan.cn/noahlan/ntool/nstr"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type LoginByCodeLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
r *http.Request
|
||||
}
|
||||
|
||||
func NewLoginByCodeLogic(r *http.Request, ctx context.Context, svcCtx *svc.ServiceContext) *LoginByCodeLogic {
|
||||
return &LoginByCodeLogic{
|
||||
r: r,
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *LoginByCodeLogic) LoginByCode(req *types.LoginReq) (resp *types.LoginResp, err error) {
|
||||
if err := l.svcCtx.Captcha.Verify(req.CaptchaId, req.Captcha, true); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var user *core.UserInfo
|
||||
if nstr.IsChineseMobile(req.Subject) {
|
||||
// mobile
|
||||
user, err = l.getUserByPhone(req.Subject, req.Credentials)
|
||||
} else if nstr.IsEmpty(req.Subject) {
|
||||
// email
|
||||
user, err = l.getUserByEmail(req.Subject, req.Credentials)
|
||||
} else {
|
||||
return nil, nstatus.NewBizErrWithCode(errx.NeedPhoneOrEmail)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 登录
|
||||
resp, err = login(l.ctx, l.svcCtx, l.r, user)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (l *LoginByCodeLogic) getUserByPhone(phone, credentials string) (*core.UserInfo, error) {
|
||||
// 验证
|
||||
code, _, err := l.svcCtx.CodeCache.GetCachedCode(phone, types.CodeSourceSms, types.SmsCodeTypeLogin)
|
||||
if err != nil {
|
||||
return nil, nstatus.NewApiInternalErr(msg.CacheError)
|
||||
}
|
||||
if credentials != code {
|
||||
return nil, nstatus.NewBizErrWithCode(errx.WrongCode)
|
||||
}
|
||||
dbData, err := l.svcCtx.CoreRpc.GetUser(l.ctx, &core.UserReq{
|
||||
PhoneNumber: phone,
|
||||
})
|
||||
if err != nil {
|
||||
if nstatus.IsNotFound(err) {
|
||||
dbData, err = register(l.ctx, l.svcCtx, &core.UserInfo{
|
||||
Username: phone,
|
||||
PhoneNumber: &phone,
|
||||
Password: l.svcCtx.Config.RegisterConf.DefaultPassword,
|
||||
Nickname: tea.String("手机用户" + phone),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return dbData, nil
|
||||
}
|
||||
|
||||
func (l *LoginByCodeLogic) getUserByEmail(subject, credentials string) (*core.UserInfo, error) {
|
||||
// 验证
|
||||
code, _, err := l.svcCtx.CodeCache.GetCachedCode(subject, types.CodeSourceEmail, types.SmsCodeTypeLogin)
|
||||
if err != nil {
|
||||
return nil, nstatus.NewApiInternalErr(msg.CacheError)
|
||||
}
|
||||
if credentials != code {
|
||||
return nil, nstatus.NewBizErrWithCode(errx.WrongCode)
|
||||
}
|
||||
dbData, err := l.svcCtx.CoreRpc.GetUser(l.ctx, &core.UserReq{
|
||||
Email: subject,
|
||||
})
|
||||
if err != nil {
|
||||
if nstatus.IsNotFound(err) {
|
||||
dbData, err = register(l.ctx, l.svcCtx, &core.UserInfo{
|
||||
Username: subject,
|
||||
Email: &subject,
|
||||
Password: l.svcCtx.Config.RegisterConf.DefaultPassword,
|
||||
Nickname: tea.String("邮箱用户" + subject),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return dbData, nil
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/dal/errx"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/types/core"
|
||||
"git.noahlan.cn/noahlan/ntool-biz/core/nstatus"
|
||||
"git.noahlan.cn/noahlan/ntool-biz/core/nstatus/msg"
|
||||
"git.noahlan.cn/noahlan/ntool/ncrypt"
|
||||
"git.noahlan.cn/noahlan/ntool/nstr"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type LoginLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
r *http.Request
|
||||
}
|
||||
|
||||
func NewLoginLogic(r *http.Request, ctx context.Context, svcCtx *svc.ServiceContext) *LoginLogic {
|
||||
return &LoginLogic{
|
||||
r: r,
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *LoginLogic) Login(req *types.LoginReq) (resp *types.LoginResp, err error) {
|
||||
if err := l.svcCtx.Captcha.Verify(req.CaptchaId, req.Captcha, true); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var phone, email, username string
|
||||
if nstr.IsChineseMobile(req.Subject) {
|
||||
phone = req.Subject
|
||||
} else if nstr.IsEmail(req.Subject) {
|
||||
email = req.Subject
|
||||
} else {
|
||||
username = req.Subject
|
||||
}
|
||||
user, err := l.svcCtx.CoreRpc.GetUser(l.ctx, &core.UserReq{
|
||||
Username: username,
|
||||
PhoneNumber: phone,
|
||||
Email: email,
|
||||
})
|
||||
if err != nil {
|
||||
nerr := nstatus.ConvertErr(err)
|
||||
if nerr.Msg == msg.ObjectNotFound {
|
||||
return nil, nstatus.NewBizErrWithCode(errx.UserNotFound)
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
if !ncrypt.BcryptCheck(req.Credentials, user.Password) {
|
||||
return nil, nstatus.NewBizErrWithCode(errx.WrongPassword)
|
||||
}
|
||||
// 登录
|
||||
resp, err = login(l.ctx, l.svcCtx, l.r, user)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type OauthCallbackLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
r *http.Request
|
||||
}
|
||||
|
||||
func NewOauthCallbackLogic(r *http.Request, ctx context.Context, svcCtx *svc.ServiceContext) *OauthCallbackLogic {
|
||||
return &OauthCallbackLogic{
|
||||
r: r,
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *OauthCallbackLogic) OauthCallback() (resp *types.LoginResp, err error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type OauthLoginByCodeLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
r *http.Request
|
||||
}
|
||||
|
||||
func NewOauthLoginByCodeLogic(r *http.Request, ctx context.Context, svcCtx *svc.ServiceContext) *OauthLoginByCodeLogic {
|
||||
return &OauthLoginByCodeLogic{
|
||||
r: r,
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *OauthLoginByCodeLogic) OauthLoginByCode(req *types.OauthLoginByCodeReq) (resp *types.LoginResp, err error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/dal/errx"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/types/core"
|
||||
"git.noahlan.cn/noahlan/ntool-biz/core/nstatus"
|
||||
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type OauthLoginByPhoneLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
r *http.Request
|
||||
}
|
||||
|
||||
func NewOauthLoginByPhoneLogic(r *http.Request, ctx context.Context, svcCtx *svc.ServiceContext) *OauthLoginByPhoneLogic {
|
||||
return &OauthLoginByPhoneLogic{
|
||||
r: r,
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *OauthLoginByPhoneLogic) OauthLoginByPhone(req *types.OauthLoginByPhoneCodeReq) (resp *types.LoginResp, err error) {
|
||||
var phoneNumber string
|
||||
rpcProvider, err := l.svcCtx.CoreRpc.GetOauthProvider(l.ctx, &core.OauthProviderReq{
|
||||
Name: req.Provider,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !rpcProvider.Init {
|
||||
return nil, nstatus.NewBizErrWithCode(errx.ProviderNotInit)
|
||||
}
|
||||
// TODO Social Helper
|
||||
user, err := l.svcCtx.CoreRpc.GetUser(l.ctx, &core.UserReq{
|
||||
PhoneNumber: phoneNumber,
|
||||
})
|
||||
// 登录
|
||||
resp, err = login(l.ctx, l.svcCtx, l.r, user)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type OauthLoginLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
r *http.Request
|
||||
}
|
||||
|
||||
func NewOauthLoginLogic(r *http.Request, ctx context.Context, svcCtx *svc.ServiceContext) *OauthLoginLogic {
|
||||
return &OauthLoginLogic{
|
||||
r: r,
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *OauthLoginLogic) OauthLogin(req *types.OauthLoginReq) (resp *types.OauthLoginResp, err error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/dal/errx"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/types/core"
|
||||
"git.noahlan.cn/noahlan/ntool-biz/core/nstatus"
|
||||
"git.noahlan.cn/noahlan/ntool-biz/core/nstatus/msg"
|
||||
"git.noahlan.cn/noahlan/ntool/nrandom"
|
||||
"git.noahlan.cn/noahlan/ntool/nstd/tea"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type RegisterLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
r *http.Request
|
||||
}
|
||||
|
||||
func NewRegisterLogic(r *http.Request, ctx context.Context, svcCtx *svc.ServiceContext) *RegisterLogic {
|
||||
return &RegisterLogic{
|
||||
r: r,
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *RegisterLogic) Register(req *types.RegisterReq) (resp *types.BaseID, err error) {
|
||||
if err := l.svcCtx.Captcha.Verify(req.CaptchaId, req.Captcha, true); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// verify code
|
||||
if req.Code != nil {
|
||||
if req.PhoneNumber != nil && *req.PhoneNumber != "" {
|
||||
code, _, err := l.svcCtx.CodeCache.GetCachedCode(*req.PhoneNumber, types.CodeSourceSms, types.SmsCodeTypeRegister)
|
||||
if err != nil {
|
||||
return nil, nstatus.NewApiInternalErr(msg.CacheError)
|
||||
}
|
||||
if *req.Code != code {
|
||||
return nil, nstatus.NewBizErrWithCode(errx.WrongCode)
|
||||
}
|
||||
} else if req.Email != nil && *req.Email != "" {
|
||||
code, _, err := l.svcCtx.CodeCache.GetCachedCode(*req.PhoneNumber, types.CodeSourceEmail, types.SmsCodeTypeRegister)
|
||||
if err != nil {
|
||||
return nil, nstatus.NewApiInternalErr(msg.CacheError)
|
||||
}
|
||||
if *req.Code != code {
|
||||
return nil, nstatus.NewBizErrWithCode(errx.WrongCode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// username not empty
|
||||
if req.Username == nil {
|
||||
req.Username = tea.String(nrandom.RandString(6))
|
||||
}
|
||||
|
||||
user, err := register(l.ctx, l.svcCtx, &core.UserInfo{
|
||||
Username: *req.Username,
|
||||
PhoneNumber: req.PhoneNumber,
|
||||
Email: req.Email,
|
||||
Password: req.Credentials,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp = &types.BaseID{ID: user.ID}
|
||||
return
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package base
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/types/core"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type InitDatabaseLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
r *http.Request
|
||||
}
|
||||
|
||||
func NewInitDatabaseLogic(r *http.Request, ctx context.Context, svcCtx *svc.ServiceContext) *InitDatabaseLogic {
|
||||
return &InitDatabaseLogic{
|
||||
r: r,
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *InitDatabaseLogic) InitDatabase() error {
|
||||
_, err := l.svcCtx.CoreRpc.InitDatabase(l.ctx, &core.Empty{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package captcha
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type GetCaptchaLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
r *http.Request
|
||||
}
|
||||
|
||||
func NewGetCaptchaLogic(r *http.Request, ctx context.Context, svcCtx *svc.ServiceContext) *GetCaptchaLogic {
|
||||
return &GetCaptchaLogic{
|
||||
r: r,
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetCaptchaLogic) GetCaptcha() (resp *types.CaptchaInfo, err error) {
|
||||
id, b64s, err := l.svcCtx.Captcha.Generate()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp = &types.CaptchaInfo{
|
||||
CaptchaId: id,
|
||||
Base64: b64s,
|
||||
}
|
||||
return
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package captcha
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type ValidateCaptchaLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
r *http.Request
|
||||
}
|
||||
|
||||
func NewValidateCaptchaLogic(r *http.Request, ctx context.Context, svcCtx *svc.ServiceContext) *ValidateCaptchaLogic {
|
||||
return &ValidateCaptchaLogic{
|
||||
r: r,
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *ValidateCaptchaLogic) ValidateCaptcha(req *types.ValidateCaptchaReq) error {
|
||||
if err := l.svcCtx.Captcha.Verify(req.CaptchaId, req.Captcha, req.Clear); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package department_admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/types/core"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type CreateDepartmentAdminLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
r *http.Request
|
||||
}
|
||||
|
||||
func NewCreateDepartmentAdminLogic(r *http.Request, ctx context.Context, svcCtx *svc.ServiceContext) *CreateDepartmentAdminLogic {
|
||||
return &CreateDepartmentAdminLogic{
|
||||
r: r,
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *CreateDepartmentAdminLogic) CreateDepartmentAdmin(req *types.DepartmentInfo) (resp *types.BaseID, err error) {
|
||||
rpcResp, err := l.svcCtx.CoreRpc.CreateDepartment(l.ctx, &core.DepartmentInfo{
|
||||
Status: req.Status,
|
||||
Name: req.Name,
|
||||
LeaderId: req.LeaderId,
|
||||
Remark: req.Remark,
|
||||
ParentId: req.ParentId,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp = &types.BaseID{ID: rpcResp.ID}
|
||||
return
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package department_admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/types/core"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type DeleteDepartmentAdminLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
r *http.Request
|
||||
}
|
||||
|
||||
func NewDeleteDepartmentAdminLogic(r *http.Request, ctx context.Context, svcCtx *svc.ServiceContext) *DeleteDepartmentAdminLogic {
|
||||
return &DeleteDepartmentAdminLogic{
|
||||
r: r,
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *DeleteDepartmentAdminLogic) DeleteDepartmentAdmin(req *types.BaseIDs) error {
|
||||
_, err := l.svcCtx.CoreRpc.DeleteDepartment(l.ctx, &core.IDsReq{Ids: req.Ids})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package department_admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/types/core"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type GetDepartmentAdminLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
r *http.Request
|
||||
}
|
||||
|
||||
func NewGetDepartmentAdminLogic(r *http.Request, ctx context.Context, svcCtx *svc.ServiceContext) *GetDepartmentAdminLogic {
|
||||
return &GetDepartmentAdminLogic{
|
||||
r: r,
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetDepartmentAdminLogic) GetDepartmentAdmin(req *types.DepartmentReq) (resp *types.DepartmentInfo, err error) {
|
||||
rpcResp, err := l.svcCtx.CoreRpc.GetDepartment(l.ctx, &core.DepartmentReq{
|
||||
ID: req.ID,
|
||||
Name: req.Name,
|
||||
LeaderId: req.LeaderId,
|
||||
ParentId: req.ParentId,
|
||||
WithLeader: true,
|
||||
WithUser: false,
|
||||
WithChildren: true,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp = l.svcCtx.Convert.ConvertDepartment(l.ctx, rpcResp)
|
||||
return
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package department_admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/types/core"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type GetDepartmentListAdminLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
r *http.Request
|
||||
}
|
||||
|
||||
func NewGetDepartmentListAdminLogic(r *http.Request, ctx context.Context, svcCtx *svc.ServiceContext) *GetDepartmentListAdminLogic {
|
||||
return &GetDepartmentListAdminLogic{
|
||||
r: r,
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetDepartmentListAdminLogic) GetDepartmentListAdmin(req *types.DepartmentReq) (resp *types.DepartmentListResp, err error) {
|
||||
rpcResp, err := l.svcCtx.CoreRpc.GetDepartmentList(l.ctx, &core.DepartmentReq{
|
||||
ID: req.ID,
|
||||
Name: req.Name,
|
||||
LeaderId: req.LeaderId,
|
||||
ParentId: req.ParentId,
|
||||
WithLeader: true,
|
||||
WithUser: false,
|
||||
WithChildren: true,
|
||||
Page: l.svcCtx.Convert.ConvertPaginationRpc(req.Pagination),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp = &types.DepartmentListResp{
|
||||
Page: l.svcCtx.Convert.ConvertPaginationApi(rpcResp.Page),
|
||||
List: make([]*types.DepartmentInfo, len(rpcResp.Data)),
|
||||
}
|
||||
return
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package department_admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/types/core"
|
||||
"github.com/jinzhu/copier"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type UpdateDepartmentAdminLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
r *http.Request
|
||||
}
|
||||
|
||||
func NewUpdateDepartmentAdminLogic(r *http.Request, ctx context.Context, svcCtx *svc.ServiceContext) *UpdateDepartmentAdminLogic {
|
||||
return &UpdateDepartmentAdminLogic{
|
||||
r: r,
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *UpdateDepartmentAdminLogic) UpdateDepartmentAdmin(req *types.DepartmentInfo) error {
|
||||
var updateModel core.DepartmentInfo
|
||||
_ = copier.Copy(&updateModel, req)
|
||||
|
||||
_, err := l.svcCtx.CoreRpc.UpdateDepartment(l.ctx, &updateModel)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package dictionary_admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/types/core"
|
||||
"github.com/jinzhu/copier"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type CreateDictionaryAdminLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
r *http.Request
|
||||
}
|
||||
|
||||
func NewCreateDictionaryAdminLogic(r *http.Request, ctx context.Context, svcCtx *svc.ServiceContext) *CreateDictionaryAdminLogic {
|
||||
return &CreateDictionaryAdminLogic{
|
||||
r: r,
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *CreateDictionaryAdminLogic) CreateDictionaryAdmin(req *types.DictionaryInfo) (resp *types.BaseID, err error) {
|
||||
var rpcReq core.DictionaryInfo
|
||||
_ = copier.Copy(&rpcReq, req)
|
||||
|
||||
rpcResp, err := l.svcCtx.CoreRpc.CreateDictionary(l.ctx, &rpcReq)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp = &types.BaseID{ID: rpcResp.ID}
|
||||
return
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package dictionary_admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/types/core"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type DeleteDictionaryAdminLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
r *http.Request
|
||||
}
|
||||
|
||||
func NewDeleteDictionaryAdminLogic(r *http.Request, ctx context.Context, svcCtx *svc.ServiceContext) *DeleteDictionaryAdminLogic {
|
||||
return &DeleteDictionaryAdminLogic{
|
||||
r: r,
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *DeleteDictionaryAdminLogic) DeleteDictionaryAdmin(req *types.BaseIDs) error {
|
||||
_, err := l.svcCtx.CoreRpc.DeleteDictionary(l.ctx, &core.IDsReq{Ids: req.Ids})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package detail
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/types/core"
|
||||
"github.com/jinzhu/copier"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type CreateDictionaryDetailAdminLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
r *http.Request
|
||||
}
|
||||
|
||||
func NewCreateDictionaryDetailAdminLogic(r *http.Request, ctx context.Context, svcCtx *svc.ServiceContext) *CreateDictionaryDetailAdminLogic {
|
||||
return &CreateDictionaryDetailAdminLogic{
|
||||
r: r,
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *CreateDictionaryDetailAdminLogic) CreateDictionaryDetailAdmin(req *types.DictionaryDetailInfo) (resp *types.BaseID, err error) {
|
||||
var rpcReq core.DictionaryDetailInfo
|
||||
_ = copier.Copy(&rpcReq, req)
|
||||
|
||||
rpcResp, err := l.svcCtx.CoreRpc.CreateDictionaryDetail(l.ctx, &rpcReq)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp = &types.BaseID{ID: rpcResp.ID}
|
||||
return
|
||||
|
||||
return
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package detail
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/types/core"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type DeleteDictionaryDetailAdminLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
r *http.Request
|
||||
}
|
||||
|
||||
func NewDeleteDictionaryDetailAdminLogic(r *http.Request, ctx context.Context, svcCtx *svc.ServiceContext) *DeleteDictionaryDetailAdminLogic {
|
||||
return &DeleteDictionaryDetailAdminLogic{
|
||||
r: r,
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *DeleteDictionaryDetailAdminLogic) DeleteDictionaryDetailAdmin(req *types.DeleteDictionaryDetailReq) error {
|
||||
_, err := l.svcCtx.CoreRpc.DeleteDictionaryDetail(l.ctx, &core.DeleteDictionaryDetailReq{
|
||||
Ids: req.Ids,
|
||||
DictId: req.DictionaryID,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package detail
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/types/core"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type GetDictionaryDetailAdminLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
r *http.Request
|
||||
}
|
||||
|
||||
func NewGetDictionaryDetailAdminLogic(r *http.Request, ctx context.Context, svcCtx *svc.ServiceContext) *GetDictionaryDetailAdminLogic {
|
||||
return &GetDictionaryDetailAdminLogic{
|
||||
r: r,
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetDictionaryDetailAdminLogic) GetDictionaryDetailAdmin(req *types.DictionaryDetailReq) (resp *types.DictionaryDetailInfo, err error) {
|
||||
if req.Keyword != "" {
|
||||
if req.Title == "" {
|
||||
req.Title = req.Keyword
|
||||
} else if req.Key == "" {
|
||||
req.Key = req.Keyword
|
||||
}
|
||||
}
|
||||
rpcResp, err := l.svcCtx.CoreRpc.GetDictionaryDetail(l.ctx, &core.DictionaryDetailReq{
|
||||
ID: req.ID,
|
||||
DictId: req.DictionaryID,
|
||||
Title: req.Title,
|
||||
Key: req.Key,
|
||||
WithDictionary: false,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp = l.svcCtx.Convert.ConvertDictionaryDetail(l.ctx, rpcResp)
|
||||
|
||||
return
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package detail
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/types/core"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type GetDictionaryDetailListAdminLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
r *http.Request
|
||||
}
|
||||
|
||||
func NewGetDictionaryDetailListAdminLogic(r *http.Request, ctx context.Context, svcCtx *svc.ServiceContext) *GetDictionaryDetailListAdminLogic {
|
||||
return &GetDictionaryDetailListAdminLogic{
|
||||
r: r,
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetDictionaryDetailListAdminLogic) GetDictionaryDetailListAdmin(req *types.DictionaryDetailReq) (resp *types.DictionaryDetailListResp, err error) {
|
||||
if req.Keyword != "" {
|
||||
if req.Title == "" {
|
||||
req.Title = req.Keyword
|
||||
} else if req.Key == "" {
|
||||
req.Key = req.Keyword
|
||||
}
|
||||
}
|
||||
rpcResp, err := l.svcCtx.CoreRpc.GetDictionaryDetailList(l.ctx, &core.DictionaryDetailReq{
|
||||
Page: l.svcCtx.Convert.ConvertPaginationRpc(req.Pagination),
|
||||
ID: req.ID,
|
||||
DictId: req.DictionaryID,
|
||||
Title: req.Title,
|
||||
Key: req.Key,
|
||||
WithDictionary: false,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp = &types.DictionaryDetailListResp{
|
||||
Page: l.svcCtx.Convert.ConvertPaginationApi(rpcResp.Page),
|
||||
List: make([]*types.DictionaryDetailInfo, len(rpcResp.Data)),
|
||||
}
|
||||
for i, item := range rpcResp.Data {
|
||||
resp.List[i] = l.svcCtx.Convert.ConvertDictionaryDetail(l.ctx, item)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package detail
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/types/core"
|
||||
"github.com/jinzhu/copier"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type UpdateDictionaryDetailAdminLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
r *http.Request
|
||||
}
|
||||
|
||||
func NewUpdateDictionaryDetailAdminLogic(r *http.Request, ctx context.Context, svcCtx *svc.ServiceContext) *UpdateDictionaryDetailAdminLogic {
|
||||
return &UpdateDictionaryDetailAdminLogic{
|
||||
r: r,
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *UpdateDictionaryDetailAdminLogic) UpdateDictionaryDetailAdmin(req *types.DictionaryDetailInfo) error {
|
||||
var rpcReq core.DictionaryDetailInfo
|
||||
_ = copier.Copy(&rpcReq, req)
|
||||
|
||||
_, err := l.svcCtx.CoreRpc.UpdateDictionaryDetail(l.ctx, &rpcReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package dictionary_admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/types/core"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type GetDictionaryAdminLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
r *http.Request
|
||||
}
|
||||
|
||||
func NewGetDictionaryAdminLogic(r *http.Request, ctx context.Context, svcCtx *svc.ServiceContext) *GetDictionaryAdminLogic {
|
||||
return &GetDictionaryAdminLogic{
|
||||
r: r,
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetDictionaryAdminLogic) GetDictionaryAdmin(req *types.DictionaryReq) (resp *types.DictionaryInfo, err error) {
|
||||
rpcResp, err := l.svcCtx.CoreRpc.GetDictionary(l.ctx, &core.DictionaryReq{
|
||||
ID: req.ID,
|
||||
Name: req.Name,
|
||||
Title: req.Title,
|
||||
WithDetails: false,
|
||||
Page: nil,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp = l.svcCtx.Convert.ConvertDictionary(l.ctx, rpcResp)
|
||||
return
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package dictionary_admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/types/core"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type GetDictionaryListAdminLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
r *http.Request
|
||||
}
|
||||
|
||||
func NewGetDictionaryListAdminLogic(r *http.Request, ctx context.Context, svcCtx *svc.ServiceContext) *GetDictionaryListAdminLogic {
|
||||
return &GetDictionaryListAdminLogic{
|
||||
r: r,
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetDictionaryListAdminLogic) GetDictionaryListAdmin(req *types.DictionaryReq) (resp *types.DictionaryListResp, err error) {
|
||||
rpcResp, err := l.svcCtx.CoreRpc.GetDictionaryList(l.ctx, &core.DictionaryReq{
|
||||
ID: req.ID,
|
||||
Name: req.Name,
|
||||
Title: req.Title,
|
||||
WithDetails: false,
|
||||
Page: l.svcCtx.Convert.ConvertPaginationRpc(req.Pagination),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp = &types.DictionaryListResp{
|
||||
Page: l.svcCtx.Convert.ConvertPaginationApi(rpcResp.Page),
|
||||
List: make([]*types.DictionaryInfo, len(rpcResp.Data)),
|
||||
}
|
||||
for i, item := range rpcResp.Data {
|
||||
resp.List[i] = l.svcCtx.Convert.ConvertDictionary(l.ctx, item)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package dictionary_admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/types/core"
|
||||
"github.com/jinzhu/copier"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type UpdateDictionaryAdminLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
r *http.Request
|
||||
}
|
||||
|
||||
func NewUpdateDictionaryAdminLogic(r *http.Request, ctx context.Context, svcCtx *svc.ServiceContext) *UpdateDictionaryAdminLogic {
|
||||
return &UpdateDictionaryAdminLogic{
|
||||
r: r,
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *UpdateDictionaryAdminLogic) UpdateDictionaryAdmin(req *types.DictionaryInfo) error {
|
||||
var rpcReq core.DictionaryInfo
|
||||
_ = copier.Copy(&rpcReq, req)
|
||||
|
||||
_, err := l.svcCtx.CoreRpc.UpdateDictionary(l.ctx, &rpcReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package district
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/types/core"
|
||||
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type GetDistrictChildrenLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
r *http.Request
|
||||
}
|
||||
|
||||
func NewGetDistrictChildrenLogic(r *http.Request, ctx context.Context, svcCtx *svc.ServiceContext) *GetDistrictChildrenLogic {
|
||||
return &GetDistrictChildrenLogic{
|
||||
r: r,
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetDistrictChildrenLogic) GetDistrictChildren(req *types.GetDistrictChildrenReq) (resp []*types.DistrictInfo, err error) {
|
||||
rpcReq := &core.DistrictReq{ParentCode: req.ParentCode, QueryType: core.DistrictQueryType_Children}
|
||||
if req.ParentCode == "" {
|
||||
rpcReq.Level = 1
|
||||
}
|
||||
rpcResp, err := l.svcCtx.CoreRpc.GetDistrictList(l.ctx, rpcReq)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp = make([]*types.DistrictInfo, len(rpcResp.Data))
|
||||
|
||||
for i, item := range rpcResp.Data {
|
||||
resp[i] = l.svcCtx.Convert.ConvertDistrict(l.ctx, item)
|
||||
}
|
||||
return
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package district
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/types/core"
|
||||
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type GetDistrictListLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
r *http.Request
|
||||
}
|
||||
|
||||
func NewGetDistrictListLogic(r *http.Request, ctx context.Context, svcCtx *svc.ServiceContext) *GetDistrictListLogic {
|
||||
return &GetDistrictListLogic{
|
||||
r: r,
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetDistrictListLogic) GetDistrictList(req *types.GetDistrictListReq) (resp []*types.DistrictInfo, err error) {
|
||||
rpcReq := &core.DistrictReq{
|
||||
Province: req.Province,
|
||||
City: req.City,
|
||||
Area: req.Area,
|
||||
Street: req.Street,
|
||||
Level: req.Level,
|
||||
Name: req.Name,
|
||||
}
|
||||
list, err := l.svcCtx.CoreRpc.GetDistrictList(l.ctx, rpcReq)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp = make([]*types.DistrictInfo, len(list.Data))
|
||||
|
||||
for i, item := range list.Data {
|
||||
resp[i] = l.svcCtx.Convert.ConvertDistrict(l.ctx, item)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package district
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/types/core"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type GetDistrictNameLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
r *http.Request
|
||||
}
|
||||
|
||||
func NewGetDistrictNameLogic(r *http.Request, ctx context.Context, svcCtx *svc.ServiceContext) *GetDistrictNameLogic {
|
||||
return &GetDistrictNameLogic{
|
||||
r: r,
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetDistrictNameLogic) GetDistrictName(req *types.GetDistrictNameReq) (resp *types.GetDistrictNameResp, err error) {
|
||||
rpcResp, err := l.svcCtx.CoreRpc.GetDistrictName(l.ctx, &core.GetDistrictNameReq{
|
||||
Code: req.Code,
|
||||
Separator: req.Separator,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp = &types.GetDistrictNameResp{
|
||||
Code: rpcResp.Code,
|
||||
Name: rpcResp.Name,
|
||||
NameList: rpcResp.NameList,
|
||||
}
|
||||
return
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package district
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/types/core"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type GetDistrictTreeLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
r *http.Request
|
||||
}
|
||||
|
||||
func NewGetDistrictTreeLogic(r *http.Request, ctx context.Context, svcCtx *svc.ServiceContext) *GetDistrictTreeLogic {
|
||||
return &GetDistrictTreeLogic{
|
||||
r: r,
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetDistrictTreeLogic) GetDistrictTree(req *types.DistrictReq) (resp *types.DistrictTree, err error) {
|
||||
rpcResp, err := l.svcCtx.CoreRpc.GetDistrictTree(l.ctx, &core.DistrictCodeReq{Code: req.Code})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp = &types.DistrictTree{
|
||||
Tree: make([]*types.DistrictInfo, len(rpcResp.Tree)),
|
||||
}
|
||||
l.transTree(resp.Tree, rpcResp.Tree)
|
||||
return
|
||||
}
|
||||
|
||||
func (l *GetDistrictTreeLogic) transTree(tree []*types.DistrictInfo, data []*core.DistrictInfo) {
|
||||
for i, info := range data {
|
||||
tmpInfo := l.svcCtx.Convert.ConvertDistrict(l.ctx, info)
|
||||
if len(info.Children) > 0 {
|
||||
l.transTree(tmpInfo.Children, info.Children)
|
||||
}
|
||||
tree[i] = tmpInfo
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package oauthprovider_admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/types/core"
|
||||
"github.com/jinzhu/copier"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type CreateOauthProviderAdminLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
r *http.Request
|
||||
}
|
||||
|
||||
func NewCreateOauthProviderAdminLogic(r *http.Request, ctx context.Context, svcCtx *svc.ServiceContext) *CreateOauthProviderAdminLogic {
|
||||
return &CreateOauthProviderAdminLogic{
|
||||
r: r,
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *CreateOauthProviderAdminLogic) CreateOauthProviderAdmin(req *types.OauthProviderInfo) error {
|
||||
var rpcReq core.OauthProviderInfo
|
||||
_ = copier.Copy(&rpcReq, req)
|
||||
rpcReq.System = false
|
||||
rpcReq.Init = true
|
||||
|
||||
_, err := l.svcCtx.CoreRpc.CreateOauthProvider(l.ctx, &rpcReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package oauthprovider_admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/types/core"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type DeleteOauthProviderAdminLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
r *http.Request
|
||||
}
|
||||
|
||||
func NewDeleteOauthProviderAdminLogic(r *http.Request, ctx context.Context, svcCtx *svc.ServiceContext) *DeleteOauthProviderAdminLogic {
|
||||
return &DeleteOauthProviderAdminLogic{
|
||||
r: r,
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *DeleteOauthProviderAdminLogic) DeleteOauthProviderAdmin(req *types.BaseIDs) error {
|
||||
_, err := l.svcCtx.CoreRpc.DeleteOauthProvider(l.ctx, &core.IDsReq{Ids: req.Ids})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package oauthprovider_admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/types/core"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type GetOauthProviderAdminLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
r *http.Request
|
||||
}
|
||||
|
||||
func NewGetOauthProviderAdminLogic(r *http.Request, ctx context.Context, svcCtx *svc.ServiceContext) *GetOauthProviderAdminLogic {
|
||||
return &GetOauthProviderAdminLogic{
|
||||
r: r,
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetOauthProviderAdminLogic) GetOauthProviderAdmin(req *types.OauthProviderReq) (resp *types.OauthProviderInfo, err error) {
|
||||
rpcResp, err := l.svcCtx.CoreRpc.GetOauthProvider(l.ctx, &core.OauthProviderReq{
|
||||
ID: req.ID,
|
||||
Name: req.Name,
|
||||
ClientId: req.ClientId,
|
||||
System: req.System,
|
||||
Init: req.Init,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp = l.svcCtx.Convert.ConvertOAuthProvider(l.ctx, rpcResp)
|
||||
return
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package oauthprovider_admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/types/core"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type GetOauthProviderListAdminLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
r *http.Request
|
||||
}
|
||||
|
||||
func NewGetOauthProviderListAdminLogic(r *http.Request, ctx context.Context, svcCtx *svc.ServiceContext) *GetOauthProviderListAdminLogic {
|
||||
return &GetOauthProviderListAdminLogic{
|
||||
r: r,
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetOauthProviderListAdminLogic) GetOauthProviderListAdmin(req *types.OauthProviderReq) (resp *types.OauthProviderListResp, err error) {
|
||||
rpcResp, err := l.svcCtx.CoreRpc.GetOauthProviderList(l.ctx, &core.OauthProviderReq{
|
||||
ID: req.ID,
|
||||
Name: req.Name,
|
||||
ClientId: req.ClientId,
|
||||
System: req.System,
|
||||
Init: req.Init,
|
||||
Page: l.svcCtx.Convert.ConvertPaginationRpc(req.Pagination),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp = &types.OauthProviderListResp{
|
||||
Page: l.svcCtx.Convert.ConvertPaginationApi(rpcResp.Page),
|
||||
List: make([]*types.OauthProviderInfo, len(rpcResp.Data)),
|
||||
}
|
||||
for i, item := range rpcResp.Data {
|
||||
resp.List[i] = l.svcCtx.Convert.ConvertOAuthProvider(l.ctx, item)
|
||||
}
|
||||
return
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package oauthprovider_admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/types/core"
|
||||
"github.com/jinzhu/copier"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type UpdateOauthProviderAdminLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
r *http.Request
|
||||
}
|
||||
|
||||
func NewUpdateOauthProviderAdminLogic(r *http.Request, ctx context.Context, svcCtx *svc.ServiceContext) *UpdateOauthProviderAdminLogic {
|
||||
return &UpdateOauthProviderAdminLogic{
|
||||
r: r,
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *UpdateOauthProviderAdminLogic) UpdateOauthProviderAdmin(req *types.OauthProviderInfo) error {
|
||||
var rpcReq core.OauthProviderInfo
|
||||
_ = copier.Copy(&rpcReq, req)
|
||||
rpcReq.Init = true
|
||||
|
||||
_, err := l.svcCtx.CoreRpc.UpdateOauthProvider(l.ctx, &rpcReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package role_admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/types/core"
|
||||
"github.com/jinzhu/copier"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type CreateRoleAdminLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
r *http.Request
|
||||
}
|
||||
|
||||
func NewCreateRoleAdminLogic(r *http.Request, ctx context.Context, svcCtx *svc.ServiceContext) *CreateRoleAdminLogic {
|
||||
return &CreateRoleAdminLogic{
|
||||
r: r,
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *CreateRoleAdminLogic) CreateRoleAdmin(req *types.RoleInfo) error {
|
||||
var rpcReq core.RoleInfo
|
||||
_ = copier.Copy(&rpcReq, req)
|
||||
|
||||
_, err := l.svcCtx.CoreRpc.CreateRole(l.ctx, &rpcReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package role_admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/types/core"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type DeleteRoleAdminLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
r *http.Request
|
||||
}
|
||||
|
||||
func NewDeleteRoleAdminLogic(r *http.Request, ctx context.Context, svcCtx *svc.ServiceContext) *DeleteRoleAdminLogic {
|
||||
return &DeleteRoleAdminLogic{
|
||||
r: r,
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *DeleteRoleAdminLogic) DeleteRoleAdmin(req *types.BaseIDs) error {
|
||||
_, err := l.svcCtx.CoreRpc.DeleteRole(l.ctx, &core.IDsReq{Ids: req.Ids})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package role_admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/types/core"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type GetRoleAdminLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
r *http.Request
|
||||
}
|
||||
|
||||
func NewGetRoleAdminLogic(r *http.Request, ctx context.Context, svcCtx *svc.ServiceContext) *GetRoleAdminLogic {
|
||||
return &GetRoleAdminLogic{
|
||||
r: r,
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetRoleAdminLogic) GetRoleAdmin(req *types.RoleReq) (resp *types.RoleInfo, err error) {
|
||||
rpcResp, err := l.svcCtx.CoreRpc.GetRole(l.ctx, &core.RoleReq{
|
||||
ID: req.ID,
|
||||
Name: req.Name,
|
||||
Code: req.Code,
|
||||
WithUser: false,
|
||||
Page: nil,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp = l.svcCtx.Convert.ConvertRole(l.ctx, rpcResp)
|
||||
return
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package role_admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/types/core"
|
||||
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type GetRoleListAdminLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
r *http.Request
|
||||
}
|
||||
|
||||
func NewGetRoleListAdminLogic(r *http.Request, ctx context.Context, svcCtx *svc.ServiceContext) *GetRoleListAdminLogic {
|
||||
return &GetRoleListAdminLogic{
|
||||
r: r,
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetRoleListAdminLogic) GetRoleListAdmin(req *types.RoleReq) (resp *types.RoleListResp, err error) {
|
||||
rpcResp, err := l.svcCtx.CoreRpc.GetRoleList(l.ctx, &core.RoleReq{
|
||||
ID: req.ID,
|
||||
Name: req.Name,
|
||||
Code: req.Code,
|
||||
Page: l.svcCtx.Convert.ConvertPaginationRpc(req.Pagination),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp = &types.RoleListResp{
|
||||
Page: l.svcCtx.Convert.ConvertPaginationApi(rpcResp.Page),
|
||||
List: make([]*types.RoleInfo, len(rpcResp.Data)),
|
||||
}
|
||||
for i, item := range rpcResp.Data {
|
||||
resp.List[i] = l.svcCtx.Convert.ConvertRole(l.ctx, item)
|
||||
}
|
||||
return
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package role_admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/types/core"
|
||||
"github.com/jinzhu/copier"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type UpdateRoleAdminLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
r *http.Request
|
||||
}
|
||||
|
||||
func NewUpdateRoleAdminLogic(r *http.Request, ctx context.Context, svcCtx *svc.ServiceContext) *UpdateRoleAdminLogic {
|
||||
return &UpdateRoleAdminLogic{
|
||||
r: r,
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *UpdateRoleAdminLogic) UpdateRoleAdmin(req *types.RoleInfo) error {
|
||||
var rpcReq core.RoleInfo
|
||||
_ = copier.Copy(&rpcReq, req)
|
||||
|
||||
_, err := l.svcCtx.CoreRpc.UpdateRole(l.ctx, &rpcReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package token_admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
||||
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
||||
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type DisableTokenAdminLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
r *http.Request
|
||||
}
|
||||
|
||||
func NewDisableTokenAdminLogic(r *http.Request, ctx context.Context, svcCtx *svc.ServiceContext) *DisableTokenAdminLogic {
|
||||
return &DisableTokenAdminLogic{
|
||||
r: r,
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *DisableTokenAdminLogic) DisableTokenAdmin(req *types.BaseID) error {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return nil
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue