|
@@ -0,0 +1,55 @@ |
|
|
|
|
|
package implement |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
|
|
"code.fnuoos.com/EggPlanet/egg_models.git/src/dao" |
|
|
|
|
|
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" |
|
|
|
|
|
zhios_order_relate_utils "code.fnuoos.com/EggPlanet/egg_models.git/utils" |
|
|
|
|
|
zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_models.git/utils/logx" |
|
|
|
|
|
"strings" |
|
|
|
|
|
"xorm.io/xorm" |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
func NewUserCertificateDb(engine *xorm.Engine) dao.UserCertificateDao { |
|
|
|
|
|
return &UserCertificateDb{Db: engine} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
type UserCertificateDb struct { |
|
|
|
|
|
Db *xorm.Engine |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (u UserCertificateDb) FindUserCertificate(page, limit, uid string) (*[]model.UserCertificate, error) { |
|
|
|
|
|
var m []model.UserCertificate |
|
|
|
|
|
sess := u.Db.Where("1=1") |
|
|
|
|
|
if uid != "" { |
|
|
|
|
|
sess.In("uid", strings.Split(uid, ",")) |
|
|
|
|
|
} |
|
|
|
|
|
start := (zhios_order_relate_utils.StrToInt(page) - 1) * zhios_order_relate_utils.StrToInt(limit) |
|
|
|
|
|
err := sess.Limit(zhios_order_relate_utils.StrToInt(limit), start).OrderBy("id desc").Find(&m) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return nil, zhios_order_relate_logx.Error(err) |
|
|
|
|
|
} |
|
|
|
|
|
return &m, nil |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (u UserCertificateDb) GetUserCertificateByNo(no string) (m *model.UserCertificate, err error) { |
|
|
|
|
|
m = new(model.UserCertificate) |
|
|
|
|
|
has, err := u.Db.Where("no =?", no).Get(m) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return nil, zhios_order_relate_logx.Error(err) |
|
|
|
|
|
} |
|
|
|
|
|
if has == false { |
|
|
|
|
|
return nil, nil |
|
|
|
|
|
} |
|
|
|
|
|
return m, nil |
|
|
|
|
|
} |
|
|
|
|
|
func (u UserCertificateDb) GetUserCertificateById(id string) (m *model.UserCertificate, err error) { |
|
|
|
|
|
m = new(model.UserCertificate) |
|
|
|
|
|
has, err := u.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 |
|
|
|
|
|
} |