feat:完善项目
This commit is contained in:
@ -10,7 +10,7 @@ import (
|
||||
type Tenant struct{}
|
||||
|
||||
type tenantForm struct {
|
||||
ParentID uint64 `json:"parent_id" form:"parent_id"`
|
||||
ParentID string `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"`
|
||||
@ -23,11 +23,80 @@ type tenantForm struct {
|
||||
* @apiDefine Tenant 租户(单位)管理
|
||||
*/
|
||||
|
||||
/**
|
||||
* @api {post} /api/v1/tenant/list 单位列表
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName TenantList
|
||||
* @apiGroup Tenant
|
||||
*
|
||||
* @apiHeader {string} x-token token
|
||||
*
|
||||
* @apiSuccess (200) {Object} data 数据信息
|
||||
* @apiSuccess (200) {Object} data.data 具体信息
|
||||
* @apiSuccess (200) {String} data.id ID
|
||||
* @apiSuccess (200) {String} data.name 名称
|
||||
* @apiSuccess (200) {String} data.province 省
|
||||
* @apiSuccess (200) {String} data.city 市
|
||||
* @apiSuccess (200) {String} data.district 区
|
||||
* @apiSuccess (200) {String} data.address 地址
|
||||
* @apiSuccess (200) {String} data.remark 备注
|
||||
* @apiSuccess (200) {Object} data.children 子集
|
||||
* @apiSuccess (200) {Number} code 成功响应状态码!
|
||||
* @apiSuccess (200) {String} msg 成功提示
|
||||
*
|
||||
* @apiSuccessExample {json} Success response:
|
||||
* HTTPS 200 OK
|
||||
* {
|
||||
* "code": 200
|
||||
* "msg": "ok"
|
||||
* "data": {
|
||||
* [
|
||||
* {
|
||||
* "id": "EgmJ4Ga7LQ",
|
||||
* "name": "合肥市武警支队",
|
||||
* "province": "安徽省",
|
||||
* "city": "合肥市",
|
||||
* "district": "蜀山区",
|
||||
* "address": "大蜀山。 ",
|
||||
* "remark": "",
|
||||
* "children": []
|
||||
* }
|
||||
* ],
|
||||
* }
|
||||
*/
|
||||
func (*Tenant) List(c *gin.Context) {
|
||||
data, err := tenant.NewInstance()(getSession()(c).(*service.Session)).List()
|
||||
APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} /api/v1/tenant/add 单位信息添加
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName TenantAdd
|
||||
* @apiGroup Tenant
|
||||
*
|
||||
* @apiHeader {string} x-token token
|
||||
*
|
||||
* @apiParam {String} [parent_id="''"] 父集
|
||||
* @apiParam {String} name 名称
|
||||
* @apiParam {String} [remark="''"] 名称
|
||||
* @apiParam {String} [province="''"] 省
|
||||
* @apiParam {String} [city="''"] 市
|
||||
* @apiParam {String} [district="''"] 区
|
||||
* @apiParam {String} [address="''"] 地址
|
||||
*
|
||||
* @apiSuccess (200) {Object} data 数据信息
|
||||
* @apiSuccess (200) {Number} code 成功响应状态码!
|
||||
* @apiSuccess (200) {String} msg 成功提示
|
||||
*
|
||||
* @apiSuccessExample {json} Success response:
|
||||
* HTTPS 200 OK
|
||||
* {
|
||||
* "code": 200
|
||||
* "msg": "ok"
|
||||
* "data": null
|
||||
* }
|
||||
*/
|
||||
func (*Tenant) Add(c *gin.Context) {
|
||||
form := new(tenantForm)
|
||||
|
||||
@ -35,8 +104,9 @@ func (*Tenant) Add(c *gin.Context) {
|
||||
APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
obj := &IDStringForm{ID: form.ParentID}
|
||||
err := tenant.NewInstance()(getSession()(c).(*service.Session)).Form(&tenant.InstanceParams{
|
||||
ParentID: form.ParentID, Name: form.Name, Remark: form.Remark,
|
||||
ParentID: obj.Convert(), Name: form.Name, Remark: form.Remark,
|
||||
CommonArea: basic.CommonArea{
|
||||
Province: form.Province, City: form.City, District: form.District, Address: form.Address,
|
||||
},
|
||||
@ -44,6 +114,35 @@ func (*Tenant) Add(c *gin.Context) {
|
||||
APIResponse(err)(c)
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} /api/v1/tenant/edit 单位信息修改
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName TenantEdit
|
||||
* @apiGroup Tenant
|
||||
*
|
||||
* @apiHeader {string} x-token token
|
||||
*
|
||||
* @apiParam {String} id ID
|
||||
* @apiParam {String} [parent_id="''"] 父集
|
||||
* @apiParam {String} name 名称
|
||||
* @apiParam {String} [remark="''"] 名称
|
||||
* @apiParam {String} [province="''"] 省
|
||||
* @apiParam {String} [city="''"] 市
|
||||
* @apiParam {String} [district="''"] 区
|
||||
* @apiParam {String} [address="''"] 地址
|
||||
*
|
||||
* @apiSuccess (200) {Object} data 数据信息
|
||||
* @apiSuccess (200) {Number} code 成功响应状态码!
|
||||
* @apiSuccess (200) {String} msg 成功提示
|
||||
*
|
||||
* @apiSuccessExample {json} Success response:
|
||||
* HTTPS 200 OK
|
||||
* {
|
||||
* "code": 200
|
||||
* "msg": "ok"
|
||||
* "data": null
|
||||
* }
|
||||
*/
|
||||
func (*Tenant) Edit(c *gin.Context) {
|
||||
form := &struct {
|
||||
IDStringForm
|
||||
@ -53,8 +152,9 @@ func (*Tenant) Edit(c *gin.Context) {
|
||||
APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
obj := &IDStringForm{ID: form.ParentID}
|
||||
err := tenant.NewInstance()(getSession()(c).(*service.Session)).Form(&tenant.InstanceParams{
|
||||
ID: form.Convert(), ParentID: form.ParentID, Name: form.Name, Remark: form.Remark,
|
||||
ID: form.Convert(), ParentID: obj.Convert(), Name: form.Name, Remark: form.Remark,
|
||||
CommonArea: basic.CommonArea{
|
||||
Province: form.Province, City: form.City, District: form.District, Address: form.Address,
|
||||
},
|
||||
@ -62,6 +162,28 @@ func (*Tenant) Edit(c *gin.Context) {
|
||||
APIResponse(err)(c)
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} /api/v1/tenant/delete 单位信息删除
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName TenantDelete
|
||||
* @apiGroup Tenant
|
||||
*
|
||||
* @apiHeader {string} x-token token
|
||||
*
|
||||
* @apiParam {String} id ID
|
||||
*
|
||||
* @apiSuccess (200) {Object} data 数据信息
|
||||
* @apiSuccess (200) {Number} code 成功响应状态码!
|
||||
* @apiSuccess (200) {String} msg 成功提示
|
||||
*
|
||||
* @apiSuccessExample {json} Success response:
|
||||
* HTTPS 200 OK
|
||||
* {
|
||||
* "code": 200
|
||||
* "msg": "ok"
|
||||
* "data": null
|
||||
* }
|
||||
*/
|
||||
func (*Tenant) Delete(c *gin.Context) {
|
||||
form := new(IDStringForm)
|
||||
|
||||
|
Reference in New Issue
Block a user