feat:完善项目
This commit is contained in:
@ -92,6 +92,40 @@ func (*Manage) Equipment(c *gin.Context) {
|
||||
APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} /api/v1/manage/equipment/select 装备Select信息
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName ManageEquipmentSelect
|
||||
* @apiGroup Manage
|
||||
*
|
||||
* @apiHeader {string} x-token token
|
||||
*
|
||||
* @apiSuccess (200) {Object} data 数据信息
|
||||
* @apiSuccess (200) {String} data.id ID
|
||||
* @apiSuccess (200) {String} data.code 装备编码
|
||||
* @apiSuccess (200) {String} data.title 装备名称
|
||||
* @apiSuccess (200) {Number} code 成功响应状态码!
|
||||
* @apiSuccess (200) {String} msg 成功提示
|
||||
*
|
||||
* @apiSuccessExample {json} Success response:
|
||||
* HTTPS 200 OK
|
||||
* {
|
||||
* "code": 200
|
||||
* "msg": "ok"
|
||||
* "data": [
|
||||
* {
|
||||
* "id": "EgmJ4Ga7LQ",
|
||||
* "code": "S110",
|
||||
* "title": "装甲车-11",
|
||||
* }
|
||||
* ]
|
||||
* }
|
||||
*/
|
||||
func (*Manage) EquipmentSelect(c *gin.Context) {
|
||||
data, err := manage.NewEquipment()(getSession()(c).(*service.Session)).Select()
|
||||
APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} /api/v1/manage/equipment/detail 装备详细信息
|
||||
* @apiVersion 1.0.0
|
||||
@ -213,6 +247,44 @@ func (*Manage) Material(c *gin.Context) {
|
||||
APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} /api/v1/manage/material/select 器材Select信息
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName ManageMaterialSelect
|
||||
* @apiGroup Manage
|
||||
*
|
||||
* @apiHeader {string} x-token token
|
||||
*
|
||||
* @apiSuccess (200) {Object} data 数据信息
|
||||
* @apiSuccess (200) {String} data.id ID
|
||||
* @apiSuccess (200) {String} data.code 装备编码
|
||||
* @apiSuccess (200) {String} data.title 装备名称
|
||||
* @apiSuccess (200) {Float} data.price 单价
|
||||
* @apiSuccess (200) {String} data.manufacturer_name 制造商
|
||||
* @apiSuccess (200) {Number} code 成功响应状态码!
|
||||
* @apiSuccess (200) {String} msg 成功提示
|
||||
*
|
||||
* @apiSuccessExample {json} Success response:
|
||||
* HTTPS 200 OK
|
||||
* {
|
||||
* "code": 200
|
||||
* "msg": "ok"
|
||||
* "data": [
|
||||
* {
|
||||
* "id": "EgmJ4Ga7LQ",
|
||||
* "code": "S110",
|
||||
* "title": "装甲车-11",
|
||||
* "price": 8.88,
|
||||
* "manufacturer_name": "供应商",
|
||||
* }
|
||||
* ]
|
||||
* }
|
||||
*/
|
||||
func (*Manage) MaterialSelect(c *gin.Context) {
|
||||
data, err := manage.NewMaterial()(getSession()(c).(*service.Session)).Select()
|
||||
APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (*Manage) MaterialAdd(c *gin.Context) {
|
||||
form := new(manageMaterialForm)
|
||||
|
||||
|
@ -8,9 +8,9 @@ type ManageMaterial struct {
|
||||
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"`
|
||||
Image
|
||||
Unit ManageMaterialUnit `gorm:"column:unit;type:tinyint(1);default:0;comment:单位" json:"unit"`
|
||||
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"`
|
||||
Price float64 `gorm:"column:price;type:decimal(10,2);default:0;comment:单价" json:"price"`
|
||||
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"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ type ManageSupplier struct {
|
||||
Mobile string `gorm:"column:mobile;type:varchar(20);default:null;comment:联系方式" json:"mobile"`
|
||||
Contacts string `gorm:"column:contacts;type:varchar(20);default:null;comment:联系人" json:"contacts"`
|
||||
Address string `gorm:"column:address;type:varchar(255);default:null;comment:联系地址" json:"address"`
|
||||
Position string `gorm:"column:position;type:varchar(20);default:null;comment:坐标" json:"position"`
|
||||
Remark string `gorm:"column:remark;type:varchar(255);default:null;comment:备注信息 " json:"remark"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
|
@ -15,6 +15,12 @@ type Equipment struct{ *service.Session }
|
||||
type EquipmentHandle func(session *service.Session) *Equipment
|
||||
|
||||
type (
|
||||
// EquipmentBasic 装备基本信息
|
||||
EquipmentBasic struct {
|
||||
basic.CommonIDString
|
||||
Code string `json:"code"`
|
||||
Title string `json:"title"`
|
||||
}
|
||||
// EquipmentInfo 装备信息
|
||||
EquipmentInfo struct {
|
||||
basic.CommonIDString
|
||||
@ -57,12 +63,6 @@ func (c *Equipment) tree(iModel model2.IModel, src []*model2.ManageEquipment, pa
|
||||
|
||||
for _, v := range src {
|
||||
if v.ParentID == parentID {
|
||||
//parentID := "0"
|
||||
//
|
||||
//if v.ParentID > 0 {
|
||||
// iModel.SetID(v.ParentID)
|
||||
// parentID = iModel.GetEncodeID()
|
||||
//}
|
||||
out = append(out, &EquipmentInfo{
|
||||
CommonIDString: basic.CommonIDString{ID: v.GetEncodeID()},
|
||||
Code: v.Code,
|
||||
@ -93,10 +93,6 @@ func (c *Equipment) List(parentID uint64, title string, page, pageSize int) (*ba
|
||||
Where: model2.NewWhereLike("title", title),
|
||||
})
|
||||
}
|
||||
//if err := model2.ScanFields(mManageEquipment.ManageEquipment, &out, []string{"id", "code", "title", "image", "created_at"},
|
||||
// where...); err != nil {
|
||||
// return nil, err
|
||||
//}
|
||||
var count int64
|
||||
|
||||
if err := model2.PagesFields(mManageEquipment.ManageEquipment, &out, []string{"id", "code", "title", "image", "created_at"},
|
||||
@ -109,6 +105,27 @@ func (c *Equipment) List(parentID uint64, title string, page, pageSize int) (*ba
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Select 筛选信息
|
||||
func (c *Equipment) Select() ([]*EquipmentBasic, error) {
|
||||
mManageEquipment := model.NewManageEquipment()
|
||||
|
||||
out := make([]*model2.ManageEquipment, 0)
|
||||
|
||||
if err := model2.ScanFields(mManageEquipment.ManageEquipment, &out, []string{"id", "code", "title"}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*EquipmentBasic, 0)
|
||||
|
||||
for _, v := range out {
|
||||
list = append(list, &EquipmentBasic{
|
||||
CommonIDString: basic.CommonIDString{ID: v.GetEncodeID()},
|
||||
Code: v.Code,
|
||||
Title: v.Title,
|
||||
})
|
||||
}
|
||||
return list, nil
|
||||
}
|
||||
|
||||
// Detail 详细信息
|
||||
func (c *Equipment) Detail(id uint64) (*EquipmentDetail, error) {
|
||||
mManageEquipment := model.NewManageEquipment()
|
||||
|
@ -15,6 +15,11 @@ type Material struct{ *service.Session }
|
||||
type MaterialHandle func(session *service.Session) *Material
|
||||
|
||||
type (
|
||||
// MaterialBasic 基本信息
|
||||
MaterialBasic struct {
|
||||
basic.CommonIDString
|
||||
*model.ManageMaterialBasic
|
||||
}
|
||||
// MaterialInfo 基本信息
|
||||
MaterialInfo struct {
|
||||
basic.CommonIDString
|
||||
@ -74,6 +79,28 @@ func (c *Material) List(manufacturerID, supplierID uint64, code, title string, p
|
||||
return &basic.PageDataResponse{Data: list, Count: count}, nil
|
||||
}
|
||||
|
||||
// Select 信息筛选
|
||||
func (c *Material) Select() ([]*MaterialBasic, error) {
|
||||
mManageMaterial := model.NewManageMaterial()
|
||||
|
||||
out, err := mManageMaterial.Basic()
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*MaterialBasic, 0)
|
||||
|
||||
for _, v := range out {
|
||||
mManageMaterial.ID = v.ID
|
||||
|
||||
list = append(list, &MaterialBasic{
|
||||
CommonIDString: basic.CommonIDString{ID: mManageMaterial.GetEncodeID()},
|
||||
ManageMaterialBasic: v,
|
||||
})
|
||||
}
|
||||
return list, nil
|
||||
}
|
||||
|
||||
// Form 数据操作
|
||||
func (c *Material) Form(params *MaterialParams) error {
|
||||
mManageMaterial := model.NewManageMaterial()
|
||||
@ -100,7 +127,6 @@ func (c *Material) Form(params *MaterialParams) error {
|
||||
mManageMaterial.Code = params.Code
|
||||
mManageMaterial.Title = params.Title
|
||||
mManageMaterial.Unit = model2.ManageMaterialUnit(params.Unit)
|
||||
mManageMaterial.Position = params.Position
|
||||
mManageMaterial.Remark = params.Remark
|
||||
|
||||
if mManageMaterial.ID > 0 {
|
||||
|
@ -1,11 +1,16 @@
|
||||
package model
|
||||
|
||||
import "ArmedPolice/app/common/model"
|
||||
import (
|
||||
"ArmedPolice/app/common/model"
|
||||
)
|
||||
|
||||
type ManageEquipment struct {
|
||||
*model.ManageEquipment
|
||||
}
|
||||
|
||||
type ManageEquipmentInfo struct {
|
||||
}
|
||||
|
||||
func NewManageEquipment() *ManageEquipment {
|
||||
return &ManageEquipment{model.NewManageEquipment()}
|
||||
}
|
||||
|
@ -13,18 +13,41 @@ type ManageMaterial struct {
|
||||
type (
|
||||
// ManageMaterialBasic 基本信息
|
||||
ManageMaterialBasic struct {
|
||||
Code string `json:"code"`
|
||||
Title string `json:"title"`
|
||||
Unit int `json:"unit"`
|
||||
ManufacturerName string `json:"manufacturer_name"`
|
||||
ID uint64 `json:"id"`
|
||||
Code string `json:"code"`
|
||||
Title string `json:"title"`
|
||||
Price float64 `json:"price"`
|
||||
ManufacturerName string `json:"manufacturer_name"`
|
||||
}
|
||||
ManageMaterialInfo struct {
|
||||
*model.ManageMaterial
|
||||
ManufacturerName string `json:"manufacturer_name"`
|
||||
SupplierName string `json:"supplier_name"`
|
||||
ManufacturerName string `json:"manufacturer_name"` // 制造商
|
||||
SupplierName string `json:"supplier_name"` // 合作商
|
||||
}
|
||||
)
|
||||
|
||||
// Basic 器材信息
|
||||
func (m *ManageMaterial) Basic(where ...*model.ModelWhere) ([]*ManageMaterialBasic, error) {
|
||||
mManageSupplier := model.NewManageSupplier()
|
||||
|
||||
db := orm.GetDB().Table(m.TableName()+" AS m").
|
||||
Select("m.id", "m.code", "m.title", "m.price", "manufacturer.name AS manufacturer_name").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS manufacturer ON m.manufacturer_id = manufacturer.id", mManageSupplier.TableName()))
|
||||
|
||||
if len(where) > 0 {
|
||||
for _, wo := range where {
|
||||
db = db.Where(wo.Condition, wo.Value)
|
||||
}
|
||||
}
|
||||
out := make([]*ManageMaterialBasic, 0)
|
||||
|
||||
if err := db.Scan(&out).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
|
||||
}
|
||||
|
||||
// Materials 器材信息
|
||||
func (m *ManageMaterial) Materials(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ManageMaterialInfo, error) {
|
||||
mManageSupplier := model.NewManageSupplier()
|
||||
@ -32,9 +55,9 @@ func (m *ManageMaterial) Materials(page, pageSize int, count *int64, where ...*m
|
||||
db := orm.GetDB().Table(m.TableName()+" AS m").
|
||||
Select("m.*", "manufacturer.name AS manufacturer_name", "s.name AS supplier_name").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS manufacturer ON m.manufacturer_id = manufacturer.id", mManageSupplier.TableName())).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS m_d ON m.id = m_d.material_id AND m_d.is_deleted = %d",
|
||||
model.NewManageEquipmentMaterial().TableName(), model.DeleteStatusForNot)).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS s ON m_d.supplier_id = s.id", mManageSupplier.TableName()))
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS m_s ON m.id = m_s.material_id AND m_s.is_deleted = %d",
|
||||
model.NewManageMaterialSupplier().TableName(), model.DeleteStatusForNot)).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS s ON m_s.supplier_id = s.id", mManageSupplier.TableName()))
|
||||
|
||||
if len(where) > 0 {
|
||||
for _, wo := range where {
|
||||
|
10
config.yaml
10
config.yaml
@ -12,16 +12,6 @@ server:
|
||||
write_timeout: 5
|
||||
idle_timeout: 5
|
||||
|
||||
# config 配置信息
|
||||
config:
|
||||
vip_price: 99
|
||||
|
||||
wechat:
|
||||
# appid: wxc8b039943eca7a27
|
||||
appid: wx880e43c02bf7bd55
|
||||
# appsecret: a96335396caa2e91d9f93c8ba88f83ae
|
||||
appsecret: 10017dff4f55f86cb2074003f38b5a23
|
||||
|
||||
# RATE 限流器
|
||||
rate:
|
||||
# 每秒注入容器中数量
|
||||
|
@ -56,15 +56,6 @@ type Setting struct {
|
||||
IdleTimeout int `yaml:"idle_timeout"`
|
||||
}
|
||||
|
||||
// Config 配置
|
||||
Config struct {
|
||||
VipPrice float64 `yaml:"vip_price"`
|
||||
Wechat struct {
|
||||
AppID string `json:"appid"`
|
||||
AppSecret string `yaml:"appsecret"`
|
||||
} `yaml:"wechat"`
|
||||
}
|
||||
|
||||
// Rate 限流器
|
||||
Rate struct {
|
||||
Limit int `yaml:"limit"`
|
||||
|
@ -143,11 +143,13 @@ func (this *Router) registerAPI() {
|
||||
{
|
||||
_api := new(api.Manage)
|
||||
manageV1.POST("/equipment", _api.Equipment)
|
||||
manageV1.GET("/equipment/select", _api.EquipmentSelect)
|
||||
manageV1.POST("/equipment/detail", _api.EquipmentDetail)
|
||||
manageV1.POST("/equipment/add", _api.EquipmentAdd)
|
||||
manageV1.POST("/equipment/edit", _api.EquipmentEdit)
|
||||
manageV1.POST("/equipment/delete", _api.EquipmentDelete)
|
||||
manageV1.POST("/material", _api.Material)
|
||||
manageV1.GET("/material/select", _api.MaterialSelect)
|
||||
manageV1.POST("/material/add", _api.MaterialAdd)
|
||||
manageV1.POST("/material/edit", _api.MaterialEdit)
|
||||
manageV1.POST("/material/delete", _api.MaterialDelete)
|
||||
|
Reference in New Issue
Block a user