debug done.

This commit is contained in:
Sense T 2024-04-19 13:52:33 +08:00
parent 47335ca5e9
commit af9d966376
6 changed files with 16 additions and 14 deletions

2
TODO
View File

@ -2,7 +2,7 @@
- [x] Web UI - [x] Web UI
- [x] i18n - [x] i18n
- [x] modals - [x] modals
- [] debug - [x] debug
- [x] swagger - [x] swagger
- [] comments - [] comments
- [] Nix Module - [] Nix Module

View File

@ -138,7 +138,7 @@ func DeleteDomain(id string) error {
return err return err
} }
if err := (recordsDAO{}).Delete(tx, &models.Record[models.RecordContentDefault]{Zone: domain.WithDotEnd()}); err != nil { if err := (recordsDAO{}).Delete(tx, &models.Record[models.RecordContentDefault]{}, &models.Record[models.RecordContentDefault]{Zone: domain.WithDotEnd()}); err != nil {
tx.Rollback() tx.Rollback()
return err return err
} }

View File

@ -90,8 +90,13 @@ func (b BaseDAO[T]) UpdateOrCreate(db *gorm.DB, e T, cond ...T) (T, error) {
return e, err return e, err
} }
func (BaseDAO[T]) Delete(db *gorm.DB, e T) error { func (BaseDAO[T]) Delete(db *gorm.DB, e T, cond ...T) error {
if err := db.Delete(e).Error; err != nil { tx := db
for _, c := range cond {
tx = tx.Where(c)
}
if err := tx.Delete(e).Error; err != nil {
return err return err
} }
return nil return nil

View File

@ -59,7 +59,7 @@ type CNAMERecord struct {
} }
func (r CNAMERecord) Validate() error { func (r CNAMERecord) Validate() error {
if strings.HasSuffix(r.Host, ".") { if !strings.HasSuffix(r.Host, ".") {
return ErrNoDotSuffix return ErrNoDotSuffix
} }
return nil return nil
@ -70,7 +70,7 @@ type NSRecord struct {
} }
func (r NSRecord) Validate() error { func (r NSRecord) Validate() error {
if strings.HasSuffix(r.Host, ".") { if !strings.HasSuffix(r.Host, ".") {
return ErrNoDotSuffix return ErrNoDotSuffix
} }
return nil return nil
@ -81,7 +81,7 @@ type MXRecord struct {
} }
func (r MXRecord) Validate() error { func (r MXRecord) Validate() error {
if strings.HasSuffix(r.Host, ".") { if !strings.HasSuffix(r.Host, ".") {
return ErrNoDotSuffix return ErrNoDotSuffix
} }
return nil return nil
@ -92,7 +92,7 @@ type SRVRecord struct {
} }
func (r SRVRecord) Validate() error { func (r SRVRecord) Validate() error {
if strings.HasPrefix(r.Target, ".") { if !strings.HasPrefix(r.Target, ".") {
return ErrNoDotSuffix return ErrNoDotSuffix
} }
@ -104,11 +104,7 @@ type SOARecord struct {
} }
func (r SOARecord) Validate() error { func (r SOARecord) Validate() error {
if strings.HasPrefix(r.MBox, ".") { if !strings.HasSuffix(r.Ns, ".") {
return ErrNoDotSuffix
}
if strings.HasSuffix(r.Ns, ".") {
return ErrNoDotSuffix return ErrNoDotSuffix
} }

View File

@ -234,7 +234,7 @@ func updateRecord(c *gin.Context) {
} }
domain := c.Param("domain") domain := c.Param("domain")
if domain != record.Zone { if domain != record.WithOutDotTail() {
c.JSON(http.StatusBadRequest, Response{ c.JSON(http.StatusBadRequest, Response{
Succeed: false, Succeed: false,
Message: "request body doesn't match URI", Message: "request body doesn't match URI",

View File

@ -227,6 +227,7 @@ export default function RecordEditModal({ open, record, onOk, onCancel, editReco
validateTrigger='onBlur' validateTrigger='onBlur'
> >
<Form.Item<Record> hidden name='id' /> <Form.Item<Record> hidden name='id' />
<Form.Item<Record> hidden name='zone' />
<Form.Item<Record> label={t('records.recordType')} required name='record_type'> <Form.Item<Record> label={t('records.recordType')} required name='record_type'>
<Select allowClear={false} options={recordTypeOptions} /> <Select allowClear={false} options={recordTypeOptions} />
</Form.Item> </Form.Item>