Commit 36497b1f by keith

删除concat引发空指针问题

parent 5fb8f530
......@@ -61,10 +61,10 @@ func (c *ContactController) Delete() {
auth := c.GetAdminAuthInfo()
// delete
rows, err := c.ContactRepository.Delete(id, auth.UID)
rows := c.ContactRepository.Delete(id, auth.UID)
if err != nil || rows == 0 {
c.JSON(configs.ResponseFail, "删除失败!", err.Error())
if rows == 0 {
c.JSON(configs.ResponseFail, "删除失败!", nil)
}
c.JSON(configs.ResponseSucess, "删除成功!", rows)
......
......@@ -14,7 +14,7 @@ type ContactRepositoryInterface interface {
GetContacts(uid int64) ([]models.ContactDto, error)
UpdateIsSessionEnd(uid int64) (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)
Add(contact *models.Contact) (int64, error)
GetContactWithIds(ids ...int64) (*models.Contact, error)
......@@ -112,13 +112,14 @@ func (r *ContactRepository) GetContacts(uid int64) ([]models.ContactDto, error)
}
// 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()
rows, _ := res.RowsAffected()
if err != nil {
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