12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- package repository
- import (
- "city_chips/internal/model"
- helper "city_chips/pkg/helper/dbutils"
- "context"
- )
- type IntelligentBuildingControlRepository interface {
- GetIntelligentBuildingControl(ctx context.Context, id int64) (*model.IntelligentBuildingControl, error)
- GetPoint(conds map[string]any) (*[]model.Point, error)
- GetPointType() ([]string, error)
- }
- func NewIntelligentBuildingControlRepository(
- repository *Repository,
- ) IntelligentBuildingControlRepository {
- return &intelligentBuildingControlRepository{
- Repository: repository,
- }
- }
- type intelligentBuildingControlRepository struct {
- *Repository
- }
- // GetPointType implements IntelligentBuildingControlRepository.
- func (r *intelligentBuildingControlRepository) GetPointType() ([]string, error) {
- var names []string
- err := r.db.Model(&model.Point{}).Select("point_name").Group("point_name").Find(&names).Error
- if err != nil {
- return nil, err
- }
- return names, nil
- }
- func (r *intelligentBuildingControlRepository) GetIntelligentBuildingControl(ctx context.Context, id int64) (*model.IntelligentBuildingControl, error) {
- var intelligentBuildingControl model.IntelligentBuildingControl
- // 模拟从数据库获取数据
- return &intelligentBuildingControl, nil
- }
- // 根据点位数据获取点位信息
- func (r *intelligentBuildingControlRepository) GetPoint(conds map[string]any) (*[]model.Point, error) {
- var points []model.Point
- points, err := helper.QueryByConditions[model.Point](r.db, conds)
- if err != nil {
- return &points, err
- }
- return &points, nil
- }
|