feat:完善项目

This commit is contained in:
henry
2021-11-04 15:30:10 +08:00
parent 153df336b8
commit 0b41c97899
6 changed files with 157 additions and 13 deletions

1
.gitignore vendored
View File

@ -5,6 +5,7 @@
*.test
*.prof
.idea/
doc/
log/
cmd/ctl/main
cmd/ctl/ctl

View File

@ -64,7 +64,7 @@ func (a *Role) Delete(c *gin.Context) {
}
/**
* @api {post} /api/v1/role/menu 菜单信息
* @api {post} /api/v1/role/menus 菜单信息
* @apiVersion 1.0.0
* @apiName RoleMenu
* @apiGroup Role

View File

@ -1 +1,74 @@
package api
import (
"ArmedPolice/app/controller/basic"
"ArmedPolice/app/controller/tenant"
"ArmedPolice/app/service"
"github.com/gin-gonic/gin"
)
type Tenant struct{}
type tenantForm struct {
ParentID uint64 `json:"parent_id" form:"parent_id"`
Name string `json:"name" form:"name" binding:"required"`
Remark string `json:"remark" form:"remark"`
Province string `json:"province" form:"province"`
City string `json:"city" form:"city"`
District string `json:"district" form:"district"`
Address string `json:"address" form:"address"`
}
/**
* @apiDefine Tenant 租户(单位)管理
*/
func (*Tenant) List(c *gin.Context) {
data, err := tenant.NewInstance()(getSession()(c).(*service.Session)).List()
APIResponse(err, data)(c)
}
func (*Tenant) Add(c *gin.Context) {
form := new(tenantForm)
if err := bind(form)(c); err != nil {
APIFailure(err.(error))(c)
return
}
err := tenant.NewInstance()(getSession()(c).(*service.Session)).Form(&tenant.InstanceParams{
ParentID: form.ParentID, Name: form.Name, Remark: form.Remark,
CommonArea: basic.CommonArea{
Province: form.Province, City: form.City, District: form.District, Address: form.Address,
},
})
APIResponse(err)(c)
}
func (*Tenant) Edit(c *gin.Context) {
form := &struct {
IDStringForm
tenantForm
}{}
if err := bind(form)(c); err != nil {
APIFailure(err.(error))(c)
return
}
err := tenant.NewInstance()(getSession()(c).(*service.Session)).Form(&tenant.InstanceParams{
ID: form.Convert(), ParentID: form.ParentID, Name: form.Name, Remark: form.Remark,
CommonArea: basic.CommonArea{
Province: form.Province, City: form.City, District: form.District, Address: form.Address,
},
})
APIResponse(err)(c)
}
func (*Tenant) Delete(c *gin.Context) {
form := new(IDStringForm)
if err := bind(form)(c); err != nil {
APIFailure(err.(error))(c)
return
}
err := tenant.NewInstance()(getSession()(c).(*service.Session)).Delete(form.Convert())
APIResponse(err)(c)
}

View File

@ -14,7 +14,7 @@ type Upload struct{}
*/
/**
* @api {post} /api/upload 上传接口
* @api {post} /api/v1/upload 上传接口
* @apiVersion 1.0.0
* @apiName Upload
* @apiGroup Upload

58
package.json Normal file
View File

@ -0,0 +1,58 @@
{
"name": "armedpolice",
"version": "1.0.0",
"description": "ArmedPolice 武警ERP",
"main": "index.js",
"directories": {
"lib": "lib"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://git.ipeace.org.cn/GolangCoding/ArmedPolice.git"
},
"author": "Henry",
"license": "ISC",
"apidoc": {
"name": "Tenant",
"title": "TenantAPI",
"description": "Tenant多租户管理-让用户更加紧密",
"url": "http://192.168.0.153:9000",
"sampleUrl": "http://192.168.0.153:9000",
"order": [
"Account",
"User",
"Menu",
"Role",
"Captcha",
"Upload",
"Manage"
]
},
"pack": [
{
"name": "ArmedPoliceServer-Window",
"format": "zip",
"pattern": "{Serve.exe,config.yaml,keys/*,file/*,start.sh,stop.sh}",
"options": {
"dot": true,
"ignore": [
"*.log"
]
}
},
{
"name": "ArmedPoliceServer-Linux",
"format": "tar",
"pattern": "{SciencesServer,config.yaml,keys/*,file/*,start.sh,stop.sh}",
"options": {
"dot": true,
"ignore": [
"*.log"
]
}
}
]
}

View File

@ -52,6 +52,23 @@ func (this *Router) registerAPI() {
accountV1.POST("/login", _api.Login)
accountV1.POST("/logout", _api.Logout)
}
// Tenant 租户单位管理
tenantV1 := v1.Group("/tenant")
{
_api := new(api.Tenant)
tenantV1.POST("/list", _api.List)
tenantV1.POST("/add", _api.Add)
tenantV1.POST("/edit", _api.Add)
tenantV1.POST("/delete", _api.Add)
}
// User 用户管理
userV1 := v1.Group("/user")
{
_api := new(api.User)
userV1.GET("/info", _api.Info)
userV1.GET("/menu", _api.Menu)
userV1.POST("/list", _api.List)
}
// Menu 菜单管理
menuV1 := v1.Group("/menu")
{
@ -62,21 +79,16 @@ func (this *Router) registerAPI() {
menuV1.POST("/status", _api.Status)
menuV1.POST("/delete", _api.Delete)
}
// User 用户管理
userV1 := v1.Group("/user")
{
_api := new(api.User)
userV1.GET("/info", _api.Info)
userV1.GET("/menu", _api.Menu)
userV1.POST("/list", _api.List)
}
// Role 角色管理
roleV1 := v1.Group("/role")
{
_api := new(api.User)
_api := new(api.Role)
roleV1.POST("/list", _api.List)
roleV1.GET("/menu", _api.Menu)
roleV1.GET("/list", _api.List)
roleV1.POST("/add", _api.Add)
roleV1.POST("/menu", _api.Edit)
roleV1.POST("/delete", _api.Delete)
roleV1.POST("/menus", _api.Menu)
roleV1.POST("/menu/bind", _api.MenuBind)
}
}