初始化脚手架

This commit is contained in:
qiyunfanbo126.com 2024-05-08 12:26:02 +08:00
parent 35c9dbdd95
commit a8e7a96d4c
8 changed files with 0 additions and 236 deletions

View File

@ -1,71 +0,0 @@
package backend
import (
"qteam/app/http/domains"
"time"
)
type ProductCreateRequest struct {
ProductName string `json:"product_name" validate:"required" example:"snow"`
ProductType int `json:"product_type" validate:"required,oneof=1 2 3" example:"1"` // 产品类型1/优惠券类2/组合礼包类3/商城积分类)
PacketRule int `json:"packet_rule"`
ProductKind int `json:"'product_kind'"`
Amount string `json:"'amount'"`
CouponType int `json:"'coupon_type'"`
IsSuperposition int `json:"'is_superposition'"`
TemplateId int `json:"'template_id'"`
Status int `json:"status"`
IsNeedBill int `json:"'is_need_bill'"`
SupplierProductId int64 `json:"supplier_product_id"`
SupplierProductName string `json:"supplier_product_name"`
}
func (p *ProductCreateRequest) ToDomain() (do domains.Product, err error) {
do.ProductName = p.ProductName
do.ProductType = p.ProductType
do.PacketRule = p.PacketRule
do.ProductKind = p.ProductKind
do.Amount = p.Amount
do.CouponType = p.CouponType
do.IsSuperposition = p.IsSuperposition
do.TemplateId = do.TemplateId
do.Status = p.Status
do.SupplierProductId = p.SupplierProductId
do.SupplierProductName = p.SupplierProductName
return
}
type ProductCreateResponse struct {
Id int `json:"id"`
ProductName string `json:"product_name"`
ProductType int `json:"product_type"`
PacketRule int `json:"packet_rule"`
ProductKind int `json:"'product_kind'"`
Amount string `json:"'amount'"`
CouponType int `json:"'coupon_type'"`
IsSuperposition int `json:"'is_superposition'"`
TemplateId int `json:"'template_id'"`
Status int `json:"status"`
IsNeedBill int `json:"'is_need_bill'"`
SupplierProductId int64 `json:"supplier_product_id"`
SupplierProductName string `json:"supplier_product_name"`
CreateTime string `json:"create_time"`
UpdateTime string `json:"update_time"`
Creator string `json:"creator"`
}
func (p *ProductCreateResponse) FromDomain(do domains.Product) {
p.ProductName = do.ProductName
p.ProductType = do.ProductType
p.PacketRule = do.PacketRule
p.ProductKind = do.ProductKind
p.Amount = do.Amount
p.CouponType = do.CouponType
p.IsSuperposition = do.IsSuperposition
p.TemplateId = do.TemplateId
p.Status = do.Status
p.SupplierProductId = do.SupplierProductId
p.SupplierProductName = do.SupplierProductName
p.CreateTime = do.CreateTime.Format(time.DateTime)
}

View File

@ -1,16 +0,0 @@
package backend
type UserListRequest struct {
Page int `json:"page" validate:"required"`
Limit int `json:"limit" validate:"required"`
Mobile string `json:"mobile"`
}
type UserListResponse struct {
Id int `xorm:"'Id' int(11)"`
Clientuniqueidentification string `xorm:"'ClientUniqueIdentification' varchar(255)"`
Mobile string `xorm:"'Mobile' varchar(13)"`
Status int `xorm:"'Status' TINYINT"`
Aer string
Createtime string
}

View File

@ -1,5 +0,0 @@
package front
type LoginRequest struct {
UserName string `json:"user_name" validate:"required"`
}

View File

