service.xpcool.com/internal/dao/internal/user_favorite.go
夏犀麟 4aca0c7f6f
Some checks failed
Build and Deploy (service.xpcool.com) / build-and-deploy (push) Failing after 5m7s
feat(house): 实现看房模块后端功能
- 新增 9 张房屋相关数据表(社区/楼宇/房源/价格快照/交易/设施/社区设施/学区/偏好)
- 添加菜单权限种子数据并绑定超级管理员角色
- 生成 DAO 层代码和实体对象
- 实现房屋模块 API 接口(社区/房源/看板)和控制器服务层
- 支持多平台软关联匹配、笋盘标记和低可信度标记功能
- 更新超级管理员账号为 xxcool/xxCool@2026
- 调整 RBAC 菜单结构,移除管理员管理功能,新增日志管理菜单
- 修复 RBAC 安全漏洞,确保禁用角色权限失效
- 重构认证模块,将登录相关接口迁移到统一包结构下
- 移除废弃的管理模块和工具类接口定义
- 为通用工具包添加中文注释和文档说明
2026-08-26 23:42:38 +08:00

90 lines
2.7 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// ==========================================================================
// 本文件由 GoFrame CLI 工具生成并维护,请勿编辑。
// ==========================================================================
package internal
import (
"context"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
)
// UserFavoriteDao 是表 user_favorite 的数据访问对象。
type UserFavoriteDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns UserFavoriteColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// UserFavoriteColumns 定义并存储表 user_favorite 的列名。
type UserFavoriteColumns struct {
Id string //
UserId string //
ContentId string //
CreatedAt string //
UpdatedAt string //
DeletedAt string //
}
// userFavoriteColumns 保存表 user_favorite 的列信息。
var userFavoriteColumns = UserFavoriteColumns{
Id: "id",
UserId: "user_id",
ContentId: "content_id",
CreatedAt: "created_at",
UpdatedAt: "updated_at",
DeletedAt: "deleted_at",
}
// NewUserFavoriteDao 创建并返回一个新的表数据访问 DAO 对象。
func NewUserFavoriteDao(handlers ...gdb.ModelHandler) *UserFavoriteDao {
return &UserFavoriteDao{
group: "default",
table: "user_favorite",
columns: userFavoriteColumns,
handlers: handlers,
}
}
// DB 获取并返回当前 DAO 的底层原始数据库管理对象。
func (dao *UserFavoriteDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table 返回当前 DAO 的表名。
func (dao *UserFavoriteDao) Table() string {
return dao.table
}
// Columns 返回当前 DAO 的全部列名。
func (dao *UserFavoriteDao) Columns() UserFavoriteColumns {
return dao.columns
}
// Group 返回当前 DAO 的数据库配置组名。
func (dao *UserFavoriteDao) Group() string {
return dao.group
}
// Ctx 为当前 DAO 创建并返回一个 Model自动设置本次操作的上下文。
func (dao *UserFavoriteDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction 使用函数 f 包裹事务逻辑。
// 若 f 返回非 nil 错误,则回滚事务并返回该错误。
// 若 f 返回 nil则提交事务并返回 nil。
//
// 注意:请勿在函数 f 内提交或回滚事务,
// 该函数会自动处理。
func (dao *UserFavoriteDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}