Ai
3 Star 2 Fork 1

fotomxq/weeekj_core

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
content_delete.go 1.82 KB
一键复制 编辑 原始数据 按行查看 历史
fotomxq 提交于 2025-02-05 18:52 +08:00 . 修改项目路径;
package BlogCore
import (
CoreNats "gitee.com/fotomxq/weeekj_core/v5/core/nats"
CoreSQL "gitee.com/fotomxq/weeekj_core/v5/core/sql"
Router2SystemConfig "gitee.com/fotomxq/weeekj_core/v5/router2/system_config"
)
// ArgsDeleteContent 删除词条参数
type ArgsDeleteContent struct {
//ID
ID int64 `db:"id" json:"id" check:"id"`
//组织ID
OrgID int64 `db:"org_id" json:"orgID" check:"id" empty:"true"`
//用户ID
// 文章可以是由用户发出,组织ID可以为0
UserID int64 `db:"user_id" json:"userID" check:"id" empty:"true"`
//成员ID
BindID int64 `db:"bind_id" json:"bindID" check:"id" empty:"true"`
}
// DeleteContent 删除词条
func DeleteContent(args *ArgsDeleteContent) (err error) {
_, err = CoreSQL.DeleteAllSoft(Router2SystemConfig.MainDB.DB, "blog_core_content", "id = :id AND (org_id = :org_id OR :org_id < 1) AND (:user_id < 1 OR user_id = :user_id) AND (:bind_id < 1 OR bind_id = :bind_id)", args)
if err != nil {
return
}
deleteContentCacheByID(args.ID)
CoreNats.PushDataNoErr("blog_core_delete", "/blog/core/delete", "", args.ID, "", nil)
return
}
// ArgsReturnContent 还原内容参数
type ArgsReturnContent struct {
//ID
ID int64 `db:"id" json:"id" check:"id"`
//组织ID
OrgID int64 `db:"org_id" json:"orgID" check:"id" empty:"true"`
//用户ID
// 文章可以是由用户发出,组织ID可以为0
UserID int64 `db:"user_id" json:"userID" check:"id" empty:"true"`
}
// ReturnContent 还原内容
func ReturnContent(args *ArgsReturnContent) (err error) {
_, err = CoreSQL.UpdateOne(Router2SystemConfig.MainDB.DB, "UPDATE blog_core_content SET delete_at = TO_TIMESTAMP(0), audit_at = TO_TIMESTAMP(0), publish_at = TO_TIMESTAMP(0) WHERE id = :id AND (org_id = :org_id OR :org_id < 1) AND (:user_id < 1 OR user_id = :user_id)", args)
if err != nil {
return
}
deleteContentCacheByID(args.ID)
return
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/fotomxq/weeekj_core.git
git@gitee.com:fotomxq/weeekj_core.git
fotomxq
weeekj_core
weeekj_core
v5.3.96

搜索帮助