123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- package data
- import (
- "eta/eta_api/models/common"
- )
- // CommonClassifyStrategy 通用分类策略接口
- type CommonClassifyStrategy interface {
- GetCommonClassifyCols() common.CommonClassifyCols
- GetCommonClassifyById(classifyId int) (*common.CommonClassify, error)
- GetClassifyByParentIdAndName(parentId int, name string, excludeId int) (*common.CommonClassify, error)
- GetClassifySortMaxByParentId(parentId int) (int, error)
- GetFirstClassifyByParentId(parentId int) (*common.CommonClassify, error)
- SetClassifySortByParentId(parentId, classifyId, sort int, sortUpdate string) error
- UpdateCommonClassify(classify *common.CommonClassify, updateCols []string) error
- UpdateClassifyChildByParentId(classifyIds []int, rootId int, stepLevel int) error
- GetCommonClassifyObjCols() common.CommonClassifyObjCols
- GetObjectById(objectId int) (*common.CommonClassifyObj, error)
- GetObjectSortMaxByClassifyId(classifyId int) (int, error)
- GetFirstObjectByClassifyId(classifyId int) (*common.CommonClassifyObj, error)
- SetObjectSortByClassifyId(classifyId, sort, prevObjectId int, sortUpdate string) error
- UpdateCommonClassifyObj(object *common.CommonClassifyObj, updateCols []string) (err error)
- }
- // CommonClassifyCtx 通用分类上下文
- type CommonClassifyCtx struct {
- strategy CommonClassifyStrategy
- }
- // NewCommonClassifyCtx New一个通用分类上下文
- func NewCommonClassifyCtx(strategy CommonClassifyStrategy) *CommonClassifyCtx {
- return &CommonClassifyCtx{strategy: strategy}
- }
- // GetCommonClassifyCols 通用分类字段映射
- func (c *CommonClassifyCtx) GetCommonClassifyCols() common.CommonClassifyCols {
- return c.strategy.GetCommonClassifyCols()
- }
- // GetCommonClassifyById 通过策略获取分类信息
- func (c *CommonClassifyCtx) GetCommonClassifyById(classifyId int) (*common.CommonClassify, error) {
- return c.strategy.GetCommonClassifyById(classifyId)
- }
- // GetClassifyByParentIdAndName 通过策略获取分类信息
- func (c *CommonClassifyCtx) GetClassifyByParentIdAndName(parentId int, name string, excludeId int) (*common.CommonClassify, error) {
- return c.strategy.GetClassifyByParentIdAndName(parentId, name, excludeId)
- }
- // GetClassifySortMaxByParentId 获取父级分类下最大排序
- func (c *CommonClassifyCtx) GetClassifySortMaxByParentId(parentId int) (int, error) {
- return c.strategy.GetClassifySortMaxByParentId(parentId)
- }
- // GetFirstClassifyByParentId 获取父级分类下首个分类
- func (c *CommonClassifyCtx) GetFirstClassifyByParentId(parentId int) (*common.CommonClassify, error) {
- return c.strategy.GetFirstClassifyByParentId(parentId)
- }
- // SetClassifySortByParentId 通过父级ID更新分类排序
- func (c *CommonClassifyCtx) SetClassifySortByParentId(parentId, classifyId, sort int, sortUpdate string) error {
- return c.strategy.SetClassifySortByParentId(parentId, classifyId, sort, sortUpdate)
- }
- // UpdateCommonClassify 更新通用分类
- func (c *CommonClassifyCtx) UpdateCommonClassify(classify *common.CommonClassify, updateCols []string) error {
- return c.strategy.UpdateCommonClassify(classify, updateCols)
- }
- // UpdateClassifyChildByParentId 更新分类子节点RootId
- func (c *CommonClassifyCtx) UpdateClassifyChildByParentId(classifyIds []int, rootId int, stepLevel int) error {
- return c.strategy.UpdateClassifyChildByParentId(classifyIds, rootId, stepLevel)
- }
- // GetCommonClassifyObjCols 通用分类对象字段映射
- func (c *CommonClassifyCtx) GetCommonClassifyObjCols() common.CommonClassifyObjCols {
- return c.strategy.GetCommonClassifyObjCols()
- }
- // GetObjectById 获取分类对象
- func (c *CommonClassifyCtx) GetObjectById(objectId int) (*common.CommonClassifyObj, error) {
- return c.strategy.GetObjectById(objectId)
- }
- // GetObjectSortMaxByClassifyId 获取分类下最大排序
- func (c *CommonClassifyCtx) GetObjectSortMaxByClassifyId(classifyId int) (int, error) {
- return c.strategy.GetObjectSortMaxByClassifyId(classifyId)
- }
- // GetFirstObjectByClassifyId 获取分类下首个对象
- func (c *CommonClassifyCtx) GetFirstObjectByClassifyId(classifyId int) (*common.CommonClassifyObj, error) {
- return c.strategy.GetFirstObjectByClassifyId(classifyId)
- }
- // SetObjectSortByClassifyId 通过分类ID更新对象排序
- func (c *CommonClassifyCtx) SetObjectSortByClassifyId(classifyId, sort, prevObjectId int, sortUpdate string) error {
- return c.strategy.SetObjectSortByClassifyId(classifyId, sort, prevObjectId, sortUpdate)
- }
- // UpdateCommonClassifyObj 更新分类对象
- func (c *CommonClassifyCtx) UpdateCommonClassifyObj(object *common.CommonClassifyObj, updateCols []string) (err error) {
- return c.strategy.UpdateCommonClassifyObj(object, updateCols)
- }
|