jiangshuai
2023-11-16 a0125ef3d6ce35be7b6dc4919c4192dba4a7329a
constvar/const.go
@@ -1 +1,225 @@
package constvar
type BaseOperationType int
const (
   BaseOperationTypeIncoming BaseOperationType = iota + 1 //收货
   BaseOperationTypeOutgoing                              //交货
   BaseOperationTypeInternal                              //内部调拨
   BaseOperationTypeDisuse                                //报废
   BaseOperationTypeAdjust                                //库存盘点
)
func (slf BaseOperationType) IsValid() bool {
   return slf == BaseOperationTypeIncoming ||
      slf == BaseOperationTypeOutgoing ||
      slf == BaseOperationTypeInternal
}
type ReservationMethod int
const (
   ReservationMethodAtConfirm ReservationMethod = iota + 1 //在确认时
   ReservationMethodManual                                 //手动
   ReservationMethodByDate                                 //在预定日期之前
)
func (slf ReservationMethod) IsValid() bool {
   return slf == ReservationMethodAtConfirm ||
      slf == ReservationMethodManual ||
      slf == ReservationMethodByDate
}
type WhetherType int
const (
   WhetherTypeAsk    WhetherType = iota + 1 //询问
   WhetherTypeAlways                        //总是
   ReservationNever                         //从不
)
func (slf WhetherType) IsValid() bool {
   return slf == WhetherTypeAsk ||
      slf == WhetherTypeAlways ||
      slf == ReservationNever
}
// ProductType 产品类型
type ProductType int
const (
   Consumables   ProductType = iota + 1 // 消耗品
   Server                               // 服务
   StoredProduct                        // 可储存的产品
)
type MaterialMode string
const (
   MaterialModeRaw      MaterialMode = "原材料"
   MaterialModeSemi     MaterialMode = "半成品"
   MaterialModeFinished MaterialMode = "成品"
)
type MaterialStatus int
const (
   MaterialStatusCreate   MaterialStatus = iota // 新建
   MaterialStatusActive                         // 启用
   MaterialStatusInactive = -1                  // 停用
)
// InvoicingStrategy 开票策略
type InvoicingStrategy int
const (
   IndentNumber       InvoicingStrategy = iota + 1 //订购数量
   DeliverNumber                                   //交付数量
   PrepaidPrice                                    //预付\固定价格
   Milestones                                      //基于里程碑
   BasedDeliverNumber                              //基于交付数量
)
// OrderCreation 订单创建
type OrderCreation int
const (
   Nothing       OrderCreation = iota + 1 //不操作
   Task                                   //任务
   Object                                 //项目
   TaskAndObject                          //任务和项目
)
type ProductStatus int
const (
   ProductStatusCreate   ProductStatus = iota // 新建
   ProductStatusActive                        // 启用
   ProductStatusInactive = -1                 // 停用
)
// PurchaseType 采购类型
type PurchaseType int
const (
   PurchaseTypeOutSource PurchaseType = iota + 1 // 采购
   PurchaseTypeSelf                              // 自制
   PurchaseTypeEntrust                           // 委外
)
func (t PurchaseType) Valid() bool {
   if t < PurchaseTypeOutSource ||
      t > PurchaseTypeEntrust {
      return false
   }
   return true
}
// LocationType 位置类型
type LocationType int
const (
   LocationTypeVendor        LocationType = iota + 1 // 供应商位置
   LocationTypeView                                  // 视图
   LocationTypeInternal                              // 内部位置
   LocationTypeCustomer                              // 客户位置
   LocationTypeInventoryLoss                         // 库存损失
   LocationTypeProduction                            // 生产
   LocationTypeTransit                               // 中转位置
   LocationTypeDisuse                                //报废位置
   LocationTypeAdjust                                //库存盘点
)
func (t LocationType) Valid() bool {
   return t >= LocationTypeVendor && t <= LocationTypeTransit
}
type ForceRemovalStrategy int
const (
   ForceRemovalStrategyFIFO ForceRemovalStrategy = iota + 1
   ForceRemovalStrategyLIFO
   ForceRemovalStrategyClosestLocation
)
func (t ForceRemovalStrategy) Valid() bool {
   return t >= ForceRemovalStrategyFIFO && t <= ForceRemovalStrategyClosestLocation
}
type CostingMethod int
const (
   CostingMethodStandardPrice CostingMethod = iota + 1 //标准价格
   CostingMethodFIFO                                   //先进先出
   CostingMethodAverageCost                            //平均成本
)
func (t CostingMethod) Valid() bool {
   return t >= CostingMethodStandardPrice && t <= CostingMethodAverageCost
}
type InventoryValuation int
const (
   InventoryValuationManual InventoryValuation = iota + 1 //手动
   InventoryValuationAuto                                 //自动
)
func (t InventoryValuation) Valid() bool {
   return t >= InventoryValuationManual && t <= InventoryValuationAuto
}
type OperationStatus int
const (
   OperationStatus_Draft   OperationStatus = iota + 1 //草稿
   OperationStatus_Waiting                            //正在等待
   OperationStatus_Ready                              //就绪
   OperationStatus_Finish                             //完成
   OperationStatus_Cancel                             //完成
)
type PostType int
const (
   PostType_Soon       PostType = iota + 1 //尽快
   PostType_AfterReady                     //当所有产品就绪时
)
type RuleType int
const (
   RuleType_Product         RuleType = iota + 1 //产品上架规则
   RuleType_ProductCategory                     //产品类别上架规则
)
type UserType int
const (
   UserTypeSuper   UserType = iota + 1 // 超级管理员
   UserTypePrimary                     // 主账户
   UserTypeSub                         // 子账户
)
type FileType string
const (
   FileType_File      FileType = "file"      //文件
   FileType_Picture   FileType = "picture"   //图片
   FileType_Thumbnail FileType = "thumbnail" //缩略图
)
var FileExtMap = map[string]FileType{
   "doc":  FileType_File,
   "docx": FileType_File,
   "xls":  FileType_File,
   "xlsx": FileType_File,
   "txt":  FileType_File,
}
var PicExtMap = map[string]FileType{
   "jpg":  FileType_Picture,
   "jpeg": FileType_Picture,
   "png":  FileType_Picture,
   "svg":  FileType_Picture,
}