Some checks failed
Build and Deploy (service.xpcool.com) / build-and-deploy (push) Failing after 35s
- 新增新房预售证表 house_presale 存储预售许可信息 - 为 house_community 表添加 avg_price 字段存储小区参考均价 - 增强服务器操作审计日志功能,新增管理员账号、IP归属地、错误信息、UA等字段 - 实现纯Go版IP归属地离线解析器,无外部依赖,支持二分查找 - 优化看房列表查询逻辑,修复Fields设置位置导致的SQL语法错误 - 集成招聘模块,添加独立数据库配置和Bark推送服务支持 - 重构日志查询接口,支持多维度筛选和综合分页列表展示 - 更新DAO实体结构同步数据库表结构调整
55 lines
1.6 KiB
Go
55 lines
1.6 KiB
Go
// Package house_transaction 提供成交记录领域服务。
|
|
package house_transaction
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/gogf/gf/v2/errors/gerror"
|
|
|
|
"service.xpcool.com/internal/dao"
|
|
"service.xpcool.com/internal/model/dto"
|
|
)
|
|
|
|
// ITransaction 成交记录领域服务接口。
|
|
type ITransaction interface {
|
|
List(context.Context, int, int, string, string) ([]dto.HouseTransactionVO, int, error)
|
|
}
|
|
|
|
type transaction struct{}
|
|
|
|
var localTransaction ITransaction
|
|
|
|
func NewTransaction() ITransaction { return &transaction{} }
|
|
|
|
// Transaction 返回已注册的成交服务实现。
|
|
func Transaction() ITransaction {
|
|
if localTransaction == nil {
|
|
panic("Transaction implementation not registered")
|
|
}
|
|
return localTransaction
|
|
}
|
|
|
|
// RegisterTransaction 注册成交服务实现。
|
|
func RegisterTransaction(i ITransaction) { localTransaction = i }
|
|
|
|
// List 分页查询成交记录,关联小区名,按成交日期倒序。
|
|
func (s *transaction) List(ctx context.Context, page, size int, region, keyword string) ([]dto.HouseTransactionVO, int, error) {
|
|
m := dao.HouseTransaction.Ctx(ctx).As("t").
|
|
LeftJoin("house_community c", "t.community_id=c.id")
|
|
if region != "" {
|
|
m = m.Where("c.region", region)
|
|
}
|
|
if keyword != "" {
|
|
m = m.Where("c.name LIKE ? OR t.layout LIKE ?", "%"+keyword+"%", "%"+keyword+"%")
|
|
}
|
|
total, err := m.Clone().Count()
|
|
if err != nil {
|
|
return nil, 0, gerror.Wrap(err, "count transaction")
|
|
}
|
|
var list []dto.HouseTransactionVO
|
|
if err = m.Clone().Fields("t.*, c.name AS community_name").Page(page, size).OrderDesc("t.deal_date").Scan(&list); err != nil {
|
|
return nil, 0, gerror.Wrap(err, "query transaction list")
|
|
}
|
|
return list, total, nil
|
|
}
|