feat:完善项目
This commit is contained in:
@ -28,14 +28,19 @@ type Account struct{}
|
|||||||
*
|
*
|
||||||
* @apiSuccess (200) {Number} code 成功响应状态码!
|
* @apiSuccess (200) {Number} code 成功响应状态码!
|
||||||
* @apiSuccess (200) {String} msg 成功提示
|
* @apiSuccess (200) {String} msg 成功提示
|
||||||
* @apiSuccess (200) {String} data token
|
* @apiSuccess (200) {Json} data 具体信息
|
||||||
|
* @apiSuccess (200) {String} data.token token信息,接口需要携带
|
||||||
|
* @apiSuccess (200) {Number} data.effect_time token有效时长,秒
|
||||||
*
|
*
|
||||||
* @apiSuccessExample {json} Success response:
|
* @apiSuccessExample {json} Success response:
|
||||||
* HTTPS 200 OK
|
* HTTPS 200 OK
|
||||||
* {
|
* {
|
||||||
* "code": 200
|
* "code": 200
|
||||||
* "msg": "ok"
|
* "msg": "ok"
|
||||||
* "data": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOiIxNjE3NDU2OTMwIiwiaWF0IjoiMTYxNjg1MjEzMCIsInVpZCI6IjIwMTMxMTI4MTMwMTg0MTkyMDAifQ.D7oSD4OGdz8rJt0rFNVEl5Ea47_vtuC51IDrY9mUTPo"
|
* "data": {
|
||||||
|
* "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOiIxNjM4NjA0NDYwIiwiaWF0IjoiMTYzNjAxMjQ2MCIsInVpZCI6IjIwOTU2MTg2ODk5ODEyMjI5MTIifQ.Q4_peBb9aeGaZAfUFMMzn21cbfhY6_DEocI9xlj9v9g",
|
||||||
|
* "effect_time": 2592000
|
||||||
|
* }
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
func (a *Account) Login(c *gin.Context) {
|
func (a *Account) Login(c *gin.Context) {
|
||||||
|
@ -12,6 +12,34 @@ type Config struct{}
|
|||||||
* @apiDefine Config 配置管理
|
* @apiDefine Config 配置管理
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @api {get} /api/v1/config/area 区域管理
|
||||||
|
* @apiVersion 1.0.0
|
||||||
|
* @apiName ConfigArea
|
||||||
|
* @apiGroup Config
|
||||||
|
*
|
||||||
|
* @apiHeader {string} x-token token
|
||||||
|
* @apiHeader {string} Content-Type=application/json 传输方式
|
||||||
|
*
|
||||||
|
* @apiParam {String} [key="''"] 区域标识
|
||||||
|
*
|
||||||
|
* @apiSuccess (200) {Number} code 成功响应状态码!
|
||||||
|
* @apiSuccess (200) {String} msg 成功提示
|
||||||
|
* @apiSuccess (200) {Json} data 数据信息{"110000": "北京市", "120000": "天津市", ...}
|
||||||
|
*
|
||||||
|
* @apiSuccessExample {json} Success response:
|
||||||
|
* HTTPS 200 OK
|
||||||
|
* {
|
||||||
|
* "code": 200
|
||||||
|
* "msg": "ok"
|
||||||
|
* "data": {
|
||||||
|
* "110000": "北京市",
|
||||||
|
* "120000": "天津市",
|
||||||
|
* "130000": "河北省",
|
||||||
|
* "140000": "山西省",
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*/
|
||||||
func (*Config) Area(c *gin.Context) {
|
func (*Config) Area(c *gin.Context) {
|
||||||
form := &struct {
|
form := &struct {
|
||||||
Key string `json:"key" form:"key"`
|
Key string `json:"key" form:"key"`
|
||||||
@ -21,5 +49,5 @@ func (*Config) Area(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
data := config.NewInstance()(getSession()(c).(*service.Session)).Area(form.Key)
|
data := config.NewInstance()(getSession()(c).(*service.Session)).Area(form.Key)
|
||||||
APIResponse(nil, data)
|
APIResponse(nil, data)(c)
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
type Manage struct{}
|
type Manage struct{}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @apiDefine Manage 数据管理
|
||||||
|
*/
|
||||||
|
@ -45,7 +45,7 @@ func (*Supplier) MaterialAdd(c *gin.Context) {
|
|||||||
Name: form.Name, Mobile: form.Mobile, Address: form.Address, Remark: form.Remark,
|
Name: form.Name, Mobile: form.Mobile, Address: form.Address, Remark: form.Remark,
|
||||||
Kind: model.ManageSupplierKindForMaterial,
|
Kind: model.ManageSupplierKindForMaterial,
|
||||||
})
|
})
|
||||||
APIResponse(err)
|
APIResponse(err)(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*Supplier) MaterialEdit(c *gin.Context) {
|
func (*Supplier) MaterialEdit(c *gin.Context) {
|
||||||
@ -61,7 +61,7 @@ func (*Supplier) MaterialEdit(c *gin.Context) {
|
|||||||
ID: form.Convert(), Name: form.Name, Mobile: form.Mobile, Address: form.Address, Remark: form.Remark,
|
ID: form.Convert(), Name: form.Name, Mobile: form.Mobile, Address: form.Address, Remark: form.Remark,
|
||||||
Kind: model.ManageSupplierKindForMaterial,
|
Kind: model.ManageSupplierKindForMaterial,
|
||||||
})
|
})
|
||||||
APIResponse(err)
|
APIResponse(err)(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*Supplier) MaterialDelete(c *gin.Context) {
|
func (*Supplier) MaterialDelete(c *gin.Context) {
|
||||||
@ -72,7 +72,7 @@ func (*Supplier) MaterialDelete(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
err := manage.NewSupplier()(getSession()(c).(*service.Session)).Delete(form.Convert())
|
err := manage.NewSupplier()(getSession()(c).(*service.Session)).Delete(form.Convert())
|
||||||
APIResponse(err)
|
APIResponse(err)(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*Supplier) Repair(c *gin.Context) {
|
func (*Supplier) Repair(c *gin.Context) {
|
||||||
@ -101,7 +101,7 @@ func (*Supplier) RepairAdd(c *gin.Context) {
|
|||||||
Name: form.Name, Mobile: form.Mobile, Address: form.Address, Remark: form.Remark,
|
Name: form.Name, Mobile: form.Mobile, Address: form.Address, Remark: form.Remark,
|
||||||
Kind: model.ManageSupplierKindForRepair,
|
Kind: model.ManageSupplierKindForRepair,
|
||||||
})
|
})
|
||||||
APIResponse(err)
|
APIResponse(err)(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*Supplier) RepairEdit(c *gin.Context) {
|
func (*Supplier) RepairEdit(c *gin.Context) {
|
||||||
@ -117,7 +117,7 @@ func (*Supplier) RepairEdit(c *gin.Context) {
|
|||||||
ID: form.Convert(), Name: form.Name, Mobile: form.Mobile, Address: form.Address, Remark: form.Remark,
|
ID: form.Convert(), Name: form.Name, Mobile: form.Mobile, Address: form.Address, Remark: form.Remark,
|
||||||
Kind: model.ManageSupplierKindForRepair,
|
Kind: model.ManageSupplierKindForRepair,
|
||||||
})
|
})
|
||||||
APIResponse(err)
|
APIResponse(err)(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*Supplier) RepairDelete(c *gin.Context) {
|
func (*Supplier) RepairDelete(c *gin.Context) {
|
||||||
@ -128,5 +128,5 @@ func (*Supplier) RepairDelete(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
err := manage.NewSupplier()(getSession()(c).(*service.Session)).Delete(form.Convert())
|
err := manage.NewSupplier()(getSession()(c).(*service.Session)).Delete(form.Convert())
|
||||||
APIResponse(err)
|
APIResponse(err)(c)
|
||||||
}
|
}
|
||||||
|
@ -10,12 +10,12 @@ type User struct{}
|
|||||||
|
|
||||||
func (*User) Info(c *gin.Context) {
|
func (*User) Info(c *gin.Context) {
|
||||||
data := user.NewInstance()(getSession()(c).(*service.Session)).Info()
|
data := user.NewInstance()(getSession()(c).(*service.Session)).Info()
|
||||||
APIResponse(nil, data)
|
APIResponse(nil, data)(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*User) Menu(c *gin.Context) {
|
func (*User) Menu(c *gin.Context) {
|
||||||
data, err := user.NewMenu()(getSession()(c).(*service.Session)).Menu()
|
data, err := user.NewMenu()(getSession()(c).(*service.Session)).Menu()
|
||||||
APIResponse(err, data)
|
APIResponse(err, data)(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*User) List(c *gin.Context) {
|
func (*User) List(c *gin.Context) {
|
||||||
@ -31,7 +31,7 @@ func (*User) List(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
data, err := user.NewInstance()(getSession()(c).(*service.Session)).List(form.Name, form.Mobile, form.TenantID,
|
data, err := user.NewInstance()(getSession()(c).(*service.Session)).List(form.Name, form.Mobile, form.TenantID,
|
||||||
form.Page, form.PageSize)
|
form.Page, form.PageSize)
|
||||||
APIResponse(err, data)
|
APIResponse(err, data)(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*User) Add(c *gin.Context) {
|
func (*User) Add(c *gin.Context) {
|
||||||
@ -47,7 +47,7 @@ func (*User) Add(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
data, err := user.NewInstance()(getSession()(c).(*service.Session)).List(form.Name, form.Mobile, form.TenantID,
|
data, err := user.NewInstance()(getSession()(c).(*service.Session)).List(form.Name, form.Mobile, form.TenantID,
|
||||||
form.Page, form.PageSize)
|
form.Page, form.PageSize)
|
||||||
APIResponse(err, data)
|
APIResponse(err, data)(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*User) Edit(c *gin.Context) {
|
func (*User) Edit(c *gin.Context) {
|
||||||
@ -63,5 +63,5 @@ func (*User) Edit(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
data, err := user.NewInstance()(getSession()(c).(*service.Session)).List(form.Name, form.Mobile, form.TenantID,
|
data, err := user.NewInstance()(getSession()(c).(*service.Session)).List(form.Name, form.Mobile, form.TenantID,
|
||||||
form.Page, form.PageSize)
|
form.Page, form.PageSize)
|
||||||
APIResponse(err, data)
|
APIResponse(err, data)(c)
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,9 @@ type ManageMaterial struct {
|
|||||||
Code string `gorm:"column:code;type:varchar(35);default:null;comment:编号" json:"code"`
|
Code string `gorm:"column:code;type:varchar(35);default:null;comment:编号" json:"code"`
|
||||||
Title string `gorm:"column:title;type:varchar(100);default:null;comment:名称" json:"title"`
|
Title string `gorm:"column:title;type:varchar(100);default:null;comment:名称" json:"title"`
|
||||||
Image
|
Image
|
||||||
Unit ManageMaterialUnit `gorm:"column:unit;type:tinyint(1);default:0;comment:单位" json:"unit"`
|
Unit ManageMaterialUnit `gorm:"column:unit;type:tinyint(1);default:0;comment:单位" json:"unit"`
|
||||||
Remark string `gorm:"column:remark;type:varchar(255);default:null;comment:备注" json:"remark"`
|
Position string `gorm:"column:position;type:varchar(20);default:null;comment:position" json:"position"`
|
||||||
|
Remark string `gorm:"column:remark;type:varchar(255);default:null;comment:备注" json:"remark"`
|
||||||
ModelDeleted
|
ModelDeleted
|
||||||
ModelAt
|
ModelAt
|
||||||
}
|
}
|
||||||
|
@ -52,17 +52,19 @@ func (c *Instance) Login(account, password, captchaKey, captchaValue, ip string)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
session := service.NewSession()
|
session := service.NewSession()
|
||||||
session.Token = utils.JWTEncrypt(config.SettingInfo.TokenEffectTime, map[string]interface{}{
|
|
||||||
config.TokenForUID: mSysUser.UUID,
|
|
||||||
})
|
|
||||||
session.UID = mSysUser.UUID
|
session.UID = mSysUser.UUID
|
||||||
|
key := session.UIDToString()
|
||||||
|
|
||||||
|
session.Token = utils.JWTEncrypt(config.SettingInfo.TokenEffectTime, map[string]interface{}{
|
||||||
|
config.TokenForUID: key,
|
||||||
|
})
|
||||||
session.TenantID = mSysUser.TenantID
|
session.TenantID = mSysUser.TenantID
|
||||||
session.Name = mSysUser.Name
|
session.Name = mSysUser.Name
|
||||||
session.Avatar = mSysUser.Avatar
|
session.Avatar = mSysUser.Avatar
|
||||||
session.Mobile = mSysUser.Mobile
|
session.Mobile = mSysUser.Mobile
|
||||||
session.IsAdmin = mSysUser.IsAdminUser()
|
session.IsAdmin = mSysUser.IsAdminUser()
|
||||||
|
|
||||||
service.Publish(config.EventForRedisHashProduce, config.RedisKeyForAccount, session.UIDToString(), session)
|
service.Publish(config.EventForRedisHashProduce, config.RedisKeyForAccount, key, session)
|
||||||
service.Publish(config.EventForAccountLoginProduce, session.TenantID, session.UID, ip)
|
service.Publish(config.EventForAccountLoginProduce, session.TenantID, session.UID, ip)
|
||||||
|
|
||||||
return &InstanceLoginResponse{Token: session.Token, EffectTime: config.SettingInfo.TokenEffectTime}, nil
|
return &InstanceLoginResponse{Token: session.Token, EffectTime: config.SettingInfo.TokenEffectTime}, nil
|
||||||
|
@ -22,9 +22,9 @@ type (
|
|||||||
}
|
}
|
||||||
// MaterialParams 基本参数
|
// MaterialParams 基本参数
|
||||||
MaterialParams struct {
|
MaterialParams struct {
|
||||||
ID, ManufacturerID uint64
|
ID, ManufacturerID uint64
|
||||||
Code, Title, Image, Remark string
|
Code, Title, Image, Position, Remark string
|
||||||
Unit int
|
Unit int
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -97,6 +97,7 @@ func (c *Material) Form(params *MaterialParams) error {
|
|||||||
mManageMaterial.Code = params.Code
|
mManageMaterial.Code = params.Code
|
||||||
mManageMaterial.Title = params.Title
|
mManageMaterial.Title = params.Title
|
||||||
mManageMaterial.Unit = model2.ManageMaterialUnit(params.Unit)
|
mManageMaterial.Unit = model2.ManageMaterialUnit(params.Unit)
|
||||||
|
mManageMaterial.Position = params.Position
|
||||||
mManageMaterial.Remark = params.Remark
|
mManageMaterial.Remark = params.Remark
|
||||||
|
|
||||||
if mManageMaterial.ID > 0 {
|
if mManageMaterial.ID > 0 {
|
||||||
@ -121,10 +122,6 @@ func (c *Material) Delete(id uint64) error {
|
|||||||
return model2.Delete(mManageMaterial.ManageMaterial)
|
return model2.Delete(mManageMaterial.ManageMaterial)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Material) Supplier() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewMaterial() MaterialHandle {
|
func NewMaterial() MaterialHandle {
|
||||||
return func(session *service.Session) *Material {
|
return func(session *service.Session) *Material {
|
||||||
return &Material{session}
|
return &Material{session}
|
||||||
|
@ -4,9 +4,12 @@ import (
|
|||||||
"ArmedPolice/app/event"
|
"ArmedPolice/app/event"
|
||||||
"ArmedPolice/app/service"
|
"ArmedPolice/app/service"
|
||||||
"ArmedPolice/config"
|
"ArmedPolice/config"
|
||||||
|
"ArmedPolice/lib"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Init() {
|
func Init() {
|
||||||
|
// 载入数据配置
|
||||||
|
lib.LoadConfig("./json/area.json", &config.SettingAreaInfo)
|
||||||
// RedisHash存储/移除监听
|
// RedisHash存储/移除监听
|
||||||
service.Subscribe(config.EventForRedisHashProduce, event.NewRedisHashProduce())
|
service.Subscribe(config.EventForRedisHashProduce, event.NewRedisHashProduce())
|
||||||
service.Subscribe(config.EventForRedisHashDestroy, event.NewRedisHashDestroy())
|
service.Subscribe(config.EventForRedisHashDestroy, event.NewRedisHashDestroy())
|
||||||
|
@ -52,6 +52,12 @@ func (this *Router) registerAPI() {
|
|||||||
accountV1.POST("/login", _api.Login)
|
accountV1.POST("/login", _api.Login)
|
||||||
accountV1.POST("/logout", _api.Logout)
|
accountV1.POST("/logout", _api.Logout)
|
||||||
}
|
}
|
||||||
|
// Config 配置管理
|
||||||
|
configV1 := v1.Group("/config")
|
||||||
|
{
|
||||||
|
_api := new(api.Config)
|
||||||
|
configV1.GET("/area", _api.Area)
|
||||||
|
}
|
||||||
// Tenant 租户单位管理
|
// Tenant 租户单位管理
|
||||||
tenantV1 := v1.Group("/tenant")
|
tenantV1 := v1.Group("/tenant")
|
||||||
{
|
{
|
||||||
@ -73,7 +79,7 @@ func (this *Router) registerAPI() {
|
|||||||
menuV1 := v1.Group("/menu")
|
menuV1 := v1.Group("/menu")
|
||||||
{
|
{
|
||||||
_api := new(api.Menu)
|
_api := new(api.Menu)
|
||||||
menuV1.POST("/list", _api.List)
|
menuV1.GET("/list", _api.List)
|
||||||
menuV1.POST("/add", _api.Add)
|
menuV1.POST("/add", _api.Add)
|
||||||
menuV1.POST("/edit", _api.Edit)
|
menuV1.POST("/edit", _api.Edit)
|
||||||
menuV1.POST("/status", _api.Status)
|
menuV1.POST("/status", _api.Status)
|
||||||
|
Reference in New Issue
Block a user