|
@@ -1,6 +1,8 @@
|
|
|
package financial_analyst
|
|
|
|
|
|
import (
|
|
|
+ "errors"
|
|
|
+ logger "eta/eta_mini_ht_api/common/component/log"
|
|
|
"eta/eta_mini_ht_api/models"
|
|
|
"gorm.io/gorm"
|
|
|
"gorm.io/gorm/clause"
|
|
@@ -59,15 +61,24 @@ func GetAnalystByName(name string) (analyst CrmFinancialAnalyst, err error) {
|
|
|
|
|
|
func GetCount() (total int64) {
|
|
|
db := models.Main()
|
|
|
- err := db.Model(&CrmFinancialAnalyst{}).Select("count(*) count").Scan(&total).Error
|
|
|
+ err := db.Model(&CrmFinancialAnalyst{}).Select("count(*) count").Scan(&total).Order("id asc").Error
|
|
|
if err != nil {
|
|
|
return 0
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-func GetAnalystList(offset int, limit int) (analysts []CrmFinancialAnalyst, err error) {
|
|
|
+func GetAnalystList(latestId int64, offset int, limit int) (analysts []CrmFinancialAnalyst, err error) {
|
|
|
+ if latestId < 0 {
|
|
|
+ err = errors.New("非法的id参数")
|
|
|
+ logger.Error("非法的id参数:%d", latestId)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if limit <= 0 {
|
|
|
+ err = errors.New("非法的limit参数")
|
|
|
+ logger.Error("非法的limit参数:%d", limit)
|
|
|
+ }
|
|
|
db := models.Main()
|
|
|
- err = db.Select(columns).Offset(offset).Limit(limit).Find(&analysts).Order("create_time desc").Error
|
|
|
+ err = db.Select(columns).Where(" id<= ? ", latestId).Offset(offset).Limit(limit).Find(&analysts).Order("create_time desc").Error
|
|
|
return
|
|
|
}
|