feat(house): 实现看房模块后端功能
Some checks failed
Build and Deploy (service.xpcool.com) / build-and-deploy (push) Failing after 5m7s

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

View File

@ -0,0 +1,78 @@
# service.xpcool.com 自动部署Gitea act_runnerpush main/dev 触发
# 注意点与前端差异
# 1. 后端不是拷贝静态文件而是 Go 交叉编译 + Docker 镜像重建容器runner 已挂载 docker.sock
# 2. job 基础镜像 node:20-bullseye Go需下载 Go 1.23 工具链npmmirror GOPROXY goproxy.cn
# 3. 容器 env 通过 Gitea Actions secrets 注入DB_DSN 必须带 mysql: 类型前缀勿写死在仓库
# 4. 数据库结构变更请手动执行 manifest/sql/ 下脚本003004004b007workflow 不做自动 DDL
name: Build and Deploy (service.xpcool.com)
on:
push:
branches: [main, dev]
workflow_dispatch:
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Install git & download Go toolchain
run: |
set -e
apt-get update -qq
apt-get install -y -qq git >/dev/null
curl -fsSL https://npmmirror.com/mirrors/golang/go1.23.12.linux-amd64.tar.gz -o /tmp/go.tar.gz
mkdir -p /usr/local && tar -C /usr/local -xzf /tmp/go.tar.gz
export PATH="/usr/local/go/bin:$PATH"
echo "/usr/local/go/bin" >> "$GITHUB_ENV"
go version
- name: Checkout (local Gitea)
run: |
git clone --depth 1 --branch "${{ github.ref_name }}" https://oauth2:${{ github.token }}@git.xpcool.com/${{ github.repository }}.git .
git checkout ${{ github.sha }}
- name: Cross compile (linux/amd64, CGO disabled)
env:
GOPROXY: https://goproxy.cn,direct
GOFLAGS: -mod=mod
run: |
export PATH="/usr/local/go/bin:$PATH"
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /tmp/deploy/main main.go
ls -lh /tmp/deploy/main
- name: Assemble deploy dir (binary + config + resource + Dockerfile)
run: |
set -e
mkdir -p /tmp/deploy/manifest/config /tmp/deploy/resource
# 配置基础 config.yaml + 环境化 config.prod.yamlGF_GCFG_ENV=prod 时生效
cp manifest/config/config.prod.yaml /tmp/deploy/manifest/config/config.prod.yaml
cp manifest/config/config.prod.yaml /tmp/deploy/manifest/config/config.yaml
# 静态资源GoFrame public/template
cp -r resource/public /tmp/deploy/resource/public
mkdir -p /tmp/deploy/resource/template
# 容器 Dockerfile仓库内维护 deploy/Dockerfile避免 workflow heredoc 缩进问题
cp deploy/Dockerfile /tmp/deploy/Dockerfile
echo "assemble done"
- name: Build image & restart container
env:
DB_DSN: ${{ secrets.DB_DSN }}
JWT_SECRET: ${{ secrets.JWT_SECRET }}
run: |
set -e
cd /tmp/deploy
docker build -t service.xpcool.com:latest .
docker rm -f service.xpcool.com >/dev/null 2>&1 || true
docker run -d --name service.xpcool.com \
--network xpcool-net \
-p 127.0.0.1:10100:10100 \
-e GF_GCFG_ENV=prod \
-e "DB_DSN=$DB_DSN" \
-e "JWT_SECRET=$JWT_SECRET" \
--restart unless-stopped \
service.xpcool.com:latest
# 冒烟等待启动并验证 OpenAPI
sleep 5
curl -fsS -m 10 http://127.0.0.1:10100/api.json | head -c 120 || { echo "SMOKE TEST FAILED"; exit 1; }
echo
echo "Deployed service.xpcool.com (container restarted, 127.0.0.1:10100)"

3
.gitignore vendored
View File

@ -28,3 +28,6 @@ log/
# 本地环境变量含数据库口令禁止提交 # 本地环境变量含数据库口令禁止提交
.env* .env*
# GoLand 项目级运行配置含数据库口令禁止提交
.run/

View File

@ -1,6 +1,10 @@
# service.xpcool.com 变更记录 # service.xpcool.com 变更记录
> 倒序最新在上格式YYYY-MM-DD | 类型 | 摘要 > 倒序最新在上格式YYYY-MM-DD | 类型 | 摘要
2026-08-26 | CFG | 新增 Gitea act_runner 自动部署.gitea/workflows/deploy.ymlpush main/dev 下载 Go1.23 工具链 npmmirror + GOPROXY goproxy.cn CGO=0 linux/amd64 交叉编译 组装 main+manifest/config(config.yaml+config.prod.yaml)+resource+deploy/Dockerfile docker build 重建容器 127.0.0.1:10100xpcool-netGF_GCFG_ENV=prodDB_DSN/JWT_SECRET Gitea Actions secrets curl /api.json 冒烟deploy/Dockerfile 仓库内维护DB 结构变更不自动 DDL需手动导 manifest/sql
2026-08-26 | FIX | 本地登录 no rows 修复根因=本地库 service_xpcool_com admin_user 空表本地/服务器库两套此前仅改服务器 super_admin 角色 + 导入 009_admin_account_v2.sql --default-character-set=utf8mb4 否则中文 Data too long 本地 xxcool/xxCool@2026 登录成功subject=3同时服务器废弃 webhook 方案已删除deploy-webhook.service/webhook.py/secrets.env/deploy.sh自动部署改走 Gitea act_runner + .gitea/workflows仓库内尚未配置待补
2026-08-26 | CHG | 看房 house 模块后端落地010_house_tables.sql 9 community/building/listing/price_snapshot/transaction/facility/community_facility/school_district/preference+ 011_house_menu.sql 菜单/权限种子超管 role_id=1 绑定gf gen dao 生成 dao/entity/do实现 api/house/{community,listing,dashboard} + controller/house + service/house管理 CRUD + 看板聚合 POST 动作式前缀 /api/service/admin/house含多平台软关联 match_group_id笋盘/低可信标记cmd.go 注册 housectl + 3 RegisterServicego build 通过gf CLI com.lib.gf.v2 分支gen dao 产物 import sed github.com/gogf/gf/v218 文件mysql 客户端须 --default-character-set=utf8mb4 否则中文 COMMENT/INSERT 乱码TINYINT 字段 comment 0/1 gf 映射 boolstatus 三值改 INThack/config.yaml link+tables 已指向本地库
2026-08-26 | CHG | 生产超级管理员账号替换删除 admin/admin123用户/绑定/refresh 会话全清新增 xxcool/xxCool@2026bcrypt $2b$10$绑定 super_admin脚本 manifest/sql/009_admin_account_v2.sql008 编号已被 008_menu_rbac_v4.sql 占用004_seed.sql 种子账号同步改 xxcool登录验证xxcool 成功admin no rows预期 线上前端仍是旧版默认 admin/admin123需部署新版 dist xxcool 才可正常登录
2026-08-26 | CHG | RBAC 菜单调整移除管理员管理id=2 及按钮 21-25 软删+解绑新增日志管理菜单id=7, system:log, component=system/log/index原按钮 63system:log:list挂到 id=7 超管绑定新菜单幂等脚本 manifest/sql/008_menu_rbac_v4.sql 2026-08-26 | CHG | RBAC 菜单调整移除管理员管理id=2 及按钮 21-25 软删+解绑新增日志管理菜单id=7, system:log, component=system/log/index原按钮 63system:log:list挂到 id=7 超管绑定新菜单幂等脚本 manifest/sql/008_menu_rbac_v4.sql
2026-08-26 | FIX | RBAC 安全漏洞修复禁用角色status=0绑定的权限仍生效根因为 Codes/HasPermission/Routes 三处联表查询未过滤 admin_role 启用状态 roleCodes 过滤修复三处统一 LeftJoin admin_role 并加 r.status=1opuser 联调验证 codes /routes /接口 403admin 全链路回归通过 2026-08-26 | FIX | RBAC 安全漏洞修复禁用角色status=0绑定的权限仍生效根因为 Codes/HasPermission/Routes 三处联表查询未过滤 admin_role 启用状态 roleCodes 过滤修复三处统一 LeftJoin admin_role 并加 r.status=1opuser 联调验证 codes /routes /接口 403admin 全链路回归通过

View File

