feat(house): 实现看房模块后端功能
Some checks failed
Build and Deploy (service.xpcool.com) / build-and-deploy (push) Failing after 5m7s
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:
parent
ded75e1bed
commit
4aca0c7f6f
78
.gitea/workflows/deploy.yml
Normal file
78
.gitea/workflows/deploy.yml
Normal file
@ -0,0 +1,78 @@
|
||||
# service.xpcool.com 自动部署:Gitea act_runner(push 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/ 下脚本(003→004→004b→007),workflow 不做自动 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.yaml(GF_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
3
.gitignore
vendored
@ -28,3 +28,6 @@ log/
|
||||
|
||||
# 本地环境变量(含数据库口令),禁止提交
|
||||
.env*
|
||||
|
||||
# GoLand 项目级运行配置(含数据库口令),禁止提交
|
||||
.run/
|
||||
|
||||
@ -1,6 +1,10 @@
|
||||
# service.xpcool.com 变更记录
|
||||
> 倒序:最新在上。格式:YYYY-MM-DD | 类型 | 摘要
|
||||
|
||||
2026-08-26 | CFG | 新增 Gitea act_runner 自动部署:.gitea/workflows/deploy.yml(push 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:10100(xpcool-net,GF_GCFG_ENV=prod,DB_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 个 RegisterService;go build 通过。坑①gf CLI 为 com.lib.gf.v2 分支,gen dao 产物 import 需 sed 回 github.com/gogf/gf/v2(18 文件);②mysql 客户端须 --default-character-set=utf8mb4 否则中文 COMMENT/INSERT 乱码;③TINYINT 字段 comment 含 0/1 被 gf 映射 bool(status 三值改 INT);hack/config.yaml 的 link+tables 已指向本地库
|
||||
2026-08-26 | CHG | 生产超级管理员账号替换:删除 admin/admin123(用户/绑定/refresh 会话全清),新增 xxcool/xxCool@2026(bcrypt $2b$10$,绑定 super_admin);脚本 manifest/sql/009_admin_account_v2.sql(008 编号已被 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),原按钮 63(system: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=1,opuser 联调验证 codes 空/routes 空/接口 403,admin 全链路回归通过
|
||||
|
||||
|
||||
@ -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.
|
||||
|
||||
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.
|
||||
|
||||
|
||||
@ -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{}
|
||||
|
||||
30
api/admin/system/login_log/login_log.go
Normal file
30
api/admin/system/login_log/login_log.go
Normal 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"`
|
||||
}
|
||||
@ -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{}
|
||||
@ -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{}
|
||||
@ -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"`
|
||||
}
|
||||
@ -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{}
|
||||
@ -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{}
|
||||
@ -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)
|
||||
}
|
||||
@ -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"`
|
||||
}
|
||||
93
api/house/community/community.go
Normal file
93
api/house/community/community.go
Normal 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{}
|
||||
85
api/house/dashboard/dashboard.go
Normal file
85
api/house/dashboard/dashboard.go
Normal 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"`
|
||||
}
|
||||
139
api/house/listing/listing.go
Normal file
139
api/house/listing/listing.go
Normal 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"`
|
||||
}
|
||||
@ -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
|
||||
@ -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
|
||||
}
|
||||
@ -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"`
|
||||
}
|
||||
@ -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"`
|
||||
}
|
||||
@ -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
|
||||
}
|
||||
@ -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
1
api/user/login/login.go
Normal file
@ -0,0 +1 @@
|
||||
package user_login
|
||||
@ -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
|
||||
@ -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
|
||||
// be shared across services inside the repository, or extracted into a
|
||||
// standalone library later without touching business code.
|
||||
// 仅包含与 internal/ 无关的代码——此处的内容可以
|
||||
// 在仓库内跨服务共享,或日后抽取为独立库,
|
||||
// 均无需改动业务代码。
|
||||
//
|
||||
// Current layout:
|
||||
// 当前结构:
|
||||
//
|
||||
// common/tools shared utility toolbox (md5, cryptox, uuid, ...)
|
||||
package common
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
// Package convertx provides type conversion helpers with default-value
|
||||
// fallback, built on top of gconv.
|
||||
// Package convertx 提供带默认值兜底的类型转换工具,
|
||||
// 基于 gconv 构建。
|
||||
//
|
||||
// Note: gconv silently returns the zero value when conversion fails, so the
|
||||
// helpers here only fall back to the default for nil / blank-string inputs.
|
||||
// Pass pre-validated data when strict conversion is required.
|
||||
// 注意:gconv 转换失败时静默返回零值,
|
||||
// 因此本工具仅对 nil / 空字符串输入回退到默认值。
|
||||
// 需要严格转换时请传入已校验的数据。
|
||||
package convertx
|
||||
|
||||
import (
|
||||
@ -12,7 +12,7 @@ import (
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
)
|
||||
|
||||
// ToInt converts v to int, returning def when v is nil or a blank string.
|
||||
// ToInt 将 v 转为 int,v 为 nil 或空字符串时返回 def。
|
||||
func ToInt(v any, def int) int {
|
||||
if isEmpty(v) {
|
||||
return def
|
||||
@ -20,7 +20,7 @@ func ToInt(v any, def int) int {
|
||||
return gconv.Int(v)
|
||||
}
|
||||
|
||||
// ToInt64 converts v to int64, returning def when v is nil or a blank string.
|
||||
// ToInt64 将 v 转为 int64,v 为 nil 或空字符串时返回 def。
|
||||
func ToInt64(v any, def int64) int64 {
|
||||
if isEmpty(v) {
|
||||
return def
|
||||
@ -28,7 +28,7 @@ func ToInt64(v any, def int64) int64 {
|
||||
return gconv.Int64(v)
|
||||
}
|
||||
|
||||
// ToFloat64 converts v to float64, returning def when v is nil or a blank string.
|
||||
// ToFloat64 将 v 转为 float64,v 为 nil 或空字符串时返回 def。
|
||||
func ToFloat64(v any, def float64) float64 {
|
||||
if isEmpty(v) {
|
||||
return def
|
||||
@ -36,7 +36,7 @@ func ToFloat64(v any, def float64) float64 {
|
||||
return gconv.Float64(v)
|
||||
}
|
||||
|
||||
// ToString converts v to string, returning def when v is nil.
|
||||
// ToString 将 v 转为 string,v 为 nil 时返回 def。
|
||||
func ToString(v any, def string) string {
|
||||
if v == nil {
|
||||
return def
|
||||
@ -44,7 +44,7 @@ func ToString(v any, def string) string {
|
||||
return gconv.String(v)
|
||||
}
|
||||
|
||||
// ToBool converts v to bool, returning def when v is nil or a blank string.
|
||||
// ToBool 将 v 转为 bool,v 为 nil 或空字符串时返回 def。
|
||||
func ToBool(v any, def bool) bool {
|
||||
if isEmpty(v) {
|
||||
return def
|
||||
@ -52,7 +52,7 @@ func ToBool(v any, def bool) bool {
|
||||
return gconv.Bool(v)
|
||||
}
|
||||
|
||||
// isEmpty reports whether v is nil or a blank string.
|
||||
// isEmpty 判断 v 是否为 nil 或空字符串。
|
||||
func isEmpty(v any) bool {
|
||||
if v == nil {
|
||||
return true
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
// Package cryptox provides AES/DES encryption helpers with base64 output,
|
||||
// built on top of gaes and gdes.
|
||||
// Package cryptox 提供 AES/DES 加解密工具(base64 输出),
|
||||
// 基于 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
|
||||
|
||||
import (
|
||||
@ -19,7 +19,7 @@ const (
|
||||
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 {
|
||||
key := []byte(secret)
|
||||
if len(key) == size {
|
||||
@ -33,8 +33,8 @@ func normalizeKey(secret string, size int) []byte {
|
||||
return out
|
||||
}
|
||||
|
||||
// AesEncrypt encrypts plainText with AES-128-CBC using a key derived from
|
||||
// secret, and returns the ciphertext encoded in base64.
|
||||
// AesEncrypt 使用由 secret 派生的密钥对 plainText 做 AES-128-CBC 加密,
|
||||
// 返回 base64 编码的密文。
|
||||
func AesEncrypt(plainText, secret string) (string, error) {
|
||||
out, err := gaes.Encrypt([]byte(plainText), normalizeKey(secret, aesKeySize))
|
||||
if err != nil {
|
||||
@ -43,7 +43,7 @@ func AesEncrypt(plainText, secret string) (string, error) {
|
||||
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) {
|
||||
data, err := base64.StdEncoding.DecodeString(cipherText)
|
||||
if err != nil {
|
||||
@ -56,8 +56,8 @@ func AesDecrypt(cipherText, secret string) (string, error) {
|
||||
return string(out), nil
|
||||
}
|
||||
|
||||
// DesEncrypt encrypts plainText with DES-ECB (PKCS5 padding) using a key
|
||||
// derived from secret, and returns the ciphertext encoded in base64.
|
||||
// DesEncrypt 使用由 secret 派生的密钥对 plainText 做 DES-ECB(PKCS5 填充)加密,
|
||||
// 返回 base64 编码的密文。
|
||||
func DesEncrypt(plainText, secret string) (string, error) {
|
||||
out, err := gdes.EncryptECB([]byte(plainText), normalizeKey(secret, desKeySize), gdes.PKCS5PADDING)
|
||||
if err != nil {
|
||||
@ -66,7 +66,7 @@ func DesEncrypt(plainText, secret string) (string, error) {
|
||||
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) {
|
||||
data, err := base64.StdEncoding.DecodeString(cipherText)
|
||||
if err != nil {
|
||||
|
||||
@ -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
|
||||
// components (gmd5, gaes, gdes, guid, grand, gtime, gconv, gstr, gfile, ...),
|
||||
// so it stays small and consistent with the framework.
|
||||
// 每个子包都是对 GoFrame 内置组件的薄封装,
|
||||
// (gmd5、gaes、gdes、guid、grand、gtime、gconv、gstr、gfile 等),
|
||||
// 保持小巧且与框架风格一致。
|
||||
//
|
||||
// Layout:
|
||||
// 结构:
|
||||
//
|
||||
// common/tools/md5 MD5 digest helpers
|
||||
// common/tools/cryptox AES/DES encryption with base64 output
|
||||
@ -17,7 +17,7 @@
|
||||
// common/tools/ip IP address helpers
|
||||
// common/tools/filex file system helpers
|
||||
//
|
||||
// Rules:
|
||||
// 规则:
|
||||
// - Never depend on internal/ — this module must stay self-contained.
|
||||
// - Prefer reusing GoFrame built-in components over re-implementing.
|
||||
// - Keep each helper small and add a Chinese doc comment.
|
||||
|
||||
@ -1,28 +1,28 @@
|
||||
// Package filex provides common file system helpers on top of gfile.
|
||||
// Package filex 基于 gfile 提供常用文件系统工具。
|
||||
package filex
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/os/gfile"
|
||||
)
|
||||
|
||||
// Exists reports whether the file or directory at path exists.
|
||||
// Exists 判断 path 对应的文件或目录是否存在。
|
||||
func Exists(path string) bool {
|
||||
return gfile.Exists(path)
|
||||
}
|
||||
|
||||
// IsDir reports whether path is a directory.
|
||||
// IsDir 判断 path 是否为目录。
|
||||
func IsDir(path string) bool {
|
||||
return gfile.IsDir(path)
|
||||
}
|
||||
|
||||
// ReadString returns the full content of the file at path as a string.
|
||||
// Returns an empty string when the file does not exist.
|
||||
// ReadString 以字符串形式返回 path 文件的完整内容,
|
||||
// 文件不存在时返回空字符串。
|
||||
func ReadString(path string) string {
|
||||
return gfile.GetContents(path)
|
||||
}
|
||||
|
||||
// WriteString writes content to the file at path, creating intermediate
|
||||
// directories if needed.
|
||||
// WriteString 将 content 写入 path 文件,必要时自动创建中间目录。
|
||||
// (续上一行)
|
||||
func WriteString(path, content string) error {
|
||||
return gfile.PutContents(path, content)
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Package ip provides IP address helpers.
|
||||
// Package ip 提供 IP 地址工具。
|
||||
package ip
|
||||
|
||||
import (
|
||||
@ -9,12 +9,12 @@ import (
|
||||
"github.com/gogf/gf/v2/net/gipv4"
|
||||
)
|
||||
|
||||
// IsValid reports whether s is a valid IPv4 address.
|
||||
// IsValid 判断 s 是否为合法的 IPv4 地址。
|
||||
func IsValid(s string) bool {
|
||||
return gipv4.Validate(s)
|
||||
}
|
||||
|
||||
// LocalIP returns the first non-loopback IPv4 address of this host.
|
||||
// LocalIP 返回本机第一个非回环 IPv4 地址。
|
||||
func LocalIP() (string, error) {
|
||||
addrs, err := net.InterfaceAddrs()
|
||||
if err != nil {
|
||||
@ -30,7 +30,7 @@ func LocalIP() (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
// IsInternal reports whether s is a private/internal IPv4 address
|
||||
// IsInternal 判断 s 是否为私有/内网 IPv4 地址
|
||||
// (private ranges, loopback or link-local).
|
||||
func IsInternal(s string) bool {
|
||||
parsed := net.ParseIP(s)
|
||||
@ -40,7 +40,7 @@ func IsInternal(s string) bool {
|
||||
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).
|
||||
func ToLong(s string) (uint32, error) {
|
||||
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
|
||||
}
|
||||
|
||||
// ToString converts a uint32 IPv4 value to its dotted-decimal string.
|
||||
// ToString 将 uint32 的 IPv4 值转为点分十进制字符串。
|
||||
func ToString(v uint32) string {
|
||||
return strconv.Itoa(int(v>>24)) + "." +
|
||||
strconv.Itoa(int(v>>16&0xFF)) + "." +
|
||||
|
||||
@ -1,23 +1,23 @@
|
||||
// Package md5 provides MD5 digest helpers.
|
||||
// Package md5 提供 MD5 摘要工具。
|
||||
package md5
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/crypto/gmd5"
|
||||
)
|
||||
|
||||
// Md5Hex returns the MD5 digest of s as a lowercase hex string.
|
||||
// The underlying error is ignored because it never fails for in-memory input.
|
||||
// Md5Hex 返回 s 的 MD5 摘要(小写十六进制字符串)。
|
||||
// 底层错误被忽略,因为对内存输入永远不会失败。
|
||||
func Md5Hex(s string) string {
|
||||
h, _ := gmd5.EncryptString(s)
|
||||
return h
|
||||
}
|
||||
|
||||
// Md5Bytes returns the MD5 digest of data as a lowercase hex string.
|
||||
// Md5Bytes 返回 data 的 MD5 摘要(小写十六进制字符串)。
|
||||
func Md5Bytes(data []byte) (string, error) {
|
||||
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) {
|
||||
return gmd5.EncryptFile(path)
|
||||
}
|
||||
|
||||
@ -1,26 +1,26 @@
|
||||
// Package random provides random number and string generation helpers.
|
||||
// Package random 提供随机数与随机字符串生成工具。
|
||||
package random
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/util/grand"
|
||||
)
|
||||
|
||||
// Int returns a random integer in [min, max].
|
||||
// Int 返回 [min, max] 区间内的随机整数。
|
||||
func Int(min, max int) int {
|
||||
return grand.N(min, max)
|
||||
}
|
||||
|
||||
// String returns a random alphanumeric string of length n.
|
||||
// String 返回长度为 n 的随机字母数字字符串。
|
||||
func String(n int) string {
|
||||
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 {
|
||||
return grand.Digits(n)
|
||||
}
|
||||
|
||||
// Letters returns a random letter-only string of length n.
|
||||
// Letters 返回长度为 n 的纯字母随机字符串。
|
||||
func Letters(n int) string {
|
||||
return grand.Letters(n)
|
||||
}
|
||||
|
||||
@ -1,17 +1,17 @@
|
||||
// Package slicex provides generic slice utilities built on the standard
|
||||
// library (Go 1.23+).
|
||||
// Package slicex 基于标准库提供通用切片工具(Go 1.23+)。
|
||||
// (续上一行)
|
||||
package slicex
|
||||
|
||||
import (
|
||||
"slices"
|
||||
)
|
||||
|
||||
// Contains reports whether v is present in items.
|
||||
// Contains 判断 items 中是否包含 v。
|
||||
func Contains[T comparable](items []T, v T) bool {
|
||||
return slices.Contains(items, v)
|
||||
}
|
||||
|
||||
// Unique returns items with duplicates removed, preserving first-seen order.
|
||||
// Unique 去除 items 中重复元素,保持首次出现顺序。
|
||||
func Unique[T comparable](items []T) []T {
|
||||
seen := make(map[T]struct{}, len(items))
|
||||
out := make([]T, 0, len(items))
|
||||
@ -25,8 +25,8 @@ func Unique[T comparable](items []T) []T {
|
||||
return out
|
||||
}
|
||||
|
||||
// Chunk splits items into sub-slices of at most size elements.
|
||||
// Returns nil when size <= 0 or items is empty.
|
||||
// Chunk 将 items 切分为最多 size 个元素的子切片,
|
||||
// size <= 0 或 items 为空时返回 nil。
|
||||
func Chunk[T any](items []T, size int) [][]T {
|
||||
if size <= 0 || len(items) == 0 {
|
||||
return nil
|
||||
@ -43,7 +43,7 @@ func Chunk[T any](items []T, size int) [][]T {
|
||||
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 {
|
||||
out := make([]R, len(items))
|
||||
for i, v := range items {
|
||||
@ -52,7 +52,7 @@ func Map[T, R any](items []T, fn func(T) R) []R {
|
||||
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 {
|
||||
out := make([]T, 0, len(items))
|
||||
for _, v := range items {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// Package strx provides string helpers on top of gstr, including naming
|
||||
// conversion and sensitive-data masking.
|
||||
// Package strx 基于 gstr 提供字符串工具,含命名
|
||||
// 转换与敏感数据脱敏。
|
||||
package strx
|
||||
|
||||
import (
|
||||
@ -8,28 +8,28 @@ import (
|
||||
"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 {
|
||||
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 {
|
||||
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 {
|
||||
return gstr.CaseCamelLower(s)
|
||||
}
|
||||
|
||||
// IsEmpty reports whether s is empty or whitespace-only.
|
||||
// IsEmpty 判断 s 是否为空或仅含空白字符。
|
||||
func IsEmpty(s string) bool {
|
||||
return strings.TrimSpace(s) == ""
|
||||
}
|
||||
|
||||
// MaskPhone masks a phone number, keeping the first 3 and last 4 characters.
|
||||
// e.g. "13812345678" -> "138****5678".
|
||||
// MaskPhone 对手机号脱敏,保留前 3 位与后 4 位。
|
||||
// 例如 "13812345678" -> "138****5678"。
|
||||
func MaskPhone(s string) string {
|
||||
if len(s) < 7 {
|
||||
return s
|
||||
@ -37,8 +37,8 @@ func MaskPhone(s string) string {
|
||||
return s[:3] + "****" + s[len(s)-4:]
|
||||
}
|
||||
|
||||
// MaskIDCard masks a Chinese ID card number, keeping the first 6 and last 4
|
||||
// characters. e.g. "110101199003074512" -> "110101********4512".
|
||||
// MaskIDCard 对身份证号脱敏,保留前 6 位与后 4 位,
|
||||
// 例如 "110101199003074512" -> "110101********4512"。
|
||||
func MaskIDCard(s string) string {
|
||||
if len(s) < 10 {
|
||||
return s
|
||||
@ -46,7 +46,7 @@ func MaskIDCard(s string) string {
|
||||
return s[:6] + "********" + s[len(s)-4:]
|
||||
}
|
||||
|
||||
// MaskName masks a Chinese name, keeping only the first character.
|
||||
// MaskName 对中文姓名脱敏,仅保留首字符。
|
||||
// e.g. "张三丰" -> "张**".
|
||||
func MaskName(s string) string {
|
||||
r := []rune(s)
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Package timex provides time formatting and computation helpers on top of gtime.
|
||||
// Package timex 基于 gtime 提供时间格式化与计算工具。
|
||||
package timex
|
||||
|
||||
import (
|
||||
@ -6,22 +6,22 @@ import (
|
||||
)
|
||||
|
||||
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"
|
||||
// LayoutDate is the conventional date layout: 2006-01-02.
|
||||
// LayoutDate 是常用日期格式:2006-01-02。
|
||||
LayoutDate = "2006-01-02"
|
||||
)
|
||||
|
||||
// Now returns the current time.
|
||||
// Now 返回当前时间。
|
||||
func Now() *gtime.Time {
|
||||
return gtime.Now()
|
||||
}
|
||||
|
||||
// Format returns t formatted with the given Go layout.
|
||||
// When layout is empty, LayoutDateTime is used.
|
||||
// Format 按给定 Go 布局格式化 t,
|
||||
// layout 为空时使用 LayoutDateTime。
|
||||
//
|
||||
// Note: gtime v2.10.2's Format() takes PHP-style format ("Y-m-d H:i:s"),
|
||||
// so this helper uses the Layout() method which accepts Go layouts.
|
||||
// 注意:gtime v2.10.2 的 Format() 接收 PHP 风格格式("Y-m-d H:i:s"),
|
||||
// 因此本工具改用接受 Go 布局的 Layout() 方法。
|
||||
func Format(t *gtime.Time, layout ...string) string {
|
||||
ly := LayoutDateTime
|
||||
if len(layout) > 0 && layout[0] != "" {
|
||||
@ -30,17 +30,17 @@ func Format(t *gtime.Time, layout ...string) string {
|
||||
return t.Layout(ly)
|
||||
}
|
||||
|
||||
// Timestamp returns the current Unix timestamp in seconds.
|
||||
// Timestamp 返回当前 Unix 秒级时间戳。
|
||||
func Timestamp() int64 {
|
||||
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 {
|
||||
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 {
|
||||
return gtime.NewFromStr(t.Layout(LayoutDate) + " 23:59:59")
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Package uuid provides unique ID generation helpers.
|
||||
// Package uuid 提供唯一 ID 生成工具。
|
||||
package uuid
|
||||
|
||||
import (
|
||||
@ -6,13 +6,13 @@ import (
|
||||
"github.com/gogf/gf/v2/util/guid"
|
||||
)
|
||||
|
||||
// New returns a 32-character unique ID without dashes.
|
||||
// New 返回不带连字符的 32 位唯一 ID。
|
||||
func New() string {
|
||||
return guid.S()
|
||||
}
|
||||
|
||||
// Short returns a random alphanumeric ID of length n (defaults to 8 when n <= 0).
|
||||
// Suitable for short invite codes / trace ids.
|
||||
// Short 返回长度为 n 的随机字母数字 ID(n <= 0 时默认为 8 位),
|
||||
// 适合短邀请码 / 追踪 ID 场景。
|
||||
func Short(n int) string {
|
||||
if n <= 0 {
|
||||
n = 8
|
||||
|
||||
223
docs/house-system-design.md
Normal file
223
docs/house-system-design.md
Normal 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 5(web-tdesign)+ echarts@6 + vxe-table@4 | 全部现成依赖,零新增 |
|
||||
| 地图 | 腾讯地图 GL JS(合规)+ DataV GeoJSON | 底图合规、支持 MultiMarker/热力/多边形 |
|
||||
| 采集分析 | Python(Scrapy/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` 分列。**趋势分析命脉,长期保留 1–2 年**。
|
||||
|
||||
### 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 方案定稿 | 1–2 天 | 建表 + gf gen dao + Python 骨架 |
|
||||
| 1 MVP | ~1 周 | 贝壳二手房挂牌 + 价格快照;房源列表/详情 API;列表 + 趋势图 |
|
||||
| 2 分析 | ~1 周 | 成交/网签 + 软关联对比 + 地图热力 + 楼盘对比 |
|
||||
| 3 决策 | ~1 周 | 新房备案价 + 学区/配套 + 偏好打分 |
|
||||
| 4 自动化 | ~1 周 | Bark 推送 + 迁腾讯云 7×24 |
|
||||
|
||||
## 12. 合规与风险
|
||||
|
||||
- 地图:仅腾讯/高德/百度/天地图;区县边界用 DataV 审图号数据;key 走代理不外泄;不采集他人个人位置
|
||||
- 爬虫:遵守 robots、低频、代理池、只存公开信息、个人自用
|
||||
- **最大风险**:贵阳网签/成交数据公开程度不如一线,MVP 用贝壳成交频道兜底
|
||||
@ -4,8 +4,9 @@
|
||||
gfcli:
|
||||
gen:
|
||||
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
|
||||
tables: "house_community,house_building,house_listing,house_price_snapshot,house_transaction,house_facility,house_community_facility,house_school_district,house_preference"
|
||||
|
||||
docker:
|
||||
build: "-a amd64 -s linux -p temp -ew"
|
||||
|
||||
@ -10,19 +10,23 @@ import (
|
||||
"github.com/gogf/gf/v2/os/genv"
|
||||
|
||||
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"
|
||||
userctl "service.xpcool.com/internal/controller/user"
|
||||
"service.xpcool.com/internal/library/jwt"
|
||||
"service.xpcool.com/internal/middleware"
|
||||
"service.xpcool.com/internal/service/admin/admin"
|
||||
"service.xpcool.com/internal/service/admin/base/log"
|
||||
adminaudit "service.xpcool.com/internal/service/admin/system/audit"
|
||||
adminauth "service.xpcool.com/internal/service/admin/system/auth"
|
||||
admin "service.xpcool.com/internal/service/admin/admin/admin"
|
||||
adminauth "service.xpcool.com/internal/service/admin/admin/login"
|
||||
log "service.xpcool.com/internal/service/admin/base/log"
|
||||
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"
|
||||
"service.xpcool.com/internal/service/admin/system/menu_manage"
|
||||
"service.xpcool.com/internal/service/admin/system/role"
|
||||
menu_manage "service.xpcool.com/internal/service/admin/system/menu_manage"
|
||||
role "service.xpcool.com/internal/service/admin/system/role"
|
||||
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 手动把关键环境变量写入配置系统。
|
||||
@ -58,37 +62,35 @@ var (
|
||||
menu_manage.RegisterMenuManage(menu_manage.NewMenuManage())
|
||||
log.RegisterLogManage(log.NewLogManage())
|
||||
adminaudit.RegisterAdminAudit(adminaudit.NewAdminAudit())
|
||||
s.Group("/", func(group *ghttp.RouterGroup) {
|
||||
group.Middleware(middleware.Recover, middleware.CORS)
|
||||
group.Middleware(ghttp.MiddlewareHandlerResponse)
|
||||
group.Bind(
|
||||
hello.NewV1(),
|
||||
)
|
||||
})
|
||||
s.Group("/api/open/v1", func(group *ghttp.RouterGroup) {
|
||||
adminloginlog.RegisterAdminLoginLog(adminloginlog.NewAdminLoginLog())
|
||||
housecommunity.RegisterCommunity(housecommunity.NewCommunity())
|
||||
houselisting.RegisterListing(houselisting.NewListing())
|
||||
housedashboard.RegisterDashboard(housedashboard.NewDashboard())
|
||||
s.Group("/api/service/open", func(group *ghttp.RouterGroup) {
|
||||
group.Middleware(middleware.Recover, middleware.CORS, ghttp.MiddlewareHandlerResponse)
|
||||
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.Bind(userctl.New()) // Login and refresh routes are public.
|
||||
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.Bind(adminctl.NewAuth()) // Public: login only.
|
||||
group.Group("/", func(profile *ghttp.RouterGroup) {
|
||||
// Login-only endpoints: own profile / access codes / menu routes.
|
||||
// 仅登录端点:个人资料 / 权限码 / 菜单路由。
|
||||
profile.Middleware(middleware.AdminAuthOnly(tokens))
|
||||
profile.Bind(adminctl.NewProfile())
|
||||
})
|
||||
group.Group("/", func(protected *ghttp.RouterGroup) {
|
||||
// Permission-protected endpoints: RBAC management, logs, ...
|
||||
// 受权限保护端点:RBAC 管理、日志等。
|
||||
// 权限由后端按「方法+路径」自动匹配,无需前端传 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) {
|
||||
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(housectl.New())
|
||||
})
|
||||
})
|
||||
s.Run()
|
||||
|
||||
@ -3,12 +3,12 @@ package admin
|
||||
import (
|
||||
"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/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) {
|
||||
items, total, err := admin.AdminManage().List(ctx, dto.PageQuery{Page: req.Page, Size: req.Size, Keyword: req.Keyword})
|
||||
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
|
||||
}
|
||||
|
||||
// AdminCreate creates an administrator.
|
||||
// AdminCreate 创建管理员。
|
||||
func (c *Controller) AdminCreate(ctx context.Context, req *adminv1.AdminCreateReq) (res *adminv1.AdminCreateRes, err error) {
|
||||
id, err := admin.AdminManage().Create(ctx, dto.AdminCreateInput{
|
||||
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
|
||||
}
|
||||
|
||||
// AdminUpdate updates an administrator.
|
||||
// AdminUpdate 更新管理员。
|
||||
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 {
|
||||
return nil, err
|
||||
@ -43,7 +43,7 @@ func (c *Controller) AdminUpdate(ctx context.Context, req *adminv1.AdminUpdateRe
|
||||
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) {
|
||||
if err = admin.AdminManage().ResetPassword(ctx, req.Id, req.Password); err != nil {
|
||||
return nil, err
|
||||
@ -51,7 +51,7 @@ func (c *Controller) AdminResetPwd(ctx context.Context, req *adminv1.AdminResetP
|
||||
return &adminv1.AdminResetPwdRes{}, nil
|
||||
}
|
||||
|
||||
// AdminDelete deletes an administrator.
|
||||
// AdminDelete 删除管理员。
|
||||
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 {
|
||||
return nil, err
|
||||
|
||||
@ -3,27 +3,41 @@ package admin
|
||||
import (
|
||||
"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/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{}
|
||||
|
||||
// NewAuth creates the public admin auth controller (login only).
|
||||
// NewAuth 创建公开的管理端认证控制器(仅登录)。
|
||||
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) {
|
||||
// 从请求上下文提取来源信息用于登录审计
|
||||
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})
|
||||
if err != nil {
|
||||
// 登录失败也落库(含失败原因),便于排查异常登录;日志失败不回传
|
||||
_ = loginlog.AdminLoginLog().Record(ctx, loginlog.LoginEvent{Username: req.Username, IP: ip, UserAgent: ua, Status: 0, FailReason: err.Error()})
|
||||
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
|
||||
}
|
||||
|
||||
// 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) {
|
||||
p, id, err := auth.AdminAuth().Refresh(ctx, req.RefreshToken)
|
||||
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
|
||||
}
|
||||
|
||||
// Logout ends the administrator session. Stateless JWT logout relies on the
|
||||
// client discarding tokens; the endpoint always succeeds for an authenticated admin.
|
||||
// Logout 结束管理员会话。无状态 JWT 登出依赖客户端
|
||||
// 丢弃令牌,该端点对任意已登录管理员始终成功。
|
||||
func (c *AuthController) Logout(ctx context.Context, req *authv1.LogoutReq) (res *authv1.LogoutRes, err error) {
|
||||
return &authv1.LogoutRes{}, nil
|
||||
}
|
||||
|
||||
@ -8,14 +8,14 @@ import (
|
||||
"service.xpcool.com/internal/middleware"
|
||||
)
|
||||
|
||||
// Controller implements the permission-protected /admin/v1 endpoints
|
||||
// Controller 实现受权限保护的后台管理端点
|
||||
// (RBAC management, logs, etc.). Bind behind AdminAuth (X-Permission).
|
||||
type Controller struct{}
|
||||
|
||||
// New creates the protected admin controller.
|
||||
// New 创建受保护的后台管理控制器。
|
||||
func New() *Controller { return &Controller{} }
|
||||
|
||||
// adminID returns the authenticated admin id stored by the auth middleware.
|
||||
// adminID 返回认证中间件写入的管理员 id。
|
||||
func adminID(ctx context.Context) uint64 {
|
||||
return g.RequestFromCtx(ctx).GetCtxVar(middleware.AdminIDKey).Uint64()
|
||||
}
|
||||
|
||||
@ -3,11 +3,14 @@ package admin
|
||||
import (
|
||||
"context"
|
||||
|
||||
logv1 "service.xpcool.com/api/admin/v1/base/log"
|
||||
"service.xpcool.com/internal/service/admin/base/log"
|
||||
logv1 "service.xpcool.com/api/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) {
|
||||
dir, files, err := log.LogManage().Files(ctx)
|
||||
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
|
||||
}
|
||||
|
||||
// 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) {
|
||||
lines, err := log.LogManage().Tail(ctx, req.File, req.Lines, req.Keyword)
|
||||
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
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
27
internal/controller/admin/login_log.go
Normal file
27
internal/controller/admin/login_log.go
Normal 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
|
||||
}
|
||||
@ -3,12 +3,12 @@ package admin
|
||||
import (
|
||||
"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/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) {
|
||||
tree, err := menu_manage.MenuManage().Tree(ctx)
|
||||
if err != nil {
|
||||
@ -21,7 +21,7 @@ func (c *Controller) MenuTree(ctx context.Context, req *menuv1.MenuTreeReq) (res
|
||||
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) {
|
||||
id, err := menu_manage.MenuManage().Create(ctx, dto.MenuCreateInput{
|
||||
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
|
||||
}
|
||||
|
||||
// MenuUpdate updates a menu or button node.
|
||||
// MenuUpdate 更新菜单或按钮节点。
|
||||
func (c *Controller) MenuUpdate(ctx context.Context, req *menuv1.MenuUpdateReq) (res *menuv1.MenuUpdateRes, err error) {
|
||||
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,
|
||||
@ -44,7 +44,7 @@ func (c *Controller) MenuUpdate(ctx context.Context, req *menuv1.MenuUpdateReq)
|
||||
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) {
|
||||
if err = menu_manage.MenuManage().Delete(ctx, req.Id); err != nil {
|
||||
return nil, err
|
||||
|
||||
@ -3,21 +3,21 @@ package admin
|
||||
import (
|
||||
"context"
|
||||
|
||||
authv1 "service.xpcool.com/api/admin/v1/system/auth"
|
||||
menuv1 "service.xpcool.com/api/admin/v1/system/menu"
|
||||
authv1 "service.xpcool.com/api/admin/admin/login"
|
||||
menuv1 "service.xpcool.com/api/admin/system/menu"
|
||||
"service.xpcool.com/internal/model/dto"
|
||||
"service.xpcool.com/internal/service/admin/system/auth"
|
||||
"service.xpcool.com/internal/service/admin/system/menu"
|
||||
auth "service.xpcool.com/internal/service/admin/admin/login"
|
||||
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.
|
||||
type ProfileController struct{}
|
||||
|
||||
// NewProfile creates the profile controller.
|
||||
// NewProfile 创建资料控制器。
|
||||
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) {
|
||||
info, err := auth.AdminAuth().Info(ctx, adminID(ctx))
|
||||
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
|
||||
}
|
||||
|
||||
// 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) {
|
||||
codes, err := auth.AdminAuth().Codes(ctx, adminID(ctx))
|
||||
if err != nil {
|
||||
@ -35,7 +35,7 @@ func (c *ProfileController) Codes(ctx context.Context, req *authv1.CodesReq) (re
|
||||
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) {
|
||||
routes, err := menu.AdminMenu().Routes(ctx, adminID(ctx))
|
||||
if err != nil {
|
||||
@ -48,7 +48,7 @@ func (c *ProfileController) Routes(ctx context.Context, req *menuv1.MenuRoutesRe
|
||||
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 {
|
||||
item := &menuv1.RouteItem{
|
||||
Name: r.Name,
|
||||
|
||||
@ -3,12 +3,12 @@ package admin
|
||||
import (
|
||||
"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/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) {
|
||||
items, total, err := role.RoleManage().List(ctx, dto.PageQuery{Page: req.Page, Size: req.Size, Keyword: req.Keyword})
|
||||
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
|
||||
}
|
||||
|
||||
// RoleCreate creates a role.
|
||||
// RoleCreate 创建角色。
|
||||
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})
|
||||
if err != nil {
|
||||
@ -32,7 +32,7 @@ func (c *Controller) RoleCreate(ctx context.Context, req *rolev1.RoleCreateReq)
|
||||
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) {
|
||||
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
|
||||
@ -40,7 +40,7 @@ func (c *Controller) RoleUpdate(ctx context.Context, req *rolev1.RoleUpdateReq)
|
||||
return &rolev1.RoleUpdateRes{}, nil
|
||||
}
|
||||
|
||||
// RoleDelete deletes a role.
|
||||
// RoleDelete 删除角色。
|
||||
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 {
|
||||
return nil, err
|
||||
|
||||
@ -1,5 +0,0 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package hello
|
||||
@ -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{}
|
||||
}
|
||||
@ -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
|
||||
}
|
||||
64
internal/controller/house/community.go
Normal file
64
internal/controller/house/community.go
Normal 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
|
||||
}
|
||||
8
internal/controller/house/controller.go
Normal file
8
internal/controller/house/controller.go
Normal file
@ -0,0 +1,8 @@
|
||||
// Package house 实现看房模块的管理端点,绑定在 admin 受权限保护分组下。
|
||||
package house
|
||||
|
||||
// Controller 实现看房模块的所有端点。
|
||||
type Controller struct{}
|
||||
|
||||
// New 创建看房模块控制器。
|
||||
func New() *Controller { return &Controller{} }
|
||||
67
internal/controller/house/dashboard.go
Normal file
67
internal/controller/house/dashboard.go
Normal 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
|
||||
}
|
||||
85
internal/controller/house/listing.go
Normal file
85
internal/controller/house/listing.go
Normal 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
|
||||
}
|
||||
@ -1,11 +1,11 @@
|
||||
// Package open implements the public open API (/api/open/v1).
|
||||
// These controllers are thin adapters over the common/tools Go packages and
|
||||
// require no authentication. Each sub-feature lives in its own file here,
|
||||
// mirroring api/open/v1/tools/<name>/index.go.
|
||||
// Package open 实现公开的开放接口(/api/open)。
|
||||
// 这些控制器是 common/tools Go 包的薄适配层,
|
||||
// 无需认证。每个子功能位于本目录下的独立文件,
|
||||
// 与 api/open/tools/<name>/index.go 一一对应。
|
||||
package open
|
||||
|
||||
// Controller implements the /api/open/v1 endpoints.
|
||||
// Controller 实现 /api/open 端点。
|
||||
type Controller struct{}
|
||||
|
||||
// New creates an open API controller.
|
||||
// New 创建开放接口控制器。
|
||||
func New() *Controller { return &Controller{} }
|
||||
|
||||
@ -5,11 +5,11 @@ import (
|
||||
|
||||
"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"
|
||||
)
|
||||
|
||||
// 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) {
|
||||
clientIP := g.RequestFromCtx(ctx).GetClientIp()
|
||||
return &ipapi.IPRes{IP: clientIP, Internal: ip.IsInternal(clientIP)}, nil
|
||||
|
||||
@ -3,11 +3,11 @@ package open
|
||||
import (
|
||||
"context"
|
||||
|
||||
md5api "service.xpcool.com/api/open/v1/tools/md5"
|
||||
md5api "service.xpcool.com/api/open/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) {
|
||||
return &md5api.MD5Res{MD5: md5.Md5Hex(req.Text)}, nil
|
||||
}
|
||||
|
||||
@ -3,11 +3,11 @@ package open
|
||||
import (
|
||||
"context"
|
||||
|
||||
randomapi "service.xpcool.com/api/open/v1/tools/random"
|
||||
randomapi "service.xpcool.com/api/open/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) {
|
||||
var value string
|
||||
switch req.Type {
|
||||
|
||||
@ -3,11 +3,11 @@ package open
|
||||
import (
|
||||
"context"
|
||||
|
||||
timeapi "service.xpcool.com/api/open/v1/tools/time"
|
||||
timeapi "service.xpcool.com/api/open/tools/time"
|
||||
"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) {
|
||||
now := timex.Now()
|
||||
return &timeapi.TimeRes{
|
||||
|
||||
@ -3,11 +3,11 @@ package open
|
||||
import (
|
||||
"context"
|
||||
|
||||
uuidapi "service.xpcool.com/api/open/v1/tools/uuid"
|
||||
uuidapi "service.xpcool.com/api/open/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) {
|
||||
if req.Short {
|
||||
return &uuidapi.UUIDRes{UUID: uuid.Short(8)}, nil
|
||||
|
||||
@ -2,9 +2,9 @@ package user
|
||||
|
||||
import (
|
||||
"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/service/user/auth"
|
||||
auth "service.xpcool.com/internal/service/user/auth"
|
||||
)
|
||||
|
||||
type Controller struct{}
|
||||
|
||||
22
internal/dao/admin_login_log.go
Normal file
22
internal/dao/admin_login_log.go
Normal 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()}
|
||||
)
|
||||
|
||||
// 在下方添加你的自定义方法。
|
||||
@ -1,5 +1,5 @@
|
||||
// =================================================================================
|
||||
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||
// 本文件由 GoFrame CLI 工具自动生成,可按需修改。
|
||||
// =================================================================================
|
||||
|
||||
package dao
|
||||
@ -8,15 +8,15 @@ import (
|
||||
"service.xpcool.com/internal/dao/internal"
|
||||
)
|
||||
|
||||
// adminMenuDao is the data access object for the table admin_menu.
|
||||
// You can define custom methods on it to extend its functionality as needed.
|
||||
// adminMenuDao 是表 admin_menu 的数据访问对象。
|
||||
// 可在其上定义自定义方法以扩展其功能。
|
||||
type adminMenuDao struct {
|
||||
*internal.AdminMenuDao
|
||||
}
|
||||
|
||||
var (
|
||||
// AdminMenu is a globally accessible object for table admin_menu operations.
|
||||
// AdminMenu 是表 admin_menu 的全局可访问操作对象。
|
||||
AdminMenu = adminMenuDao{internal.NewAdminMenuDao()}
|
||||
)
|
||||
|
||||
// Add your custom methods and functionality below.
|
||||
// 在下方添加你的自定义方法。
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// =================================================================================
|
||||
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||
// 本文件由 GoFrame CLI 工具自动生成,可按需修改。
|
||||
// =================================================================================
|
||||
|
||||
package dao
|
||||
@ -8,15 +8,15 @@ import (
|
||||
"service.xpcool.com/internal/dao/internal"
|
||||
)
|
||||
|
||||
// adminOperationLogDao is the data access object for the table admin_operation_log.
|
||||
// You can define custom methods on it to extend its functionality as needed.
|
||||
// adminOperationLogDao 是表 admin_operation_log 的数据访问对象。
|
||||
// 可在其上定义自定义方法以扩展其功能。
|
||||
type adminOperationLogDao struct {
|
||||
*internal.AdminOperationLogDao
|
||||
}
|
||||
|
||||
var (
|
||||
// AdminOperationLog is a globally accessible object for table admin_operation_log operations.
|
||||
// AdminOperationLog 是表 admin_operation_log 的全局可访问操作对象。
|
||||
AdminOperationLog = adminOperationLogDao{internal.NewAdminOperationLogDao()}
|
||||
)
|
||||
|
||||
// Add your custom methods and functionality below.
|
||||
// 在下方添加你的自定义方法。
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// =================================================================================
|
||||
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||
// 本文件由 GoFrame CLI 工具自动生成,可按需修改。
|
||||
// =================================================================================
|
||||
|
||||
package dao
|
||||
@ -8,15 +8,15 @@ import (
|
||||
"service.xpcool.com/internal/dao/internal"
|
||||
)
|
||||
|
||||
// adminRoleDao is the data access object for the table admin_role.
|
||||
// You can define custom methods on it to extend its functionality as needed.
|
||||
// adminRoleDao 是表 admin_role 的数据访问对象。
|
||||
// 可在其上定义自定义方法以扩展其功能。
|
||||
type adminRoleDao struct {
|
||||
*internal.AdminRoleDao
|
||||
}
|
||||
|
||||
var (
|
||||
// AdminRole is a globally accessible object for table admin_role operations.
|
||||
// AdminRole 是表 admin_role 的全局可访问操作对象。
|
||||
AdminRole = adminRoleDao{internal.NewAdminRoleDao()}
|
||||
)
|
||||
|
||||
// Add your custom methods and functionality below.
|
||||
// 在下方添加你的自定义方法。
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// =================================================================================
|
||||
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||
// 本文件由 GoFrame CLI 工具自动生成,可按需修改。
|
||||
// =================================================================================
|
||||
|
||||
package dao
|
||||
@ -8,15 +8,15 @@ import (
|
||||
"service.xpcool.com/internal/dao/internal"
|
||||
)
|
||||
|
||||
// adminRoleMenuDao is the data access object for the table admin_role_menu.
|
||||
// You can define custom methods on it to extend its functionality as needed.
|
||||
// adminRoleMenuDao 是表 admin_role_menu 的数据访问对象。
|
||||
// 可在其上定义自定义方法以扩展其功能。
|
||||
type adminRoleMenuDao struct {
|
||||
*internal.AdminRoleMenuDao
|
||||
}
|
||||
|
||||
var (
|
||||
// AdminRoleMenu is a globally accessible object for table admin_role_menu operations.
|
||||
// AdminRoleMenu 是表 admin_role_menu 的全局可访问操作对象。
|
||||
AdminRoleMenu = adminRoleMenuDao{internal.NewAdminRoleMenuDao()}
|
||||
)
|
||||
|
||||
// Add your custom methods and functionality below.
|
||||
// 在下方添加你的自定义方法。
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// =================================================================================
|
||||
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||
// 本文件由 GoFrame CLI 工具自动生成,可按需修改。
|
||||
// =================================================================================
|
||||
|
||||
package dao
|
||||
@ -8,15 +8,15 @@ import (
|
||||
"service.xpcool.com/internal/dao/internal"
|
||||
)
|
||||
|
||||
// adminUserDao is the data access object for the table admin_user.
|
||||
// You can define custom methods on it to extend its functionality as needed.
|
||||
// adminUserDao 是表 admin_user 的数据访问对象。
|
||||
// 可在其上定义自定义方法以扩展其功能。
|
||||
type adminUserDao struct {
|
||||
*internal.AdminUserDao
|
||||
}
|
||||
|
||||
var (
|
||||
// AdminUser is a globally accessible object for table admin_user operations.
|
||||
// AdminUser 是表 admin_user 的全局可访问操作对象。
|
||||
AdminUser = adminUserDao{internal.NewAdminUserDao()}
|
||||
)
|
||||
|
||||
// Add your custom methods and functionality below.
|
||||
// 在下方添加你的自定义方法。
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// =================================================================================
|
||||
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||
// 本文件由 GoFrame CLI 工具自动生成,可按需修改。
|
||||
// =================================================================================
|
||||
|
||||
package dao
|
||||
@ -8,15 +8,15 @@ import (
|
||||
"service.xpcool.com/internal/dao/internal"
|
||||
)
|
||||
|
||||
// adminUserRoleDao is the data access object for the table admin_user_role.
|
||||
// You can define custom methods on it to extend its functionality as needed.
|
||||
// adminUserRoleDao 是表 admin_user_role 的数据访问对象。
|
||||
// 可在其上定义自定义方法以扩展其功能。
|
||||
type adminUserRoleDao struct {
|
||||
*internal.AdminUserRoleDao
|
||||
}
|
||||
|
||||
var (
|
||||
// AdminUserRole is a globally accessible object for table admin_user_role operations.
|
||||
// AdminUserRole 是表 admin_user_role 的全局可访问操作对象。
|
||||
AdminUserRole = adminUserRoleDao{internal.NewAdminUserRoleDao()}
|
||||
)
|
||||
|
||||
// Add your custom methods and functionality below.
|
||||
// 在下方添加你的自定义方法。
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// =================================================================================
|
||||
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||
// 本文件由 GoFrame CLI 工具自动生成,可按需修改。
|
||||
// =================================================================================
|
||||
|
||||
package dao
|
||||
@ -8,15 +8,15 @@ import (
|
||||
"service.xpcool.com/internal/dao/internal"
|
||||
)
|
||||
|
||||
// authRefreshSessionDao is the data access object for the table auth_refresh_session.
|
||||
// You can define custom methods on it to extend its functionality as needed.
|
||||
// authRefreshSessionDao 是表 auth_refresh_session 的数据访问对象。
|
||||
// 可在其上定义自定义方法以扩展其功能。
|
||||
type authRefreshSessionDao struct {
|
||||
*internal.AuthRefreshSessionDao
|
||||
}
|
||||
|
||||
var (
|
||||
// AuthRefreshSession is a globally accessible object for table auth_refresh_session operations.
|
||||
// AuthRefreshSession 是表 auth_refresh_session 的全局可访问操作对象。
|
||||
AuthRefreshSession = authRefreshSessionDao{internal.NewAuthRefreshSessionDao()}
|
||||
)
|
||||
|
||||
// Add your custom methods and functionality below.
|
||||
// 在下方添加你的自定义方法。
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// =================================================================================
|
||||
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||
// 本文件由 GoFrame CLI 工具自动生成,可按需修改。
|
||||
// =================================================================================
|
||||
|
||||
package dao
|
||||
@ -8,15 +8,15 @@ import (
|
||||
"service.xpcool.com/internal/dao/internal"
|
||||
)
|
||||
|
||||
// contentDao is the data access object for the table content.
|
||||
// You can define custom methods on it to extend its functionality as needed.
|
||||
// contentDao 是表 content 的数据访问对象。
|
||||
// 可在其上定义自定义方法以扩展其功能。
|
||||
type contentDao struct {
|
||||
*internal.ContentDao
|
||||
}
|
||||
|
||||
var (
|
||||
// Content is a globally accessible object for table content operations.
|
||||
// Content 是表 content 的全局可访问操作对象。
|
||||
Content = contentDao{internal.NewContentDao()}
|
||||
)
|
||||
|
||||
// Add your custom methods and functionality below.
|
||||
// 在下方添加你的自定义方法。
|
||||
|
||||
22
internal/dao/house_building.go
Normal file
22
internal/dao/house_building.go
Normal 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.
|
||||
22
internal/dao/house_community.go
Normal file
22
internal/dao/house_community.go
Normal 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.
|
||||
22
internal/dao/house_community_facility.go
Normal file
22
internal/dao/house_community_facility.go
Normal 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.
|
||||
22
internal/dao/house_facility.go
Normal file
22
internal/dao/house_facility.go
Normal 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.
|
||||
22
internal/dao/house_listing.go
Normal file
22
internal/dao/house_listing.go
Normal 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.
|
||||
22
internal/dao/house_preference.go
Normal file
22
internal/dao/house_preference.go
Normal 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.
|
||||
22
internal/dao/house_price_snapshot.go
Normal file
22
internal/dao/house_price_snapshot.go
Normal 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.
|
||||
22
internal/dao/house_school_district.go
Normal file
22
internal/dao/house_school_district.go
Normal 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.
|
||||
22
internal/dao/house_transaction.go
Normal file
22
internal/dao/house_transaction.go
Normal 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.
|
||||
91
internal/dao/internal/admin_login_log.go
Normal file
91
internal/dao/internal/admin_login_log.go
Normal 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)
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
// ==========================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// 本文件由 GoFrame CLI 工具生成并维护,请勿编辑。
|
||||
// ==========================================================================
|
||||
|
||||
package internal
|
||||
@ -11,7 +11,7 @@ import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// AdminMenuDao is the data access object for the table admin_menu.
|
||||
// AdminMenuDao 是表 admin_menu 的数据访问对象。
|
||||
type AdminMenuDao 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.
|
||||
@ -19,7 +19,7 @@ type AdminMenuDao struct {
|
||||
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 {
|
||||
Id string //
|
||||
ParentId string //
|
||||
@ -34,7 +34,7 @@ type AdminMenuColumns struct {
|
||||
DeletedAt string //
|
||||
}
|
||||
|
||||
// adminMenuColumns holds the columns for the table admin_menu.
|
||||
// adminMenuColumns 保存表 admin_menu 的列信息。
|
||||
var adminMenuColumns = AdminMenuColumns{
|
||||
Id: "id",
|
||||
ParentId: "parent_id",
|
||||
@ -49,7 +49,7 @@ var adminMenuColumns = AdminMenuColumns{
|
||||
DeletedAt: "deleted_at",
|
||||
}
|
||||
|
||||
// NewAdminMenuDao creates and returns a new DAO object for table data access.
|
||||
// NewAdminMenuDao 创建并返回一个新的表数据访问 DAO 对象。
|
||||
func NewAdminMenuDao(handlers ...gdb.ModelHandler) *AdminMenuDao {
|
||||
return &AdminMenuDao{
|
||||
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 {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of the current DAO.
|
||||
// Table 返回当前 DAO 的表名。
|
||||
func (dao *AdminMenuDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of the current DAO.
|
||||
// Columns 返回当前 DAO 的全部列名。
|
||||
func (dao *AdminMenuDao) Columns() AdminMenuColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the database configuration group name of the current DAO.
|
||||
// Group 返回当前 DAO 的数据库配置组名。
|
||||
func (dao *AdminMenuDao) Group() string {
|
||||
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 {
|
||||
model := dao.DB().Model(dao.table)
|
||||
for _, handler := range dao.handlers {
|
||||
@ -88,12 +88,12 @@ func (dao *AdminMenuDao) Ctx(ctx context.Context) *gdb.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.
|
||||
// Transaction 使用函数 f 包裹事务逻辑。
|
||||
// 若 f 返回非 nil 错误,则回滚事务并返回该错误。
|
||||
// 若 f 返回 nil,则提交事务并返回 nil。
|
||||
//
|
||||
// Note: Do not commit or roll back the transaction in function f,
|
||||
// as it is automatically handled by this function.
|
||||
// 注意:请勿在函数 f 内提交或回滚事务,
|
||||
// 该函数会自动处理。
|
||||
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)
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// ==========================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// 本文件由 GoFrame CLI 工具生成并维护,请勿编辑。
|
||||
// ==========================================================================
|
||||
|
||||
package internal
|
||||
@ -11,7 +11,7 @@ import (
|
||||
"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 {
|
||||
table string // table is the underlying table name of the 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.
|
||||
}
|
||||
|
||||
// AdminOperationLogColumns defines and stores column names for the table admin_operation_log.
|
||||
// AdminOperationLogColumns 定义并存储表 admin_operation_log 的列名。
|
||||
type AdminOperationLogColumns struct {
|
||||
Id string //
|
||||
AdminUserId string //
|
||||
@ -35,7 +35,7 @@ type AdminOperationLogColumns struct {
|
||||
DeletedAt string //
|
||||
}
|
||||
|
||||
// adminOperationLogColumns holds the columns for the table admin_operation_log.
|
||||
// adminOperationLogColumns 保存表 admin_operation_log 的列信息。
|
||||
var adminOperationLogColumns = AdminOperationLogColumns{
|
||||
Id: "id",
|
||||
AdminUserId: "admin_user_id",
|
||||
@ -51,7 +51,7 @@ var adminOperationLogColumns = AdminOperationLogColumns{
|
||||
DeletedAt: "deleted_at",
|
||||
}
|
||||
|
||||
// NewAdminOperationLogDao creates and returns a new DAO object for table data access.
|
||||
// NewAdminOperationLogDao 创建并返回一个新的表数据访问 DAO 对象。
|
||||
func NewAdminOperationLogDao(handlers ...gdb.ModelHandler) *AdminOperationLogDao {
|
||||
return &AdminOperationLogDao{
|
||||
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 {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of the current DAO.
|
||||
// Table 返回当前 DAO 的表名。
|
||||
func (dao *AdminOperationLogDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of the current DAO.
|
||||
// Columns 返回当前 DAO 的全部列名。
|
||||
func (dao *AdminOperationLogDao) Columns() AdminOperationLogColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the database configuration group name of the current DAO.
|
||||
// Group 返回当前 DAO 的数据库配置组名。
|
||||
func (dao *AdminOperationLogDao) Group() string {
|
||||
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 {
|
||||
model := dao.DB().Model(dao.table)
|
||||
for _, handler := range dao.handlers {
|
||||
@ -90,12 +90,12 @@ func (dao *AdminOperationLogDao) Ctx(ctx context.Context) *gdb.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.
|
||||
// Transaction 使用函数 f 包裹事务逻辑。
|
||||
// 若 f 返回非 nil 错误,则回滚事务并返回该错误。
|
||||
// 若 f 返回 nil,则提交事务并返回 nil。
|
||||
//
|
||||
// Note: Do not commit or roll back the transaction in function f,
|
||||
// as it is automatically handled by this function.
|
||||
// 注意:请勿在函数 f 内提交或回滚事务,
|
||||
// 该函数会自动处理。
|
||||
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)
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// ==========================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// 本文件由 GoFrame CLI 工具生成并维护,请勿编辑。
|
||||
// ==========================================================================
|
||||
|
||||
package internal
|
||||
@ -11,7 +11,7 @@ import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// AdminRoleDao is the data access object for the table admin_role.
|
||||
// AdminRoleDao 是表 admin_role 的数据访问对象。
|
||||
type AdminRoleDao 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.
|
||||
@ -19,7 +19,7 @@ type AdminRoleDao struct {
|
||||
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 {
|
||||
Id string //
|
||||
Code string //
|
||||
@ -30,7 +30,7 @@ type AdminRoleColumns struct {
|
||||
DeletedAt string //
|
||||
}
|
||||
|
||||
// adminRoleColumns holds the columns for the table admin_role.
|
||||
// adminRoleColumns 保存表 admin_role 的列信息。
|
||||
var adminRoleColumns = AdminRoleColumns{
|
||||
Id: "id",
|
||||
Code: "code",
|
||||
@ -41,7 +41,7 @@ var adminRoleColumns = AdminRoleColumns{
|
||||
DeletedAt: "deleted_at",
|
||||
}
|
||||
|
||||
// NewAdminRoleDao creates and returns a new DAO object for table data access.
|
||||
// NewAdminRoleDao 创建并返回一个新的表数据访问 DAO 对象。
|
||||
func NewAdminRoleDao(handlers ...gdb.ModelHandler) *AdminRoleDao {
|
||||
return &AdminRoleDao{
|
||||
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 {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of the current DAO.
|
||||
// Table 返回当前 DAO 的表名。
|
||||
func (dao *AdminRoleDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of the current DAO.
|
||||
// Columns 返回当前 DAO 的全部列名。
|
||||
func (dao *AdminRoleDao) Columns() AdminRoleColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the database configuration group name of the current DAO.
|
||||
// Group 返回当前 DAO 的数据库配置组名。
|
||||
func (dao *AdminRoleDao) Group() string {
|
||||
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 {
|
||||
model := dao.DB().Model(dao.table)
|
||||
for _, handler := range dao.handlers {
|
||||
@ -80,12 +80,12 @@ func (dao *AdminRoleDao) Ctx(ctx context.Context) *gdb.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.
|
||||
// Transaction 使用函数 f 包裹事务逻辑。
|
||||
// 若 f 返回非 nil 错误,则回滚事务并返回该错误。
|
||||
// 若 f 返回 nil,则提交事务并返回 nil。
|
||||
//
|
||||
// Note: Do not commit or roll back the transaction in function f,
|
||||
// as it is automatically handled by this function.
|
||||
// 注意:请勿在函数 f 内提交或回滚事务,
|
||||
// 该函数会自动处理。
|
||||
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)
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// ==========================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// 本文件由 GoFrame CLI 工具生成并维护,请勿编辑。
|
||||
// ==========================================================================
|
||||
|
||||
package internal
|
||||
@ -11,7 +11,7 @@ import (
|
||||
"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 {
|
||||
table string // table is the underlying table name of the 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.
|
||||
}
|
||||
|
||||
// AdminRoleMenuColumns defines and stores column names for the table admin_role_menu.
|
||||
// AdminRoleMenuColumns 定义并存储表 admin_role_menu 的列名。
|
||||
type AdminRoleMenuColumns struct {
|
||||
Id string //
|
||||
RoleId string //
|
||||
@ -29,7 +29,7 @@ type AdminRoleMenuColumns struct {
|
||||
DeletedAt string //
|
||||
}
|
||||
|
||||
// adminRoleMenuColumns holds the columns for the table admin_role_menu.
|
||||
// adminRoleMenuColumns 保存表 admin_role_menu 的列信息。
|
||||
var adminRoleMenuColumns = AdminRoleMenuColumns{
|
||||
Id: "id",
|
||||
RoleId: "role_id",
|
||||
@ -39,7 +39,7 @@ var adminRoleMenuColumns = AdminRoleMenuColumns{
|
||||
DeletedAt: "deleted_at",
|
||||
}
|
||||
|
||||
// NewAdminRoleMenuDao creates and returns a new DAO object for table data access.
|
||||
// NewAdminRoleMenuDao 创建并返回一个新的表数据访问 DAO 对象。
|
||||
func NewAdminRoleMenuDao(handlers ...gdb.ModelHandler) *AdminRoleMenuDao {
|
||||
return &AdminRoleMenuDao{
|
||||
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 {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of the current DAO.
|
||||
// Table 返回当前 DAO 的表名。
|
||||
func (dao *AdminRoleMenuDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of the current DAO.
|
||||
// Columns 返回当前 DAO 的全部列名。
|
||||
func (dao *AdminRoleMenuDao) Columns() AdminRoleMenuColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the database configuration group name of the current DAO.
|
||||
// Group 返回当前 DAO 的数据库配置组名。
|
||||
func (dao *AdminRoleMenuDao) Group() string {
|
||||
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 {
|
||||
model := dao.DB().Model(dao.table)
|
||||
for _, handler := range dao.handlers {
|
||||
@ -78,12 +78,12 @@ func (dao *AdminRoleMenuDao) Ctx(ctx context.Context) *gdb.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.
|
||||
// Transaction 使用函数 f 包裹事务逻辑。
|
||||
// 若 f 返回非 nil 错误,则回滚事务并返回该错误。
|
||||
// 若 f 返回 nil,则提交事务并返回 nil。
|
||||
//
|
||||
// Note: Do not commit or roll back the transaction in function f,
|
||||
// as it is automatically handled by this function.
|
||||
// 注意:请勿在函数 f 内提交或回滚事务,
|
||||
// 该函数会自动处理。
|
||||
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)
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// ==========================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// 本文件由 GoFrame CLI 工具生成并维护,请勿编辑。
|
||||
// ==========================================================================
|
||||
|
||||
package internal
|
||||
@ -11,7 +11,7 @@ import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// AdminUserDao is the data access object for the table admin_user.
|
||||
// AdminUserDao 是表 admin_user 的数据访问对象。
|
||||
type AdminUserDao 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.
|
||||
@ -19,7 +19,7 @@ type AdminUserDao struct {
|
||||
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 {
|
||||
Id string //
|
||||
Username string //
|
||||
@ -32,7 +32,7 @@ type AdminUserColumns struct {
|
||||
DeletedAt string //
|
||||
}
|
||||
|
||||
// adminUserColumns holds the columns for the table admin_user.
|
||||
// adminUserColumns 保存表 admin_user 的列信息。
|
||||
var adminUserColumns = AdminUserColumns{
|
||||
Id: "id",
|
||||
Username: "username",
|
||||
@ -45,7 +45,7 @@ var adminUserColumns = AdminUserColumns{
|
||||
DeletedAt: "deleted_at",
|
||||
}
|
||||
|
||||
// NewAdminUserDao creates and returns a new DAO object for table data access.
|
||||
// NewAdminUserDao 创建并返回一个新的表数据访问 DAO 对象。
|
||||
func NewAdminUserDao(handlers ...gdb.ModelHandler) *AdminUserDao {
|
||||
return &AdminUserDao{
|
||||
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 {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of the current DAO.
|
||||
// Table 返回当前 DAO 的表名。
|
||||
func (dao *AdminUserDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of the current DAO.
|
||||
// Columns 返回当前 DAO 的全部列名。
|
||||
func (dao *AdminUserDao) Columns() AdminUserColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the database configuration group name of the current DAO.
|
||||
// Group 返回当前 DAO 的数据库配置组名。
|
||||
func (dao *AdminUserDao) Group() string {
|
||||
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 {
|
||||
model := dao.DB().Model(dao.table)
|
||||
for _, handler := range dao.handlers {
|
||||
@ -84,12 +84,12 @@ func (dao *AdminUserDao) Ctx(ctx context.Context) *gdb.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.
|
||||
// Transaction 使用函数 f 包裹事务逻辑。
|
||||
// 若 f 返回非 nil 错误,则回滚事务并返回该错误。
|
||||
// 若 f 返回 nil,则提交事务并返回 nil。
|
||||
//
|
||||
// Note: Do not commit or roll back the transaction in function f,
|
||||
// as it is automatically handled by this function.
|
||||
// 注意:请勿在函数 f 内提交或回滚事务,
|
||||
// 该函数会自动处理。
|
||||
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)
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// ==========================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// 本文件由 GoFrame CLI 工具生成并维护,请勿编辑。
|
||||
// ==========================================================================
|
||||
|
||||
package internal
|
||||
@ -11,7 +11,7 @@ import (
|
||||
"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 {
|
||||
table string // table is the underlying table name of the 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.
|
||||
}
|
||||
|
||||
// AdminUserRoleColumns defines and stores column names for the table admin_user_role.
|
||||
// AdminUserRoleColumns 定义并存储表 admin_user_role 的列名。
|
||||
type AdminUserRoleColumns struct {
|
||||
Id string //
|
||||
AdminUserId string //
|
||||
@ -29,7 +29,7 @@ type AdminUserRoleColumns struct {
|
||||
DeletedAt string //
|
||||
}
|
||||
|
||||
// adminUserRoleColumns holds the columns for the table admin_user_role.
|
||||
// adminUserRoleColumns 保存表 admin_user_role 的列信息。
|
||||
var adminUserRoleColumns = AdminUserRoleColumns{
|
||||
Id: "id",
|
||||
AdminUserId: "admin_user_id",
|
||||
@ -39,7 +39,7 @@ var adminUserRoleColumns = AdminUserRoleColumns{
|
||||
DeletedAt: "deleted_at",
|
||||
}
|
||||
|
||||
// NewAdminUserRoleDao creates and returns a new DAO object for table data access.
|
||||
// NewAdminUserRoleDao 创建并返回一个新的表数据访问 DAO 对象。
|
||||
func NewAdminUserRoleDao(handlers ...gdb.ModelHandler) *AdminUserRoleDao {
|
||||
return &AdminUserRoleDao{
|
||||
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 {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of the current DAO.
|
||||
// Table 返回当前 DAO 的表名。
|
||||
func (dao *AdminUserRoleDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of the current DAO.
|
||||
// Columns 返回当前 DAO 的全部列名。
|
||||
func (dao *AdminUserRoleDao) Columns() AdminUserRoleColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the database configuration group name of the current DAO.
|
||||
// Group 返回当前 DAO 的数据库配置组名。
|
||||
func (dao *AdminUserRoleDao) Group() string {
|
||||
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 {
|
||||
model := dao.DB().Model(dao.table)
|
||||
for _, handler := range dao.handlers {
|
||||
@ -78,12 +78,12 @@ func (dao *AdminUserRoleDao) Ctx(ctx context.Context) *gdb.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.
|
||||
// Transaction 使用函数 f 包裹事务逻辑。
|
||||
// 若 f 返回非 nil 错误,则回滚事务并返回该错误。
|
||||
// 若 f 返回 nil,则提交事务并返回 nil。
|
||||
//
|
||||
// Note: Do not commit or roll back the transaction in function f,
|
||||
// as it is automatically handled by this function.
|
||||
// 注意:请勿在函数 f 内提交或回滚事务,
|
||||
// 该函数会自动处理。
|
||||
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)
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// ==========================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// 本文件由 GoFrame CLI 工具生成并维护,请勿编辑。
|
||||
// ==========================================================================
|
||||
|
||||
package internal
|
||||
@ -11,7 +11,7 @@ import (
|
||||
"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 {
|
||||
table string // table is the underlying table name of the 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.
|
||||
}
|
||||
|
||||
// AuthRefreshSessionColumns defines and stores column names for the table auth_refresh_session.
|
||||
// AuthRefreshSessionColumns 定义并存储表 auth_refresh_session 的列名。
|
||||
type AuthRefreshSessionColumns struct {
|
||||
Id string //
|
||||
SubjectId string // ????????? ID
|
||||
@ -33,7 +33,7 @@ type AuthRefreshSessionColumns struct {
|
||||
DeletedAt string //
|
||||
}
|
||||
|
||||
// authRefreshSessionColumns holds the columns for the table auth_refresh_session.
|
||||
// authRefreshSessionColumns 保存表 auth_refresh_session 的列信息。
|
||||
var authRefreshSessionColumns = AuthRefreshSessionColumns{
|
||||
Id: "id",
|
||||
SubjectId: "subject_id",
|
||||
@ -47,7 +47,7 @@ var authRefreshSessionColumns = AuthRefreshSessionColumns{
|
||||
DeletedAt: "deleted_at",
|
||||
}
|
||||
|
||||
// NewAuthRefreshSessionDao creates and returns a new DAO object for table data access.
|
||||
// NewAuthRefreshSessionDao 创建并返回一个新的表数据访问 DAO 对象。
|
||||
func NewAuthRefreshSessionDao(handlers ...gdb.ModelHandler) *AuthRefreshSessionDao {
|
||||
return &AuthRefreshSessionDao{
|
||||
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 {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of the current DAO.
|
||||
// Table 返回当前 DAO 的表名。
|
||||
func (dao *AuthRefreshSessionDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of the current DAO.
|
||||
// Columns 返回当前 DAO 的全部列名。
|
||||
func (dao *AuthRefreshSessionDao) Columns() AuthRefreshSessionColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the database configuration group name of the current DAO.
|
||||
// Group 返回当前 DAO 的数据库配置组名。
|
||||
func (dao *AuthRefreshSessionDao) Group() string {
|
||||
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 {
|
||||
model := dao.DB().Model(dao.table)
|
||||
for _, handler := range dao.handlers {
|
||||
@ -86,12 +86,12 @@ func (dao *AuthRefreshSessionDao) Ctx(ctx context.Context) *gdb.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.
|
||||
// Transaction 使用函数 f 包裹事务逻辑。
|
||||
// 若 f 返回非 nil 错误,则回滚事务并返回该错误。
|
||||
// 若 f 返回 nil,则提交事务并返回 nil。
|
||||
//
|
||||
// Note: Do not commit or roll back the transaction in function f,
|
||||
// as it is automatically handled by this function.
|
||||
// 注意:请勿在函数 f 内提交或回滚事务,
|
||||
// 该函数会自动处理。
|
||||
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)
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// ==========================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// 本文件由 GoFrame CLI 工具生成并维护,请勿编辑。
|
||||
// ==========================================================================
|
||||
|
||||
package internal
|
||||
@ -11,7 +11,7 @@ import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// ContentDao is the data access object for the table content.
|
||||
// ContentDao 是表 content 的数据访问对象。
|
||||
type ContentDao 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.
|
||||
@ -19,7 +19,7 @@ type ContentDao struct {
|
||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||
}
|
||||
|
||||
// ContentColumns defines and stores column names for the table content.
|
||||
// ContentColumns 定义并存储表 content 的列名。
|
||||
type ContentColumns struct {
|
||||
Id string //
|
||||
Title string //
|
||||
@ -30,7 +30,7 @@ type ContentColumns struct {
|
||||
DeletedAt string //
|
||||
}
|
||||
|
||||
// contentColumns holds the columns for the table content.
|
||||
// contentColumns 保存表 content 的列信息。
|
||||
var contentColumns = ContentColumns{
|
||||
Id: "id",
|
||||
Title: "title",
|
||||
@ -41,7 +41,7 @@ var contentColumns = ContentColumns{
|
||||
DeletedAt: "deleted_at",
|
||||
}
|
||||
|
||||
// NewContentDao creates and returns a new DAO object for table data access.
|
||||
// NewContentDao 创建并返回一个新的表数据访问 DAO 对象。
|
||||
func NewContentDao(handlers ...gdb.ModelHandler) *ContentDao {
|
||||
return &ContentDao{
|
||||
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 {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of the current DAO.
|
||||
// Table 返回当前 DAO 的表名。
|
||||
func (dao *ContentDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of the current DAO.
|
||||
// Columns 返回当前 DAO 的全部列名。
|
||||
func (dao *ContentDao) Columns() ContentColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the database configuration group name of the current DAO.
|
||||
// Group 返回当前 DAO 的数据库配置组名。
|
||||
func (dao *ContentDao) Group() string {
|
||||
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 {
|
||||
model := dao.DB().Model(dao.table)
|
||||
for _, handler := range dao.handlers {
|
||||
@ -80,12 +80,12 @@ func (dao *ContentDao) Ctx(ctx context.Context) *gdb.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.
|
||||
// Transaction 使用函数 f 包裹事务逻辑。
|
||||
// 若 f 返回非 nil 错误,则回滚事务并返回该错误。
|
||||
// 若 f 返回 nil,则提交事务并返回 nil。
|
||||
//
|
||||
// Note: Do not commit or roll back the transaction in function f,
|
||||
// as it is automatically handled by this function.
|
||||
// 注意:请勿在函数 f 内提交或回滚事务,
|
||||
// 该函数会自动处理。
|
||||
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)
|
||||
}
|
||||
|
||||
103
internal/dao/internal/house_building.go
Normal file
103
internal/dao/internal/house_building.go
Normal 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)
|
||||
}
|
||||
113
internal/dao/internal/house_community.go
Normal file
113
internal/dao/internal/house_community.go
Normal 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)
|
||||
}
|
||||
93
internal/dao/internal/house_community_facility.go
Normal file
93
internal/dao/internal/house_community_facility.go
Normal 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)
|
||||
}
|
||||
95
internal/dao/internal/house_facility.go
Normal file
95
internal/dao/internal/house_facility.go
Normal 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)
|
||||
}
|
||||
131
internal/dao/internal/house_listing.go
Normal file
131
internal/dao/internal/house_listing.go
Normal 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)
|
||||
}
|
||||
107
internal/dao/internal/house_preference.go
Normal file
107
internal/dao/internal/house_preference.go
Normal 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)
|
||||
}
|
||||
95
internal/dao/internal/house_price_snapshot.go
Normal file
95
internal/dao/internal/house_price_snapshot.go
Normal 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)
|
||||
}
|
||||
95
internal/dao/internal/house_school_district.go
Normal file
95
internal/dao/internal/house_school_district.go
Normal 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)
|
||||
}
|
||||
103
internal/dao/internal/house_transaction.go
Normal file
103
internal/dao/internal/house_transaction.go
Normal 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)
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
// ==========================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// 本文件由 GoFrame CLI 工具生成并维护,请勿编辑。
|
||||
// ==========================================================================
|
||||
|
||||
package internal
|
||||
@ -11,7 +11,7 @@ import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// UserDao is the data access object for the table user.
|
||||
// UserDao 是表 user 的数据访问对象。
|
||||
type UserDao 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.
|
||||
@ -19,7 +19,7 @@ type UserDao struct {
|
||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||
}
|
||||
|
||||
// UserColumns defines and stores column names for the table user.
|
||||
// UserColumns 定义并存储表 user 的列名。
|
||||
type UserColumns struct {
|
||||
Id string //
|
||||
UnionId string //
|
||||
@ -36,7 +36,7 @@ type UserColumns struct {
|
||||
DeletedAt string //
|
||||
}
|
||||
|
||||
// userColumns holds the columns for the table user.
|
||||
// userColumns 保存表 user 的列信息。
|
||||
var userColumns = UserColumns{
|
||||
Id: "id",
|
||||
UnionId: "union_id",
|
||||
@ -53,7 +53,7 @@ var userColumns = UserColumns{
|
||||
DeletedAt: "deleted_at",
|
||||
}
|
||||
|
||||
// NewUserDao creates and returns a new DAO object for table data access.
|
||||
// NewUserDao 创建并返回一个新的表数据访问 DAO 对象。
|
||||
func NewUserDao(handlers ...gdb.ModelHandler) *UserDao {
|
||||
return &UserDao{
|
||||
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 {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of the current DAO.
|
||||
// Table 返回当前 DAO 的表名。
|
||||
func (dao *UserDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of the current DAO.
|
||||
// Columns 返回当前 DAO 的全部列名。
|
||||
func (dao *UserDao) Columns() UserColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the database configuration group name of the current DAO.
|
||||
// Group 返回当前 DAO 的数据库配置组名。
|
||||
func (dao *UserDao) Group() string {
|
||||
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 {
|
||||
model := dao.DB().Model(dao.table)
|
||||
for _, handler := range dao.handlers {
|
||||
@ -92,12 +92,12 @@ func (dao *UserDao) Ctx(ctx context.Context) *gdb.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.
|
||||
// Transaction 使用函数 f 包裹事务逻辑。
|
||||
// 若 f 返回非 nil 错误,则回滚事务并返回该错误。
|
||||
// 若 f 返回 nil,则提交事务并返回 nil。
|
||||
//
|
||||
// Note: Do not commit or roll back the transaction in function f,
|
||||
// as it is automatically handled by this function.
|
||||
// 注意:请勿在函数 f 内提交或回滚事务,
|
||||
// 该函数会自动处理。
|
||||
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)
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// ==========================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// 本文件由 GoFrame CLI 工具生成并维护,请勿编辑。
|
||||
// ==========================================================================
|
||||
|
||||
package internal
|
||||
@ -11,7 +11,7 @@ import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// UserFavoriteDao is the data access object for the table user_favorite.
|
||||
// UserFavoriteDao 是表 user_favorite 的数据访问对象。
|
||||
type UserFavoriteDao struct {
|
||||
table string // table is the underlying table name of the DAO.
|
||||
group string // group is the database configuration group name of the current DAO.
|
||||
@ -19,7 +19,7 @@ type UserFavoriteDao struct {
|
||||
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 {
|
||||
Id string //
|
||||
UserId string //
|
||||
@ -29,7 +29,7 @@ type UserFavoriteColumns struct {
|
||||
DeletedAt string //
|
||||
}
|
||||
|
||||
// userFavoriteColumns holds the columns for the table user_favorite.
|
||||
// userFavoriteColumns 保存表 user_favorite 的列信息。
|
||||
var userFavoriteColumns = UserFavoriteColumns{
|
||||
Id: "id",
|
||||
UserId: "user_id",
|
||||
@ -39,7 +39,7 @@ var userFavoriteColumns = UserFavoriteColumns{
|
||||
DeletedAt: "deleted_at",
|
||||
}
|
||||
|
||||
// NewUserFavoriteDao creates and returns a new DAO object for table data access.
|
||||
// NewUserFavoriteDao 创建并返回一个新的表数据访问 DAO 对象。
|
||||
func NewUserFavoriteDao(handlers ...gdb.ModelHandler) *UserFavoriteDao {
|
||||
return &UserFavoriteDao{
|
||||
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 {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of the current DAO.
|
||||
// Table 返回当前 DAO 的表名。
|
||||
func (dao *UserFavoriteDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of the current DAO.
|
||||
// Columns 返回当前 DAO 的全部列名。
|
||||
func (dao *UserFavoriteDao) Columns() UserFavoriteColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the database configuration group name of the current DAO.
|
||||
// Group 返回当前 DAO 的数据库配置组名。
|
||||
func (dao *UserFavoriteDao) Group() string {
|
||||
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 {
|
||||
model := dao.DB().Model(dao.table)
|
||||
for _, handler := range dao.handlers {
|
||||
@ -78,12 +78,12 @@ func (dao *UserFavoriteDao) Ctx(ctx context.Context) *gdb.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.
|
||||
// Transaction 使用函数 f 包裹事务逻辑。
|
||||
// 若 f 返回非 nil 错误,则回滚事务并返回该错误。
|
||||
// 若 f 返回 nil,则提交事务并返回 nil。
|
||||
//
|
||||
// Note: Do not commit or roll back the transaction in function f,
|
||||
// as it is automatically handled by this function.
|
||||
// 注意:请勿在函数 f 内提交或回滚事务,
|
||||
// 该函数会自动处理。
|
||||
func (dao *UserFavoriteDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// ==========================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// 本文件由 GoFrame CLI 工具生成并维护,请勿编辑。
|
||||
// ==========================================================================
|
||||
|
||||
package internal
|
||||
@ -11,7 +11,7 @@ import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// UserMessageDao is the data access object for the table user_message.
|
||||
// UserMessageDao 是表 user_message 的数据访问对象。
|
||||
type UserMessageDao 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.
|
||||
@ -19,7 +19,7 @@ type UserMessageDao struct {
|
||||
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 {
|
||||
Id string //
|
||||
UserId string //
|
||||
@ -31,7 +31,7 @@ type UserMessageColumns struct {
|
||||
DeletedAt string //
|
||||
}
|
||||
|
||||
// userMessageColumns holds the columns for the table user_message.
|
||||
// userMessageColumns 保存表 user_message 的列信息。
|
||||
var userMessageColumns = UserMessageColumns{
|
||||
Id: "id",
|
||||
UserId: "user_id",
|
||||
@ -43,7 +43,7 @@ var userMessageColumns = UserMessageColumns{
|
||||
DeletedAt: "deleted_at",
|
||||
}
|
||||
|
||||
// NewUserMessageDao creates and returns a new DAO object for table data access.
|
||||
// NewUserMessageDao 创建并返回一个新的表数据访问 DAO 对象。
|
||||
func NewUserMessageDao(handlers ...gdb.ModelHandler) *UserMessageDao {
|
||||
return &UserMessageDao{
|
||||
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 {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of the current DAO.
|
||||
// Table 返回当前 DAO 的表名。
|
||||
func (dao *UserMessageDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of the current DAO.
|
||||
// Columns 返回当前 DAO 的全部列名。
|
||||
func (dao *UserMessageDao) Columns() UserMessageColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the database configuration group name of the current DAO.
|
||||
// Group 返回当前 DAO 的数据库配置组名。
|
||||
func (dao *UserMessageDao) Group() string {
|
||||
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 {
|
||||
model := dao.DB().Model(dao.table)
|
||||
for _, handler := range dao.handlers {
|
||||
@ -82,12 +82,12 @@ func (dao *UserMessageDao) Ctx(ctx context.Context) *gdb.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.
|
||||
// Transaction 使用函数 f 包裹事务逻辑。
|
||||
// 若 f 返回非 nil 错误,则回滚事务并返回该错误。
|
||||
// 若 f 返回 nil,则提交事务并返回 nil。
|
||||
//
|
||||
// Note: Do not commit or roll back the transaction in function f,
|
||||
// as it is automatically handled by this function.
|
||||
// 注意:请勿在函数 f 内提交或回滚事务,
|
||||
// 该函数会自动处理。
|
||||
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)
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user