@ -1,34 +0,0 @@
package productsmodel
import "qteam/app/http/domains"
func (p *Products) FromDomain(do domains.Product) {
p.Id = do.Id
p.Productname = do.ProductName
p.Producttype = do.ProductType
p.Packetrule = do.PacketRule
p.Productkind = do.ProductKind
p.Amount = do.Amount
p.Coupontype = do.CouponType
p.Issuperposition = do.IsSuperposition
p.Status = do.Status
p.Isneedbill = do.TemplateId
p.Supplierproductname = do.SupplierProductName
p.Supplierproductid = do.SupplierProductId
}
func (p *Products) ToDomain() (do domains.Product) {
do.Id = p.Id
do.ProductName = p.Productname
do.ProductType = p.Producttype
do.PacketRule = p.Packetrule
do.ProductKind = p.Productkind
do.Amount = p.Amount
do.CouponType = p.Coupontype
do.IsSuperposition = p.Issuperposition
do.Status = p.Status
do.TemplateId = p.Isneedbill
do.SupplierProductName = p.Supplierproductname
do.SupplierProductId = p.Supplierproductid
return
}

View File

@ -1,48 +0,0 @@
package productsmodel
import (
"github.com/qit-team/snow-core/db"
"sync"
)
var (
once sync.Once
m *ProductsModel
)
// 实体
type Products struct {
Id int `xorm:"'Id' int(0)"`
Productname string `xorm:"'ProductName' varchar(255)"`
Producttype int `xorm:"'ProductType' int(0)"`
Packetrule int `xorm:"'PacketRule' TINYINT"`
Productkind int `xorm:"'ProductKind' TINYINT"`
Amount string `xorm:"'Amount' decimal(9,2)"`
Coupontype int `xorm:"'CouponType' TINYINT"`
Issuperposition int `xorm:"'IsSuperposition' TINYINT"`
Templateid int `xorm:"'TemplateId' int(0)"`
Status int `xorm:"'Status' TINYINT"`
Isneedbill int `xorm:"'IsNeedBill' TINYINT"`
//Createtime time.Time `xorm:"'CreateTime' datetime"`
Supplierproductid int64 `xorm:"'SupplierProductId' bigint(0)"`
Supplierproductname string `xorm:"'SupplierProductName' varchar(255)"`
}
// 表名
func (m *Products) TableName() string {
return "Products"
}
// 私有化防止被外部new
type ProductsModel struct {
db.Model //组合基础Model集成基础Model的属性和方法
}
// 单例模式
func GetInstance() *ProductsModel {
once.Do(func() {
m = new(ProductsModel)
//m.DiName = "" //设置数据库实例连接默认db.SingletonMain
})
return m
}

View File

@ -1,15 +0,0 @@
package userinfomodel
import (
"qteam/app/http/entities/backend"
"time"
)
func (m *UserInfo) ToDomain() (do backend.UserListResponse) {
do.Id = m.Id
do.Clientuniqueidentification = m.Clientuniqueidentification
do.Mobile = m.Mobile
do.Status = m.Status
do.Createtime = m.Createtime.Format(time.DateTime)
return
}

View File

@ -1,47 +0,0 @@
package userinfomodel
import (
"github.com/qit-team/snow-core/db"
"sync"
"time"
)
var (
once sync.Once
m *UserInfoModel
)
// 实体
type UserInfo struct {
Id int `xorm:"'Id' int(11)"`
Clientuniqueidentification string `xorm:"'ClientUniqueIdentification' varchar(255)"`
Mobile string `xorm:"'Mobile' varchar(13)"`
Status int `xorm:"'Status' TINYINT"`
Lastupdatetime time.Time `xorm:"'LastUpdateTime' datetime"`
Createtime time.Time `xorm:"'CreateTime' datetime"`
}
// 表名
func (m *UserInfo) TableName() string {
return "UserInfo"
}
// 私有化防止被外部new
type UserInfoModel struct {
db.Model //组合基础Model集成基础Model的属性和方法
}
// 单例模式
func GetInstance() *UserInfoModel {
once.Do(func() {
m = new(UserInfoModel)
//m.DiName = "" //设置数据库实例连接默认db.SingletonMain
})
return m
}
func (m *UserInfoModel) GetListByMobile(mobile string, limits ...int) (banners []*UserInfo, err error) {
banners = make([]*UserInfo, 0)
err = m.GetList(&banners, "Mobile like ?", []interface{}{"%" + mobile + "%"}, limits)
return
}