@ -20,3 +20,9 @@ The command is intentionally the only source of `internal/dao`, `internal/model/
- `/admin/v1/*`: admin API. Protected endpoints require both an admin access token and an `X-Permission` identifier. - `/admin/v1/*`: admin API. Protected endpoints require both an admin access token and an `X-Permission` identifier.
Use `GF_GCFG_FILE=config.dev.yaml` (or `config.test.yaml` / `config.prod.yaml`) and set `DB_DSN` plus a strong `JWT_SECRET` before startup. Use `GF_GCFG_FILE=config.dev.yaml` (or `config.test.yaml` / `config.prod.yaml`) and set `DB_DSN` plus a strong `JWT_SECRET` before startup.
## Local startup
- **Terminal**: `source .env.dev && go run main.go` (`.env.dev` is gitignored, holds local DSN + secret).
- **GoLand**: run configuration `.run/service-dev.run.xml` (project-level, auto-detected after reloading the project) already injects `GF_GCFG_FILE` / `DB_DSN` / `JWT_SECRET`; pick it in the run dropdown. The file is gitignored because it contains the DB password.

View File

@ -1 +1,59 @@
package login // Package admin_admin_login 定义管理端认证接口(登录/资料/权限码/刷新/登出),路由前缀 /admin。
package admin_admin_login
import "github.com/gogf/gf/v2/frame/g"
// LoginReq 管理员登录请求。
type LoginReq struct {
g.Meta `path:"/system/auth/login" method:"post" tags:"Admin/System/Auth" summary:"管理员登录"`
Username string `json:"username" v:"required"`
Password string `json:"password" v:"required"`
}
// LoginRes 管理员登录响应(令牌对 + 管理员 ID
type LoginRes struct {
AccessToken string `json:"accessToken"`
RefreshToken string `json:"refreshToken"`
ExpiresIn int64 `json:"expiresIn"`
AdminID uint64 `json:"adminId"`
}
// InfoReq 获取当前管理员资料(供 vben getUserInfo 使用)。
type InfoReq struct {
g.Meta `path:"/system/auth/info" method:"post" tags:"Admin/System/Auth" summary:"当前管理员资料"`
}
// InfoRes 是 InfoReq 的响应Roles 携带角色码供 vben 权限使用。
type InfoRes struct {
AdminID uint64 `json:"adminId"`
Username string `json:"username"`
Nickname string `json:"nickname"`
Roles []string `json:"roles"`
}
// CodesReq 获取当前管理员的按钮级权限码vben getAccessCodes后端鉴权模式
type CodesReq struct {
g.Meta `path:"/system/auth/codes" method:"post" tags:"Admin/System/Auth" summary:"当前管理员权限码"`
}
// CodesRes 是 CodesReq 的响应。
type CodesRes struct {
Codes []string `json:"codes"`
}
// RefreshReq 使用刷新令牌轮换管理员令牌对。
type RefreshReq struct {
g.Meta `path:"/system/auth/refresh" method:"post" tags:"Admin/System/Auth" summary:"轮换管理员令牌"`
RefreshToken string `json:"refreshToken" v:"required"`
}
// RefreshRes 是 RefreshReq 的响应。
type RefreshRes LoginRes
// LogoutReq 结束管理员会话。
type LogoutReq struct {
g.Meta `path:"/system/auth/logout" method:"post" tags:"Admin/System/Auth" summary:"管理员登出"`
}
// LogoutRes 是 LogoutReq 的响应。
type LogoutRes struct{}

View File

@ -0,0 +1,30 @@
// Package admin_system_login_log 定义管理员登录日志查询接口,路由前缀 /admin。
package admin_system_login_log
import "github.com/gogf/gf/v2/frame/g"
// LoginLogItem 一条管理员登录日志记录。
type LoginLogItem struct {
Id uint64 `json:"id"`
Username string `json:"username"`
IP string `json:"ip"`
UserAgent string `json:"userAgent"`
Status int `json:"status"` // 1 成功, 0 失败
FailReason string `json:"failReason"`
CreatedAt string `json:"createdAt"`
}
// LoginLogListReq 分页查询管理员登录日志。
type LoginLogListReq struct {
g.Meta `path:"/system/login-log" method:"post" tags:"Admin/System/LoginLog" summary:"登录日志列表"`
Page int `json:"page" d:"1" v:"min:1"`
Size int `json:"size" d:"10" v:"min:1|max:100"`
Username string `json:"username"` // 按账号过滤
Status *int `json:"status"` // 按结果过滤1 成功 0 失败,不传为全部
}
// LoginLogListRes 是 LoginLogListReq 的响应。
type LoginLogListRes struct {
List []*LoginLogItem `json:"list"`
Total int `json:"total"`
}

View File

@ -1,74 +0,0 @@
// Package admin 定义后台管理接口(管理员账号管理),路由前缀 /admin/v1/admin/admin。
package admin
import "github.com/gogf/gf/v2/frame/g"
// AdminItem is one row of the admin list.
type AdminItem struct {
Id uint64 `json:"id"`
Username string `json:"username"`
Nickname string `json:"nickname"`
Status int `json:"status"`
RoleIds []uint64 `json:"roleIds"`
RoleNames []string `json:"roleNames"`
CreatedAt string `json:"createdAt"`
}
// AdminListReq pages the administrators.
type AdminListReq struct {
g.Meta `path:"/admin" method:"get" tags:"Admin/Admin" summary:"Admin list"`
Page int `json:"page" d:"1" v:"min:1"`
Size int `json:"size" d:"10" v:"min:1|max:100"`
Keyword string `json:"keyword"` // matches username or nickname
}
// AdminListRes is the response of AdminListReq.
type AdminListRes struct {
List []*AdminItem `json:"list"`
Total int `json:"total"`
}
// AdminCreateReq creates an administrator.
type AdminCreateReq struct {
g.Meta `path:"/admin" method:"post" tags:"Admin/Admin" summary:"Create admin"`
Username string `json:"username" v:"required"`
Password string `json:"password" v:"required|min-length:6#password required|password too short"`
Nickname string `json:"nickname"`
RoleIds []uint64 `json:"roleIds"`
}
// AdminCreateRes is the response of AdminCreateReq.
type AdminCreateRes struct {
Id uint64 `json:"id"`
}
// AdminUpdateReq updates profile/status/roles of an administrator.
type AdminUpdateReq struct {
g.Meta `path:"/admin/{id}" method:"put" tags:"Admin/Admin" summary:"Update admin"`
Id uint64 `json:"id" in:"path" v:"required"`
Nickname string `json:"nickname"`
Status int `json:"status"`
RoleIds []uint64 `json:"roleIds"`
}
// AdminUpdateRes is the response of AdminUpdateReq.
type AdminUpdateRes struct{}
// AdminResetPwdReq resets an administrator's password.
type AdminResetPwdReq struct {
g.Meta `path:"/admin/{id}/password" method:"put" tags:"Admin/Admin" summary:"Reset admin password"`
Id uint64 `json:"id" in:"path" v:"required"`
Password string `json:"password" v:"required|min-length:6#password required|password too short"`
}
// AdminResetPwdRes is the response of AdminResetPwdReq.
type AdminResetPwdRes struct{}
// AdminDeleteReq deletes an administrator (soft delete).
type AdminDeleteReq struct {
g.Meta `path:"/admin/{id}" method:"delete" tags:"Admin/Admin" summary:"Delete admin"`
Id uint64 `json:"id" in:"path" v:"required"`
}
// AdminDeleteRes is the response of AdminDeleteReq.
type AdminDeleteRes struct{}

View File

@ -1,53 +0,0 @@
// Package auth 定义管理端认证接口(登录/资料/权限码/刷新/登出),路由前缀 /admin/v1/system/auth。
package auth
import "github.com/gogf/gf/v2/frame/g"
type LoginReq struct {
g.Meta `path:"/system/auth/login" method:"post" tags:"Admin/System/Auth" summary:"Administrator login"`
Username string `json:"username" v:"required"`
Password string `json:"password" v:"required"`
}
type LoginRes struct {
AccessToken string `json:"accessToken"`
RefreshToken string `json:"refreshToken"`
ExpiresIn int64 `json:"expiresIn"`
AdminID uint64 `json:"adminId"`
}
// InfoReq returns the current administrator profile (vben getUserInfo).
type InfoReq struct {
g.Meta `path:"/system/auth/info" method:"get" tags:"Admin/System/Auth" summary:"Current admin info"`
}
// InfoRes is the response of InfoReq. Roles carries role codes for vben authority.
type InfoRes struct {
AdminID uint64 `json:"adminId"`
Username string `json:"username"`
Nickname string `json:"nickname"`
Roles []string `json:"roles"`
}
// CodesReq returns the button-level permission codes of the current admin
// (vben getAccessCodes, backend access mode).
type CodesReq struct {
g.Meta `path:"/system/auth/codes" method:"get" tags:"Admin/System/Auth" summary:"Current admin access codes"`
}
// CodesRes is the response of CodesReq.
type CodesRes struct {
Codes []string `json:"codes"`
}
// RefreshReq rotates the administrator token pair using a refresh token.
type RefreshReq struct {
g.Meta `path:"/system/auth/refresh" method:"post" tags:"Admin/System/Auth" summary:"Rotate admin token"`
RefreshToken string `json:"refreshToken" v:"required"`
}
type RefreshRes LoginRes
// LogoutReq ends the administrator session.
type LogoutReq struct {
g.Meta `path:"/system/auth/logout" method:"post" tags:"Admin/System/Auth" summary:"Admin logout"`
}
type LogoutRes struct{}

View File

@ -1,33 +0,0 @@
package menu
import "github.com/gogf/gf/v2/frame/g"
// RouteMeta mirrors vben admin dynamic route metadata.
type RouteMeta struct {
Title string `json:"title"`
Icon string `json:"icon"`
Order int `json:"order"`
Authority []string `json:"authority,omitempty"` // role codes
HideInMenu bool `json:"hideInMenu,omitempty"`
KeepAlive bool `json:"keepAlive,omitempty"`
}
// RouteItem is one node of the vben route tree.
type RouteItem struct {
Name string `json:"name"`
Path string `json:"path"`
Component string `json:"component,omitempty"`
Meta RouteMeta `json:"meta"`
Children []*RouteItem `json:"children,omitempty"`
}
// MenuRoutesReq returns the current admin's menu tree as vben routes
// (backend access mode, login-only endpoint).
type MenuRoutesReq struct {
g.Meta `path:"/system/menu/routes" method:"get" tags:"Admin/System/Menu" summary:"Current admin menu routes"`
}
// MenuRoutesRes is the response of MenuRoutesReq.
type MenuRoutesRes struct {
Routes []*RouteItem `json:"routes"`
}

View File

@ -1,77 +0,0 @@
package menu_manage
import "github.com/gogf/gf/v2/frame/g"
// MenuItem is one node of the full menu tree (type 1 menu / 2 button).
type MenuItem struct {
Id uint64 `json:"id"`
ParentId uint64 `json:"parentId"`
Name string `json:"name"`
Icon string `json:"icon"`
Type int `json:"type"` // 1 menu, 2 button/api
Path string `json:"path"`
Component string `json:"component"`
Permission string `json:"permission"`
Sort int `json:"sort"`
Status int `json:"status"`
Hidden bool `json:"hidden"`
Children []*MenuItem `json:"children,omitempty"`
}
// MenuTreeReq returns the full menu tree for management.
type MenuTreeReq struct {
g.Meta `path:"/system/menu/tree" method:"get" tags:"Admin/System/Menu" summary:"Full menu tree"`
}
// MenuTreeRes is the response of MenuTreeReq.
type MenuTreeRes struct {
Tree []*MenuItem `json:"tree"`
}
// MenuCreateReq creates a menu or button node.
type MenuCreateReq struct {
g.Meta `path:"/system/menu" method:"post" tags:"Admin/System/Menu" summary:"Create menu"`
ParentId uint64 `json:"parentId"`
Name string `json:"name" v:"required"`
Icon string `json:"icon"`
Type int `json:"type" v:"in:1,2#type must be 1 or 2"`
Path string `json:"path"`
Component string `json:"component"`
Permission string `json:"permission" v:"required"`
Sort int `json:"sort"`
Status int `json:"status"`
Hidden bool `json:"hidden"`
}
// MenuCreateRes is the response of MenuCreateReq.
type MenuCreateRes struct {
Id uint64 `json:"id"`
}
// MenuUpdateReq updates a menu or button node.
type MenuUpdateReq struct {
g.Meta `path:"/system/menu/{id}" method:"put" tags:"Admin/System/Menu" summary:"Update menu"`
Id uint64 `json:"id" in:"path" v:"required"`
ParentId uint64 `json:"parentId"`
Name string `json:"name" v:"required"`
Icon string `json:"icon"`
Type int `json:"type" v:"in:1,2#type must be 1 or 2"`
Path string `json:"path"`
Component string `json:"component"`
Permission string `json:"permission" v:"required"`
Sort int `json:"sort"`
Status int `json:"status"`
Hidden bool `json:"hidden"`
}
// MenuUpdateRes is the response of MenuUpdateReq.
type MenuUpdateRes struct{}
// MenuDeleteReq deletes a menu node (soft delete).
type MenuDeleteReq struct {
g.Meta `path:"/system/menu/{id}" method:"delete" tags:"Admin/System/Menu" summary:"Delete menu"`
Id uint64 `json:"id" in:"path" v:"required"`
}
// MenuDeleteRes is the response of MenuDeleteReq.
type MenuDeleteRes struct{}

View File

@ -1,62 +0,0 @@
package role
import "github.com/gogf/gf/v2/frame/g"
// RoleItem is one row of the role list.
type RoleItem struct {
Id uint64 `json:"id"`
Code string `json:"code"`
Name string `json:"name"`
Status int `json:"status"`
MenuIds []uint64 `json:"menuIds"` // bound menu ids (for editing)
CreatedAt string `json:"createdAt"`
}
// RoleListReq pages the roles.
type RoleListReq struct {
g.Meta `path:"/system/role" method:"get" tags:"Admin/System/Role" summary:"Role list"`
Page int `json:"page" d:"1" v:"min:1"`
Size int `json:"size" d:"10" v:"min:1|max:100"`
Keyword string `json:"keyword"` // matches code or name
}
// RoleListRes is the response of RoleListReq.
type RoleListRes struct {
List []*RoleItem `json:"list"`
Total int `json:"total"`
}
// RoleCreateReq creates a role and binds menu ids.
type RoleCreateReq struct {
g.Meta `path:"/system/role" method:"post" tags:"Admin/System/Role" summary:"Create role"`
Code string `json:"code" v:"required"`
Name string `json:"name" v:"required"`
Status int `json:"status"`
MenuIds []uint64 `json:"menuIds"`
}
// RoleCreateRes is the response of RoleCreateReq.
type RoleCreateRes struct {
Id uint64 `json:"id"`
}
// RoleUpdateReq updates a role and rebinds menu ids.
type RoleUpdateReq struct {
g.Meta `path:"/system/role/{id}" method:"put" tags:"Admin/System/Role" summary:"Update role"`
Id uint64 `json:"id" in:"path" v:"required"`
Name string `json:"name" v:"required"`
Status int `json:"status"`
MenuIds []uint64 `json:"menuIds"`
}
// RoleUpdateRes is the response of RoleUpdateReq.
type RoleUpdateRes struct{}
// RoleDeleteReq deletes a role (soft delete).
type RoleDeleteReq struct {
g.Meta `path:"/system/role/{id}" method:"delete" tags:"Admin/System/Role" summary:"Delete role"`
Id uint64 `json:"id" in:"path" v:"required"`
}
// RoleDeleteRes is the response of RoleDeleteReq.
type RoleDeleteRes struct{}

View File

@ -1,15 +0,0 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package hello
import (
"context"
"service.xpcool.com/api/hello/v1"
)
type IHelloV1 interface {
Hello(ctx context.Context, req *v1.HelloReq) (res *v1.HelloRes, err error)
}

View File

@ -1,12 +0,0 @@
package v1
import (
"github.com/gogf/gf/v2/frame/g"
)
type HelloReq struct {
g.Meta `path:"/hello" tags:"Hello" method:"get" summary:"You first hello api"`
}
type HelloRes struct {
g.Meta `mime:"text/html" example:"string"`
}

View File

@ -0,0 +1,93 @@
// Package house_community 定义楼盘/小区管理接口,路由前缀 /house。
package house_community
import "github.com/gogf/gf/v2/frame/g"
// CommunityItem 小区列表中的一行。
type CommunityItem struct {
Id uint64 `json:"id"`
Name string `json:"name"`
Region string `json:"region"`
BusinessDistrict string `json:"businessDistrict"`
Address string `json:"address"`
Lng float64 `json:"lng"`
Lat float64 `json:"lat"`
BuildYear int `json:"buildYear"`
Households int `json:"households"`
PlotRatio float64 `json:"plotRatio"`
GreenRate float64 `json:"greenRate"`
PropertyCompany string `json:"propertyCompany"`
PropertyFee float64 `json:"propertyFee"`
Developer string `json:"developer"`
Source string `json:"source"`
}
// CommunityListReq 分页查询小区。
type CommunityListReq struct {
g.Meta `path:"/house/community/list" method:"post" tags:"Admin/House/Community" summary:"小区列表"`
Page int `json:"page" d:"1" v:"min:1"`
Size int `json:"size" d:"10" v:"min:1|max:100"`
Keyword string `json:"keyword"` // 匹配名称/地址
Region string `json:"region"`
}
// CommunityListRes 是 CommunityListReq 的响应。
type CommunityListRes struct {
List []*CommunityItem `json:"list"`
Total int `json:"total"`
}
// CommunityCreateReq 新增小区。
type CommunityCreateReq struct {
g.Meta `path:"/house/community/create" method:"post" tags:"Admin/House/Community" summary:"新增小区"`
Name string `json:"name" v:"required"`
Region string `json:"region"`
BusinessDistrict string `json:"businessDistrict"`
Address string `json:"address"`
Lng float64 `json:"lng"`
Lat float64 `json:"lat"`
BuildYear int `json:"buildYear"`
Households int `json:"households"`
PlotRatio float64 `json:"plotRatio"`
GreenRate float64 `json:"greenRate"`
PropertyCompany string `json:"propertyCompany"`
PropertyFee float64 `json:"propertyFee"`
Developer string `json:"developer"`
Source string `json:"source"`
}
// CommunityCreateRes 是 CommunityCreateReq 的响应。
type CommunityCreateRes struct {
Id uint64 `json:"id"`
}
// CommunityUpdateReq 更新小区。
type CommunityUpdateReq struct {
g.Meta `path:"/house/community/update/{id}" method:"post" tags:"Admin/House/Community" summary:"更新小区"`
Id uint64 `json:"id" in:"path" v:"required"`
Name string `json:"name" v:"required"`
Region string `json:"region"`
BusinessDistrict string `json:"businessDistrict"`
Address string `json:"address"`
Lng float64 `json:"lng"`
Lat float64 `json:"lat"`
BuildYear int `json:"buildYear"`
Households int `json:"households"`
PlotRatio float64 `json:"plotRatio"`
GreenRate float64 `json:"greenRate"`
PropertyCompany string `json:"propertyCompany"`
PropertyFee float64 `json:"propertyFee"`
Developer string `json:"developer"`
}
// CommunityUpdateRes 是 CommunityUpdateReq 的响应。
type CommunityUpdateRes struct{}
// CommunityDeleteReq 删除小区(软删除)。
type CommunityDeleteReq struct {
g.Meta `path:"/house/community/delete/{id}" method:"post" tags:"Admin/House/Community" summary:"删除小区"`
Id uint64 `json:"id" in:"path" v:"required"`
}
// CommunityDeleteRes 是 CommunityDeleteReq 的响应。
type CommunityDeleteRes struct{}

View File

@ -0,0 +1,85 @@
// Package house_dashboard 定义看房数据看板聚合接口,路由前缀 /house。
package house_dashboard
import "github.com/gogf/gf/v2/frame/g"
// OverviewRes 看板统计概览。
type OverviewRes struct {
CommunityCount int `json:"communityCount"` // 小区数
ListingCount int `json:"listingCount"` // 在售房源数
BargainCount int `json:"bargainCount"` // 笋盘数
LowConfidence int `json:"lowConfidence"` // 低可信房源数
AvgUnitPrice float64 `json:"avgUnitPrice"` // 在售均价(元/平米)
AvgTotalPrice float64 `json:"avgTotalPrice"` // 在售平均总价(万元)
AvgListDays float64 `json:"avgListDays"` // 平均挂牌天数
}
// OverviewReq 看板统计概览请求。
type OverviewReq struct {
g.Meta `path:"/house/dashboard/overview" method:"post" tags:"Admin/House/Dashboard" summary:"看板概览"`
Region string `json:"region"`
}
// MapPoint 地图上的一个小区点。
type MapPoint struct {
CommunityId uint64 `json:"communityId"`
Name string `json:"name"`
Region string `json:"region"`
Lng float64 `json:"lng"`
Lat float64 `json:"lat"`
AvgUnitPrice float64 `json:"avgUnitPrice"`
ListingCount int `json:"listingCount"`
BargainCount int `json:"bargainCount"`
}
// MapPointsReq 地图点位查询(带筛选)。
type MapPointsReq struct {
g.Meta `path:"/house/dashboard/map-points" method:"post" tags:"Admin/House/Dashboard" summary:"地图点位"`
Region string `json:"region"`
PriceMin float64 `json:"priceMin"`
PriceMax float64 `json:"priceMax"`
Status int `json:"status"`
}
// MapPointsRes 是 MapPointsReq 的响应。
type MapPointsRes struct {
Points []*MapPoint `json:"points"`
}
// TrendPoint 一个日期的均价点。
type TrendPoint struct {
Date string `json:"date"`
AvgListPrice float64 `json:"avgListPrice"` // 挂牌均价(万元)
AvgDealPrice float64 `json:"avgDealPrice"` // 成交均价(万元)
}
// PriceTrendReq 价格趋势查询。
type PriceTrendReq struct {
g.Meta `path:"/house/dashboard/price-trend" method:"post" tags:"Admin/House/Dashboard" summary:"价格趋势"`
CommunityId uint64 `json:"communityId"`
Region string `json:"region"`
Limit int `json:"limit" d:"30"` // 最近 N 天
}
// PriceTrendRes 是 PriceTrendReq 的响应。
type PriceTrendRes struct {
Trend []*TrendPoint `json:"trend"`
}
// RegionAgg 一个区域的聚合指标。
type RegionAgg struct {
Region string `json:"region"`
AvgUnitPrice float64 `json:"avgUnitPrice"`
ListingCount int `json:"listingCount"`
BargainCount int `json:"bargainCount"`
}
// AggregateRegionReq 区域聚合查询。
type AggregateRegionReq struct {
g.Meta `path:"/house/dashboard/aggregate-region" method:"post" tags:"Admin/House/Dashboard" summary:"区域聚合"`
}
// AggregateRegionRes 是 AggregateRegionReq 的响应。
type AggregateRegionRes struct {
List []*RegionAgg `json:"list"`
}

View File

@ -0,0 +1,139 @@
// Package house_listing 定义房源/挂牌管理接口,路由前缀 /house。
package house_listing
import "github.com/gogf/gf/v2/frame/g"
// ListingItem 房源列表中的一行。
type ListingItem struct {
Id uint64 `json:"id"`
CommunityId uint64 `json:"communityId"`
CommunityName string `json:"communityName"`
BuildingId uint64 `json:"buildingId"`
HouseNo string `json:"houseNo"`
Layout string `json:"layout"`
Area float64 `json:"area"`
UsableArea float64 `json:"usableArea"`
Orientation string `json:"orientation"`
Floor int `json:"floor"`
TotalFloors int `json:"totalFloors"`
Decoration string `json:"decoration"`
TotalPrice float64 `json:"totalPrice"`
UnitPrice float64 `json:"unitPrice"`
ListPrice float64 `json:"listPrice"`
Source string `json:"source"`
SourceHouseId string `json:"sourceHouseId"`
SourceUrl string `json:"sourceUrl"`
MatchGroupId uint64 `json:"matchGroupId"`
OnMarketDays int `json:"onMarketDays"`
PriceChangeCount int `json:"priceChangeCount"`
Status int `json:"status"`
Confidence int `json:"confidence"`
IsBargain int `json:"isBargain"`
ListingTime string `json:"listingTime"`
CreatedAt string `json:"createdAt"`
}
// ListingListReq 分页查询房源(统一筛选入参,供管理列表与看板共用)。
type ListingListReq struct {
g.Meta `path:"/house/listing/list" method:"post" tags:"Admin/House/Listing" summary:"房源列表"`
Page int `json:"page" d:"1" v:"min:1"`
Size int `json:"size" d:"10" v:"min:1|max:100"`
CommunityId uint64 `json:"communityId"`
Keyword string `json:"keyword"` // 匹配房号/户型
Layout string `json:"layout"`
Region string `json:"region"`
Source string `json:"source"`
PriceMin float64 `json:"priceMin"`
PriceMax float64 `json:"priceMax"`
AreaMin float64 `json:"areaMin"`
AreaMax float64 `json:"areaMax"`
Status int `json:"status"`
IsBargain int `json:"isBargain"` // 0 全部1 仅笋盘
Confidence int `json:"confidence"` // 0 全部1 仅低可信
}
// ListingListRes 是 ListingListReq 的响应。
type ListingListRes struct {
List []*ListingItem `json:"list"`
Total int `json:"total"`
}
// ListingCreateReq 新增房源(采集器/手动录入)。
type ListingCreateReq struct {
g.Meta `path:"/house/listing/create" method:"post" tags:"Admin/House/Listing" summary:"新增房源"`
CommunityId uint64 `json:"communityId" v:"required"`
BuildingId uint64 `json:"buildingId"`
HouseNo string `json:"houseNo"`
Layout string `json:"layout"`
Area float64 `json:"area"`
UsableArea float64 `json:"usableArea"`
Orientation string `json:"orientation"`
Floor int `json:"floor"`
TotalFloors int `json:"totalFloors"`
Decoration string `json:"decoration"`
TotalPrice float64 `json:"totalPrice"`
UnitPrice float64 `json:"unitPrice"`
ListPrice float64 `json:"listPrice"`
Source string `json:"source"`
SourceHouseId string `json:"sourceHouseId"`
SourceUrl string `json:"sourceUrl"`
MatchGroupId uint64 `json:"matchGroupId"`
OnMarketDays int `json:"onMarketDays"`
PriceChangeCount int `json:"priceChangeCount"`
Status int `json:"status" d:"1"`
Confidence int `json:"confidence"`
IsBargain int `json:"isBargain"`
}
// ListingCreateRes 是 ListingCreateReq 的响应。
type ListingCreateRes struct {
Id uint64 `json:"id"`
}
// ListingUpdateReq 更新房源。
type ListingUpdateReq struct {
g.Meta `path:"/house/listing/update/{id}" method:"post" tags:"Admin/House/Listing" summary:"更新房源"`
Id uint64 `json:"id" in:"path" v:"required"`
CommunityId uint64 `json:"communityId"`
BuildingId uint64 `json:"buildingId"`
HouseNo string `json:"houseNo"`
Layout string `json:"layout"`
Area float64 `json:"area"`
UsableArea float64 `json:"usableArea"`
Orientation string `json:"orientation"`
Floor int `json:"floor"`
TotalFloors int `json:"totalFloors"`
Decoration string `json:"decoration"`
TotalPrice float64 `json:"totalPrice"`
UnitPrice float64 `json:"unitPrice"`
ListPrice float64 `json:"listPrice"`
MatchGroupId uint64 `json:"matchGroupId"`
Status int `json:"status"`
Confidence int `json:"confidence"`
IsBargain int `json:"isBargain"`
}
// ListingUpdateRes 是 ListingUpdateReq 的响应。
type ListingUpdateRes struct{}
// ListingDeleteReq 删除房源(软删除)。
type ListingDeleteReq struct {
g.Meta `path:"/house/listing/delete/{id}" method:"post" tags:"Admin/House/Listing" summary:"删除房源"`
Id uint64 `json:"id" in:"path" v:"required"`
}
// ListingDeleteRes 是 ListingDeleteReq 的响应。
type ListingDeleteRes struct{}
// ListingBatchMarkReq 批量标记房源(置信度/笋盘/状态)。
type ListingBatchMarkReq struct {
g.Meta `path:"/house/listing/batch-mark" method:"post" tags:"Admin/House/Listing" summary:"批量标记房源"`
Ids []uint64 `json:"ids" v:"required"`
Field string `json:"field" v:"required"` // confidence/isBargain/status
Value int `json:"value"`
}
// ListingBatchMarkRes 是 ListingBatchMarkReq 的响应。
type ListingBatchMarkRes struct {
Affected int64 `json:"affected"`
}

View File

@ -1,18 +0,0 @@
// Package tools hosts the open API tool endpoints (GET/POST /tools/*).
//
// Naming rule: every sub-feature gets its own directory under tools/, named
// after the feature (dir name = package name), and the Req/Res contracts live
// in a file named after the feature inside that directory, e.g.
//
// api/open/v1/tools/uuid/uuid.go - GET /tools/uuid
// api/open/v1/tools/md5/md5.go - POST /tools/md5
// api/open/v1/tools/random/random.go - GET /tools/random
// api/open/v1/tools/time/time.go - GET /tools/time
// api/open/v1/tools/ip/ip.go - GET /tools/ip
//
// As a feature grows, add more files inside its directory (e.g. idcard.go,
// invoice.go under ocr/) instead of bloating the starting file.
//
// Add a new feature by creating tools/<name>/<name>.go and a matching method
// in internal/controller/open/<name>.go; the router binds it automatically.
package tools

View File

@ -1,15 +0,0 @@
// Package ip defines the GET /tools/ip endpoint contract.
package ip
import "github.com/gogf/gf/v2/frame/g"
// IPReq returns the caller's IP information.
type IPReq struct {
g.Meta `path:"/tools/ip" method:"get" tags:"Open/Tools" summary:"Client IP info"`
}
// IPRes is the response of IPReq.
type IPRes struct {
IP string `json:"ip"`
Internal bool `json:"internal"` // whether the IP is a private/internal address
}

View File

@ -1,15 +0,0 @@
// Package md5 defines the POST /tools/md5 endpoint contract.
package md5
import "github.com/gogf/gf/v2/frame/g"
// MD5Req computes an MD5 digest.
type MD5Req struct {
g.Meta `path:"/tools/md5" method:"post" tags:"Open/Tools" summary:"Compute MD5 digest"`
Text string `json:"text" v:"required#text required"`
}
// MD5Res is the response of MD5Req.
type MD5Res struct {
MD5 string `json:"md5"`
}

View File

@ -1,16 +0,0 @@
// Package random defines the GET /tools/random endpoint contract.
package random
import "github.com/gogf/gf/v2/frame/g"
// RandomReq generates a random string.
type RandomReq struct {
g.Meta `path:"/tools/random" method:"get" tags:"Open/Tools" summary:"Generate a random string"`
Length int `json:"length" d:"16" v:"min:1|max:128#length must be 1-128"`
Type string `json:"type" d:"alnum" v:"in:alnum,digits,letters#unsupported type"`
}
// RandomRes is the response of RandomReq.
type RandomRes struct {
Value string `json:"value"`
}

View File

@ -1,16 +0,0 @@
// Package time defines the GET /tools/time endpoint contract.
package time
import "github.com/gogf/gf/v2/frame/g"
// TimeReq returns the current server time.
type TimeReq struct {
g.Meta `path:"/tools/time" method:"get" tags:"Open/Tools" summary:"Current server time"`
}
// TimeRes is the response of TimeReq.
type TimeRes struct {
Timestamp int64 `json:"timestamp"` // unix seconds
DateTime string `json:"dateTime"` // 2006-01-02 15:04:05
Date string `json:"date"` // 2006-01-02
}

View File

@ -1,15 +0,0 @@
// Package uuid defines the GET /tools/uuid endpoint contract.
package uuid
import "github.com/gogf/gf/v2/frame/g"
// UUIDReq generates a unique ID.
type UUIDReq struct {
g.Meta `path:"/tools/uuid" method:"get" tags:"Open/Tools" summary:"Generate a unique ID"`
Short bool `json:"short"` // true: 8-char short code; false: 32-char ID
}
// UUIDRes is the response of UUIDReq.
type UUIDRes struct {
UUID string `json:"uuid"`
}

1
api/user/login/login.go Normal file
View File

@ -0,0 +1 @@
package user_login

View File

@ -1,25 +0,0 @@
package auth
import "github.com/gogf/gf/v2/frame/g"
type LoginReq struct {
g.Meta `path:"/auth/login" method:"post" tags:"User/Auth" summary:"User login"`
LoginType string `json:"loginType" v:"required|in:wechat,mobile,password#login type required|unsupported login type"`
Code string `json:"code"`
Mobile string `json:"mobile"`
VerifyCode string `json:"verifyCode"`
Account string `json:"account"`
Password string `json:"password"`
Terminal string `json:"terminal" v:"required|in:mini,h5,app#terminal required|invalid terminal"`
}
type LoginRes struct {
AccessToken string `json:"accessToken"`
RefreshToken string `json:"refreshToken"`
ExpiresIn int64 `json:"expiresIn"`
UserID uint64 `json:"userId"`
}
type RefreshReq struct {
g.Meta `path:"/auth/refresh" method:"post" tags:"User/Auth" summary:"Rotate user token"`
RefreshToken string `json:"refreshToken" v:"required"`
}
type RefreshRes LoginRes

View File

@ -1,10 +1,10 @@
// Package common is the public, reusable module of service.xpcool.com. // Package common 是 service.xpcool.com 的公共可复用模块。
// //
// It contains only code that is independent of internal/ — anything here can // 仅包含与 internal/ 无关的代码——此处的内容可以
// be shared across services inside the repository, or extracted into a // 在仓库内跨服务共享,或日后抽取为独立库,
// standalone library later without touching business code. // 均无需改动业务代码。
// //
// Current layout: // 当前结构:
// //
// common/tools shared utility toolbox (md5, cryptox, uuid, ...) // common/tools shared utility toolbox (md5, cryptox, uuid, ...)
package common package common

View File

@ -1,9 +1,9 @@
// Package convertx provides type conversion helpers with default-value // Package convertx 提供带默认值兜底的类型转换工具,
// fallback, built on top of gconv. // 基于 gconv 构建。
// //
// Note: gconv silently returns the zero value when conversion fails, so the // 注意gconv 转换失败时静默返回零值,
// helpers here only fall back to the default for nil / blank-string inputs. // 因此本工具仅对 nil / 空字符串输入回退到默认值。
// Pass pre-validated data when strict conversion is required. // 需要严格转换时请传入已校验的数据。
package convertx package convertx
import ( import (
@ -12,7 +12,7 @@ import (
"github.com/gogf/gf/v2/util/gconv" "github.com/gogf/gf/v2/util/gconv"
) )
// ToInt converts v to int, returning def when v is nil or a blank string. // ToInt 将 v 转为 intv 为 nil 或空字符串时返回 def。
func ToInt(v any, def int) int { func ToInt(v any, def int) int {
if isEmpty(v) { if isEmpty(v) {
return def return def
@ -20,7 +20,7 @@ func ToInt(v any, def int) int {
return gconv.Int(v) return gconv.Int(v)
} }
// ToInt64 converts v to int64, returning def when v is nil or a blank string. // ToInt64 将 v 转为 int64v 为 nil 或空字符串时返回 def。
func ToInt64(v any, def int64) int64 { func ToInt64(v any, def int64) int64 {
if isEmpty(v) { if isEmpty(v) {
return def return def
@ -28,7 +28,7 @@ func ToInt64(v any, def int64) int64 {
return gconv.Int64(v) return gconv.Int64(v)
} }
// ToFloat64 converts v to float64, returning def when v is nil or a blank string. // ToFloat64 将 v 转为 float64v 为 nil 或空字符串时返回 def。
func ToFloat64(v any, def float64) float64 { func ToFloat64(v any, def float64) float64 {
if isEmpty(v) { if isEmpty(v) {
return def return def
@ -36,7 +36,7 @@ func ToFloat64(v any, def float64) float64 {
return gconv.Float64(v) return gconv.Float64(v)
} }
// ToString converts v to string, returning def when v is nil. // ToString 将 v 转为 stringv 为 nil 时返回 def。
func ToString(v any, def string) string { func ToString(v any, def string) string {
if v == nil { if v == nil {
return def return def
@ -44,7 +44,7 @@ func ToString(v any, def string) string {
return gconv.String(v) return gconv.String(v)
} }
// ToBool converts v to bool, returning def when v is nil or a blank string. // ToBool 将 v 转为 boolv 为 nil 或空字符串时返回 def。
func ToBool(v any, def bool) bool { func ToBool(v any, def bool) bool {
if isEmpty(v) { if isEmpty(v) {
return def return def
@ -52,7 +52,7 @@ func ToBool(v any, def bool) bool {
return gconv.Bool(v) return gconv.Bool(v)
} }
// isEmpty reports whether v is nil or a blank string. // isEmpty 判断 v 是否为 nil 或空字符串。
func isEmpty(v any) bool { func isEmpty(v any) bool {
if v == nil { if v == nil {
return true return true

View File

@ -1,8 +1,8 @@
// Package cryptox provides AES/DES encryption helpers with base64 output, // Package cryptox 提供 AES/DES 加解密工具base64 输出),
// built on top of gaes and gdes. // 基于 gaes 与 gdes 构建。
// //
// Keys: any-length secrets are accepted — they are normalized to the exact // 密钥:接受任意长度密钥,内部会归一化为精确密钥尺寸,
// key size internally, so callers do not need to manage key lengths. // 调用方无需关心密钥长度。
package cryptox package cryptox
import ( import (
@ -19,7 +19,7 @@ const (
desKeySize = 8 // DES key size in bytes desKeySize = 8 // DES key size in bytes
) )
// normalizeKey derives a fixed-size key from an arbitrary-length secret. // normalizeKey 从任意长度密钥派生出固定尺寸密钥。
func normalizeKey(secret string, size int) []byte { func normalizeKey(secret string, size int) []byte {
key := []byte(secret) key := []byte(secret)
if len(key) == size { if len(key) == size {
@ -33,8 +33,8 @@ func normalizeKey(secret string, size int) []byte {
return out return out
} }
// AesEncrypt encrypts plainText with AES-128-CBC using a key derived from // AesEncrypt 使用由 secret 派生的密钥对 plainText 做 AES-128-CBC 加密,
// secret, and returns the ciphertext encoded in base64. // 返回 base64 编码的密文。
func AesEncrypt(plainText, secret string) (string, error) { func AesEncrypt(plainText, secret string) (string, error) {
out, err := gaes.Encrypt([]byte(plainText), normalizeKey(secret, aesKeySize)) out, err := gaes.Encrypt([]byte(plainText), normalizeKey(secret, aesKeySize))
if err != nil { if err != nil {
@ -43,7 +43,7 @@ func AesEncrypt(plainText, secret string) (string, error) {
return base64.StdEncoding.EncodeToString(out), nil return base64.StdEncoding.EncodeToString(out), nil
} }
// AesDecrypt decrypts the base64-encoded cipherText produced by AesEncrypt. // AesDecrypt 解密 AesEncrypt 产生的 base64 密文。
func AesDecrypt(cipherText, secret string) (string, error) { func AesDecrypt(cipherText, secret string) (string, error) {
data, err := base64.StdEncoding.DecodeString(cipherText) data, err := base64.StdEncoding.DecodeString(cipherText)
if err != nil { if err != nil {
@ -56,8 +56,8 @@ func AesDecrypt(cipherText, secret string) (string, error) {
return string(out), nil return string(out), nil
} }
// DesEncrypt encrypts plainText with DES-ECB (PKCS5 padding) using a key // DesEncrypt 使用由 secret 派生的密钥对 plainText 做 DES-ECBPKCS5 填充)加密,
// derived from secret, and returns the ciphertext encoded in base64. // 返回 base64 编码的密文。
func DesEncrypt(plainText, secret string) (string, error) { func DesEncrypt(plainText, secret string) (string, error) {
out, err := gdes.EncryptECB([]byte(plainText), normalizeKey(secret, desKeySize), gdes.PKCS5PADDING) out, err := gdes.EncryptECB([]byte(plainText), normalizeKey(secret, desKeySize), gdes.PKCS5PADDING)
if err != nil { if err != nil {
@ -66,7 +66,7 @@ func DesEncrypt(plainText, secret string) (string, error) {
return base64.StdEncoding.EncodeToString(out), nil return base64.StdEncoding.EncodeToString(out), nil
} }
// DesDecrypt decrypts the base64-encoded cipherText produced by DesEncrypt. // DesDecrypt 解密 DesEncrypt 产生的 base64 密文。
func DesDecrypt(cipherText, secret string) (string, error) { func DesDecrypt(cipherText, secret string) (string, error) {
data, err := base64.StdEncoding.DecodeString(cipherText) data, err := base64.StdEncoding.DecodeString(cipherText)
if err != nil { if err != nil {

View File

@ -1,10 +1,10 @@
// Package tools is the shared utility toolbox of the project. // Package tools 是项目的公共工具集。
// //
// Every sub-package is a thin, documented wrapper around GoFrame built-in // 每个子包都是对 GoFrame 内置组件的薄封装,
// components (gmd5, gaes, gdes, guid, grand, gtime, gconv, gstr, gfile, ...), // gmd5、gaes、gdes、guid、grand、gtime、gconv、gstr、gfile 等),
// so it stays small and consistent with the framework. // 保持小巧且与框架风格一致。
// //
// Layout: // 结构:
// //
// common/tools/md5 MD5 digest helpers // common/tools/md5 MD5 digest helpers
// common/tools/cryptox AES/DES encryption with base64 output // common/tools/cryptox AES/DES encryption with base64 output
@ -17,7 +17,7 @@
// common/tools/ip IP address helpers // common/tools/ip IP address helpers
// common/tools/filex file system helpers // common/tools/filex file system helpers
// //
// Rules: // 规则:
// - Never depend on internal/ — this module must stay self-contained. // - Never depend on internal/ — this module must stay self-contained.
// - Prefer reusing GoFrame built-in components over re-implementing. // - Prefer reusing GoFrame built-in components over re-implementing.
// - Keep each helper small and add a Chinese doc comment. // - Keep each helper small and add a Chinese doc comment.

View File

@ -1,28 +1,28 @@
// Package filex provides common file system helpers on top of gfile. // Package filex 基于 gfile 提供常用文件系统工具。
package filex package filex
import ( import (
"github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/os/gfile"
) )
// Exists reports whether the file or directory at path exists. // Exists 判断 path 对应的文件或目录是否存在。
func Exists(path string) bool { func Exists(path string) bool {
return gfile.Exists(path) return gfile.Exists(path)
} }
// IsDir reports whether path is a directory. // IsDir 判断 path 是否为目录。
func IsDir(path string) bool { func IsDir(path string) bool {
return gfile.IsDir(path) return gfile.IsDir(path)
} }
// ReadString returns the full content of the file at path as a string. // ReadString 以字符串形式返回 path 文件的完整内容,
// Returns an empty string when the file does not exist. // 文件不存在时返回空字符串。
func ReadString(path string) string { func ReadString(path string) string {
return gfile.GetContents(path) return gfile.GetContents(path)
} }
// WriteString writes content to the file at path, creating intermediate // WriteString 将 content 写入 path 文件,必要时自动创建中间目录。
// directories if needed. // (续上一行)
func WriteString(path, content string) error { func WriteString(path, content string) error {
return gfile.PutContents(path, content) return gfile.PutContents(path, content)
} }

View File

@ -1,4 +1,4 @@
// Package ip provides IP address helpers. // Package ip 提供 IP 地址工具。
package ip package ip
import ( import (
@ -9,12 +9,12 @@ import (
"github.com/gogf/gf/v2/net/gipv4" "github.com/gogf/gf/v2/net/gipv4"
) )
// IsValid reports whether s is a valid IPv4 address. // IsValid 判断 s 是否为合法的 IPv4 地址。
func IsValid(s string) bool { func IsValid(s string) bool {
return gipv4.Validate(s) return gipv4.Validate(s)
} }
// LocalIP returns the first non-loopback IPv4 address of this host. // LocalIP 返回本机第一个非回环 IPv4 地址。
func LocalIP() (string, error) { func LocalIP() (string, error) {
addrs, err := net.InterfaceAddrs() addrs, err := net.InterfaceAddrs()
if err != nil { if err != nil {
@ -30,7 +30,7 @@ func LocalIP() (string, error) {
return "", nil return "", nil
} }
// IsInternal reports whether s is a private/internal IPv4 address // IsInternal 判断 s 是否为私有/内网 IPv4 地址
// (private ranges, loopback or link-local). // (private ranges, loopback or link-local).
func IsInternal(s string) bool { func IsInternal(s string) bool {
parsed := net.ParseIP(s) parsed := net.ParseIP(s)
@ -40,7 +40,7 @@ func IsInternal(s string) bool {
return parsed.IsPrivate() || parsed.IsLoopback() || parsed.IsLinkLocalUnicast() return parsed.IsPrivate() || parsed.IsLoopback() || parsed.IsLinkLocalUnicast()
} }
// ToLong converts an IPv4 string to its uint32 representation // ToLong 将 IPv4 字符串转为 uint32 数值表示
// (big-endian, same as inet_aton). // (big-endian, same as inet_aton).
func ToLong(s string) (uint32, error) { func ToLong(s string) (uint32, error) {
ipv4 := net.ParseIP(s).To4() ipv4 := net.ParseIP(s).To4()
@ -50,7 +50,7 @@ func ToLong(s string) (uint32, error) {
return uint32(ipv4[0])<<24 | uint32(ipv4[1])<<16 | uint32(ipv4[2])<<8 | uint32(ipv4[3]), nil return uint32(ipv4[0])<<24 | uint32(ipv4[1])<<16 | uint32(ipv4[2])<<8 | uint32(ipv4[3]), nil
} }
// ToString converts a uint32 IPv4 value to its dotted-decimal string. // ToString 将 uint32 的 IPv4 值转为点分十进制字符串。
func ToString(v uint32) string { func ToString(v uint32) string {
return strconv.Itoa(int(v>>24)) + "." + return strconv.Itoa(int(v>>24)) + "." +
strconv.Itoa(int(v>>16&0xFF)) + "." + strconv.Itoa(int(v>>16&0xFF)) + "." +

View File

@ -1,23 +1,23 @@
// Package md5 provides MD5 digest helpers. // Package md5 提供 MD5 摘要工具。
package md5 package md5
import ( import (
"github.com/gogf/gf/v2/crypto/gmd5" "github.com/gogf/gf/v2/crypto/gmd5"
) )
// Md5Hex returns the MD5 digest of s as a lowercase hex string. // Md5Hex 返回 s 的 MD5 摘要(小写十六进制字符串)。
// The underlying error is ignored because it never fails for in-memory input. // 底层错误被忽略,因为对内存输入永远不会失败。
func Md5Hex(s string) string { func Md5Hex(s string) string {
h, _ := gmd5.EncryptString(s) h, _ := gmd5.EncryptString(s)
return h return h
} }
// Md5Bytes returns the MD5 digest of data as a lowercase hex string. // Md5Bytes 返回 data 的 MD5 摘要(小写十六进制字符串)。
func Md5Bytes(data []byte) (string, error) { func Md5Bytes(data []byte) (string, error) {
return gmd5.Encrypt(data) return gmd5.Encrypt(data)
} }
// Md5File returns the MD5 digest of the local file at path as a hex string. // Md5File 返回 path 本地文件的 MD5 摘要(十六进制字符串)。
func Md5File(path string) (string, error) { func Md5File(path string) (string, error) {
return gmd5.EncryptFile(path) return gmd5.EncryptFile(path)
} }

View File

@ -1,26 +1,26 @@
// Package random provides random number and string generation helpers. // Package random 提供随机数与随机字符串生成工具。
package random package random
import ( import (
"github.com/gogf/gf/v2/util/grand" "github.com/gogf/gf/v2/util/grand"
) )
// Int returns a random integer in [min, max]. // Int 返回 [min, max] 区间内的随机整数。
func Int(min, max int) int { func Int(min, max int) int {
return grand.N(min, max) return grand.N(min, max)
} }
// String returns a random alphanumeric string of length n. // String 返回长度为 n 的随机字母数字字符串。
func String(n int) string { func String(n int) string {
return grand.S(n) return grand.S(n)
} }
// Digits returns a random numeric-only string of length n, e.g. SMS codes. // Digits 返回长度为 n 的纯数字随机字符串,如短信验证码。
func Digits(n int) string { func Digits(n int) string {
return grand.Digits(n) return grand.Digits(n)
} }
// Letters returns a random letter-only string of length n. // Letters 返回长度为 n 的纯字母随机字符串。
func Letters(n int) string { func Letters(n int) string {
return grand.Letters(n) return grand.Letters(n)
} }

View File

@ -1,17 +1,17 @@
// Package slicex provides generic slice utilities built on the standard // Package slicex 基于标准库提供通用切片工具Go 1.23+)。
// library (Go 1.23+). // (续上一行)
package slicex package slicex
import ( import (
"slices" "slices"
) )
// Contains reports whether v is present in items. // Contains 判断 items 中是否包含 v。
func Contains[T comparable](items []T, v T) bool { func Contains[T comparable](items []T, v T) bool {
return slices.Contains(items, v) return slices.Contains(items, v)
} }
// Unique returns items with duplicates removed, preserving first-seen order. // Unique 去除 items 中重复元素,保持首次出现顺序。
func Unique[T comparable](items []T) []T { func Unique[T comparable](items []T) []T {
seen := make(map[T]struct{}, len(items)) seen := make(map[T]struct{}, len(items))
out := make([]T, 0, len(items)) out := make([]T, 0, len(items))
@ -25,8 +25,8 @@ func Unique[T comparable](items []T) []T {
return out return out
} }
// Chunk splits items into sub-slices of at most size elements. // Chunk 将 items 切分为最多 size 个元素的子切片,
// Returns nil when size <= 0 or items is empty. // size <= 0 或 items 为空时返回 nil。
func Chunk[T any](items []T, size int) [][]T { func Chunk[T any](items []T, size int) [][]T {
if size <= 0 || len(items) == 0 { if size <= 0 || len(items) == 0 {
return nil return nil
@ -43,7 +43,7 @@ func Chunk[T any](items []T, size int) [][]T {
return out return out
} }
// Map applies fn to every element and returns the results. // Map 对每个元素应用 fn 并返回结果。
func Map[T, R any](items []T, fn func(T) R) []R { func Map[T, R any](items []T, fn func(T) R) []R {
out := make([]R, len(items)) out := make([]R, len(items))
for i, v := range items { for i, v := range items {
@ -52,7 +52,7 @@ func Map[T, R any](items []T, fn func(T) R) []R {
return out return out
} }
// Filter returns the elements for which fn returns true, preserving order. // Filter 返回 fn 为 true 的元素,保持原顺序。
func Filter[T any](items []T, fn func(T) bool) []T { func Filter[T any](items []T, fn func(T) bool) []T {
out := make([]T, 0, len(items)) out := make([]T, 0, len(items))
for _, v := range items { for _, v := range items {

View File

@ -1,5 +1,5 @@
// Package strx provides string helpers on top of gstr, including naming // Package strx 基于 gstr 提供字符串工具,含命名
// conversion and sensitive-data masking. // 转换与敏感数据脱敏。
package strx package strx
import ( import (
@ -8,28 +8,28 @@ import (
"github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/text/gstr"
) )
// SnakeCase converts s to snake_case, e.g. "UserName" -> "user_name". // SnakeCase 将 s 转为 snake_case如 "UserName" -> "user_name"。
func SnakeCase(s string) string { func SnakeCase(s string) string {
return gstr.CaseSnake(s) return gstr.CaseSnake(s)
} }
// CamelCase converts s to CamelCase, e.g. "user_name" -> "UserName". // CamelCase 将 s 转为 CamelCase如 "user_name" -> "UserName"。
func CamelCase(s string) string { func CamelCase(s string) string {
return gstr.CaseCamel(s) return gstr.CaseCamel(s)
} }
// LowerCamelCase converts s to lowerCamelCase, e.g. "user_name" -> "userName". // LowerCamelCase 将 s 转为 lowerCamelCase如 "user_name" -> "userName"。
func LowerCamelCase(s string) string { func LowerCamelCase(s string) string {
return gstr.CaseCamelLower(s) return gstr.CaseCamelLower(s)
} }
// IsEmpty reports whether s is empty or whitespace-only. // IsEmpty 判断 s 是否为空或仅含空白字符。
func IsEmpty(s string) bool { func IsEmpty(s string) bool {
return strings.TrimSpace(s) == "" return strings.TrimSpace(s) == ""
} }
// MaskPhone masks a phone number, keeping the first 3 and last 4 characters. // MaskPhone 对手机号脱敏,保留前 3 位与后 4 位。
// e.g. "13812345678" -> "138****5678". // 例如 "13812345678" -> "138****5678"。
func MaskPhone(s string) string { func MaskPhone(s string) string {
if len(s) < 7 { if len(s) < 7 {
return s return s
@ -37,8 +37,8 @@ func MaskPhone(s string) string {
return s[:3] + "****" + s[len(s)-4:] return s[:3] + "****" + s[len(s)-4:]
} }
// MaskIDCard masks a Chinese ID card number, keeping the first 6 and last 4 // MaskIDCard 对身份证号脱敏,保留前 6 位与后 4 位,
// characters. e.g. "110101199003074512" -> "110101********4512". // 例如 "110101199003074512" -> "110101********4512"。
func MaskIDCard(s string) string { func MaskIDCard(s string) string {
if len(s) < 10 { if len(s) < 10 {
return s return s
@ -46,7 +46,7 @@ func MaskIDCard(s string) string {
return s[:6] + "********" + s[len(s)-4:] return s[:6] + "********" + s[len(s)-4:]
} }
// MaskName masks a Chinese name, keeping only the first character. // MaskName 对中文姓名脱敏,仅保留首字符。
// e.g. "张三丰" -> "张**". // e.g. "张三丰" -> "张**".
func MaskName(s string) string { func MaskName(s string) string {
r := []rune(s) r := []rune(s)

View File

@ -1,4 +1,4 @@
// Package timex provides time formatting and computation helpers on top of gtime. // Package timex 基于 gtime 提供时间格式化与计算工具。
package timex package timex
import ( import (
@ -6,22 +6,22 @@ import (
) )
const ( const (
// LayoutDateTime is the conventional datetime layout: 2006-01-02 15:04:05. // LayoutDateTime 是常用日期时间格式2006-01-02 15:04:05。
LayoutDateTime = "2006-01-02 15:04:05" LayoutDateTime = "2006-01-02 15:04:05"
// LayoutDate is the conventional date layout: 2006-01-02. // LayoutDate 是常用日期格式2006-01-02。
LayoutDate = "2006-01-02" LayoutDate = "2006-01-02"
) )
// Now returns the current time. // Now 返回当前时间。
func Now() *gtime.Time { func Now() *gtime.Time {
return gtime.Now() return gtime.Now()
} }
// Format returns t formatted with the given Go layout. // Format 按给定 Go 布局格式化 t
// When layout is empty, LayoutDateTime is used. // layout 为空时使用 LayoutDateTime。
// //
// Note: gtime v2.10.2's Format() takes PHP-style format ("Y-m-d H:i:s"), // 注意gtime v2.10.2 的 Format() 接收 PHP 风格格式("Y-m-d H:i:s"
// so this helper uses the Layout() method which accepts Go layouts. // 因此本工具改用接受 Go 布局的 Layout() 方法。
func Format(t *gtime.Time, layout ...string) string { func Format(t *gtime.Time, layout ...string) string {
ly := LayoutDateTime ly := LayoutDateTime
if len(layout) > 0 && layout[0] != "" { if len(layout) > 0 && layout[0] != "" {
@ -30,17 +30,17 @@ func Format(t *gtime.Time, layout ...string) string {
return t.Layout(ly) return t.Layout(ly)
} }
// Timestamp returns the current Unix timestamp in seconds. // Timestamp 返回当前 Unix 秒级时间戳。
func Timestamp() int64 { func Timestamp() int64 {
return gtime.Now().Timestamp() return gtime.Now().Timestamp()
} }
// StartOfDay returns the beginning (00:00:00) of the day containing t. // StartOfDay 返回 t 所在日期的零点00:00:00
func StartOfDay(t *gtime.Time) *gtime.Time { func StartOfDay(t *gtime.Time) *gtime.Time {
return gtime.NewFromStr(t.Layout(LayoutDate) + " 00:00:00") return gtime.NewFromStr(t.Layout(LayoutDate) + " 00:00:00")
} }
// EndOfDay returns the end (23:59:59) of the day containing t. // EndOfDay 返回 t 所在日期的末尾23:59:59
func EndOfDay(t *gtime.Time) *gtime.Time { func EndOfDay(t *gtime.Time) *gtime.Time {
return gtime.NewFromStr(t.Layout(LayoutDate) + " 23:59:59") return gtime.NewFromStr(t.Layout(LayoutDate) + " 23:59:59")
} }

View File

@ -1,4 +1,4 @@
// Package uuid provides unique ID generation helpers. // Package uuid 提供唯一 ID 生成工具。
package uuid package uuid
import ( import (
@ -6,13 +6,13 @@ import (
"github.com/gogf/gf/v2/util/guid" "github.com/gogf/gf/v2/util/guid"
) )
// New returns a 32-character unique ID without dashes. // New 返回不带连字符的 32 位唯一 ID。
func New() string { func New() string {
return guid.S() return guid.S()
} }
// Short returns a random alphanumeric ID of length n (defaults to 8 when n <= 0). // Short 返回长度为 n 的随机字母数字 IDn <= 0 时默认为 8 位),
// Suitable for short invite codes / trace ids. // 适合短邀请码 / 追踪 ID 场景。
func Short(n int) string { func Short(n int) string {
if n <= 0 { if n <= 0 {
n = 8 n = 8

223
docs/house-system-design.md Normal file
View File

@ -0,0 +1,223 @@
# 看房系统House总设计文档
> 版本v1.0 | 日期2026-08-26 | 状态开发中阶段 0/1
> 定位贵阳购房决策辅助系统从公开房源数据中筛选最适合自己的房子
## 1. 项目概述
买房的核心矛盾是信息高度不对称本系统通过 **采集 存储 管理 可视化 推送** 五段闭环把贵阳公开房源数据沉淀成一份可管理可分析可对比的个人决策资产
- **目标城市**贵阳二线/省会数据源以贝壳/安居客/房天下 + 住建局网签为主
- **房源类型**新房 + 二手房都做两套数据模型并存
- **核心诉求**房价波动分析楼盘楼栋级地图多平台报价对比个性化打分推荐Bark 推送
## 2. 总体架构
### 2.1 五层架构
```
应用展示层 房价地图热力 · 楼盘对比看板 · 个性化榜单
分析计算层 价格趋势分析 · 匹配打分排序 · 通勤配套评估
数据治理层 清洗与标准化 · 房源去重对齐(:软关联) · 小区实体映射
数据存储层 MySQL(house_* ) · 价格时序快照
数据采集层 多平台采集器 · 调度与限频 · 代理与反反爬
```
### 2.2 落地拓扑贴合现有项目
```
贵阳公开数据源(贝壳/安居客/房天下/住建局网签)
抓取
Python 采集分析服务(独立进程: 采集/清洗/软关联/打分/调度)
写库
MySQL 共享库(house_* ) service 同库
读写
service.xpcool.com(GoFrame v2 · house 模块 REST API)
REST admin.xpcool.com(Vue3+Vben: 管理列表 + 可视化看板)
推送 Bark(苹果)
```
**关键决策**Python 只负责把数据搞干净写进库 + 算分不对外提供业务 API所有查询/推送由 Go house 模块统一暴露保持单一出口
## 3. 技术选型
| | 选型 | 理由 |
|----|------|------|
| 后端 | GoFrame v2.10现有 service | 复用分层 + RBAC + gf gen dao |
| 数据库 | MySQL 8现有同库 | 贵阳数据量级房源几十万/快照百万单机够用不引 PostGIS/TimescaleDB |
| 前端 | Vben Admin 5web-tdesign+ echarts@6 + vxe-table@4 | 全部现成依赖零新增 |
| 地图 | 腾讯地图 GL JS合规+ DataV GeoJSON | 底图合规支持 MultiMarker/热力/多边形 |
| 采集分析 | PythonScrapy/httpx + pandas | 爬虫与数据分析生态最强 |
| 推送 | Bark自建 Server 到腾讯云 / 官方免费版 | 苹果原生推送一条 HTTP 即可 |
## 4. 数据源规划贵阳
| 类别 | 数据源 | 备注 |
|------|--------|------|
| 二手房挂牌 | 贝壳 gy.ke.com安居客房天下58 | 贝壳最规整MVP 首选 |
| 成交/网签 | 贵阳市住建局网签备案贝壳成交频道 | **成交价是真实价最大风险点** |
| 新房备案价 | 住建局预售许可 + 一房一价备案 | 新房真价格来源 |
| 配套/通勤 | 高德/百度地图 API | 地铁学校商圈 POI + 真实通勤时间 |
| 学区划片 | 贵阳市/各区教育局划片文件 | 年度版本半自动采集 |
## 5. 数据模型9 张表
### 5.1 house_community 小区/楼盘
| 字段 | 类型 | 说明 |
|------|------|------|
| id | BIGINT UNSIGNED PK | |
| name | VARCHAR | 小区名 |
| region | VARCHAR | 区县云岩/南明/观山湖/花溪 |
| business_district | VARCHAR | 板块 |
| address / lng / lat | VARCHAR / DECIMAL(10,6) | 定位GCJ-02 |
| build_year / households | INT | 建成年份/户数 |
| plot_ratio / green_rate | DECIMAL | 容积率/绿化率 |
| property_company / property_fee | VARCHAR / DECIMAL | 物业/物业费 |
| developer | VARCHAR | 开发商 |
### 5.2 house_building 楼栋
| 字段 | 说明 |
|------|------|
| community_id | 所属小区 |
| building_no | 栋号 |
| units / total_floors / elevator_count / ladder_ratio | 单元/总层/电梯/梯户比 |
| building_type | 板楼/塔楼 |
| lng / lat | 楼栋级坐标三级落地小区中心楼栋图解析重点盘人工校准 |
### 5.3 house_listing 房源/挂牌核心
| 字段 | 说明 |
|------|------|
| community_id / building_id / house_no | 归属 |
| layout / area / usable_area | 户型 / 建面 / 套内**建面套内要标准化** |
| orientation / floor / total_floors / decoration | 朝向/楼层/总层/装修 |
| total_price / unit_price / list_price | 总价/单价/挂牌价 |
| **source / source_house_id / source_url** | 来源平台**跨平台不去重** |
| **match_group_id** | 疑似同房源软关联对比用 |
| on_market_days / price_change_count | 挂牌天数/调价次数 |
| status | 在售/下架/成交 |
| confidence / is_bargain | 可信度标记 / 笋盘标记 |
> 多平台对比策略同平台 `source+source_house_id` 唯一防重复抓跨平台各存一条小区+楼栋+户型+面积±3%+楼层算相似度打 `match_group_id`用于疑似同房源对比视图不合并
### 5.4 house_price_snapshot 价格快照时序
`listing_id + snap_date` 唯一`list_price` / `deal_price` 分列**趋势分析命脉长期保留 12 **
### 5.5 house_transaction 成交记录
`deal_price` / `deal_unit_price` / `list_days`挂牌到成交天数/ `deal_date`
### 5.6 house_facility 配套 POI
`name` / `type`(地铁/学校/医院/商圈) / `lng/lat` / `line`(地铁线路)
### 5.7 house_community_facility 小区-配套关系
`community_id + facility_id``distance`() + `commute_minutes`(通勤分钟)
### 5.8 house_school_district 学区划片
`school_name` / `community_id` / `district_polygon`(GeoJSON) / `district_year`(划片年度版本化)
### 5.9 house_preference 用户偏好画像
`budget_min/max` / `area_min/max` / `layouts`(JSON) / `subway_lines`(JSON) / `school_required` / `commute_target` / `commute_limit_min` / `weights`(权重 JSON)
## 6. 后端模块设计service.xpcool.com
### 6.1 目录落位
```
api/house/<resource>/<resource>.go # 契约(g.Meta path/method)
internal/controller/house/*.go # 适配层
internal/service/house/<resource>/ # 领域服务(接口+实现+Register)
internal/model/dto/house.go # 服务边界 dto
internal/model/{entity,do} # gf gen dao 生成
manifest/sql/010_house_tables.sql # 建表
manifest/sql/011_house_menu.sql # 菜单+权限种子
```
### 6.2 接口清单 POST 动作式前缀 /api/service/admin/house
**管理 CRUD**
```
/house/community/{list|create|update|delete}
/house/listing/{list|create|update|delete|batch-mark}
/house/snapshot/{list}
/house/transaction/{list}
/house/facility/{list|create|update|delete}
/house/district/{list|create|update|delete}
/house/crawl-task/{list|trigger|log}
```
**看板聚合/筛选**统一 `FilterDto` 入参
```
/house/dashboard/{overview|map-points|price-trend|aggregate-region}
/house/compare
/house/rank
```
### 6.3 权限
`admin_menu`type=1 菜单component 指向前端组件+ type=2 API 权限path=`POST /api/service/admin/house/...``admin_role_menu` 绑定超管role_id=1
## 7. 前端模块设计admin.xpcool.com
### 7.1 页面
| 分组 | 页面 | 组件路径 |
|------|------|---------|
| 数据管理 | 小区/楼盘管理 | house/community/index |
| 数据管理 | 房源管理筛选/标记/批量 | house/listing/index |
| 数据管理 | 价格快照/成交/配套/学区 | house/data/index后续拆分 |
| 可视化看板 | 看板筛选器+图表联动 | house/dashboard/index |
### 7.2 交互
- 管理列表查询表单 + vxe-table + 分页 + 行内操作 + 批量复用 RBAC
- 看板全局筛选器区域/价格/户型/面积/地铁/学区/通勤驱动图表联动筛选器图表图表交叉过滤列表地图双向状态放 Pinia
## 8. Python 采集分析服务
```
house-data/
crawlers/ 各平台采集器
pipeline/ 清洗软关联标准化入库
analysis/ pandas 趋势/议价空间/打分
scheduler/ APScheduler 调度 + 限频
notify/ 触发 Bark
```
只写库不对外 API独立 git 仓库建议 E:\xxcool\project\house-data\
## 9. 可视化设计地图图层
底图腾讯地图 GL JS自下而上叠加区县/板块边界(DataV GeoJSON) 地铁线(1/2/3号线 Polyline) 学区划片(polygon年度版本) 楼盘/楼栋点(MultiMarker) 价格热力(可切换)
## 10. 推送设计Bark
| 触发 | level | group | url |
|------|-------|-------|--------|
| 降价>3% | timeSensitive | 降价 | 跳房源对比页 |
| 新房上架 | active | 新房 | 跳详情 |
| 划片变更 | timeSensitive | 学区 | 跳小区 |
| 每日汇总 | passive | 汇总 | 跳看板 |
## 11. 分阶段路线图
| 阶段 | 周期 | 交付 |
|------|------|------|
| 0 方案定稿 | 12 | 建表 + gf gen dao + Python 骨架 |
| 1 MVP | ~1 | 贝壳二手房挂牌 + 价格快照房源列表/详情 API列表 + 趋势图 |
| 2 分析 | ~1 | 成交/网签 + 软关联对比 + 地图热力 + 楼盘对比 |
| 3 决策 | ~1 | 新房备案价 + 学区/配套 + 偏好打分 |
| 4 自动化 | ~1 | Bark 推送 + 迁腾讯云 7×24 |
## 12. 合规与风险
- 地图仅腾讯/高德/百度/天地图区县边界用 DataV 审图号数据key 走代理不外泄不采集他人个人位置
- 爬虫遵守 robots低频代理池只存公开信息个人自用
- **最大风险**贵阳网签/成交数据公开程度不如一线MVP 用贝壳成交频道兜底

View File

@ -4,8 +4,9 @@
gfcli: gfcli:
gen: gen:
dao: dao:
- link: "mysql:root:12345678@tcp(127.0.0.1:3306)/test" - link: "mysql:root:root123@tcp(127.0.0.1:3306)/service_xpcool_com"
descriptionTag: true descriptionTag: true
tables: "house_community,house_building,house_listing,house_price_snapshot,house_transaction,house_facility,house_community_facility,house_school_district,house_preference"
docker: docker:
build: "-a amd64 -s linux -p temp -ew" build: "-a amd64 -s linux -p temp -ew"

View File

@ -10,19 +10,23 @@ import (
"github.com/gogf/gf/v2/os/genv" "github.com/gogf/gf/v2/os/genv"
adminctl "service.xpcool.com/internal/controller/admin" adminctl "service.xpcool.com/internal/controller/admin"
"service.xpcool.com/internal/controller/hello" housectl "service.xpcool.com/internal/controller/house"
openctl "service.xpcool.com/internal/controller/open" openctl "service.xpcool.com/internal/controller/open"
userctl "service.xpcool.com/internal/controller/user" userctl "service.xpcool.com/internal/controller/user"
"service.xpcool.com/internal/library/jwt" "service.xpcool.com/internal/library/jwt"
"service.xpcool.com/internal/middleware" "service.xpcool.com/internal/middleware"
"service.xpcool.com/internal/service/admin/admin" admin "service.xpcool.com/internal/service/admin/admin/admin"
"service.xpcool.com/internal/service/admin/base/log" adminauth "service.xpcool.com/internal/service/admin/admin/login"
adminaudit "service.xpcool.com/internal/service/admin/system/audit" log "service.xpcool.com/internal/service/admin/base/log"
adminauth "service.xpcool.com/internal/service/admin/system/auth" adminaudit "service.xpcool.com/internal/service/admin/system/log"
adminloginlog "service.xpcool.com/internal/service/admin/system/login_log"
adminmenu "service.xpcool.com/internal/service/admin/system/menu" adminmenu "service.xpcool.com/internal/service/admin/system/menu"
"service.xpcool.com/internal/service/admin/system/menu_manage" menu_manage "service.xpcool.com/internal/service/admin/system/menu_manage"
"service.xpcool.com/internal/service/admin/system/role" role "service.xpcool.com/internal/service/admin/system/role"
userauth "service.xpcool.com/internal/service/user/auth" userauth "service.xpcool.com/internal/service/user/auth"
housecommunity "service.xpcool.com/internal/service/house/community"
housedashboard "service.xpcool.com/internal/service/house/dashboard"
houselisting "service.xpcool.com/internal/service/house/listing"
) )
// injectEnv 手动把关键环境变量写入配置系统。 // injectEnv 手动把关键环境变量写入配置系统。
@ -58,37 +62,35 @@ var (
menu_manage.RegisterMenuManage(menu_manage.NewMenuManage()) menu_manage.RegisterMenuManage(menu_manage.NewMenuManage())
log.RegisterLogManage(log.NewLogManage()) log.RegisterLogManage(log.NewLogManage())
adminaudit.RegisterAdminAudit(adminaudit.NewAdminAudit()) adminaudit.RegisterAdminAudit(adminaudit.NewAdminAudit())
s.Group("/", func(group *ghttp.RouterGroup) { adminloginlog.RegisterAdminLoginLog(adminloginlog.NewAdminLoginLog())
group.Middleware(middleware.Recover, middleware.CORS) housecommunity.RegisterCommunity(housecommunity.NewCommunity())
group.Middleware(ghttp.MiddlewareHandlerResponse) houselisting.RegisterListing(houselisting.NewListing())
group.Bind( housedashboard.RegisterDashboard(housedashboard.NewDashboard())
hello.NewV1(), s.Group("/api/service/open", func(group *ghttp.RouterGroup) {
)
})
s.Group("/api/open/v1", func(group *ghttp.RouterGroup) {
group.Middleware(middleware.Recover, middleware.CORS, ghttp.MiddlewareHandlerResponse) group.Middleware(middleware.Recover, middleware.CORS, ghttp.MiddlewareHandlerResponse)
group.Bind(openctl.New()) // Open tools API for frontends, no auth required. group.Bind(openctl.New()) // Open tools API for frontends, no auth required.
}) })
s.Group("/api/v1", func(group *ghttp.RouterGroup) { s.Group("/api/service/user", func(group *ghttp.RouterGroup) {
group.Middleware(middleware.Recover, middleware.CORS, ghttp.MiddlewareHandlerResponse) group.Middleware(middleware.Recover, middleware.CORS, ghttp.MiddlewareHandlerResponse)
group.Bind(userctl.New()) // Login and refresh routes are public. group.Bind(userctl.New()) // Login and refresh routes are public.
group.Group("/", func(protected *ghttp.RouterGroup) { protected.Middleware(middleware.UserAuth(tokens)) }) group.Group("/", func(protected *ghttp.RouterGroup) { protected.Middleware(middleware.UserAuth(tokens)) })
}) })
s.Group("/admin/v1", func(group *ghttp.RouterGroup) { s.Group("/api/service/admin", func(group *ghttp.RouterGroup) {
group.Middleware(middleware.Recover, middleware.CORS, ghttp.MiddlewareHandlerResponse) group.Middleware(middleware.Recover, middleware.CORS, ghttp.MiddlewareHandlerResponse)
group.Bind(adminctl.NewAuth()) // Public: login only. group.Bind(adminctl.NewAuth()) // Public: login only.
group.Group("/", func(profile *ghttp.RouterGroup) { group.Group("/", func(profile *ghttp.RouterGroup) {
// Login-only endpoints: own profile / access codes / menu routes. // 仅登录端点:个人资料 / 权限码 / 菜单路由。
profile.Middleware(middleware.AdminAuthOnly(tokens)) profile.Middleware(middleware.AdminAuthOnly(tokens))
profile.Bind(adminctl.NewProfile()) profile.Bind(adminctl.NewProfile())
}) })
group.Group("/", func(protected *ghttp.RouterGroup) { group.Group("/", func(protected *ghttp.RouterGroup) {
// Permission-protected endpoints: RBAC management, logs, ... // 受权限保护端点RBAC 管理、日志等。
// 权限由后端按「方法+路径」自动匹配,无需前端传 X-Permission。 // 权限由后端按「方法+路径」自动匹配,无需前端传 X-Permission。
protected.Middleware(middleware.AdminAuth(tokens, adminauth.AdminAuth().PermissionForPath, adminauth.AdminAuth().HasPermission, func(ctx context.Context, id uint64, permission, method, path, ip, param string, duration, status int) { protected.Middleware(middleware.AdminAuth(tokens, adminauth.AdminAuth().PermissionForPath, adminauth.AdminAuth().HasPermission, func(ctx context.Context, id uint64, permission, method, path, ip, param string, duration, status int) {
adminaudit.AdminAudit().Record(ctx, adminaudit.AuditEvent{AdminID: id, Permission: permission, Method: method, Path: path, IP: ip, Param: param, DurationMS: duration, StatusCode: status}) adminaudit.AdminAudit().Record(ctx, adminaudit.AuditEvent{AdminID: id, Permission: permission, Method: method, Path: path, IP: ip, Param: param, DurationMS: duration, StatusCode: status})
})) }))
protected.Bind(adminctl.New()) protected.Bind(adminctl.New())
protected.Bind(housectl.New())
}) })
}) })
s.Run() s.Run()

View File

@ -3,12 +3,12 @@ package admin
import ( import (
"context" "context"
adminv1 "service.xpcool.com/api/admin/v1/admin/admin" adminv1 "service.xpcool.com/api/admin/admin/admin"
"service.xpcool.com/internal/model/dto" "service.xpcool.com/internal/model/dto"
"service.xpcool.com/internal/service/admin/admin" admin "service.xpcool.com/internal/service/admin/admin/admin"
) )
// AdminList pages the administrators. // AdminList 分页查询管理员。
func (c *Controller) AdminList(ctx context.Context, req *adminv1.AdminListReq) (res *adminv1.AdminListRes, err error) { func (c *Controller) AdminList(ctx context.Context, req *adminv1.AdminListReq) (res *adminv1.AdminListRes, err error) {
items, total, err := admin.AdminManage().List(ctx, dto.PageQuery{Page: req.Page, Size: req.Size, Keyword: req.Keyword}) items, total, err := admin.AdminManage().List(ctx, dto.PageQuery{Page: req.Page, Size: req.Size, Keyword: req.Keyword})
if err != nil { if err != nil {
@ -24,7 +24,7 @@ func (c *Controller) AdminList(ctx context.Context, req *adminv1.AdminListReq) (
return &adminv1.AdminListRes{List: list, Total: total}, nil return &adminv1.AdminListRes{List: list, Total: total}, nil
} }
// AdminCreate creates an administrator. // AdminCreate 创建管理员。
func (c *Controller) AdminCreate(ctx context.Context, req *adminv1.AdminCreateReq) (res *adminv1.AdminCreateRes, err error) { func (c *Controller) AdminCreate(ctx context.Context, req *adminv1.AdminCreateReq) (res *adminv1.AdminCreateRes, err error) {
id, err := admin.AdminManage().Create(ctx, dto.AdminCreateInput{ id, err := admin.AdminManage().Create(ctx, dto.AdminCreateInput{
Username: req.Username, Password: req.Password, Nickname: req.Nickname, RoleIds: req.RoleIds, Username: req.Username, Password: req.Password, Nickname: req.Nickname, RoleIds: req.RoleIds,
@ -35,7 +35,7 @@ func (c *Controller) AdminCreate(ctx context.Context, req *adminv1.AdminCreateRe
return &adminv1.AdminCreateRes{Id: id}, nil return &adminv1.AdminCreateRes{Id: id}, nil
} }
// AdminUpdate updates an administrator. // AdminUpdate 更新管理员。
func (c *Controller) AdminUpdate(ctx context.Context, req *adminv1.AdminUpdateReq) (res *adminv1.AdminUpdateRes, err error) { func (c *Controller) AdminUpdate(ctx context.Context, req *adminv1.AdminUpdateReq) (res *adminv1.AdminUpdateRes, err error) {
if err = admin.AdminManage().Update(ctx, dto.AdminUpdateInput{Id: req.Id, Nickname: req.Nickname, Status: req.Status, RoleIds: req.RoleIds}); err != nil { if err = admin.AdminManage().Update(ctx, dto.AdminUpdateInput{Id: req.Id, Nickname: req.Nickname, Status: req.Status, RoleIds: req.RoleIds}); err != nil {
return nil, err return nil, err
@ -43,7 +43,7 @@ func (c *Controller) AdminUpdate(ctx context.Context, req *adminv1.AdminUpdateRe
return &adminv1.AdminUpdateRes{}, nil return &adminv1.AdminUpdateRes{}, nil
} }
// AdminResetPwd resets an administrator's password. // AdminResetPwd 重置管理员密码。
func (c *Controller) AdminResetPwd(ctx context.Context, req *adminv1.AdminResetPwdReq) (res *adminv1.AdminResetPwdRes, err error) { func (c *Controller) AdminResetPwd(ctx context.Context, req *adminv1.AdminResetPwdReq) (res *adminv1.AdminResetPwdRes, err error) {
if err = admin.AdminManage().ResetPassword(ctx, req.Id, req.Password); err != nil { if err = admin.AdminManage().ResetPassword(ctx, req.Id, req.Password); err != nil {
return nil, err return nil, err
@ -51,7 +51,7 @@ func (c *Controller) AdminResetPwd(ctx context.Context, req *adminv1.AdminResetP
return &adminv1.AdminResetPwdRes{}, nil return &adminv1.AdminResetPwdRes{}, nil
} }
// AdminDelete deletes an administrator. // AdminDelete 删除管理员。
func (c *Controller) AdminDelete(ctx context.Context, req *adminv1.AdminDeleteReq) (res *adminv1.AdminDeleteRes, err error) { func (c *Controller) AdminDelete(ctx context.Context, req *adminv1.AdminDeleteReq) (res *adminv1.AdminDeleteRes, err error) {
if err = admin.AdminManage().Delete(ctx, req.Id); err != nil { if err = admin.AdminManage().Delete(ctx, req.Id); err != nil {
return nil, err return nil, err

View File

@ -3,27 +3,41 @@ package admin
import ( import (
"context" "context"
authv1 "service.xpcool.com/api/admin/v1/system/auth" "github.com/gogf/gf/v2/net/ghttp"
authv1 "service.xpcool.com/api/admin/admin/login"
"service.xpcool.com/internal/model/dto" "service.xpcool.com/internal/model/dto"
"service.xpcool.com/internal/service/admin/system/auth" auth "service.xpcool.com/internal/service/admin/admin/login"
loginlog "service.xpcool.com/internal/service/admin/system/login_log"
) )
// AuthController exposes only the public login endpoint. // AuthController 仅暴露公开的登录相关端点。
type AuthController struct{} type AuthController struct{}
// NewAuth creates the public admin auth controller (login only). // NewAuth 创建公开的管理端认证控制器(仅登录)。
func NewAuth() *AuthController { return &AuthController{} } func NewAuth() *AuthController { return &AuthController{} }
// Login authenticates an administrator and issues a token pair. // Login 校验管理员身份并签发令牌对,成功与失败均写入登录日志。
func (c *AuthController) Login(ctx context.Context, req *authv1.LoginReq) (res *authv1.LoginRes, err error) { func (c *AuthController) Login(ctx context.Context, req *authv1.LoginReq) (res *authv1.LoginRes, err error) {
// 从请求上下文提取来源信息用于登录审计
r := ghttp.RequestFromCtx(ctx)
ip, ua := "", ""
if r != nil {
ip = r.GetClientIp()
ua = r.Header.Get("User-Agent")
}
p, id, err := auth.AdminAuth().Login(ctx, dto.AdminLoginInput{Username: req.Username, Password: req.Password}) p, id, err := auth.AdminAuth().Login(ctx, dto.AdminLoginInput{Username: req.Username, Password: req.Password})
if err != nil { if err != nil {
// 登录失败也落库(含失败原因),便于排查异常登录;日志失败不回传
_ = loginlog.AdminLoginLog().Record(ctx, loginlog.LoginEvent{Username: req.Username, IP: ip, UserAgent: ua, Status: 0, FailReason: err.Error()})
return nil, err return nil, err
} }
// 登录成功落库;日志落库失败不影响登录结果
_ = loginlog.AdminLoginLog().Record(ctx, loginlog.LoginEvent{Username: req.Username, IP: ip, UserAgent: ua, Status: 1})
return &authv1.LoginRes{AccessToken: p.AccessToken, RefreshToken: p.RefreshToken, ExpiresIn: p.ExpiresIn, AdminID: id}, nil return &authv1.LoginRes{AccessToken: p.AccessToken, RefreshToken: p.RefreshToken, ExpiresIn: p.ExpiresIn, AdminID: id}, nil
} }
// Refresh rotates the administrator token pair using a valid refresh token. // Refresh 使用有效刷新令牌轮换管理员令牌对。
func (c *AuthController) Refresh(ctx context.Context, req *authv1.RefreshReq) (res *authv1.RefreshRes, err error) { func (c *AuthController) Refresh(ctx context.Context, req *authv1.RefreshReq) (res *authv1.RefreshRes, err error) {
p, id, err := auth.AdminAuth().Refresh(ctx, req.RefreshToken) p, id, err := auth.AdminAuth().Refresh(ctx, req.RefreshToken)
if err != nil { if err != nil {
@ -32,8 +46,8 @@ func (c *AuthController) Refresh(ctx context.Context, req *authv1.RefreshReq) (r
return &authv1.RefreshRes{AccessToken: p.AccessToken, RefreshToken: p.RefreshToken, ExpiresIn: p.ExpiresIn, AdminID: id}, nil return &authv1.RefreshRes{AccessToken: p.AccessToken, RefreshToken: p.RefreshToken, ExpiresIn: p.ExpiresIn, AdminID: id}, nil
} }
// Logout ends the administrator session. Stateless JWT logout relies on the // Logout 结束管理员会话。无状态 JWT 登出依赖客户端
// client discarding tokens; the endpoint always succeeds for an authenticated admin. // 丢弃令牌,该端点对任意已登录管理员始终成功。
func (c *AuthController) Logout(ctx context.Context, req *authv1.LogoutReq) (res *authv1.LogoutRes, err error) { func (c *AuthController) Logout(ctx context.Context, req *authv1.LogoutReq) (res *authv1.LogoutRes, err error) {
return &authv1.LogoutRes{}, nil return &authv1.LogoutRes{}, nil
} }

View File

@ -8,14 +8,14 @@ import (
"service.xpcool.com/internal/middleware" "service.xpcool.com/internal/middleware"
) )
// Controller implements the permission-protected /admin/v1 endpoints // Controller 实现受权限保护的后台管理端点
// (RBAC management, logs, etc.). Bind behind AdminAuth (X-Permission). // (RBAC management, logs, etc.). Bind behind AdminAuth (X-Permission).
type Controller struct{} type Controller struct{}
// New creates the protected admin controller. // New 创建受保护的后台管理控制器。
func New() *Controller { return &Controller{} } func New() *Controller { return &Controller{} }
// adminID returns the authenticated admin id stored by the auth middleware. // adminID 返回认证中间件写入的管理员 id。
func adminID(ctx context.Context) uint64 { func adminID(ctx context.Context) uint64 {
return g.RequestFromCtx(ctx).GetCtxVar(middleware.AdminIDKey).Uint64() return g.RequestFromCtx(ctx).GetCtxVar(middleware.AdminIDKey).Uint64()
} }

View File

@ -3,11 +3,14 @@ package admin
import ( import (
"context" "context"
logv1 "service.xpcool.com/api/admin/v1/base/log" logv1 "service.xpcool.com/api/admin/base/log"
"service.xpcool.com/internal/service/admin/base/log" systemlogv1 "service.xpcool.com/api/admin/system/log"
"service.xpcool.com/internal/model/dto"
log "service.xpcool.com/internal/service/admin/base/log"
adminlog "service.xpcool.com/internal/service/admin/system/log"
) )
// LogFiles lists the server log files. // LogFiles 列出服务器日志文件。
func (c *Controller) LogFiles(ctx context.Context, req *logv1.LogFilesReq) (res *logv1.LogFilesRes, err error) { func (c *Controller) LogFiles(ctx context.Context, req *logv1.LogFilesReq) (res *logv1.LogFilesRes, err error) {
dir, files, err := log.LogManage().Files(ctx) dir, files, err := log.LogManage().Files(ctx)
if err != nil { if err != nil {
@ -20,7 +23,7 @@ func (c *Controller) LogFiles(ctx context.Context, req *logv1.LogFilesReq) (res
return &logv1.LogFilesRes{Dir: dir, Files: list}, nil return &logv1.LogFilesRes{Dir: dir, Files: list}, nil
} }
// LogTail reads the tail of a log file with optional keyword filter. // LogTail 读取日志文件尾部,支持关键字过滤。
func (c *Controller) LogTail(ctx context.Context, req *logv1.LogTailReq) (res *logv1.LogTailRes, err error) { func (c *Controller) LogTail(ctx context.Context, req *logv1.LogTailReq) (res *logv1.LogTailRes, err error) {
lines, err := log.LogManage().Tail(ctx, req.File, req.Lines, req.Keyword) lines, err := log.LogManage().Tail(ctx, req.File, req.Lines, req.Keyword)
if err != nil { if err != nil {
@ -28,3 +31,20 @@ func (c *Controller) LogTail(ctx context.Context, req *logv1.LogTailReq) (res *l
} }
return &logv1.LogTailRes{Lines: lines}, nil return &logv1.LogTailRes{Lines: lines}, nil
} }
// LogList 分页查询 admin 系统日志(操作审计记录)。
func (c *Controller) LogList(ctx context.Context, req *systemlogv1.LogListReq) (res *systemlogv1.LogListRes, err error) {
items, total, err := adminlog.AdminAudit().List(ctx, dto.LogQuery{Page: req.Page, Size: req.Size, AdminID: req.AdminID, Permission: req.Keyword})
if err != nil {
return nil, err
}
list := make([]*systemlogv1.LogItem, 0, len(items))
for _, it := range items {
list = append(list, &systemlogv1.LogItem{
Id: it.Id, AdminID: it.AdminID, Permission: it.Permission, Method: it.Method,
Path: it.Path, IP: it.IP, Param: it.Param, DurationMS: it.DurationMS,
StatusCode: it.StatusCode, CreatedAt: it.CreatedAt,
})
}
return &systemlogv1.LogListRes{List: list, Total: total}, nil
}

View File

@ -0,0 +1,27 @@
package admin
import (
"context"
loginlogv1 "service.xpcool.com/api/admin/system/login_log"
"service.xpcool.com/internal/model/dto"
loginlog "service.xpcool.com/internal/service/admin/system/login_log"
)
// LoginLogList 分页查询管理员登录日志。
func (c *Controller) LoginLogList(ctx context.Context, req *loginlogv1.LoginLogListReq) (res *loginlogv1.LoginLogListRes, err error) {
items, total, err := loginlog.AdminLoginLog().List(ctx, dto.LoginLogQuery{
Page: req.Page, Size: req.Size, Username: req.Username, Status: req.Status,
})
if err != nil {
return nil, err
}
list := make([]*loginlogv1.LoginLogItem, 0, len(items))
for _, it := range items {
list = append(list, &loginlogv1.LoginLogItem{
Id: it.Id, Username: it.Username, IP: it.IP, UserAgent: it.UserAgent,
Status: it.Status, FailReason: it.FailReason, CreatedAt: it.CreatedAt,
})
}
return &loginlogv1.LoginLogListRes{List: list, Total: total}, nil
}

View File

@ -3,12 +3,12 @@ package admin
import ( import (
"context" "context"
menuv1 "service.xpcool.com/api/admin/v1/system/menu_manage" menuv1 "service.xpcool.com/api/admin/system/menu_manage"
"service.xpcool.com/internal/model/dto" "service.xpcool.com/internal/model/dto"
"service.xpcool.com/internal/service/admin/system/menu_manage" menu_manage "service.xpcool.com/internal/service/admin/system/menu_manage"
) )
// MenuTree returns the full menu tree (menus + button permissions). // MenuTree 返回完整菜单树(菜单 + 按钮权限)。
func (c *Controller) MenuTree(ctx context.Context, req *menuv1.MenuTreeReq) (res *menuv1.MenuTreeRes, err error) { func (c *Controller) MenuTree(ctx context.Context, req *menuv1.MenuTreeReq) (res *menuv1.MenuTreeRes, err error) {
tree, err := menu_manage.MenuManage().Tree(ctx) tree, err := menu_manage.MenuManage().Tree(ctx)
if err != nil { if err != nil {
@ -21,7 +21,7 @@ func (c *Controller) MenuTree(ctx context.Context, req *menuv1.MenuTreeReq) (res
return &menuv1.MenuTreeRes{Tree: out}, nil return &menuv1.MenuTreeRes{Tree: out}, nil
} }
// MenuCreate creates a menu or button node. // MenuCreate 创建菜单或按钮节点。
func (c *Controller) MenuCreate(ctx context.Context, req *menuv1.MenuCreateReq) (res *menuv1.MenuCreateRes, err error) { func (c *Controller) MenuCreate(ctx context.Context, req *menuv1.MenuCreateReq) (res *menuv1.MenuCreateRes, err error) {
id, err := menu_manage.MenuManage().Create(ctx, dto.MenuCreateInput{ id, err := menu_manage.MenuManage().Create(ctx, dto.MenuCreateInput{
ParentId: req.ParentId, Name: req.Name, Icon: req.Icon, Type: req.Type, Path: req.Path, ParentId: req.ParentId, Name: req.Name, Icon: req.Icon, Type: req.Type, Path: req.Path,
@ -33,7 +33,7 @@ func (c *Controller) MenuCreate(ctx context.Context, req *menuv1.MenuCreateReq)
return &menuv1.MenuCreateRes{Id: id}, nil return &menuv1.MenuCreateRes{Id: id}, nil
} }
// MenuUpdate updates a menu or button node. // MenuUpdate 更新菜单或按钮节点。
func (c *Controller) MenuUpdate(ctx context.Context, req *menuv1.MenuUpdateReq) (res *menuv1.MenuUpdateRes, err error) { func (c *Controller) MenuUpdate(ctx context.Context, req *menuv1.MenuUpdateReq) (res *menuv1.MenuUpdateRes, err error) {
if err = menu_manage.MenuManage().Update(ctx, dto.MenuUpdateInput{ if err = menu_manage.MenuManage().Update(ctx, dto.MenuUpdateInput{
Id: req.Id, ParentId: req.ParentId, Name: req.Name, Icon: req.Icon, Type: req.Type, Path: req.Path, Id: req.Id, ParentId: req.ParentId, Name: req.Name, Icon: req.Icon, Type: req.Type, Path: req.Path,
@ -44,7 +44,7 @@ func (c *Controller) MenuUpdate(ctx context.Context, req *menuv1.MenuUpdateReq)
return &menuv1.MenuUpdateRes{}, nil return &menuv1.MenuUpdateRes{}, nil
} }
// MenuDelete deletes a menu node. // MenuDelete 删除菜单节点。
func (c *Controller) MenuDelete(ctx context.Context, req *menuv1.MenuDeleteReq) (res *menuv1.MenuDeleteRes, err error) { func (c *Controller) MenuDelete(ctx context.Context, req *menuv1.MenuDeleteReq) (res *menuv1.MenuDeleteRes, err error) {
if err = menu_manage.MenuManage().Delete(ctx, req.Id); err != nil { if err = menu_manage.MenuManage().Delete(ctx, req.Id); err != nil {
return nil, err return nil, err

View File

@ -3,21 +3,21 @@ package admin
import ( import (
"context" "context"
authv1 "service.xpcool.com/api/admin/v1/system/auth" authv1 "service.xpcool.com/api/admin/admin/login"
menuv1 "service.xpcool.com/api/admin/v1/system/menu" menuv1 "service.xpcool.com/api/admin/system/menu"
"service.xpcool.com/internal/model/dto" "service.xpcool.com/internal/model/dto"
"service.xpcool.com/internal/service/admin/system/auth" auth "service.xpcool.com/internal/service/admin/admin/login"
"service.xpcool.com/internal/service/admin/system/menu" menu "service.xpcool.com/internal/service/admin/system/menu"
) )
// ProfileController exposes the logged-in admin's own profile endpoints // ProfileController 暴露当前登录管理员的资料端点
// (login-only, no X-Permission required). Bind behind AdminAuthOnly. // (login-only, no X-Permission required). Bind behind AdminAuthOnly.
type ProfileController struct{} type ProfileController struct{}
// NewProfile creates the profile controller. // NewProfile 创建资料控制器。
func NewProfile() *ProfileController { return &ProfileController{} } func NewProfile() *ProfileController { return &ProfileController{} }
// Info returns the current administrator profile. // Info 返回当前管理员资料。
func (c *ProfileController) Info(ctx context.Context, req *authv1.InfoReq) (res *authv1.InfoRes, err error) { func (c *ProfileController) Info(ctx context.Context, req *authv1.InfoReq) (res *authv1.InfoRes, err error) {
info, err := auth.AdminAuth().Info(ctx, adminID(ctx)) info, err := auth.AdminAuth().Info(ctx, adminID(ctx))
if err != nil { if err != nil {
@ -26,7 +26,7 @@ func (c *ProfileController) Info(ctx context.Context, req *authv1.InfoReq) (res
return &authv1.InfoRes{AdminID: info.AdminID, Username: info.Username, Nickname: info.Nickname, Roles: info.Roles}, nil return &authv1.InfoRes{AdminID: info.AdminID, Username: info.Username, Nickname: info.Nickname, Roles: info.Roles}, nil
} }
// Codes returns the button-level permission codes of the current administrator. // Codes 返回当前管理员的按钮级权限码。
func (c *ProfileController) Codes(ctx context.Context, req *authv1.CodesReq) (res *authv1.CodesRes, err error) { func (c *ProfileController) Codes(ctx context.Context, req *authv1.CodesReq) (res *authv1.CodesRes, err error) {
codes, err := auth.AdminAuth().Codes(ctx, adminID(ctx)) codes, err := auth.AdminAuth().Codes(ctx, adminID(ctx))
if err != nil { if err != nil {
@ -35,7 +35,7 @@ func (c *ProfileController) Codes(ctx context.Context, req *authv1.CodesReq) (re
return &authv1.CodesRes{Codes: codes}, nil return &authv1.CodesRes{Codes: codes}, nil
} }
// Routes returns the current administrator's visible menu tree as vben routes. // Routes 返回当前管理员的可见菜单树vben 路由)。
func (c *ProfileController) Routes(ctx context.Context, req *menuv1.MenuRoutesReq) (res *menuv1.MenuRoutesRes, err error) { func (c *ProfileController) Routes(ctx context.Context, req *menuv1.MenuRoutesReq) (res *menuv1.MenuRoutesRes, err error) {
routes, err := menu.AdminMenu().Routes(ctx, adminID(ctx)) routes, err := menu.AdminMenu().Routes(ctx, adminID(ctx))
if err != nil { if err != nil {
@ -48,7 +48,7 @@ func (c *ProfileController) Routes(ctx context.Context, req *menuv1.MenuRoutesRe
return &menuv1.MenuRoutesRes{Routes: out}, nil return &menuv1.MenuRoutesRes{Routes: out}, nil
} }
// toV1Route converts a dto route tree into the v1 API shape. // toV1Route 将 dto 路由树转换为 API 层结构。
func toV1Route(r *dto.RouteItem) *menuv1.RouteItem { func toV1Route(r *dto.RouteItem) *menuv1.RouteItem {
item := &menuv1.RouteItem{ item := &menuv1.RouteItem{
Name: r.Name, Name: r.Name,

View File

@ -3,12 +3,12 @@ package admin
import ( import (
"context" "context"
rolev1 "service.xpcool.com/api/admin/v1/system/role" rolev1 "service.xpcool.com/api/admin/system/role"
"service.xpcool.com/internal/model/dto" "service.xpcool.com/internal/model/dto"
"service.xpcool.com/internal/service/admin/system/role" role "service.xpcool.com/internal/service/admin/system/role"
) )
// RoleList pages the roles. // RoleList 分页查询角色。
func (c *Controller) RoleList(ctx context.Context, req *rolev1.RoleListReq) (res *rolev1.RoleListRes, err error) { func (c *Controller) RoleList(ctx context.Context, req *rolev1.RoleListReq) (res *rolev1.RoleListRes, err error) {
items, total, err := role.RoleManage().List(ctx, dto.PageQuery{Page: req.Page, Size: req.Size, Keyword: req.Keyword}) items, total, err := role.RoleManage().List(ctx, dto.PageQuery{Page: req.Page, Size: req.Size, Keyword: req.Keyword})
if err != nil { if err != nil {
@ -23,7 +23,7 @@ func (c *Controller) RoleList(ctx context.Context, req *rolev1.RoleListReq) (res
return &rolev1.RoleListRes{List: list, Total: total}, nil return &rolev1.RoleListRes{List: list, Total: total}, nil
} }
// RoleCreate creates a role. // RoleCreate 创建角色。
func (c *Controller) RoleCreate(ctx context.Context, req *rolev1.RoleCreateReq) (res *rolev1.RoleCreateRes, err error) { func (c *Controller) RoleCreate(ctx context.Context, req *rolev1.RoleCreateReq) (res *rolev1.RoleCreateRes, err error) {
id, err := role.RoleManage().Create(ctx, dto.RoleCreateInput{Code: req.Code, Name: req.Name, Status: req.Status, MenuIds: req.MenuIds}) id, err := role.RoleManage().Create(ctx, dto.RoleCreateInput{Code: req.Code, Name: req.Name, Status: req.Status, MenuIds: req.MenuIds})
if err != nil { if err != nil {
@ -32,7 +32,7 @@ func (c *Controller) RoleCreate(ctx context.Context, req *rolev1.RoleCreateReq)
return &rolev1.RoleCreateRes{Id: id}, nil return &rolev1.RoleCreateRes{Id: id}, nil
} }
// RoleUpdate updates a role. // RoleUpdate 更新角色。
func (c *Controller) RoleUpdate(ctx context.Context, req *rolev1.RoleUpdateReq) (res *rolev1.RoleUpdateRes, err error) { func (c *Controller) RoleUpdate(ctx context.Context, req *rolev1.RoleUpdateReq) (res *rolev1.RoleUpdateRes, err error) {
if err = role.RoleManage().Update(ctx, dto.RoleUpdateInput{Id: req.Id, Name: req.Name, Status: req.Status, MenuIds: req.MenuIds}); err != nil { if err = role.RoleManage().Update(ctx, dto.RoleUpdateInput{Id: req.Id, Name: req.Name, Status: req.Status, MenuIds: req.MenuIds}); err != nil {
return nil, err return nil, err
@ -40,7 +40,7 @@ func (c *Controller) RoleUpdate(ctx context.Context, req *rolev1.RoleUpdateReq)
return &rolev1.RoleUpdateRes{}, nil return &rolev1.RoleUpdateRes{}, nil
} }
// RoleDelete deletes a role. // RoleDelete 删除角色。
func (c *Controller) RoleDelete(ctx context.Context, req *rolev1.RoleDeleteReq) (res *rolev1.RoleDeleteRes, err error) { func (c *Controller) RoleDelete(ctx context.Context, req *rolev1.RoleDeleteReq) (res *rolev1.RoleDeleteRes, err error) {
if err = role.RoleManage().Delete(ctx, req.Id); err != nil { if err = role.RoleManage().Delete(ctx, req.Id); err != nil {
return nil, err return nil, err

View File

@ -1,5 +0,0 @@
// =================================================================================
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
// =================================================================================
package hello

View File

@ -1,15 +0,0 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package hello
import (
"service.xpcool.com/api/hello"
)
type ControllerV1 struct{}
func NewV1() hello.IHelloV1 {
return &ControllerV1{}
}

View File

@ -1,13 +0,0 @@
package hello
import (
"context"
"github.com/gogf/gf/v2/frame/g"
"service.xpcool.com/api/hello/v1"
)
func (c *ControllerV1) Hello(ctx context.Context, req *v1.HelloReq) (res *v1.HelloRes, err error) {
g.RequestFromCtx(ctx).Response.Writeln("Hello World!")
return
}

View File

@ -0,0 +1,64 @@
package house
import (
"context"
communityv1 "service.xpcool.com/api/house/community"
"service.xpcool.com/internal/model/dto"
community "service.xpcool.com/internal/service/house/community"
)
// CommunityList 分页查询小区。
func (c *Controller) CommunityList(ctx context.Context, req *communityv1.CommunityListReq) (res *communityv1.CommunityListRes, err error) {
list, total, err := community.Community().List(ctx, req.Page, req.Size, req.Keyword, req.Region)
if err != nil {
return nil, err
}
out := make([]*communityv1.CommunityItem, 0, len(list))
for i := range list {
e := &list[i]
out = append(out, &communityv1.CommunityItem{
Id: e.Id, Name: e.Name, Region: e.Region, BusinessDistrict: e.BusinessDistrict,
Address: e.Address, Lng: e.Lng, Lat: e.Lat, BuildYear: e.BuildYear,
Households: e.Households, PlotRatio: e.PlotRatio, GreenRate: e.GreenRate,
PropertyCompany: e.PropertyCompany, PropertyFee: e.PropertyFee, Developer: e.Developer, Source: e.Source,
})
}
return &communityv1.CommunityListRes{List: out, Total: total}, nil
}
// CommunityCreate 新增小区。
func (c *Controller) CommunityCreate(ctx context.Context, req *communityv1.CommunityCreateReq) (res *communityv1.CommunityCreateRes, err error) {
id, err := community.Community().Create(ctx, dto.HouseCommunityInput{
Name: req.Name, Region: req.Region, BusinessDistrict: req.BusinessDistrict,
Address: req.Address, Lng: req.Lng, Lat: req.Lat, BuildYear: req.BuildYear,
Households: req.Households, PlotRatio: req.PlotRatio, GreenRate: req.GreenRate,
PropertyCompany: req.PropertyCompany, PropertyFee: req.PropertyFee, Developer: req.Developer, Source: req.Source,
})
if err != nil {
return nil, err
}
return &communityv1.CommunityCreateRes{Id: id}, nil
}
// CommunityUpdate 更新小区。
func (c *Controller) CommunityUpdate(ctx context.Context, req *communityv1.CommunityUpdateReq) (res *communityv1.CommunityUpdateRes, err error) {
err = community.Community().Update(ctx, dto.HouseCommunityInput{
Id: req.Id, Name: req.Name, Region: req.Region, BusinessDistrict: req.BusinessDistrict,
Address: req.Address, Lng: req.Lng, Lat: req.Lat, BuildYear: req.BuildYear,
Households: req.Households, PlotRatio: req.PlotRatio, GreenRate: req.GreenRate,
PropertyCompany: req.PropertyCompany, PropertyFee: req.PropertyFee, Developer: req.Developer,
})
if err != nil {
return nil, err
}
return &communityv1.CommunityUpdateRes{}, nil
}
// CommunityDelete 删除小区。
func (c *Controller) CommunityDelete(ctx context.Context, req *communityv1.CommunityDeleteReq) (res *communityv1.CommunityDeleteRes, err error) {
if err = community.Community().Delete(ctx, req.Id); err != nil {
return nil, err
}
return &communityv1.CommunityDeleteRes{}, nil
}

View File

@ -0,0 +1,8 @@
// Package house 实现看房模块的管理端点,绑定在 admin 受权限保护分组下。
package house
// Controller 实现看房模块的所有端点。
type Controller struct{}
// New 创建看房模块控制器。
func New() *Controller { return &Controller{} }

View File

@ -0,0 +1,67 @@
package house
import (
"context"
dashboardv1 "service.xpcool.com/api/house/dashboard"
dashboard "service.xpcool.com/internal/service/house/dashboard"
)
// DashboardOverview 看板统计概览。
func (c *Controller) DashboardOverview(ctx context.Context, req *dashboardv1.OverviewReq) (res *dashboardv1.OverviewRes, err error) {
o, err := dashboard.Dashboard().Overview(ctx, req.Region)
if err != nil {
return nil, err
}
return &dashboardv1.OverviewRes{
CommunityCount: o.CommunityCount, ListingCount: o.ListingCount, BargainCount: o.BargainCount,
LowConfidence: o.LowConfidence, AvgUnitPrice: o.AvgUnitPrice, AvgTotalPrice: o.AvgTotalPrice, AvgListDays: o.AvgListDays,
}, nil
}
// DashboardMapPoints 地图点位聚合。
func (c *Controller) DashboardMapPoints(ctx context.Context, req *dashboardv1.MapPointsReq) (res *dashboardv1.MapPointsRes, err error) {
pts, err := dashboard.Dashboard().MapPoints(ctx, req.Region, req.PriceMin, req.PriceMax, req.Status)
if err != nil {
return nil, err
}
out := make([]*dashboardv1.MapPoint, 0, len(pts))
for i := range pts {
p := &pts[i]
out = append(out, &dashboardv1.MapPoint{
CommunityId: p.CommunityId, Name: p.Name, Region: p.Region, Lng: p.Lng, Lat: p.Lat,
AvgUnitPrice: p.AvgUnitPrice, ListingCount: p.ListingCount, BargainCount: p.BargainCount,
})
}
return &dashboardv1.MapPointsRes{Points: out}, nil
}
// DashboardPriceTrend 价格趋势聚合。
func (c *Controller) DashboardPriceTrend(ctx context.Context, req *dashboardv1.PriceTrendReq) (res *dashboardv1.PriceTrendRes, err error) {
trend, err := dashboard.Dashboard().PriceTrend(ctx, req.CommunityId, req.Region, req.Limit)
if err != nil {
return nil, err
}
out := make([]*dashboardv1.TrendPoint, 0, len(trend))
for i := range trend {
t := &trend[i]
out = append(out, &dashboardv1.TrendPoint{Date: t.Date, AvgListPrice: t.AvgListPrice, AvgDealPrice: t.AvgDealPrice})
}
return &dashboardv1.PriceTrendRes{Trend: out}, nil
}
// DashboardAggregateRegion 区域聚合。
func (c *Controller) DashboardAggregateRegion(ctx context.Context, req *dashboardv1.AggregateRegionReq) (res *dashboardv1.AggregateRegionRes, err error) {
list, err := dashboard.Dashboard().AggregateRegion(ctx)
if err != nil {
return nil, err
}
out := make([]*dashboardv1.RegionAgg, 0, len(list))
for i := range list {
r := &list[i]
out = append(out, &dashboardv1.RegionAgg{
Region: r.Region, AvgUnitPrice: r.AvgUnitPrice, ListingCount: r.ListingCount, BargainCount: r.BargainCount,
})
}
return &dashboardv1.AggregateRegionRes{List: out}, nil
}

View File

@ -0,0 +1,85 @@
package house
import (
"context"
listingv1 "service.xpcool.com/api/house/listing"
"service.xpcool.com/internal/model/dto"
listing "service.xpcool.com/internal/service/house/listing"
)
// ListingList 分页查询房源(带多维筛选)。
func (c *Controller) ListingList(ctx context.Context, req *listingv1.ListingListReq) (res *listingv1.ListingListRes, err error) {
list, total, err := listing.Listing().List(ctx, dto.HouseListingFilter{
Page: req.Page, Size: req.Size, CommunityId: req.CommunityId, Keyword: req.Keyword,
Layout: req.Layout, Region: req.Region, Source: req.Source,
PriceMin: req.PriceMin, PriceMax: req.PriceMax, AreaMin: req.AreaMin, AreaMax: req.AreaMax,
Status: req.Status, IsBargain: req.IsBargain, Confidence: req.Confidence,
})
if err != nil {
return nil, err
}
out := make([]*listingv1.ListingItem, 0, len(list))
for i := range list {
v := &list[i]
out = append(out, &listingv1.ListingItem{
Id: v.Id, CommunityId: v.CommunityId, CommunityName: v.CommunityName, BuildingId: v.BuildingId,
HouseNo: v.HouseNo, Layout: v.Layout, Area: v.Area, UsableArea: v.UsableArea,
Orientation: v.Orientation, Floor: v.Floor, TotalFloors: v.TotalFloors, Decoration: v.Decoration,
TotalPrice: v.TotalPrice, UnitPrice: v.UnitPrice, ListPrice: v.ListPrice,
Source: v.Source, SourceHouseId: v.SourceHouseId, SourceUrl: v.SourceUrl,
MatchGroupId: v.MatchGroupId, OnMarketDays: v.OnMarketDays, PriceChangeCount: v.PriceChangeCount,
Status: v.Status, Confidence: v.Confidence, IsBargain: v.IsBargain,
ListingTime: v.ListingTime, CreatedAt: v.CreatedAt,
})
}
return &listingv1.ListingListRes{List: out, Total: total}, nil
}
// ListingCreate 新增房源。
func (c *Controller) ListingCreate(ctx context.Context, req *listingv1.ListingCreateReq) (res *listingv1.ListingCreateRes, err error) {
id, err := listing.Listing().Create(ctx, dto.HouseListingInput{
CommunityId: req.CommunityId, BuildingId: req.BuildingId, HouseNo: req.HouseNo, Layout: req.Layout,
Area: req.Area, UsableArea: req.UsableArea, Orientation: req.Orientation, Floor: req.Floor,
TotalFloors: req.TotalFloors, Decoration: req.Decoration, TotalPrice: req.TotalPrice, UnitPrice: req.UnitPrice,
ListPrice: req.ListPrice, Source: req.Source, SourceHouseId: req.SourceHouseId, SourceUrl: req.SourceUrl,
MatchGroupId: req.MatchGroupId, OnMarketDays: req.OnMarketDays, PriceChangeCount: req.PriceChangeCount,
Status: req.Status, Confidence: req.Confidence, IsBargain: req.IsBargain,
})
if err != nil {
return nil, err
}
return &listingv1.ListingCreateRes{Id: id}, nil
}
// ListingUpdate 更新房源。
func (c *Controller) ListingUpdate(ctx context.Context, req *listingv1.ListingUpdateReq) (res *listingv1.ListingUpdateRes, err error) {
err = listing.Listing().Update(ctx, dto.HouseListingInput{
Id: req.Id, CommunityId: req.CommunityId, BuildingId: req.BuildingId, HouseNo: req.HouseNo,
Layout: req.Layout, Area: req.Area, UsableArea: req.UsableArea, Orientation: req.Orientation,
Floor: req.Floor, TotalFloors: req.TotalFloors, Decoration: req.Decoration, TotalPrice: req.TotalPrice,
UnitPrice: req.UnitPrice, ListPrice: req.ListPrice, MatchGroupId: req.MatchGroupId,
Status: req.Status, Confidence: req.Confidence, IsBargain: req.IsBargain,
})
if err != nil {
return nil, err
}
return &listingv1.ListingUpdateRes{}, nil
}
// ListingDelete 删除房源。
func (c *Controller) ListingDelete(ctx context.Context, req *listingv1.ListingDeleteReq) (res *listingv1.ListingDeleteRes, err error) {
if err = listing.Listing().Delete(ctx, req.Id); err != nil {
return nil, err
}
return &listingv1.ListingDeleteRes{}, nil
}
// ListingBatchMark 批量标记房源。
func (c *Controller) ListingBatchMark(ctx context.Context, req *listingv1.ListingBatchMarkReq) (res *listingv1.ListingBatchMarkRes, err error) {
affected, err := listing.Listing().BatchMark(ctx, req.Ids, req.Field, req.Value)
if err != nil {
return nil, err
}
return &listingv1.ListingBatchMarkRes{Affected: affected}, nil
}

View File

@ -1,11 +1,11 @@
// Package open implements the public open API (/api/open/v1). // Package open 实现公开的开放接口(/api/open
// These controllers are thin adapters over the common/tools Go packages and // 这些控制器是 common/tools Go 包的薄适配层,
// require no authentication. Each sub-feature lives in its own file here, // 无需认证。每个子功能位于本目录下的独立文件,
// mirroring api/open/v1/tools/<name>/index.go. // 与 api/open/tools/<name>/index.go 一一对应。
package open package open
// Controller implements the /api/open/v1 endpoints. // Controller 实现 /api/open 端点。
type Controller struct{} type Controller struct{}
// New creates an open API controller. // New 创建开放接口控制器。
func New() *Controller { return &Controller{} } func New() *Controller { return &Controller{} }

View File

@ -5,11 +5,11 @@ import (
"github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/frame/g"
ipapi "service.xpcool.com/api/open/v1/tools/ip" ipapi "service.xpcool.com/api/open/tools/ip"
"service.xpcool.com/common/tools/ip" "service.xpcool.com/common/tools/ip"
) )
// IP returns the caller's IP and whether it is an internal address. // IP 返回调用方 IP 及是否为内网地址。
func (c *Controller) IP(ctx context.Context, req *ipapi.IPReq) (res *ipapi.IPRes, err error) { func (c *Controller) IP(ctx context.Context, req *ipapi.IPReq) (res *ipapi.IPRes, err error) {
clientIP := g.RequestFromCtx(ctx).GetClientIp() clientIP := g.RequestFromCtx(ctx).GetClientIp()
return &ipapi.IPRes{IP: clientIP, Internal: ip.IsInternal(clientIP)}, nil return &ipapi.IPRes{IP: clientIP, Internal: ip.IsInternal(clientIP)}, nil

View File

@ -3,11 +3,11 @@ package open
import ( import (
"context" "context"
md5api "service.xpcool.com/api/open/v1/tools/md5" md5api "service.xpcool.com/api/open/tools/md5"
"service.xpcool.com/common/tools/md5" "service.xpcool.com/common/tools/md5"
) )
// MD5 computes the MD5 digest of the given text. // MD5 计算给定文本的 MD5 摘要。
func (c *Controller) MD5(ctx context.Context, req *md5api.MD5Req) (res *md5api.MD5Res, err error) { func (c *Controller) MD5(ctx context.Context, req *md5api.MD5Req) (res *md5api.MD5Res, err error) {
return &md5api.MD5Res{MD5: md5.Md5Hex(req.Text)}, nil return &md5api.MD5Res{MD5: md5.Md5Hex(req.Text)}, nil
} }

View File

@ -3,11 +3,11 @@ package open
import ( import (
"context" "context"
randomapi "service.xpcool.com/api/open/v1/tools/random" randomapi "service.xpcool.com/api/open/tools/random"
"service.xpcool.com/common/tools/random" "service.xpcool.com/common/tools/random"
) )
// Random generates a random string of the requested type and length. // Random 生成指定类型和长度的随机字符串。
func (c *Controller) Random(ctx context.Context, req *randomapi.RandomReq) (res *randomapi.RandomRes, err error) { func (c *Controller) Random(ctx context.Context, req *randomapi.RandomReq) (res *randomapi.RandomRes, err error) {
var value string var value string
switch req.Type { switch req.Type {

View File

@ -3,11 +3,11 @@ package open
import ( import (
"context" "context"
timeapi "service.xpcool.com/api/open/v1/tools/time" timeapi "service.xpcool.com/api/open/tools/time"
"service.xpcool.com/common/tools/timex" "service.xpcool.com/common/tools/timex"
) )
// Time returns the current server timestamp and formatted time. // Time 返回当前服务器时间戳与格式化时间。
func (c *Controller) Time(ctx context.Context, req *timeapi.TimeReq) (res *timeapi.TimeRes, err error) { func (c *Controller) Time(ctx context.Context, req *timeapi.TimeReq) (res *timeapi.TimeRes, err error) {
now := timex.Now() now := timex.Now()
return &timeapi.TimeRes{ return &timeapi.TimeRes{

View File

@ -3,11 +3,11 @@ package open
import ( import (
"context" "context"
uuidapi "service.xpcool.com/api/open/v1/tools/uuid" uuidapi "service.xpcool.com/api/open/tools/uuid"
"service.xpcool.com/common/tools/uuid" "service.xpcool.com/common/tools/uuid"
) )
// UUID generates a unique ID (32-char by default, 8-char when short=true). // UUID 生成唯一 ID默认 32 位short=true 时为 8 位)。
func (c *Controller) UUID(ctx context.Context, req *uuidapi.UUIDReq) (res *uuidapi.UUIDRes, err error) { func (c *Controller) UUID(ctx context.Context, req *uuidapi.UUIDReq) (res *uuidapi.UUIDRes, err error) {
if req.Short { if req.Short {
return &uuidapi.UUIDRes{UUID: uuid.Short(8)}, nil return &uuidapi.UUIDRes{UUID: uuid.Short(8)}, nil

View File

@ -2,9 +2,9 @@ package user
import ( import (
"context" "context"
authv1 "service.xpcool.com/api/user/v1/auth" authv1 "service.xpcool.com/api/user/auth"
"service.xpcool.com/internal/model/dto" "service.xpcool.com/internal/model/dto"
"service.xpcool.com/internal/service/user/auth" auth "service.xpcool.com/internal/service/user/auth"
) )
type Controller struct{} type Controller struct{}

View File

@ -0,0 +1,22 @@
// =================================================================================
// 本文件由 GoFrame CLI 工具自动生成,可按需修改。
// =================================================================================
package dao
import (
"service.xpcool.com/internal/dao/internal"
)
// adminLoginLogDao 是表 admin_login_log 的数据访问对象。
// 可在其上定义自定义方法以扩展其功能。
type adminLoginLogDao struct {
*internal.AdminLoginLogDao
}
var (
// AdminLoginLog 是表 admin_login_log 的全局可访问操作对象。
AdminLoginLog = adminLoginLogDao{internal.NewAdminLoginLogDao()}
)
// 在下方添加你的自定义方法。

View File

@ -1,5 +1,5 @@
// ================================================================================= // =================================================================================
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed. // 本文件由 GoFrame CLI 工具自动生成,可按需修改。
// ================================================================================= // =================================================================================
package dao package dao
@ -8,15 +8,15 @@ import (
"service.xpcool.com/internal/dao/internal" "service.xpcool.com/internal/dao/internal"
) )
// adminMenuDao is the data access object for the table admin_menu. // adminMenuDao 是表 admin_menu 的数据访问对象。
// You can define custom methods on it to extend its functionality as needed. // 可在其上定义自定义方法以扩展其功能。
type adminMenuDao struct { type adminMenuDao struct {
*internal.AdminMenuDao *internal.AdminMenuDao
} }
var ( var (
// AdminMenu is a globally accessible object for table admin_menu operations. // AdminMenu 是表 admin_menu 的全局可访问操作对象。
AdminMenu = adminMenuDao{internal.NewAdminMenuDao()} AdminMenu = adminMenuDao{internal.NewAdminMenuDao()}
) )
// Add your custom methods and functionality below. // 在下方添加你的自定义方法。

View File

@ -1,5 +1,5 @@
// ================================================================================= // =================================================================================
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed. // 本文件由 GoFrame CLI 工具自动生成,可按需修改。
// ================================================================================= // =================================================================================
package dao package dao
@ -8,15 +8,15 @@ import (
"service.xpcool.com/internal/dao/internal" "service.xpcool.com/internal/dao/internal"
) )
// adminOperationLogDao is the data access object for the table admin_operation_log. // adminOperationLogDao 是表 admin_operation_log 的数据访问对象。
// You can define custom methods on it to extend its functionality as needed. // 可在其上定义自定义方法以扩展其功能。
type adminOperationLogDao struct { type adminOperationLogDao struct {
*internal.AdminOperationLogDao *internal.AdminOperationLogDao
} }
var ( var (
// AdminOperationLog is a globally accessible object for table admin_operation_log operations. // AdminOperationLog 是表 admin_operation_log 的全局可访问操作对象。
AdminOperationLog = adminOperationLogDao{internal.NewAdminOperationLogDao()} AdminOperationLog = adminOperationLogDao{internal.NewAdminOperationLogDao()}
) )
// Add your custom methods and functionality below. // 在下方添加你的自定义方法。

View File

@ -1,5 +1,5 @@
// ================================================================================= // =================================================================================
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed. // 本文件由 GoFrame CLI 工具自动生成,可按需修改。
// ================================================================================= // =================================================================================
package dao package dao
@ -8,15 +8,15 @@ import (
"service.xpcool.com/internal/dao/internal" "service.xpcool.com/internal/dao/internal"
) )
// adminRoleDao is the data access object for the table admin_role. // adminRoleDao 是表 admin_role 的数据访问对象。
// You can define custom methods on it to extend its functionality as needed. // 可在其上定义自定义方法以扩展其功能。
type adminRoleDao struct { type adminRoleDao struct {
*internal.AdminRoleDao *internal.AdminRoleDao
} }
var ( var (
// AdminRole is a globally accessible object for table admin_role operations. // AdminRole 是表 admin_role 的全局可访问操作对象。
AdminRole = adminRoleDao{internal.NewAdminRoleDao()} AdminRole = adminRoleDao{internal.NewAdminRoleDao()}
) )
// Add your custom methods and functionality below. // 在下方添加你的自定义方法。

View File

@ -1,5 +1,5 @@
// ================================================================================= // =================================================================================
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed. // 本文件由 GoFrame CLI 工具自动生成,可按需修改。
// ================================================================================= // =================================================================================
package dao package dao
@ -8,15 +8,15 @@ import (
"service.xpcool.com/internal/dao/internal" "service.xpcool.com/internal/dao/internal"
) )
// adminRoleMenuDao is the data access object for the table admin_role_menu. // adminRoleMenuDao 是表 admin_role_menu 的数据访问对象。
// You can define custom methods on it to extend its functionality as needed. // 可在其上定义自定义方法以扩展其功能。
type adminRoleMenuDao struct { type adminRoleMenuDao struct {
*internal.AdminRoleMenuDao *internal.AdminRoleMenuDao
} }
var ( var (
// AdminRoleMenu is a globally accessible object for table admin_role_menu operations. // AdminRoleMenu 是表 admin_role_menu 的全局可访问操作对象。
AdminRoleMenu = adminRoleMenuDao{internal.NewAdminRoleMenuDao()} AdminRoleMenu = adminRoleMenuDao{internal.NewAdminRoleMenuDao()}
) )
// Add your custom methods and functionality below. // 在下方添加你的自定义方法。

View File

@ -1,5 +1,5 @@
// ================================================================================= // =================================================================================
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed. // 本文件由 GoFrame CLI 工具自动生成,可按需修改。
// ================================================================================= // =================================================================================
package dao package dao
@ -8,15 +8,15 @@ import (
"service.xpcool.com/internal/dao/internal" "service.xpcool.com/internal/dao/internal"
) )
// adminUserDao is the data access object for the table admin_user. // adminUserDao 是表 admin_user 的数据访问对象。
// You can define custom methods on it to extend its functionality as needed. // 可在其上定义自定义方法以扩展其功能。
type adminUserDao struct { type adminUserDao struct {
*internal.AdminUserDao *internal.AdminUserDao
} }
var ( var (
// AdminUser is a globally accessible object for table admin_user operations. // AdminUser 是表 admin_user 的全局可访问操作对象。
AdminUser = adminUserDao{internal.NewAdminUserDao()} AdminUser = adminUserDao{internal.NewAdminUserDao()}
) )
// Add your custom methods and functionality below. // 在下方添加你的自定义方法。

View File

@ -1,5 +1,5 @@
// ================================================================================= // =================================================================================
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed. // 本文件由 GoFrame CLI 工具自动生成,可按需修改。
// ================================================================================= // =================================================================================
package dao package dao
@ -8,15 +8,15 @@ import (
"service.xpcool.com/internal/dao/internal" "service.xpcool.com/internal/dao/internal"
) )
// adminUserRoleDao is the data access object for the table admin_user_role. // adminUserRoleDao 是表 admin_user_role 的数据访问对象。
// You can define custom methods on it to extend its functionality as needed. // 可在其上定义自定义方法以扩展其功能。
type adminUserRoleDao struct { type adminUserRoleDao struct {
*internal.AdminUserRoleDao *internal.AdminUserRoleDao
} }
var ( var (
// AdminUserRole is a globally accessible object for table admin_user_role operations. // AdminUserRole 是表 admin_user_role 的全局可访问操作对象。
AdminUserRole = adminUserRoleDao{internal.NewAdminUserRoleDao()} AdminUserRole = adminUserRoleDao{internal.NewAdminUserRoleDao()}
) )
// Add your custom methods and functionality below. // 在下方添加你的自定义方法。

View File

@ -1,5 +1,5 @@
// ================================================================================= // =================================================================================
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed. // 本文件由 GoFrame CLI 工具自动生成,可按需修改。
// ================================================================================= // =================================================================================
package dao package dao
@ -8,15 +8,15 @@ import (
"service.xpcool.com/internal/dao/internal" "service.xpcool.com/internal/dao/internal"
) )
// authRefreshSessionDao is the data access object for the table auth_refresh_session. // authRefreshSessionDao 是表 auth_refresh_session 的数据访问对象。
// You can define custom methods on it to extend its functionality as needed. // 可在其上定义自定义方法以扩展其功能。
type authRefreshSessionDao struct { type authRefreshSessionDao struct {
*internal.AuthRefreshSessionDao *internal.AuthRefreshSessionDao
} }
var ( var (
// AuthRefreshSession is a globally accessible object for table auth_refresh_session operations. // AuthRefreshSession 是表 auth_refresh_session 的全局可访问操作对象。
AuthRefreshSession = authRefreshSessionDao{internal.NewAuthRefreshSessionDao()} AuthRefreshSession = authRefreshSessionDao{internal.NewAuthRefreshSessionDao()}
) )
// Add your custom methods and functionality below. // 在下方添加你的自定义方法。

View File

@ -1,5 +1,5 @@
// ================================================================================= // =================================================================================
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed. // 本文件由 GoFrame CLI 工具自动生成,可按需修改。
// ================================================================================= // =================================================================================
package dao package dao
@ -8,15 +8,15 @@ import (
"service.xpcool.com/internal/dao/internal" "service.xpcool.com/internal/dao/internal"
) )
// contentDao is the data access object for the table content. // contentDao 是表 content 的数据访问对象。
// You can define custom methods on it to extend its functionality as needed. // 可在其上定义自定义方法以扩展其功能。
type contentDao struct { type contentDao struct {
*internal.ContentDao *internal.ContentDao
} }
var ( var (
// Content is a globally accessible object for table content operations. // Content 是表 content 的全局可访问操作对象。
Content = contentDao{internal.NewContentDao()} Content = contentDao{internal.NewContentDao()}
) )
// Add your custom methods and functionality below. // 在下方添加你的自定义方法。

View File

@ -0,0 +1,22 @@
// =================================================================================
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
// =================================================================================
package dao
import (
"service.xpcool.com/internal/dao/internal"
)
// houseBuildingDao is the data access object for the table house_building.
// You can define custom methods on it to extend its functionality as needed.
type houseBuildingDao struct {
*internal.HouseBuildingDao
}
var (
// HouseBuilding is a globally accessible object for table house_building operations.
HouseBuilding = houseBuildingDao{internal.NewHouseBuildingDao()}
)
// Add your custom methods and functionality below.

View File

@ -0,0 +1,22 @@
// =================================================================================
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
// =================================================================================
package dao
import (
"service.xpcool.com/internal/dao/internal"
)
// houseCommunityDao is the data access object for the table house_community.
// You can define custom methods on it to extend its functionality as needed.
type houseCommunityDao struct {
*internal.HouseCommunityDao
}
var (
// HouseCommunity is a globally accessible object for table house_community operations.
HouseCommunity = houseCommunityDao{internal.NewHouseCommunityDao()}
)
// Add your custom methods and functionality below.

View File

@ -0,0 +1,22 @@
// =================================================================================
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
// =================================================================================
package dao
import (
"service.xpcool.com/internal/dao/internal"
)
// houseCommunityFacilityDao is the data access object for the table house_community_facility.
// You can define custom methods on it to extend its functionality as needed.
type houseCommunityFacilityDao struct {
*internal.HouseCommunityFacilityDao
}
var (
// HouseCommunityFacility is a globally accessible object for table house_community_facility operations.
HouseCommunityFacility = houseCommunityFacilityDao{internal.NewHouseCommunityFacilityDao()}
)
// Add your custom methods and functionality below.

View File

@ -0,0 +1,22 @@
// =================================================================================
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
// =================================================================================
package dao
import (
"service.xpcool.com/internal/dao/internal"
)
// houseFacilityDao is the data access object for the table house_facility.
// You can define custom methods on it to extend its functionality as needed.
type houseFacilityDao struct {
*internal.HouseFacilityDao
}
var (
// HouseFacility is a globally accessible object for table house_facility operations.
HouseFacility = houseFacilityDao{internal.NewHouseFacilityDao()}
)
// Add your custom methods and functionality below.

View File

@ -0,0 +1,22 @@
// =================================================================================
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
// =================================================================================
package dao
import (
"service.xpcool.com/internal/dao/internal"
)
// houseListingDao is the data access object for the table house_listing.
// You can define custom methods on it to extend its functionality as needed.
type houseListingDao struct {
*internal.HouseListingDao
}
var (
// HouseListing is a globally accessible object for table house_listing operations.
HouseListing = houseListingDao{internal.NewHouseListingDao()}
)
// Add your custom methods and functionality below.

View File

@ -0,0 +1,22 @@
// =================================================================================
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
// =================================================================================
package dao
import (
"service.xpcool.com/internal/dao/internal"
)
// housePreferenceDao is the data access object for the table house_preference.
// You can define custom methods on it to extend its functionality as needed.
type housePreferenceDao struct {
*internal.HousePreferenceDao
}
var (
// HousePreference is a globally accessible object for table house_preference operations.
HousePreference = housePreferenceDao{internal.NewHousePreferenceDao()}
)
// Add your custom methods and functionality below.

View File

@ -0,0 +1,22 @@
// =================================================================================
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
// =================================================================================
package dao
import (
"service.xpcool.com/internal/dao/internal"
)
// housePriceSnapshotDao is the data access object for the table house_price_snapshot.
// You can define custom methods on it to extend its functionality as needed.
type housePriceSnapshotDao struct {
*internal.HousePriceSnapshotDao
}
var (
// HousePriceSnapshot is a globally accessible object for table house_price_snapshot operations.
HousePriceSnapshot = housePriceSnapshotDao{internal.NewHousePriceSnapshotDao()}
)
// Add your custom methods and functionality below.

View File

@ -0,0 +1,22 @@
// =================================================================================
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
// =================================================================================
package dao
import (
"service.xpcool.com/internal/dao/internal"
)
// houseSchoolDistrictDao is the data access object for the table house_school_district.
// You can define custom methods on it to extend its functionality as needed.
type houseSchoolDistrictDao struct {
*internal.HouseSchoolDistrictDao
}
var (
// HouseSchoolDistrict is a globally accessible object for table house_school_district operations.
HouseSchoolDistrict = houseSchoolDistrictDao{internal.NewHouseSchoolDistrictDao()}
)
// Add your custom methods and functionality below.

View File

@ -0,0 +1,22 @@
// =================================================================================
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
// =================================================================================
package dao
import (
"service.xpcool.com/internal/dao/internal"
)
// houseTransactionDao is the data access object for the table house_transaction.
// You can define custom methods on it to extend its functionality as needed.
type houseTransactionDao struct {
*internal.HouseTransactionDao
}
var (
// HouseTransaction is a globally accessible object for table house_transaction operations.
HouseTransaction = houseTransactionDao{internal.NewHouseTransactionDao()}
)
// Add your custom methods and functionality below.

View File

@ -0,0 +1,91 @@
// ==========================================================================
// 本文件由 GoFrame CLI 工具生成并维护,请勿编辑。
// ==========================================================================
package internal
import (
"context"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
)
// AdminLoginLogDao 是表 admin_login_log 的数据访问对象。
type AdminLoginLogDao 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 AdminLoginLogColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// AdminLoginLogColumns 定义并存储表 admin_login_log 的列名。
type AdminLoginLogColumns struct {
Id string //
Username string //
Ip string //
UserAgent string //
Status string //
FailReason string //
CreatedAt string //
}
// adminLoginLogColumns 保存表 admin_login_log 的列信息。
var adminLoginLogColumns = AdminLoginLogColumns{
Id: "id",
Username: "username",
Ip: "ip",
UserAgent: "user_agent",
Status: "status",
FailReason: "fail_reason",
CreatedAt: "created_at",
}
// NewAdminLoginLogDao 创建并返回一个新的表数据访问 DAO 对象。
func NewAdminLoginLogDao(handlers ...gdb.ModelHandler) *AdminLoginLogDao {
return &AdminLoginLogDao{
group: "default",
table: "admin_login_log",
columns: adminLoginLogColumns,
handlers: handlers,
}
}
// DB 获取并返回当前 DAO 的底层原始数据库管理对象。
func (dao *AdminLoginLogDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table 返回当前 DAO 的表名。
func (dao *AdminLoginLogDao) Table() string {
return dao.table
}
// Columns 返回当前 DAO 的全部列名。
func (dao *AdminLoginLogDao) Columns() AdminLoginLogColumns {
return dao.columns
}
// Group 返回当前 DAO 的数据库配置组名。
func (dao *AdminLoginLogDao) Group() string {
return dao.group
}
// Ctx 为当前 DAO 创建并返回一个 Model自动设置本次操作的上下文。
func (dao *AdminLoginLogDao) 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 *AdminLoginLogDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}

View File

@ -1,5 +1,5 @@
// ========================================================================== // ==========================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. // 本文件由 GoFrame CLI 工具生成并维护,请勿编辑。
// ========================================================================== // ==========================================================================
package internal package internal
@ -11,7 +11,7 @@ import (
"github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/frame/g"
) )
// AdminMenuDao is the data access object for the table admin_menu. // AdminMenuDao 是表 admin_menu 的数据访问对象。
type AdminMenuDao struct { type AdminMenuDao struct {
table string // table is the underlying table name of the DAO. table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO. group string // group is the database configuration group name of the current DAO.
@ -19,7 +19,7 @@ type AdminMenuDao struct {
handlers []gdb.ModelHandler // handlers for customized model modification. handlers []gdb.ModelHandler // handlers for customized model modification.
} }
// AdminMenuColumns defines and stores column names for the table admin_menu. // AdminMenuColumns 定义并存储表 admin_menu 的列名。
type AdminMenuColumns struct { type AdminMenuColumns struct {
Id string // Id string //
ParentId string // ParentId string //
@ -34,7 +34,7 @@ type AdminMenuColumns struct {
DeletedAt string // DeletedAt string //
} }
// adminMenuColumns holds the columns for the table admin_menu. // adminMenuColumns 保存表 admin_menu 的列信息。
var adminMenuColumns = AdminMenuColumns{ var adminMenuColumns = AdminMenuColumns{
Id: "id", Id: "id",
ParentId: "parent_id", ParentId: "parent_id",
@ -49,7 +49,7 @@ var adminMenuColumns = AdminMenuColumns{
DeletedAt: "deleted_at", DeletedAt: "deleted_at",
} }
// NewAdminMenuDao creates and returns a new DAO object for table data access. // NewAdminMenuDao 创建并返回一个新的表数据访问 DAO 对象。
func NewAdminMenuDao(handlers ...gdb.ModelHandler) *AdminMenuDao { func NewAdminMenuDao(handlers ...gdb.ModelHandler) *AdminMenuDao {
return &AdminMenuDao{ return &AdminMenuDao{
group: "default", group: "default",
@ -59,27 +59,27 @@ func NewAdminMenuDao(handlers ...gdb.ModelHandler) *AdminMenuDao {
} }
} }
// DB retrieves and returns the underlying raw database management object of the current DAO. // DB 获取并返回当前 DAO 的底层原始数据库管理对象。
func (dao *AdminMenuDao) DB() gdb.DB { func (dao *AdminMenuDao) DB() gdb.DB {
return g.DB(dao.group) return g.DB(dao.group)
} }
// Table returns the table name of the current DAO. // Table 返回当前 DAO 的表名。
func (dao *AdminMenuDao) Table() string { func (dao *AdminMenuDao) Table() string {
return dao.table return dao.table
} }
// Columns returns all column names of the current DAO. // Columns 返回当前 DAO 的全部列名。
func (dao *AdminMenuDao) Columns() AdminMenuColumns { func (dao *AdminMenuDao) Columns() AdminMenuColumns {
return dao.columns return dao.columns
} }
// Group returns the database configuration group name of the current DAO. // Group 返回当前 DAO 的数据库配置组名。
func (dao *AdminMenuDao) Group() string { func (dao *AdminMenuDao) Group() string {
return dao.group return dao.group
} }
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. // Ctx 为当前 DAO 创建并返回一个 Model自动设置本次操作的上下文。
func (dao *AdminMenuDao) Ctx(ctx context.Context) *gdb.Model { func (dao *AdminMenuDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table) model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers { for _, handler := range dao.handlers {
@ -88,12 +88,12 @@ func (dao *AdminMenuDao) Ctx(ctx context.Context) *gdb.Model {
return model.Safe().Ctx(ctx) return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction 使用函数 f 包裹事务逻辑。
// It rolls back the transaction and returns the error if function f returns a non-nil error. // 若 f 返回非 nil 错误,则回滚事务并返回该错误。
// It commits the transaction and returns nil if function f returns nil. // 若 f 返回 nil则提交事务并返回 nil。
// //
// Note: Do not commit or roll back the transaction in function f, // 注意:请勿在函数 f 内提交或回滚事务,
// as it is automatically handled by this function. // 该函数会自动处理。
func (dao *AdminMenuDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { func (dao *AdminMenuDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f) return dao.Ctx(ctx).Transaction(ctx, f)
} }

View File

@ -1,5 +1,5 @@
// ========================================================================== // ==========================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. // 本文件由 GoFrame CLI 工具生成并维护,请勿编辑。
// ========================================================================== // ==========================================================================
package internal package internal
@ -11,7 +11,7 @@ import (
"github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/frame/g"
) )
// AdminOperationLogDao is the data access object for the table admin_operation_log. // AdminOperationLogDao 是表 admin_operation_log 的数据访问对象。
type AdminOperationLogDao struct { type AdminOperationLogDao struct {
table string // table is the underlying table name of the DAO. table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO. group string // group is the database configuration group name of the current DAO.
@ -19,7 +19,7 @@ type AdminOperationLogDao struct {
handlers []gdb.ModelHandler // handlers for customized model modification. handlers []gdb.ModelHandler // handlers for customized model modification.
} }
// AdminOperationLogColumns defines and stores column names for the table admin_operation_log. // AdminOperationLogColumns 定义并存储表 admin_operation_log 的列名。
type AdminOperationLogColumns struct { type AdminOperationLogColumns struct {
Id string // Id string //
AdminUserId string // AdminUserId string //
@ -35,7 +35,7 @@ type AdminOperationLogColumns struct {
DeletedAt string // DeletedAt string //
} }
// adminOperationLogColumns holds the columns for the table admin_operation_log. // adminOperationLogColumns 保存表 admin_operation_log 的列信息。
var adminOperationLogColumns = AdminOperationLogColumns{ var adminOperationLogColumns = AdminOperationLogColumns{
Id: "id", Id: "id",
AdminUserId: "admin_user_id", AdminUserId: "admin_user_id",
@ -51,7 +51,7 @@ var adminOperationLogColumns = AdminOperationLogColumns{
DeletedAt: "deleted_at", DeletedAt: "deleted_at",
} }
// NewAdminOperationLogDao creates and returns a new DAO object for table data access. // NewAdminOperationLogDao 创建并返回一个新的表数据访问 DAO 对象。
func NewAdminOperationLogDao(handlers ...gdb.ModelHandler) *AdminOperationLogDao { func NewAdminOperationLogDao(handlers ...gdb.ModelHandler) *AdminOperationLogDao {
return &AdminOperationLogDao{ return &AdminOperationLogDao{
group: "default", group: "default",
@ -61,27 +61,27 @@ func NewAdminOperationLogDao(handlers ...gdb.ModelHandler) *AdminOperationLogDao
} }
} }
// DB retrieves and returns the underlying raw database management object of the current DAO. // DB 获取并返回当前 DAO 的底层原始数据库管理对象。
func (dao *AdminOperationLogDao) DB() gdb.DB { func (dao *AdminOperationLogDao) DB() gdb.DB {
return g.DB(dao.group) return g.DB(dao.group)
} }
// Table returns the table name of the current DAO. // Table 返回当前 DAO 的表名。
func (dao *AdminOperationLogDao) Table() string { func (dao *AdminOperationLogDao) Table() string {
return dao.table return dao.table
} }
// Columns returns all column names of the current DAO. // Columns 返回当前 DAO 的全部列名。
func (dao *AdminOperationLogDao) Columns() AdminOperationLogColumns { func (dao *AdminOperationLogDao) Columns() AdminOperationLogColumns {
return dao.columns return dao.columns
} }
// Group returns the database configuration group name of the current DAO. // Group 返回当前 DAO 的数据库配置组名。
func (dao *AdminOperationLogDao) Group() string { func (dao *AdminOperationLogDao) Group() string {
return dao.group return dao.group
} }
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. // Ctx 为当前 DAO 创建并返回一个 Model自动设置本次操作的上下文。
func (dao *AdminOperationLogDao) Ctx(ctx context.Context) *gdb.Model { func (dao *AdminOperationLogDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table) model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers { for _, handler := range dao.handlers {
@ -90,12 +90,12 @@ func (dao *AdminOperationLogDao) Ctx(ctx context.Context) *gdb.Model {
return model.Safe().Ctx(ctx) return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction 使用函数 f 包裹事务逻辑。
// It rolls back the transaction and returns the error if function f returns a non-nil error. // 若 f 返回非 nil 错误,则回滚事务并返回该错误。
// It commits the transaction and returns nil if function f returns nil. // 若 f 返回 nil则提交事务并返回 nil。
// //
// Note: Do not commit or roll back the transaction in function f, // 注意:请勿在函数 f 内提交或回滚事务,
// as it is automatically handled by this function. // 该函数会自动处理。
func (dao *AdminOperationLogDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { func (dao *AdminOperationLogDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f) return dao.Ctx(ctx).Transaction(ctx, f)
} }

View File

@ -1,5 +1,5 @@
// ========================================================================== // ==========================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. // 本文件由 GoFrame CLI 工具生成并维护,请勿编辑。
// ========================================================================== // ==========================================================================
package internal package internal
@ -11,7 +11,7 @@ import (
"github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/frame/g"
) )
// AdminRoleDao is the data access object for the table admin_role. // AdminRoleDao 是表 admin_role 的数据访问对象。
type AdminRoleDao struct { type AdminRoleDao struct {
table string // table is the underlying table name of the DAO. table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO. group string // group is the database configuration group name of the current DAO.
@ -19,7 +19,7 @@ type AdminRoleDao struct {
handlers []gdb.ModelHandler // handlers for customized model modification. handlers []gdb.ModelHandler // handlers for customized model modification.
} }
// AdminRoleColumns defines and stores column names for the table admin_role. // AdminRoleColumns 定义并存储表 admin_role 的列名。
type AdminRoleColumns struct { type AdminRoleColumns struct {
Id string // Id string //
Code string // Code string //
@ -30,7 +30,7 @@ type AdminRoleColumns struct {
DeletedAt string // DeletedAt string //
} }
// adminRoleColumns holds the columns for the table admin_role. // adminRoleColumns 保存表 admin_role 的列信息。
var adminRoleColumns = AdminRoleColumns{ var adminRoleColumns = AdminRoleColumns{
Id: "id", Id: "id",
Code: "code", Code: "code",
@ -41,7 +41,7 @@ var adminRoleColumns = AdminRoleColumns{
DeletedAt: "deleted_at", DeletedAt: "deleted_at",
} }
// NewAdminRoleDao creates and returns a new DAO object for table data access. // NewAdminRoleDao 创建并返回一个新的表数据访问 DAO 对象。
func NewAdminRoleDao(handlers ...gdb.ModelHandler) *AdminRoleDao { func NewAdminRoleDao(handlers ...gdb.ModelHandler) *AdminRoleDao {
return &AdminRoleDao{ return &AdminRoleDao{
group: "default", group: "default",
@ -51,27 +51,27 @@ func NewAdminRoleDao(handlers ...gdb.ModelHandler) *AdminRoleDao {
} }
} }
// DB retrieves and returns the underlying raw database management object of the current DAO. // DB 获取并返回当前 DAO 的底层原始数据库管理对象。
func (dao *AdminRoleDao) DB() gdb.DB { func (dao *AdminRoleDao) DB() gdb.DB {
return g.DB(dao.group) return g.DB(dao.group)
} }
// Table returns the table name of the current DAO. // Table 返回当前 DAO 的表名。
func (dao *AdminRoleDao) Table() string { func (dao *AdminRoleDao) Table() string {
return dao.table return dao.table
} }
// Columns returns all column names of the current DAO. // Columns 返回当前 DAO 的全部列名。
func (dao *AdminRoleDao) Columns() AdminRoleColumns { func (dao *AdminRoleDao) Columns() AdminRoleColumns {
return dao.columns return dao.columns
} }
// Group returns the database configuration group name of the current DAO. // Group 返回当前 DAO 的数据库配置组名。
func (dao *AdminRoleDao) Group() string { func (dao *AdminRoleDao) Group() string {
return dao.group return dao.group
} }
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. // Ctx 为当前 DAO 创建并返回一个 Model自动设置本次操作的上下文。
func (dao *AdminRoleDao) Ctx(ctx context.Context) *gdb.Model { func (dao *AdminRoleDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table) model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers { for _, handler := range dao.handlers {
@ -80,12 +80,12 @@ func (dao *AdminRoleDao) Ctx(ctx context.Context) *gdb.Model {
return model.Safe().Ctx(ctx) return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction 使用函数 f 包裹事务逻辑。
// It rolls back the transaction and returns the error if function f returns a non-nil error. // 若 f 返回非 nil 错误,则回滚事务并返回该错误。
// It commits the transaction and returns nil if function f returns nil. // 若 f 返回 nil则提交事务并返回 nil。
// //
// Note: Do not commit or roll back the transaction in function f, // 注意:请勿在函数 f 内提交或回滚事务,
// as it is automatically handled by this function. // 该函数会自动处理。
func (dao *AdminRoleDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { func (dao *AdminRoleDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f) return dao.Ctx(ctx).Transaction(ctx, f)
} }

View File

@ -1,5 +1,5 @@
// ========================================================================== // ==========================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. // 本文件由 GoFrame CLI 工具生成并维护,请勿编辑。
// ========================================================================== // ==========================================================================
package internal package internal
@ -11,7 +11,7 @@ import (
"github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/frame/g"
) )
// AdminRoleMenuDao is the data access object for the table admin_role_menu. // AdminRoleMenuDao 是表 admin_role_menu 的数据访问对象。
type AdminRoleMenuDao struct { type AdminRoleMenuDao struct {
table string // table is the underlying table name of the DAO. table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO. group string // group is the database configuration group name of the current DAO.
@ -19,7 +19,7 @@ type AdminRoleMenuDao struct {
handlers []gdb.ModelHandler // handlers for customized model modification. handlers []gdb.ModelHandler // handlers for customized model modification.
} }
// AdminRoleMenuColumns defines and stores column names for the table admin_role_menu. // AdminRoleMenuColumns 定义并存储表 admin_role_menu 的列名。
type AdminRoleMenuColumns struct { type AdminRoleMenuColumns struct {
Id string // Id string //
RoleId string // RoleId string //
@ -29,7 +29,7 @@ type AdminRoleMenuColumns struct {
DeletedAt string // DeletedAt string //
} }
// adminRoleMenuColumns holds the columns for the table admin_role_menu. // adminRoleMenuColumns 保存表 admin_role_menu 的列信息。
var adminRoleMenuColumns = AdminRoleMenuColumns{ var adminRoleMenuColumns = AdminRoleMenuColumns{
Id: "id", Id: "id",
RoleId: "role_id", RoleId: "role_id",
@ -39,7 +39,7 @@ var adminRoleMenuColumns = AdminRoleMenuColumns{
DeletedAt: "deleted_at", DeletedAt: "deleted_at",
} }
// NewAdminRoleMenuDao creates and returns a new DAO object for table data access. // NewAdminRoleMenuDao 创建并返回一个新的表数据访问 DAO 对象。
func NewAdminRoleMenuDao(handlers ...gdb.ModelHandler) *AdminRoleMenuDao { func NewAdminRoleMenuDao(handlers ...gdb.ModelHandler) *AdminRoleMenuDao {
return &AdminRoleMenuDao{ return &AdminRoleMenuDao{
group: "default", group: "default",
@ -49,27 +49,27 @@ func NewAdminRoleMenuDao(handlers ...gdb.ModelHandler) *AdminRoleMenuDao {
} }
} }
// DB retrieves and returns the underlying raw database management object of the current DAO. // DB 获取并返回当前 DAO 的底层原始数据库管理对象。
func (dao *AdminRoleMenuDao) DB() gdb.DB { func (dao *AdminRoleMenuDao) DB() gdb.DB {
return g.DB(dao.group) return g.DB(dao.group)
} }
// Table returns the table name of the current DAO. // Table 返回当前 DAO 的表名。
func (dao *AdminRoleMenuDao) Table() string { func (dao *AdminRoleMenuDao) Table() string {
return dao.table return dao.table
} }
// Columns returns all column names of the current DAO. // Columns 返回当前 DAO 的全部列名。
func (dao *AdminRoleMenuDao) Columns() AdminRoleMenuColumns { func (dao *AdminRoleMenuDao) Columns() AdminRoleMenuColumns {
return dao.columns return dao.columns
} }
// Group returns the database configuration group name of the current DAO. // Group 返回当前 DAO 的数据库配置组名。
func (dao *AdminRoleMenuDao) Group() string { func (dao *AdminRoleMenuDao) Group() string {
return dao.group return dao.group
} }
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. // Ctx 为当前 DAO 创建并返回一个 Model自动设置本次操作的上下文。
func (dao *AdminRoleMenuDao) Ctx(ctx context.Context) *gdb.Model { func (dao *AdminRoleMenuDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table) model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers { for _, handler := range dao.handlers {
@ -78,12 +78,12 @@ func (dao *AdminRoleMenuDao) Ctx(ctx context.Context) *gdb.Model {
return model.Safe().Ctx(ctx) return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction 使用函数 f 包裹事务逻辑。
// It rolls back the transaction and returns the error if function f returns a non-nil error. // 若 f 返回非 nil 错误,则回滚事务并返回该错误。
// It commits the transaction and returns nil if function f returns nil. // 若 f 返回 nil则提交事务并返回 nil。
// //
// Note: Do not commit or roll back the transaction in function f, // 注意:请勿在函数 f 内提交或回滚事务,
// as it is automatically handled by this function. // 该函数会自动处理。
func (dao *AdminRoleMenuDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { func (dao *AdminRoleMenuDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f) return dao.Ctx(ctx).Transaction(ctx, f)
} }

View File

@ -1,5 +1,5 @@
// ========================================================================== // ==========================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. // 本文件由 GoFrame CLI 工具生成并维护,请勿编辑。
// ========================================================================== // ==========================================================================
package internal package internal
@ -11,7 +11,7 @@ import (
"github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/frame/g"
) )
// AdminUserDao is the data access object for the table admin_user. // AdminUserDao 是表 admin_user 的数据访问对象。
type AdminUserDao struct { type AdminUserDao struct {
table string // table is the underlying table name of the DAO. table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO. group string // group is the database configuration group name of the current DAO.
@ -19,7 +19,7 @@ type AdminUserDao struct {
handlers []gdb.ModelHandler // handlers for customized model modification. handlers []gdb.ModelHandler // handlers for customized model modification.
} }
// AdminUserColumns defines and stores column names for the table admin_user. // AdminUserColumns 定义并存储表 admin_user 的列名。
type AdminUserColumns struct { type AdminUserColumns struct {
Id string // Id string //
Username string // Username string //
@ -32,7 +32,7 @@ type AdminUserColumns struct {
DeletedAt string // DeletedAt string //
} }
// adminUserColumns holds the columns for the table admin_user. // adminUserColumns 保存表 admin_user 的列信息。
var adminUserColumns = AdminUserColumns{ var adminUserColumns = AdminUserColumns{
Id: "id", Id: "id",
Username: "username", Username: "username",
@ -45,7 +45,7 @@ var adminUserColumns = AdminUserColumns{
DeletedAt: "deleted_at", DeletedAt: "deleted_at",
} }
// NewAdminUserDao creates and returns a new DAO object for table data access. // NewAdminUserDao 创建并返回一个新的表数据访问 DAO 对象。
func NewAdminUserDao(handlers ...gdb.ModelHandler) *AdminUserDao { func NewAdminUserDao(handlers ...gdb.ModelHandler) *AdminUserDao {
return &AdminUserDao{ return &AdminUserDao{
group: "default", group: "default",
@ -55,27 +55,27 @@ func NewAdminUserDao(handlers ...gdb.ModelHandler) *AdminUserDao {
} }
} }
// DB retrieves and returns the underlying raw database management object of the current DAO. // DB 获取并返回当前 DAO 的底层原始数据库管理对象。
func (dao *AdminUserDao) DB() gdb.DB { func (dao *AdminUserDao) DB() gdb.DB {
return g.DB(dao.group) return g.DB(dao.group)
} }
// Table returns the table name of the current DAO. // Table 返回当前 DAO 的表名。
func (dao *AdminUserDao) Table() string { func (dao *AdminUserDao) Table() string {
return dao.table return dao.table
} }
// Columns returns all column names of the current DAO. // Columns 返回当前 DAO 的全部列名。
func (dao *AdminUserDao) Columns() AdminUserColumns { func (dao *AdminUserDao) Columns() AdminUserColumns {
return dao.columns return dao.columns
} }
// Group returns the database configuration group name of the current DAO. // Group 返回当前 DAO 的数据库配置组名。
func (dao *AdminUserDao) Group() string { func (dao *AdminUserDao) Group() string {
return dao.group return dao.group
} }
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. // Ctx 为当前 DAO 创建并返回一个 Model自动设置本次操作的上下文。
func (dao *AdminUserDao) Ctx(ctx context.Context) *gdb.Model { func (dao *AdminUserDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table) model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers { for _, handler := range dao.handlers {
@ -84,12 +84,12 @@ func (dao *AdminUserDao) Ctx(ctx context.Context) *gdb.Model {
return model.Safe().Ctx(ctx) return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction 使用函数 f 包裹事务逻辑。
// It rolls back the transaction and returns the error if function f returns a non-nil error. // 若 f 返回非 nil 错误,则回滚事务并返回该错误。
// It commits the transaction and returns nil if function f returns nil. // 若 f 返回 nil则提交事务并返回 nil。
// //
// Note: Do not commit or roll back the transaction in function f, // 注意:请勿在函数 f 内提交或回滚事务,
// as it is automatically handled by this function. // 该函数会自动处理。
func (dao *AdminUserDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { func (dao *AdminUserDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f) return dao.Ctx(ctx).Transaction(ctx, f)
} }

View File

@ -1,5 +1,5 @@
// ========================================================================== // ==========================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. // 本文件由 GoFrame CLI 工具生成并维护,请勿编辑。
// ========================================================================== // ==========================================================================
package internal package internal
@ -11,7 +11,7 @@ import (
"github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/frame/g"
) )
// AdminUserRoleDao is the data access object for the table admin_user_role. // AdminUserRoleDao 是表 admin_user_role 的数据访问对象。
type AdminUserRoleDao struct { type AdminUserRoleDao struct {
table string // table is the underlying table name of the DAO. table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO. group string // group is the database configuration group name of the current DAO.
@ -19,7 +19,7 @@ type AdminUserRoleDao struct {
handlers []gdb.ModelHandler // handlers for customized model modification. handlers []gdb.ModelHandler // handlers for customized model modification.
} }
// AdminUserRoleColumns defines and stores column names for the table admin_user_role. // AdminUserRoleColumns 定义并存储表 admin_user_role 的列名。
type AdminUserRoleColumns struct { type AdminUserRoleColumns struct {
Id string // Id string //
AdminUserId string // AdminUserId string //
@ -29,7 +29,7 @@ type AdminUserRoleColumns struct {
DeletedAt string // DeletedAt string //
} }
// adminUserRoleColumns holds the columns for the table admin_user_role. // adminUserRoleColumns 保存表 admin_user_role 的列信息。
var adminUserRoleColumns = AdminUserRoleColumns{ var adminUserRoleColumns = AdminUserRoleColumns{
Id: "id", Id: "id",
AdminUserId: "admin_user_id", AdminUserId: "admin_user_id",
@ -39,7 +39,7 @@ var adminUserRoleColumns = AdminUserRoleColumns{
DeletedAt: "deleted_at", DeletedAt: "deleted_at",
} }
// NewAdminUserRoleDao creates and returns a new DAO object for table data access. // NewAdminUserRoleDao 创建并返回一个新的表数据访问 DAO 对象。
func NewAdminUserRoleDao(handlers ...gdb.ModelHandler) *AdminUserRoleDao { func NewAdminUserRoleDao(handlers ...gdb.ModelHandler) *AdminUserRoleDao {
return &AdminUserRoleDao{ return &AdminUserRoleDao{
group: "default", group: "default",
@ -49,27 +49,27 @@ func NewAdminUserRoleDao(handlers ...gdb.ModelHandler) *AdminUserRoleDao {
} }
} }
// DB retrieves and returns the underlying raw database management object of the current DAO. // DB 获取并返回当前 DAO 的底层原始数据库管理对象。
func (dao *AdminUserRoleDao) DB() gdb.DB { func (dao *AdminUserRoleDao) DB() gdb.DB {
return g.DB(dao.group) return g.DB(dao.group)
} }
// Table returns the table name of the current DAO. // Table 返回当前 DAO 的表名。
func (dao *AdminUserRoleDao) Table() string { func (dao *AdminUserRoleDao) Table() string {
return dao.table return dao.table
} }
// Columns returns all column names of the current DAO. // Columns 返回当前 DAO 的全部列名。
func (dao *AdminUserRoleDao) Columns() AdminUserRoleColumns { func (dao *AdminUserRoleDao) Columns() AdminUserRoleColumns {
return dao.columns return dao.columns
} }
// Group returns the database configuration group name of the current DAO. // Group 返回当前 DAO 的数据库配置组名。
func (dao *AdminUserRoleDao) Group() string { func (dao *AdminUserRoleDao) Group() string {
return dao.group return dao.group
} }
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. // Ctx 为当前 DAO 创建并返回一个 Model自动设置本次操作的上下文。
func (dao *AdminUserRoleDao) Ctx(ctx context.Context) *gdb.Model { func (dao *AdminUserRoleDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table) model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers { for _, handler := range dao.handlers {
@ -78,12 +78,12 @@ func (dao *AdminUserRoleDao) Ctx(ctx context.Context) *gdb.Model {
return model.Safe().Ctx(ctx) return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction 使用函数 f 包裹事务逻辑。
// It rolls back the transaction and returns the error if function f returns a non-nil error. // 若 f 返回非 nil 错误,则回滚事务并返回该错误。
// It commits the transaction and returns nil if function f returns nil. // 若 f 返回 nil则提交事务并返回 nil。
// //
// Note: Do not commit or roll back the transaction in function f, // 注意:请勿在函数 f 内提交或回滚事务,
// as it is automatically handled by this function. // 该函数会自动处理。
func (dao *AdminUserRoleDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { func (dao *AdminUserRoleDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f) return dao.Ctx(ctx).Transaction(ctx, f)
} }

View File

@ -1,5 +1,5 @@
// ========================================================================== // ==========================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. // 本文件由 GoFrame CLI 工具生成并维护,请勿编辑。
// ========================================================================== // ==========================================================================
package internal package internal
@ -11,7 +11,7 @@ import (
"github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/frame/g"
) )
// AuthRefreshSessionDao is the data access object for the table auth_refresh_session. // AuthRefreshSessionDao 是表 auth_refresh_session 的数据访问对象。
type AuthRefreshSessionDao struct { type AuthRefreshSessionDao struct {
table string // table is the underlying table name of the DAO. table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO. group string // group is the database configuration group name of the current DAO.
@ -19,7 +19,7 @@ type AuthRefreshSessionDao struct {
handlers []gdb.ModelHandler // handlers for customized model modification. handlers []gdb.ModelHandler // handlers for customized model modification.
} }
// AuthRefreshSessionColumns defines and stores column names for the table auth_refresh_session. // AuthRefreshSessionColumns 定义并存储表 auth_refresh_session 的列名。
type AuthRefreshSessionColumns struct { type AuthRefreshSessionColumns struct {
Id string // Id string //
SubjectId string // ????????? ID SubjectId string // ????????? ID
@ -33,7 +33,7 @@ type AuthRefreshSessionColumns struct {
DeletedAt string // DeletedAt string //
} }
// authRefreshSessionColumns holds the columns for the table auth_refresh_session. // authRefreshSessionColumns 保存表 auth_refresh_session 的列信息。
var authRefreshSessionColumns = AuthRefreshSessionColumns{ var authRefreshSessionColumns = AuthRefreshSessionColumns{
Id: "id", Id: "id",
SubjectId: "subject_id", SubjectId: "subject_id",
@ -47,7 +47,7 @@ var authRefreshSessionColumns = AuthRefreshSessionColumns{
DeletedAt: "deleted_at", DeletedAt: "deleted_at",
} }
// NewAuthRefreshSessionDao creates and returns a new DAO object for table data access. // NewAuthRefreshSessionDao 创建并返回一个新的表数据访问 DAO 对象。
func NewAuthRefreshSessionDao(handlers ...gdb.ModelHandler) *AuthRefreshSessionDao { func NewAuthRefreshSessionDao(handlers ...gdb.ModelHandler) *AuthRefreshSessionDao {
return &AuthRefreshSessionDao{ return &AuthRefreshSessionDao{
group: "default", group: "default",
@ -57,27 +57,27 @@ func NewAuthRefreshSessionDao(handlers ...gdb.ModelHandler) *AuthRefreshSessionD
} }
} }
// DB retrieves and returns the underlying raw database management object of the current DAO. // DB 获取并返回当前 DAO 的底层原始数据库管理对象。
func (dao *AuthRefreshSessionDao) DB() gdb.DB { func (dao *AuthRefreshSessionDao) DB() gdb.DB {
return g.DB(dao.group) return g.DB(dao.group)
} }
// Table returns the table name of the current DAO. // Table 返回当前 DAO 的表名。
func (dao *AuthRefreshSessionDao) Table() string { func (dao *AuthRefreshSessionDao) Table() string {
return dao.table return dao.table
} }
// Columns returns all column names of the current DAO. // Columns 返回当前 DAO 的全部列名。
func (dao *AuthRefreshSessionDao) Columns() AuthRefreshSessionColumns { func (dao *AuthRefreshSessionDao) Columns() AuthRefreshSessionColumns {
return dao.columns return dao.columns
} }
// Group returns the database configuration group name of the current DAO. // Group 返回当前 DAO 的数据库配置组名。
func (dao *AuthRefreshSessionDao) Group() string { func (dao *AuthRefreshSessionDao) Group() string {
return dao.group return dao.group
} }
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. // Ctx 为当前 DAO 创建并返回一个 Model自动设置本次操作的上下文。
func (dao *AuthRefreshSessionDao) Ctx(ctx context.Context) *gdb.Model { func (dao *AuthRefreshSessionDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table) model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers { for _, handler := range dao.handlers {
@ -86,12 +86,12 @@ func (dao *AuthRefreshSessionDao) Ctx(ctx context.Context) *gdb.Model {
return model.Safe().Ctx(ctx) return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction 使用函数 f 包裹事务逻辑。
// It rolls back the transaction and returns the error if function f returns a non-nil error. // 若 f 返回非 nil 错误,则回滚事务并返回该错误。
// It commits the transaction and returns nil if function f returns nil. // 若 f 返回 nil则提交事务并返回 nil。
// //
// Note: Do not commit or roll back the transaction in function f, // 注意:请勿在函数 f 内提交或回滚事务,
// as it is automatically handled by this function. // 该函数会自动处理。
func (dao *AuthRefreshSessionDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { func (dao *AuthRefreshSessionDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f) return dao.Ctx(ctx).Transaction(ctx, f)
} }

View File

@ -1,5 +1,5 @@
// ========================================================================== // ==========================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. // 本文件由 GoFrame CLI 工具生成并维护,请勿编辑。
// ========================================================================== // ==========================================================================
package internal package internal
@ -11,7 +11,7 @@ import (
"github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/frame/g"
) )
// ContentDao is the data access object for the table content. // ContentDao 是表 content 的数据访问对象。
type ContentDao struct { type ContentDao struct {
table string // table is the underlying table name of the DAO. table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO. group string // group is the database configuration group name of the current DAO.
@ -19,7 +19,7 @@ type ContentDao struct {
handlers []gdb.ModelHandler // handlers for customized model modification. handlers []gdb.ModelHandler // handlers for customized model modification.
} }
// ContentColumns defines and stores column names for the table content. // ContentColumns 定义并存储表 content 的列名。
type ContentColumns struct { type ContentColumns struct {
Id string // Id string //
Title string // Title string //
@ -30,7 +30,7 @@ type ContentColumns struct {
DeletedAt string // DeletedAt string //
} }
// contentColumns holds the columns for the table content. // contentColumns 保存表 content 的列信息。
var contentColumns = ContentColumns{ var contentColumns = ContentColumns{
Id: "id", Id: "id",
Title: "title", Title: "title",
@ -41,7 +41,7 @@ var contentColumns = ContentColumns{
DeletedAt: "deleted_at", DeletedAt: "deleted_at",
} }
// NewContentDao creates and returns a new DAO object for table data access. // NewContentDao 创建并返回一个新的表数据访问 DAO 对象。
func NewContentDao(handlers ...gdb.ModelHandler) *ContentDao { func NewContentDao(handlers ...gdb.ModelHandler) *ContentDao {
return &ContentDao{ return &ContentDao{
group: "default", group: "default",
@ -51,27 +51,27 @@ func NewContentDao(handlers ...gdb.ModelHandler) *ContentDao {
} }
} }
// DB retrieves and returns the underlying raw database management object of the current DAO. // DB 获取并返回当前 DAO 的底层原始数据库管理对象。
func (dao *ContentDao) DB() gdb.DB { func (dao *ContentDao) DB() gdb.DB {
return g.DB(dao.group) return g.DB(dao.group)
} }
// Table returns the table name of the current DAO. // Table 返回当前 DAO 的表名。
func (dao *ContentDao) Table() string { func (dao *ContentDao) Table() string {
return dao.table return dao.table
} }
// Columns returns all column names of the current DAO. // Columns 返回当前 DAO 的全部列名。
func (dao *ContentDao) Columns() ContentColumns { func (dao *ContentDao) Columns() ContentColumns {
return dao.columns return dao.columns
} }
// Group returns the database configuration group name of the current DAO. // Group 返回当前 DAO 的数据库配置组名。
func (dao *ContentDao) Group() string { func (dao *ContentDao) Group() string {
return dao.group return dao.group
} }
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. // Ctx 为当前 DAO 创建并返回一个 Model自动设置本次操作的上下文。
func (dao *ContentDao) Ctx(ctx context.Context) *gdb.Model { func (dao *ContentDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table) model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers { for _, handler := range dao.handlers {
@ -80,12 +80,12 @@ func (dao *ContentDao) Ctx(ctx context.Context) *gdb.Model {
return model.Safe().Ctx(ctx) return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction 使用函数 f 包裹事务逻辑。
// It rolls back the transaction and returns the error if function f returns a non-nil error. // 若 f 返回非 nil 错误,则回滚事务并返回该错误。
// It commits the transaction and returns nil if function f returns nil. // 若 f 返回 nil则提交事务并返回 nil。
// //
// Note: Do not commit or roll back the transaction in function f, // 注意:请勿在函数 f 内提交或回滚事务,
// as it is automatically handled by this function. // 该函数会自动处理。
func (dao *ContentDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { func (dao *ContentDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f) return dao.Ctx(ctx).Transaction(ctx, f)
} }

View File

@ -0,0 +1,103 @@
// ==========================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// ==========================================================================
package internal
import (
"context"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
)
// HouseBuildingDao is the data access object for the table house_building.
type HouseBuildingDao 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 HouseBuildingColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// HouseBuildingColumns defines and stores column names for the table house_building.
type HouseBuildingColumns struct {
Id string //
CommunityId string // 小区ID
BuildingNo string // 栋号
Units string // 单元数
TotalFloors string // 总楼层
ElevatorCount string // 电梯数
LadderRatio string // 梯户比
BuildingType string // 板楼/塔楼
Lng string // 楼栋经度
Lat string // 楼栋纬度
CreatedAt string //
UpdatedAt string //
DeletedAt string //
}
// houseBuildingColumns holds the columns for the table house_building.
var houseBuildingColumns = HouseBuildingColumns{
Id: "id",
CommunityId: "community_id",
BuildingNo: "building_no",
Units: "units",
TotalFloors: "total_floors",
ElevatorCount: "elevator_count",
LadderRatio: "ladder_ratio",
BuildingType: "building_type",
Lng: "lng",
Lat: "lat",
CreatedAt: "created_at",
UpdatedAt: "updated_at",
DeletedAt: "deleted_at",
}
// NewHouseBuildingDao creates and returns a new DAO object for table data access.
func NewHouseBuildingDao(handlers ...gdb.ModelHandler) *HouseBuildingDao {
return &HouseBuildingDao{
group: "default",
table: "house_building",
columns: houseBuildingColumns,
handlers: handlers,
}
}
// DB retrieves and returns the underlying raw database management object of the current DAO.
func (dao *HouseBuildingDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of the current DAO.
func (dao *HouseBuildingDao) Table() string {
return dao.table
}
// Columns returns all column names of the current DAO.
func (dao *HouseBuildingDao) Columns() HouseBuildingColumns {
return dao.columns
}
// Group returns the database configuration group name of the current DAO.
func (dao *HouseBuildingDao) Group() string {
return dao.group
}
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *HouseBuildingDao) 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 wraps the transaction logic using function f.
// It rolls back the transaction and returns the error if function f returns a non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note: Do not commit or roll back the transaction in function f,
// as it is automatically handled by this function.
func (dao *HouseBuildingDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}

View File

@ -0,0 +1,113 @@
// ==========================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// ==========================================================================
package internal
import (
"context"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
)
// HouseCommunityDao is the data access object for the table house_community.
type HouseCommunityDao 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 HouseCommunityColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// HouseCommunityColumns defines and stores column names for the table house_community.
type HouseCommunityColumns struct {
Id string //
Name string // 小区/楼盘名
Region string // 区县(云岩/南明/观山湖/花溪等)
BusinessDistrict string // 板块
Address string // 地址
Lng string // 经度(GCJ-02)
Lat string // 纬度(GCJ-02)
BuildYear string // 建成年份
Households string // 总户数
PlotRatio string // 容积率
GreenRate string // 绿化率
PropertyCompany string // 物业公司
PropertyFee string // 物业费(元/月/平米)
Developer string // 开发商
Source string // 数据来源
CreatedAt string //
UpdatedAt string //
DeletedAt string //
}
// houseCommunityColumns holds the columns for the table house_community.
var houseCommunityColumns = HouseCommunityColumns{
Id: "id",
Name: "name",
Region: "region",
BusinessDistrict: "business_district",
Address: "address",
Lng: "lng",
Lat: "lat",
BuildYear: "build_year",
Households: "households",
PlotRatio: "plot_ratio",
GreenRate: "green_rate",
PropertyCompany: "property_company",
PropertyFee: "property_fee",
Developer: "developer",
Source: "source",
CreatedAt: "created_at",
UpdatedAt: "updated_at",
DeletedAt: "deleted_at",
}
// NewHouseCommunityDao creates and returns a new DAO object for table data access.
func NewHouseCommunityDao(handlers ...gdb.ModelHandler) *HouseCommunityDao {
return &HouseCommunityDao{
group: "default",
table: "house_community",
columns: houseCommunityColumns,
handlers: handlers,
}
}
// DB retrieves and returns the underlying raw database management object of the current DAO.
func (dao *HouseCommunityDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of the current DAO.
func (dao *HouseCommunityDao) Table() string {
return dao.table
}
// Columns returns all column names of the current DAO.
func (dao *HouseCommunityDao) Columns() HouseCommunityColumns {
return dao.columns
}
// Group returns the database configuration group name of the current DAO.
func (dao *HouseCommunityDao) Group() string {
return dao.group
}
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *HouseCommunityDao) 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 wraps the transaction logic using function f.
// It rolls back the transaction and returns the error if function f returns a non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note: Do not commit or roll back the transaction in function f,
// as it is automatically handled by this function.
func (dao *HouseCommunityDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}

View File

@ -0,0 +1,93 @@
// ==========================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// ==========================================================================
package internal
import (
"context"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
)
// HouseCommunityFacilityDao is the data access object for the table house_community_facility.
type HouseCommunityFacilityDao 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 HouseCommunityFacilityColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// HouseCommunityFacilityColumns defines and stores column names for the table house_community_facility.
type HouseCommunityFacilityColumns struct {
Id string //
CommunityId string // 小区ID
FacilityId string // 配套ID
Distance string // 距离(米)
CommuteMinutes string // 通勤分钟
CreatedAt string //
UpdatedAt string //
DeletedAt string //
}
// houseCommunityFacilityColumns holds the columns for the table house_community_facility.
var houseCommunityFacilityColumns = HouseCommunityFacilityColumns{
Id: "id",
CommunityId: "community_id",
FacilityId: "facility_id",
Distance: "distance",
CommuteMinutes: "commute_minutes",
CreatedAt: "created_at",
UpdatedAt: "updated_at",
DeletedAt: "deleted_at",
}
// NewHouseCommunityFacilityDao creates and returns a new DAO object for table data access.
func NewHouseCommunityFacilityDao(handlers ...gdb.ModelHandler) *HouseCommunityFacilityDao {
return &HouseCommunityFacilityDao{
group: "default",
table: "house_community_facility",
columns: houseCommunityFacilityColumns,
handlers: handlers,
}
}
// DB retrieves and returns the underlying raw database management object of the current DAO.
func (dao *HouseCommunityFacilityDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of the current DAO.
func (dao *HouseCommunityFacilityDao) Table() string {
return dao.table
}
// Columns returns all column names of the current DAO.
func (dao *HouseCommunityFacilityDao) Columns() HouseCommunityFacilityColumns {
return dao.columns
}
// Group returns the database configuration group name of the current DAO.
func (dao *HouseCommunityFacilityDao) Group() string {
return dao.group
}
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *HouseCommunityFacilityDao) 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 wraps the transaction logic using function f.
// It rolls back the transaction and returns the error if function f returns a non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note: Do not commit or roll back the transaction in function f,
// as it is automatically handled by this function.
func (dao *HouseCommunityFacilityDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}

View File

@ -0,0 +1,95 @@
// ==========================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// ==========================================================================
package internal
import (
"context"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
)
// HouseFacilityDao is the data access object for the table house_facility.
type HouseFacilityDao 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 HouseFacilityColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// HouseFacilityColumns defines and stores column names for the table house_facility.
type HouseFacilityColumns struct {
Id string //
Name string // 配套名称
Type string // 地铁/学校/医院/商圈
Lng string // 经度
Lat string // 纬度
Line string // 地铁线路
CreatedAt string //
UpdatedAt string //
DeletedAt string //
}
// houseFacilityColumns holds the columns for the table house_facility.
var houseFacilityColumns = HouseFacilityColumns{
Id: "id",
Name: "name",
Type: "type",
Lng: "lng",
Lat: "lat",
Line: "line",
CreatedAt: "created_at",
UpdatedAt: "updated_at",
DeletedAt: "deleted_at",
}
// NewHouseFacilityDao creates and returns a new DAO object for table data access.
func NewHouseFacilityDao(handlers ...gdb.ModelHandler) *HouseFacilityDao {
return &HouseFacilityDao{
group: "default",
table: "house_facility",
columns: houseFacilityColumns,
handlers: handlers,
}
}
// DB retrieves and returns the underlying raw database management object of the current DAO.
func (dao *HouseFacilityDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of the current DAO.
func (dao *HouseFacilityDao) Table() string {
return dao.table
}
// Columns returns all column names of the current DAO.
func (dao *HouseFacilityDao) Columns() HouseFacilityColumns {
return dao.columns
}
// Group returns the database configuration group name of the current DAO.
func (dao *HouseFacilityDao) Group() string {
return dao.group
}
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *HouseFacilityDao) 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 wraps the transaction logic using function f.
// It rolls back the transaction and returns the error if function f returns a non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note: Do not commit or roll back the transaction in function f,
// as it is automatically handled by this function.
func (dao *HouseFacilityDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}

View File

@ -0,0 +1,131 @@
// ==========================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// ==========================================================================
package internal
import (
"context"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
)
// HouseListingDao is the data access object for the table house_listing.
type HouseListingDao 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 HouseListingColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// HouseListingColumns defines and stores column names for the table house_listing.
type HouseListingColumns struct {
Id string //
CommunityId string // 小区ID
BuildingId string // 楼栋ID
HouseNo string // 房号
Layout string // 户型(如3室2厅)
Area string // 建筑面积(平米)
UsableArea string // 套内面积(平米)
Orientation string // 朝向
Floor string // 所在楼层
TotalFloors string // 总楼层
Decoration string // 装修
TotalPrice string // 总价(万元)
UnitPrice string // 单价(元/平米)
ListPrice string // 挂牌价(万元)
Source string // 来源平台
SourceHouseId string // 平台侧房源ID
SourceUrl string // 房源链接
MatchGroupId string // 疑似同房源分组(跨平台软关联)
OnMarketDays string // 挂牌天数
PriceChangeCount string // 调价次数
Status string // 1在售 2下架 3成交
Confidence string // 可信度 0正常 1低可信
IsBargain string // 笋盘标记 0否 1是
ListingTime string // 挂牌时间
CreatedAt string //
UpdatedAt string //
DeletedAt string //
}
// houseListingColumns holds the columns for the table house_listing.
var houseListingColumns = HouseListingColumns{
Id: "id",
CommunityId: "community_id",
BuildingId: "building_id",
HouseNo: "house_no",
Layout: "layout",
Area: "area",
UsableArea: "usable_area",
Orientation: "orientation",
Floor: "floor",
TotalFloors: "total_floors",
Decoration: "decoration",
TotalPrice: "total_price",
UnitPrice: "unit_price",
ListPrice: "list_price",
Source: "source",
SourceHouseId: "source_house_id",
SourceUrl: "source_url",
MatchGroupId: "match_group_id",
OnMarketDays: "on_market_days",
PriceChangeCount: "price_change_count",
Status: "status",
Confidence: "confidence",
IsBargain: "is_bargain",
ListingTime: "listing_time",
CreatedAt: "created_at",
UpdatedAt: "updated_at",
DeletedAt: "deleted_at",
}
// NewHouseListingDao creates and returns a new DAO object for table data access.
func NewHouseListingDao(handlers ...gdb.ModelHandler) *HouseListingDao {
return &HouseListingDao{
group: "default",
table: "house_listing",
columns: houseListingColumns,
handlers: handlers,
}
}
// DB retrieves and returns the underlying raw database management object of the current DAO.
func (dao *HouseListingDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of the current DAO.
func (dao *HouseListingDao) Table() string {
return dao.table
}
// Columns returns all column names of the current DAO.
func (dao *HouseListingDao) Columns() HouseListingColumns {
return dao.columns
}
// Group returns the database configuration group name of the current DAO.
func (dao *HouseListingDao) Group() string {
return dao.group
}
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *HouseListingDao) 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 wraps the transaction logic using function f.
// It rolls back the transaction and returns the error if function f returns a non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note: Do not commit or roll back the transaction in function f,
// as it is automatically handled by this function.
func (dao *HouseListingDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}

View File

@ -0,0 +1,107 @@
// ==========================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// ==========================================================================
package internal
import (
"context"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
)
// HousePreferenceDao is the data access object for the table house_preference.
type HousePreferenceDao 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 HousePreferenceColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// HousePreferenceColumns defines and stores column names for the table house_preference.
type HousePreferenceColumns struct {
Id string //
BudgetMin string // 预算下限(万元)
BudgetMax string // 预算上限(万元)
AreaMin string // 面积下限(平米)
AreaMax string // 面积上限(平米)
Layouts string // 户型偏好JSON
SubwayLines string // 地铁线路JSON
SchoolRequired string // 是否要求学区
CommuteTarget string // 通勤目标点
CommuteLimitMin string // 通勤上限(分钟)
RegionPrefer string // 区域偏好JSON
Weights string // 权重JSON
CreatedAt string //
UpdatedAt string //
DeletedAt string //
}
// housePreferenceColumns holds the columns for the table house_preference.
var housePreferenceColumns = HousePreferenceColumns{
Id: "id",
BudgetMin: "budget_min",
BudgetMax: "budget_max",
AreaMin: "area_min",
AreaMax: "area_max",
Layouts: "layouts",
SubwayLines: "subway_lines",
SchoolRequired: "school_required",
CommuteTarget: "commute_target",
CommuteLimitMin: "commute_limit_min",
RegionPrefer: "region_prefer",
Weights: "weights",
CreatedAt: "created_at",
UpdatedAt: "updated_at",
DeletedAt: "deleted_at",
}
// NewHousePreferenceDao creates and returns a new DAO object for table data access.
func NewHousePreferenceDao(handlers ...gdb.ModelHandler) *HousePreferenceDao {
return &HousePreferenceDao{
group: "default",
table: "house_preference",
columns: housePreferenceColumns,
handlers: handlers,
}
}
// DB retrieves and returns the underlying raw database management object of the current DAO.
func (dao *HousePreferenceDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of the current DAO.
func (dao *HousePreferenceDao) Table() string {
return dao.table
}
// Columns returns all column names of the current DAO.
func (dao *HousePreferenceDao) Columns() HousePreferenceColumns {
return dao.columns
}
// Group returns the database configuration group name of the current DAO.
func (dao *HousePreferenceDao) Group() string {
return dao.group
}
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *HousePreferenceDao) 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 wraps the transaction logic using function f.
// It rolls back the transaction and returns the error if function f returns a non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note: Do not commit or roll back the transaction in function f,
// as it is automatically handled by this function.
func (dao *HousePreferenceDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}

View File

@ -0,0 +1,95 @@
// ==========================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// ==========================================================================
package internal
import (
"context"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
)
// HousePriceSnapshotDao is the data access object for the table house_price_snapshot.
type HousePriceSnapshotDao 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 HousePriceSnapshotColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// HousePriceSnapshotColumns defines and stores column names for the table house_price_snapshot.
type HousePriceSnapshotColumns struct {
Id string //
ListingId string // 房源ID
CommunityId string // 小区ID
SnapDate string // 快照日期
ListPrice string // 挂牌价(万元)
DealPrice string // 成交价(万元)
CreatedAt string //
UpdatedAt string //
DeletedAt string //
}
// housePriceSnapshotColumns holds the columns for the table house_price_snapshot.
var housePriceSnapshotColumns = HousePriceSnapshotColumns{
Id: "id",
ListingId: "listing_id",
CommunityId: "community_id",
SnapDate: "snap_date",
ListPrice: "list_price",
DealPrice: "deal_price",
CreatedAt: "created_at",
UpdatedAt: "updated_at",
DeletedAt: "deleted_at",
}
// NewHousePriceSnapshotDao creates and returns a new DAO object for table data access.
func NewHousePriceSnapshotDao(handlers ...gdb.ModelHandler) *HousePriceSnapshotDao {
return &HousePriceSnapshotDao{
group: "default",
table: "house_price_snapshot",
columns: housePriceSnapshotColumns,
handlers: handlers,
}
}
// DB retrieves and returns the underlying raw database management object of the current DAO.
func (dao *HousePriceSnapshotDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of the current DAO.
func (dao *HousePriceSnapshotDao) Table() string {
return dao.table
}
// Columns returns all column names of the current DAO.
func (dao *HousePriceSnapshotDao) Columns() HousePriceSnapshotColumns {
return dao.columns
}
// Group returns the database configuration group name of the current DAO.
func (dao *HousePriceSnapshotDao) Group() string {
return dao.group
}
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *HousePriceSnapshotDao) 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 wraps the transaction logic using function f.
// It rolls back the transaction and returns the error if function f returns a non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note: Do not commit or roll back the transaction in function f,
// as it is automatically handled by this function.
func (dao *HousePriceSnapshotDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}

View File

@ -0,0 +1,95 @@
// ==========================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// ==========================================================================
package internal
import (
"context"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
)
// HouseSchoolDistrictDao is the data access object for the table house_school_district.
type HouseSchoolDistrictDao 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 HouseSchoolDistrictColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// HouseSchoolDistrictColumns defines and stores column names for the table house_school_district.
type HouseSchoolDistrictColumns struct {
Id string //
SchoolName string // 学校名
CommunityId string // 小区ID
DistrictPolygon string // 划片范围GeoJSON
DistrictYear string // 划片年度
Note string // 备注
CreatedAt string //
UpdatedAt string //
DeletedAt string //
}
// houseSchoolDistrictColumns holds the columns for the table house_school_district.
var houseSchoolDistrictColumns = HouseSchoolDistrictColumns{
Id: "id",
SchoolName: "school_name",
CommunityId: "community_id",
DistrictPolygon: "district_polygon",
DistrictYear: "district_year",
Note: "note",
CreatedAt: "created_at",
UpdatedAt: "updated_at",
DeletedAt: "deleted_at",
}
// NewHouseSchoolDistrictDao creates and returns a new DAO object for table data access.
func NewHouseSchoolDistrictDao(handlers ...gdb.ModelHandler) *HouseSchoolDistrictDao {
return &HouseSchoolDistrictDao{
group: "default",
table: "house_school_district",
columns: houseSchoolDistrictColumns,
handlers: handlers,
}
}
// DB retrieves and returns the underlying raw database management object of the current DAO.
func (dao *HouseSchoolDistrictDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of the current DAO.
func (dao *HouseSchoolDistrictDao) Table() string {
return dao.table
}
// Columns returns all column names of the current DAO.
func (dao *HouseSchoolDistrictDao) Columns() HouseSchoolDistrictColumns {
return dao.columns
}
// Group returns the database configuration group name of the current DAO.
func (dao *HouseSchoolDistrictDao) Group() string {
return dao.group
}
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *HouseSchoolDistrictDao) 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 wraps the transaction logic using function f.
// It rolls back the transaction and returns the error if function f returns a non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note: Do not commit or roll back the transaction in function f,
// as it is automatically handled by this function.
func (dao *HouseSchoolDistrictDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}

View File

@ -0,0 +1,103 @@
// ==========================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// ==========================================================================
package internal
import (
"context"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
)
// HouseTransactionDao is the data access object for the table house_transaction.
type HouseTransactionDao 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 HouseTransactionColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// HouseTransactionColumns defines and stores column names for the table house_transaction.
type HouseTransactionColumns struct {
Id string //
CommunityId string // 小区ID
BuildingId string // 楼栋ID
Layout string // 户型
Area string // 面积(平米)
DealPrice string // 成交总价(万元)
DealUnitPrice string // 成交单价(元/平米)
ListDays string // 挂牌到成交天数
DealDate string // 成交日期
Source string // 来源
CreatedAt string //
UpdatedAt string //
DeletedAt string //
}
// houseTransactionColumns holds the columns for the table house_transaction.
var houseTransactionColumns = HouseTransactionColumns{
Id: "id",
CommunityId: "community_id",
BuildingId: "building_id",
Layout: "layout",
Area: "area",
DealPrice: "deal_price",
DealUnitPrice: "deal_unit_price",
ListDays: "list_days",
DealDate: "deal_date",
Source: "source",
CreatedAt: "created_at",
UpdatedAt: "updated_at",
DeletedAt: "deleted_at",
}
// NewHouseTransactionDao creates and returns a new DAO object for table data access.
func NewHouseTransactionDao(handlers ...gdb.ModelHandler) *HouseTransactionDao {
return &HouseTransactionDao{
group: "default",
table: "house_transaction",
columns: houseTransactionColumns,
handlers: handlers,
}
}
// DB retrieves and returns the underlying raw database management object of the current DAO.
func (dao *HouseTransactionDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of the current DAO.
func (dao *HouseTransactionDao) Table() string {
return dao.table
}
// Columns returns all column names of the current DAO.
func (dao *HouseTransactionDao) Columns() HouseTransactionColumns {
return dao.columns
}
// Group returns the database configuration group name of the current DAO.
func (dao *HouseTransactionDao) Group() string {
return dao.group
}
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *HouseTransactionDao) 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 wraps the transaction logic using function f.
// It rolls back the transaction and returns the error if function f returns a non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note: Do not commit or roll back the transaction in function f,
// as it is automatically handled by this function.
func (dao *HouseTransactionDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}

View File

@ -1,5 +1,5 @@
// ========================================================================== // ==========================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. // 本文件由 GoFrame CLI 工具生成并维护,请勿编辑。
// ========================================================================== // ==========================================================================
package internal package internal
@ -11,7 +11,7 @@ import (
"github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/frame/g"
) )
// UserDao is the data access object for the table user. // UserDao 是表 user 的数据访问对象。
type UserDao struct { type UserDao struct {
table string // table is the underlying table name of the DAO. table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO. group string // group is the database configuration group name of the current DAO.
@ -19,7 +19,7 @@ type UserDao struct {
handlers []gdb.ModelHandler // handlers for customized model modification. handlers []gdb.ModelHandler // handlers for customized model modification.
} }
// UserColumns defines and stores column names for the table user. // UserColumns 定义并存储表 user 的列名。
type UserColumns struct { type UserColumns struct {
Id string // Id string //
UnionId string // UnionId string //
@ -36,7 +36,7 @@ type UserColumns struct {
DeletedAt string // DeletedAt string //
} }
// userColumns holds the columns for the table user. // userColumns 保存表 user 的列信息。
var userColumns = UserColumns{ var userColumns = UserColumns{
Id: "id", Id: "id",
UnionId: "union_id", UnionId: "union_id",
@ -53,7 +53,7 @@ var userColumns = UserColumns{
DeletedAt: "deleted_at", DeletedAt: "deleted_at",
} }
// NewUserDao creates and returns a new DAO object for table data access. // NewUserDao 创建并返回一个新的表数据访问 DAO 对象。
func NewUserDao(handlers ...gdb.ModelHandler) *UserDao { func NewUserDao(handlers ...gdb.ModelHandler) *UserDao {
return &UserDao{ return &UserDao{
group: "default", group: "default",
@ -63,27 +63,27 @@ func NewUserDao(handlers ...gdb.ModelHandler) *UserDao {
} }
} }
// DB retrieves and returns the underlying raw database management object of the current DAO. // DB 获取并返回当前 DAO 的底层原始数据库管理对象。
func (dao *UserDao) DB() gdb.DB { func (dao *UserDao) DB() gdb.DB {
return g.DB(dao.group) return g.DB(dao.group)
} }
// Table returns the table name of the current DAO. // Table 返回当前 DAO 的表名。
func (dao *UserDao) Table() string { func (dao *UserDao) Table() string {
return dao.table return dao.table
} }
// Columns returns all column names of the current DAO. // Columns 返回当前 DAO 的全部列名。
func (dao *UserDao) Columns() UserColumns { func (dao *UserDao) Columns() UserColumns {
return dao.columns return dao.columns
} }
// Group returns the database configuration group name of the current DAO. // Group 返回当前 DAO 的数据库配置组名。
func (dao *UserDao) Group() string { func (dao *UserDao) Group() string {
return dao.group return dao.group
} }
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. // Ctx 为当前 DAO 创建并返回一个 Model自动设置本次操作的上下文。
func (dao *UserDao) Ctx(ctx context.Context) *gdb.Model { func (dao *UserDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table) model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers { for _, handler := range dao.handlers {
@ -92,12 +92,12 @@ func (dao *UserDao) Ctx(ctx context.Context) *gdb.Model {
return model.Safe().Ctx(ctx) return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction 使用函数 f 包裹事务逻辑。
// It rolls back the transaction and returns the error if function f returns a non-nil error. // 若 f 返回非 nil 错误,则回滚事务并返回该错误。
// It commits the transaction and returns nil if function f returns nil. // 若 f 返回 nil则提交事务并返回 nil。
// //
// Note: Do not commit or roll back the transaction in function f, // 注意:请勿在函数 f 内提交或回滚事务,
// as it is automatically handled by this function. // 该函数会自动处理。
func (dao *UserDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { func (dao *UserDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f) return dao.Ctx(ctx).Transaction(ctx, f)
} }

View File

@ -1,5 +1,5 @@
// ========================================================================== // ==========================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. // 本文件由 GoFrame CLI 工具生成并维护,请勿编辑。
// ========================================================================== // ==========================================================================
package internal package internal
@ -11,7 +11,7 @@ import (
"github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/frame/g"
) )
// UserFavoriteDao is the data access object for the table user_favorite. // UserFavoriteDao 是表 user_favorite 的数据访问对象。
type UserFavoriteDao struct { type UserFavoriteDao struct {
table string // table is the underlying table name of the DAO. table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO. group string // group is the database configuration group name of the current DAO.
@ -19,7 +19,7 @@ type UserFavoriteDao struct {
handlers []gdb.ModelHandler // handlers for customized model modification. handlers []gdb.ModelHandler // handlers for customized model modification.
} }
// UserFavoriteColumns defines and stores column names for the table user_favorite. // UserFavoriteColumns 定义并存储表 user_favorite 的列名。
type UserFavoriteColumns struct { type UserFavoriteColumns struct {
Id string // Id string //
UserId string // UserId string //
@ -29,7 +29,7 @@ type UserFavoriteColumns struct {
DeletedAt string // DeletedAt string //
} }
// userFavoriteColumns holds the columns for the table user_favorite. // userFavoriteColumns 保存表 user_favorite 的列信息。
var userFavoriteColumns = UserFavoriteColumns{ var userFavoriteColumns = UserFavoriteColumns{
Id: "id", Id: "id",
UserId: "user_id", UserId: "user_id",
@ -39,7 +39,7 @@ var userFavoriteColumns = UserFavoriteColumns{
DeletedAt: "deleted_at", DeletedAt: "deleted_at",
} }
// NewUserFavoriteDao creates and returns a new DAO object for table data access. // NewUserFavoriteDao 创建并返回一个新的表数据访问 DAO 对象。
func NewUserFavoriteDao(handlers ...gdb.ModelHandler) *UserFavoriteDao { func NewUserFavoriteDao(handlers ...gdb.ModelHandler) *UserFavoriteDao {
return &UserFavoriteDao{ return &UserFavoriteDao{
group: "default", group: "default",
@ -49,27 +49,27 @@ func NewUserFavoriteDao(handlers ...gdb.ModelHandler) *UserFavoriteDao {
} }
} }
// DB retrieves and returns the underlying raw database management object of the current DAO. // DB 获取并返回当前 DAO 的底层原始数据库管理对象。
func (dao *UserFavoriteDao) DB() gdb.DB { func (dao *UserFavoriteDao) DB() gdb.DB {
return g.DB(dao.group) return g.DB(dao.group)
} }
// Table returns the table name of the current DAO. // Table 返回当前 DAO 的表名。
func (dao *UserFavoriteDao) Table() string { func (dao *UserFavoriteDao) Table() string {
return dao.table return dao.table
} }
// Columns returns all column names of the current DAO. // Columns 返回当前 DAO 的全部列名。
func (dao *UserFavoriteDao) Columns() UserFavoriteColumns { func (dao *UserFavoriteDao) Columns() UserFavoriteColumns {
return dao.columns return dao.columns
} }
// Group returns the database configuration group name of the current DAO. // Group 返回当前 DAO 的数据库配置组名。
func (dao *UserFavoriteDao) Group() string { func (dao *UserFavoriteDao) Group() string {
return dao.group return dao.group
} }
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. // Ctx 为当前 DAO 创建并返回一个 Model自动设置本次操作的上下文。
func (dao *UserFavoriteDao) Ctx(ctx context.Context) *gdb.Model { func (dao *UserFavoriteDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table) model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers { for _, handler := range dao.handlers {
@ -78,12 +78,12 @@ func (dao *UserFavoriteDao) Ctx(ctx context.Context) *gdb.Model {
return model.Safe().Ctx(ctx) return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction 使用函数 f 包裹事务逻辑。
// It rolls back the transaction and returns the error if function f returns a non-nil error. // 若 f 返回非 nil 错误,则回滚事务并返回该错误。
// It commits the transaction and returns nil if function f returns nil. // 若 f 返回 nil则提交事务并返回 nil。
// //
// Note: Do not commit or roll back the transaction in function f, // 注意:请勿在函数 f 内提交或回滚事务,
// as it is automatically handled by this function. // 该函数会自动处理。
func (dao *UserFavoriteDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { 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) return dao.Ctx(ctx).Transaction(ctx, f)
} }

View File

@ -1,5 +1,5 @@
// ========================================================================== // ==========================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. // 本文件由 GoFrame CLI 工具生成并维护,请勿编辑。
// ========================================================================== // ==========================================================================
package internal package internal
@ -11,7 +11,7 @@ import (
"github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/frame/g"
) )
// UserMessageDao is the data access object for the table user_message. // UserMessageDao 是表 user_message 的数据访问对象。
type UserMessageDao struct { type UserMessageDao struct {
table string // table is the underlying table name of the DAO. table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO. group string // group is the database configuration group name of the current DAO.
@ -19,7 +19,7 @@ type UserMessageDao struct {
handlers []gdb.ModelHandler // handlers for customized model modification. handlers []gdb.ModelHandler // handlers for customized model modification.
} }
// UserMessageColumns defines and stores column names for the table user_message. // UserMessageColumns 定义并存储表 user_message 的列名。
type UserMessageColumns struct { type UserMessageColumns struct {
Id string // Id string //
UserId string // UserId string //
@ -31,7 +31,7 @@ type UserMessageColumns struct {
DeletedAt string // DeletedAt string //
} }
// userMessageColumns holds the columns for the table user_message. // userMessageColumns 保存表 user_message 的列信息。
var userMessageColumns = UserMessageColumns{ var userMessageColumns = UserMessageColumns{
Id: "id", Id: "id",
UserId: "user_id", UserId: "user_id",
@ -43,7 +43,7 @@ var userMessageColumns = UserMessageColumns{
DeletedAt: "deleted_at", DeletedAt: "deleted_at",
} }
// NewUserMessageDao creates and returns a new DAO object for table data access. // NewUserMessageDao 创建并返回一个新的表数据访问 DAO 对象。
func NewUserMessageDao(handlers ...gdb.ModelHandler) *UserMessageDao { func NewUserMessageDao(handlers ...gdb.ModelHandler) *UserMessageDao {
return &UserMessageDao{ return &UserMessageDao{
group: "default", group: "default",
@ -53,27 +53,27 @@ func NewUserMessageDao(handlers ...gdb.ModelHandler) *UserMessageDao {
} }
} }
// DB retrieves and returns the underlying raw database management object of the current DAO. // DB 获取并返回当前 DAO 的底层原始数据库管理对象。
func (dao *UserMessageDao) DB() gdb.DB { func (dao *UserMessageDao) DB() gdb.DB {
return g.DB(dao.group) return g.DB(dao.group)
} }
// Table returns the table name of the current DAO. // Table 返回当前 DAO 的表名。
func (dao *UserMessageDao) Table() string { func (dao *UserMessageDao) Table() string {
return dao.table return dao.table
} }
// Columns returns all column names of the current DAO. // Columns 返回当前 DAO 的全部列名。
func (dao *UserMessageDao) Columns() UserMessageColumns { func (dao *UserMessageDao) Columns() UserMessageColumns {
return dao.columns return dao.columns
} }
// Group returns the database configuration group name of the current DAO. // Group 返回当前 DAO 的数据库配置组名。
func (dao *UserMessageDao) Group() string { func (dao *UserMessageDao) Group() string {
return dao.group return dao.group
} }
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. // Ctx 为当前 DAO 创建并返回一个 Model自动设置本次操作的上下文。
func (dao *UserMessageDao) Ctx(ctx context.Context) *gdb.Model { func (dao *UserMessageDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table) model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers { for _, handler := range dao.handlers {
@ -82,12 +82,12 @@ func (dao *UserMessageDao) Ctx(ctx context.Context) *gdb.Model {
return model.Safe().Ctx(ctx) return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction 使用函数 f 包裹事务逻辑。
// It rolls back the transaction and returns the error if function f returns a non-nil error. // 若 f 返回非 nil 错误,则回滚事务并返回该错误。
// It commits the transaction and returns nil if function f returns nil. // 若 f 返回 nil则提交事务并返回 nil。
// //
// Note: Do not commit or roll back the transaction in function f, // 注意:请勿在函数 f 内提交或回滚事务,
// as it is automatically handled by this function. // 该函数会自动处理。
func (dao *UserMessageDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { func (dao *UserMessageDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f) return dao.Ctx(ctx).Transaction(ctx, f)
} }

Some files were not shown because too many files have changed in this diff Show More