rent_computer_log.go 1.0 KB

1234567891011121314151617181920212223242526272829
  1. package rentComputer
  2. import (
  3. "log-server/global"
  4. "log-server/model/rentComputer"
  5. )
  6. type ServiceRentComputerLog struct {
  7. }
  8. func (s *ServiceRentComputerLog) AddRentComputerLog(log rentComputer.RentComputerLog) (err error) {
  9. //if !errors.Is(global.GVA_DB.Where("pc_num = ? and shop_id = ?", log.PcNum, log.ShopId).First(&rentComputer.RentComputer{}).Error, gorm.ErrRecordNotFound) {
  10. // return errors.New("租机编号已存在")
  11. //}
  12. global.GVA_LOG.Info("log>>>" + log.Log)
  13. return global.GVA_DB.Create(&log).Error
  14. }
  15. // QueryRentComputerLogByPcNum 查询日志
  16. func (s *ServiceRentComputerLog) QueryRentComputerLogByPcNum(log rentComputer.RentComputerLog) (list interface{}, err error) {
  17. //global.GVA_LOG.Info(log.PcNum)
  18. //global.GVA_LOG.Info(strconv.Itoa(int(log.ShopId)))
  19. var logList []rentComputer.RentComputerLog
  20. db := global.GVA_DB.Model(&rentComputer.RentComputerLog{})
  21. db.Where("pc_num = ? and shop_id = ?", log.PcNum, log.ShopId)
  22. err = db.Order("create_time desc").Find(&logList).Error
  23. return logList, err
  24. }