123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336 |
- package trade_analysis
- import (
- "database/sql"
- "eta/eta_api/global"
- "eta/eta_api/models/common"
- "eta/eta_api/utils"
- "fmt"
- "strings"
- "time"
- )
- type WareHouseProcessClassify struct {
- WareHouseProcessClassifyId int `orm:"column(warehouse_process_classify_id);pk"`
- ClassifyName string `description:"分类名称"`
- ClassifyNameEn string `description:"英文分类名称"`
- ParentId int `description:"父级ID"`
- SysUserId int `description:"创建人ID"`
- SysUserRealName string `description:"创建人姓名"`
- Level int `description:"层级"`
- Sort int `description:"排序"`
- RootId int `description:"顶级分类ID"`
- LevelPath string `description:"层级路径"`
- UniqueCode string `description:"唯一编码"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"修改时间"`
- }
- func (m *WareHouseProcessClassify) TableName() string {
- return "warehouse_process_classify"
- }
- type WareHouseProcessClassifyCols struct {
- PrimaryId string
- ClassifyName string
- ClassifyNameEn string
- ParentId string
- SysUserId string
- SysUserRealName string
- Level string
- Sort string
- RootId string
- LevelPath string
- UniqueCode string
- CreateTime string
- ModifyTime string
- }
- func (m *WareHouseProcessClassify) Cols() WareHouseProcessClassifyCols {
- return WareHouseProcessClassifyCols{
- PrimaryId: "warehouse_process_classify_id",
- ClassifyName: "classify_name",
- ClassifyNameEn: "classify_name_en",
- ParentId: "parent_id",
- SysUserId: "sys_user_id",
- SysUserRealName: "sys_user_real_name",
- Level: "level",
- Sort: "sort",
- RootId: "root_id",
- LevelPath: "level_path",
- UniqueCode: "unique_code",
- CreateTime: "create_time",
- ModifyTime: "modify_time",
- }
- }
- func (m *WareHouseProcessClassify) Create() (err error) {
- err = global.DbMap[utils.DbNameIndex].Create(m).Error
- if err != nil {
- return
- }
- return
- }
- func (m *WareHouseProcessClassify) CreateMulti(items []*WareHouseProcessClassify) (err error) {
- if len(items) == 0 {
- return
- }
- err = global.DbMap[utils.DbNameIndex].CreateInBatches(items, len(items)).Error
- return
- }
- func (m *WareHouseProcessClassify) Update(cols []string) (err error) {
- err = global.DbMap[utils.DbNameIndex].Select(cols).Updates(m).Error
- return
- }
- func (m *WareHouseProcessClassify) Remove() (err error) {
- sql := fmt.Sprintf(`DELETE FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), m.Cols().PrimaryId)
- err = global.DbMap[utils.DbNameIndex].Exec(sql, m.WareHouseProcessClassifyId).Error
- return
- }
- func (m *WareHouseProcessClassify) MultiRemove(ids []int) (err error) {
- if len(ids) == 0 {
- return
- }
- sql := fmt.Sprintf(`DELETE FROM %s WHERE %s IN (%s)`, m.TableName(), m.Cols().PrimaryId, utils.GetOrmInReplace(len(ids)))
- err = global.DbMap[utils.DbNameIndex].Exec(sql, ids).Error
- return
- }
- func (m *WareHouseProcessClassify) RemoveByCondition(condition string, pars []interface{}) (err error) {
- if condition == "" {
- return
- }
- sql := fmt.Sprintf(`DELETE FROM %s WHERE %s`, m.TableName(), condition)
- err = global.DbMap[utils.DbNameIndex].Exec(sql, pars).Error
- return
- }
- func (m *WareHouseProcessClassify) GetItemById(id int) (item *WareHouseProcessClassify, err error) {
- sql := fmt.Sprintf(`SELECT * FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), m.Cols().PrimaryId)
- err = global.DbMap[utils.DbNameIndex].Raw(sql, id).First(&item).Error
- return
- }
- func (m *WareHouseProcessClassify) GetItemByCondition(condition string, pars []interface{}, orderRule string) (item *WareHouseProcessClassify, err error) {
- order := ``
- if orderRule != "" {
- order = ` ORDER BY ` + orderRule
- }
- sql := fmt.Sprintf(`SELECT * FROM %s WHERE 1=1 %s %s LIMIT 1`, m.TableName(), condition, order)
- err = global.DbMap[utils.DbNameIndex].Raw(sql, pars...).First(&item).Error
- return
- }
- func (m *WareHouseProcessClassify) GetCountByCondition(condition string, pars []interface{}) (count int, err error) {
- var totalNull sql.NullInt64
- sql := fmt.Sprintf(`SELECT COUNT(1) FROM %s WHERE 1=1 %s`, m.TableName(), condition)
- err = global.DbMap[utils.DbNameIndex].Raw(sql, pars...).Scan(&count).Error
- if !totalNull.Valid {
- count = 0
- } else {
- count = int(totalNull.Int64)
- }
- return
- }
- func (m *WareHouseProcessClassify) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*WareHouseProcessClassify, err error) {
- fields := strings.Join(fieldArr, ",")
- if len(fieldArr) == 0 {
- fields = `*`
- }
- order := fmt.Sprintf(`ORDER BY %s DESC`, m.Cols().CreateTime)
- if orderRule != "" {
- order = ` ORDER BY ` + orderRule
- }
- sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s`, fields, m.TableName(), condition, order)
- err = global.DbMap[utils.DbNameIndex].Raw(sql, pars...).Find(&items).Error
- return
- }
- func (m *WareHouseProcessClassify) GetPageItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string, startSize, pageSize int) (items []*WareHouseProcessClassify, err error) {
- fields := strings.Join(fieldArr, ",")
- if len(fieldArr) == 0 {
- fields = `*`
- }
- order := fmt.Sprintf(`ORDER BY %s DESC`, m.Cols().CreateTime)
- if orderRule != "" {
- order = ` ORDER BY ` + orderRule
- }
- sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s LIMIT ?,?`, fields, m.TableName(), condition, order)
- pars = append(pars, startSize, pageSize)
- err = global.DbMap[utils.DbNameIndex].Raw(sql, pars...).Find(&items).Error
- return
- }
- type WareHouseProcessClassifyItem struct {
- ClassifyId int `description:"分类ID"`
- ClassifyName string `description:"分类名称"`
- ClassifyNameEn string `description:"英文分类名称"`
- ParentId int `description:"父级ID"`
- Level int `description:"层级"`
- Sort int `description:"排序"`
- LevelPath string `description:"层级路径"`
- UniqueCode string `description:"唯一编码"`
- Children []*WareHouseProcessClassifyItem `description:"子分类"`
- }
- func (m *WareHouseProcessClassify) Format2Item() (item *WareHouseProcessClassifyItem) {
- item = new(WareHouseProcessClassifyItem)
- item.ClassifyId = m.WareHouseProcessClassifyId
- item.ClassifyName = m.ClassifyName
- item.ClassifyNameEn = m.ClassifyNameEn
- item.ParentId = m.ParentId
- item.Level = m.Level
- item.Sort = m.Sort
- item.LevelPath = m.LevelPath
- item.UniqueCode = m.UniqueCode
- item.Children = make([]*WareHouseProcessClassifyItem, 0)
- return
- }
- func (m *WareHouseProcessClassify) GetCommonClassifyCols() common.CommonClassifyCols {
- return common.CommonClassifyCols{
- ClassifyId: m.Cols().PrimaryId,
- ClassifyName: m.Cols().ClassifyName,
- ParentId: m.Cols().ParentId,
- Sort: m.Cols().ParentId,
- RootId: m.Cols().RootId,
- Level: m.Cols().Level,
- LevelPath: m.Cols().LevelPath,
- CreateTime: m.Cols().CreateTime,
- ModifyTime: m.Cols().ModifyTime,
- }
- }
- func (m *WareHouseProcessClassify) GetCommonClassifyById(classifyId int) (commonClassify *common.CommonClassify, err error) {
- item, e := m.GetItemById(classifyId)
- if e != nil {
- err = e
- return
- }
- commonClassify = new(common.CommonClassify)
- commonClassify.ClassifyId = item.WareHouseProcessClassifyId
- commonClassify.ClassifyName = item.ClassifyName
- commonClassify.ParentId = item.ParentId
- commonClassify.RootId = item.RootId
- commonClassify.Level = item.Level
- commonClassify.LevelPath = item.LevelPath
- commonClassify.Sort = item.Sort
- commonClassify.CreateTime = item.CreateTime
- commonClassify.ModifyTime = item.ModifyTime
- return
- }
- func (m *WareHouseProcessClassify) GetClassifyByParentIdAndName(parentId int, name string, excludeId int) (*common.CommonClassify, error) {
-
- return nil, nil
- }
- func (m *WareHouseProcessClassify) UpdateCommonClassify(classify *common.CommonClassify, updateCols []string) (err error) {
- return
- }
- func (m *WareHouseProcessClassify) UpdateClassifyChildByParentId(classifyIds []int, rootId int, stepLevel int) (err error) {
-
-
-
-
-
-
-
-
-
-
-
-
- return
- }
- func (m *WareHouseProcessClassify) GetClassifySortMaxByParentId(parentId int) (sortMax int, err error) {
-
-
-
-
- return
- }
- func (m *WareHouseProcessClassify) GetFirstClassifyByParentId(parentId int) (item *common.CommonClassify, err error) {
-
-
-
- return
- }
- func (m *WareHouseProcessClassify) SetClassifySortByParentId(parentId, classifyId, sort int, sortUpdate string) (err error) {
-
-
-
-
-
-
- return
- }
- func (m *WareHouseProcessClassify) GetCommonClassifyObjCols() common.CommonClassifyObjCols {
-
- return common.CommonClassifyObjCols{
- ObjectId: m.Cols().ClassifyName,
- ClassifyId: m.Cols().PrimaryId,
- Sort: m.Cols().ParentId,
- }
- }
- func (m *WareHouseProcessClassify) GetObjectById(objectId int) (*common.CommonClassifyObj, error) {
-
- return nil, nil
- }
- func (m *WareHouseProcessClassify) GetObjectSortMaxByClassifyId(classifyId int) (sortMax int, err error) {
-
-
-
-
- return
- }
- func (m *WareHouseProcessClassify) GetFirstObjectByClassifyId(classifyId int) (item *common.CommonClassifyObj, err error) {
-
-
-
- return
- }
- func (m *WareHouseProcessClassify) SetObjectSortByClassifyId(classifyId, sort, prevObjectId int, sortUpdate string) (err error) {
-
-
-
-
-
-
-
-
- return
- }
- func (m *WareHouseProcessClassify) UpdateCommonClassifyObj(object *common.CommonClassifyObj, updateCols []string) (err error) {
- return
- }
|