Commit 36497b1f by keith

删除concat引发空指针问题

parent 5fb8f530
...@@ -61,10 +61,10 @@ func (c *ContactController) Delete() { ...@@ -61,10 +61,10 @@ func (c *ContactController) Delete() {
auth := c.GetAdminAuthInfo() auth := c.GetAdminAuthInfo()
// delete // delete
rows, err := c.ContactRepository.Delete(id, auth.UID) rows := c.ContactRepository.Delete(id, auth.UID)
if err != nil || rows == 0 { if rows == 0 {
c.JSON(configs.ResponseFail, "删除失败!", err.Error()) c.JSON(configs.ResponseFail, "删除失败!", nil)
} }
c.JSON(configs.ResponseSucess, "删除成功!", rows) c.JSON(configs.ResponseSucess, "删除成功!", rows)
......
...@@ -14,7 +14,7 @@ type ContactRepositoryInterface interface { ...@@ -14,7 +14,7 @@ type ContactRepositoryInterface interface {
GetContacts(uid int64) ([]models.ContactDto, error) GetContacts(uid int64) ([]models.ContactDto, error)
UpdateIsSessionEnd(uid int64) (int64, error) UpdateIsSessionEnd(uid int64) (int64, error)
Update(id int64, params *orm.Params) (int64, error) Update(id int64, params *orm.Params) (int64, error)
Delete(id int64, uid int64) (int64, error) Delete(id int64, uid int64) int64
DeleteAll(uid int64) (int64, error) DeleteAll(uid int64) (int64, error)
Add(contact *models.Contact) (int64, error) Add(contact *models.Contact) (int64, error)
GetContactWithIds(ids ...int64) (*models.Contact, error) GetContactWithIds(ids ...int64) (*models.Contact, error)
...@@ -112,13 +112,14 @@ func (r *ContactRepository) GetContacts(uid int64) ([]models.ContactDto, error) ...@@ -112,13 +112,14 @@ func (r *ContactRepository) GetContacts(uid int64) ([]models.ContactDto, error)
} }
// Delete delete a Contact // Delete delete a Contact
func (r *ContactRepository) Delete(id int64, uid int64) (int64, error) { func (r *ContactRepository) Delete(id int64, uid int64) int64 {
res, err := r.o.Raw("UPDATE `contact` SET `delete` = 1 WHERE id = ? AND to_account = ?", id, uid).Exec() res, err := r.o.Raw("UPDATE `contact` SET `delete` = 1 WHERE id = ? AND to_account = ?", id, uid).Exec()
rows, _ := res.RowsAffected()
if err != nil { if err != nil {
logs.Warn("GetContacts get Contacts err------------", err) logs.Warn("GetContacts get Contacts err------------", err)
return 0
} }
return rows, err rows, _ := res.RowsAffected()
return rows
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment