2 Star 0 Fork 0

TeamsHub/backend-gopkg

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
domain
infrastructure
config
connector
pkg
aes
aria2
auth
authn
balancer
browser
cache
cluster
code
color
conf
crontab
database
ddm
email
env
errno
errors
file
filesystem
gin
grpclient
hash
hashid
hcode
httpclient
ifc
img
jwt
koala
live
log
mail
md5
mocks
models
scripts
defaults.go
download.go
download_test.go
file.go
folder.go
folder_test.go
group.go
group_test.go
init.go
migration.go
migration_test.go
node.go
node_test.go
order.go
policy.go
policy_test.go
redeem.go
report.go
setting.go
setting_test.go
share.go
share_test.go
storage_pack.go
storage_pack_test.go
tag.go
tag_test.go
task.go
task_test.go
teamsFile.go
user.go
user_authn.go
user_authn_test.go
webdav.go
webdav_test.go
mongo
mq
notify
ocr
opensearch_industry
oss
pdf2imag
recaptcha
request
rsa
serializer
shutdown
signature
slsLog
sms
task
thumb
time_parse
token
tool
toolfunc
trace
urltable
util
validator
webdav
wxwork
xml
filesystem.zip
third/gismag
.gitignore
LICENSE
Makefile
README.en.md
README.md
go.mod
go.sum
plugin.go
zoneinfo.zip
克隆/下载
tag.go 1.33 KB
一键复制 编辑 原始数据 按行查看 历史
wuzheng0709 提交于 6个月前 . fix mod
package model
import (
"gitee.com/wuzheng0709/backend-gopkg/infrastructure/pkg/util"
"gorm.io/gorm"
)
// Tag 用户自定义标签
type Tag struct {
gorm.Model
Name string // 标签名
Icon string // 图标标识
Color string // 图标颜色
Type int // 标签类型(文件分类/目录直达)
Expression string `gorm:"type:text"` // 搜索表表达式/直达路径
UserID uint // 创建者ID
}
const (
// FileTagType 文件分类标签
FileTagType = iota
// DirectoryLinkType 目录快捷方式标签
DirectoryLinkType
)
// Create 创建标签记录
func (tag *Tag) Create() (uint, error) {
if err := DB.Create(tag).Error; err != nil {
util.Log().Warning("无法插入离线下载记录, %s", err)
return 0, err
}
return tag.ID, nil
}
// DeleteTagByID 根据给定ID和用户ID删除标签
func DeleteTagByID(id, uid uint) error {
result := DB.Where("id = ? and user_id = ?", id, uid).Delete(&Tag{})
return result.Error
}
// GetTagsByUID 根据用户ID查找标签
func GetTagsByUID(uid uint) ([]Tag, error) {
var tag []Tag
result := DB.Where("user_id = ?", uid).Find(&tag)
return tag, result.Error
}
// GetTagsByID 根据ID查找标签
func GetTagsByID(id, uid uint) (*Tag, error) {
var tag Tag
result := DB.Where("user_id = ? and id = ?", uid, id).First(&tag)
return &tag, result.Error
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wuzheng0709/backend-gopkg.git
git@gitee.com:wuzheng0709/backend-gopkg.git
wuzheng0709
backend-gopkg
backend-gopkg
v1.6.18

搜索帮助