feat 废弃jwt 、 学识分

This commit is contained in:
2026-02-06 22:31:31 +08:00
parent 36621140f8
commit 96f0919c05
8 changed files with 84 additions and 39 deletions

View File

@@ -45,8 +45,9 @@ func (d *PointCardDao) IncrPointCard(usn int64, point int64) error {
return nil
}
func (d *PointCardDao) FindByUserSn(usn int64) (*model.PointCard, error) {
func (d *PointCardDao) FindPointByUserSn(usn int64) (*model.PointCard, error) {
return d.query.PointCard.WithContext(d.ctx).
Select(d.query.PointCard.Point).
Where(d.query.PointCard.UserSn.Eq(usn)).
First()
}

View File

@@ -35,7 +35,7 @@ func (d *PointRecordsDao) CreateAndIncrPointCard(pointRecord *model.PointRecord)
}
pcd := NewPointCardDao(d.ctx, tx)
if _, err := pcd.FindByUserSn(pointRecord.UserSn); err != nil {
if _, err := pcd.FindPointByUserSn(pointRecord.UserSn); err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
_, err = pcd.Create(&model.PointCard{
UserSn: pointRecord.UserSn,
@@ -56,3 +56,20 @@ func (d *PointRecordsDao) CreateAndIncrPointCard(pointRecord *model.PointRecord)
return nil
})
}
func (d *PointRecordsDao) FindByUSN(usn int64, page, pageSize int) ([]*model.PointRecord, int64, error) {
result := make([]*model.PointRecord, 0)
count, err := d.query.PointRecord.WithContext(d.ctx).
Select(
d.query.PointRecord.Source,
d.query.PointRecord.Point,
d.query.PointRecord.CreatedAt,
).
Where(d.query.PointRecord.UserSn.Eq(usn)).
Order(d.query.PointRecord.CreatedAt.Desc()).
ScanByPage(&result, (page-1)*pageSize, pageSize)
if err != nil {
return nil, 0, err
}
return result, count, nil
}