|
|
@@ -0,0 +1,46 @@ |
|
|
|
package implement |
|
|
|
|
|
|
|
import ( |
|
|
|
"code.fnuoos.com/EggPlanet/egg_models.git/src/dao" |
|
|
|
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" |
|
|
|
zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_models.git/utils/logx" |
|
|
|
"xorm.io/xorm" |
|
|
|
) |
|
|
|
|
|
|
|
func NewArticleDb(engine *xorm.Engine) dao.ArticleDao { |
|
|
|
return &ArticleDb{Db: engine} |
|
|
|
} |
|
|
|
|
|
|
|
type ArticleDb struct { |
|
|
|
Db *xorm.Engine |
|
|
|
} |
|
|
|
|
|
|
|
func (a ArticleDb) GetArticle(id string) (m *model.Article, err error) { |
|
|
|
m = new(model.Article) |
|
|
|
has, err := a.Db.Where("id=?", id).Get(m) |
|
|
|
if err != nil { |
|
|
|
return nil, zhios_order_relate_logx.Error(err) |
|
|
|
} |
|
|
|
if has == false { |
|
|
|
return nil, nil |
|
|
|
} |
|
|
|
return m, nil |
|
|
|
} |
|
|
|
func (a ArticleDb) ArticleCateByTypeId(typeId string) (m *model.Article, err error) { |
|
|
|
m = new(model.Article) |
|
|
|
has, err := a.Db.Where("is_show=1 and type_id=?", typeId).Get(m) |
|
|
|
if err != nil { |
|
|
|
return nil, zhios_order_relate_logx.Error(err) |
|
|
|
} |
|
|
|
if has == false { |
|
|
|
return nil, nil |
|
|
|
} |
|
|
|
return m, nil |
|
|
|
} |
|
|
|
func (a ArticleDb) ArticleByCid(cid string) (*[]model.Article, error) { |
|
|
|
var m []model.Article |
|
|
|
if err := a.Db.Where("cate_id=?", cid).Find(&m); err != nil { |
|
|
|
return nil, zhios_order_relate_logx.Error(err) |
|
|
|
} |
|
|
|
return &m, nil |
|
|
|
} |