123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- package dao
- import (
- "gorm.io/gorm"
- "youngee_b_api/app/entity"
- )
- type InvoiceInfoDao struct{}
- func (d InvoiceInfoDao) Select(invoiceId int64) (*entity.InvoiceInfo, error) {
- var invoiceInfo entity.InvoiceInfo
- err := Db.Debug().Model(&entity.InvoiceInfo{}).Where("invoice_id = ?", invoiceId).Find(&invoiceInfo).Error
- if err != nil {
- if err == gorm.ErrRecordNotFound {
- return &invoiceInfo, nil
- }
- return nil, err
- }
- return &invoiceInfo, nil
- }
- func (d InvoiceInfoDao) Delete(invoiceInfo entity.InvoiceInfo) error {
- err := Db.Where(invoiceInfo).Delete(&entity.InvoiceInfo{}).Error
- if err != nil {
- return err
- }
- return nil
- }
- func (d InvoiceInfoDao) SelectDefault(enterpriseId string, invoiceType int64) (*entity.InvoiceInfo, error) {
- var invoiceInfo entity.InvoiceInfo
- err := Db.Debug().Model(&entity.InvoiceInfo{}).Where("enterprise_id = ? AND invoice_type = ?", enterpriseId, invoiceType).Find(&invoiceInfo).Error
- if err != nil {
- if err == gorm.ErrRecordNotFound {
- return &invoiceInfo, nil
- }
- return nil, err
- }
- return &invoiceInfo, nil
- }
- func (d InvoiceInfoDao) Insert(invoiceInfo *entity.InvoiceInfo) error {
- err := Db.Debug().Model(&entity.InvoiceInfo{}).Create(invoiceInfo).Error
- if err != nil {
- return err
- }
- return nil
- }
|