package service import ( "AIT/common" "AIT/global" "AIT/models" ) type RecordService struct { } func (f *RecordService) CreateRecord(record models.Record) int64 { affected := global.Db.Create(&record).RowsAffected return affected } func (f *RecordService) UpdateRecordById(recordId string, recordResult string) models.Record { record := models.Record{ Id: recordId, Result: recordResult, UpdateTime: common.NowTime(), } global.Db.Model(&record).Updates(record) return record } func (f *RecordService) GetRecordList(param models.RecordListParam) ([]models.Record, int64) { query := models.Record{} if len(param.UserName) > 0 { query.UserName = param.UserName } page := models.Page{ PageNum: param.PageNum, PageSize: param.PageSize, } recordList := make([]models.Record, 0) rows := common.RestPage(page, "record", query, " create_time desc", &recordList, &[]models.User{}) return recordList, rows } func (f *RecordService) FindById(recordId string) (models.Record, int64) { var record models.Record count := global.Db.Where("id = ?", recordId).First(&record).RowsAffected return record, count }