Skip to content
This repository has been archived by the owner on Nov 5, 2023. It is now read-only.

Commit

Permalink
特徴を生成列に
Browse files Browse the repository at this point in the history
  • Loading branch information
soudai committed Nov 3, 2023
1 parent 4d7461a commit 9ca8ef7
Showing 1 changed file with 25 additions and 17 deletions.
42 changes: 25 additions & 17 deletions isuumo/webapp/go/main.go
Expand Up @@ -6,14 +6,15 @@ import (
"encoding/csv"
"encoding/json"
"fmt"
"github.com/redis/go-redis/v9"
"net/http"
"os"
"os/exec"
"path/filepath"
"strconv"
"strings"

"github.com/redis/go-redis/v9"

_ "github.com/go-sql-driver/mysql"
"github.com/jmoiron/sqlx"
"github.com/labstack/echo/v4"
Expand Down Expand Up @@ -69,18 +70,19 @@ type ChairListResponse struct {

// Estate 物件
type Estate struct {
ID int64 `db:"id" json:"id"`
Thumbnail string `db:"thumbnail" json:"thumbnail"`
Name string `db:"name" json:"name"`
Description string `db:"description" json:"description"`
Latitude float64 `db:"latitude" json:"latitude"`
Longitude float64 `db:"longitude" json:"longitude"`
Address string `db:"address" json:"address"`
Rent int64 `db:"rent" json:"rent"`
DoorHeight int64 `db:"door_height" json:"doorHeight"`
DoorWidth int64 `db:"door_width" json:"doorWidth"`
Features string `db:"features" json:"features"`
Popularity int64 `db:"popularity" json:"-"`
ID int64 `db:"id" json:"id"`
Thumbnail string `db:"thumbnail" json:"thumbnail"`
Name string `db:"name" json:"name"`
Description string `db:"description" json:"description"`
Latitude float64 `db:"latitude" json:"latitude"`
Longitude float64 `db:"longitude" json:"longitude"`
Address string `db:"address" json:"address"`
Rent int64 `db:"rent" json:"rent"`
DoorHeight int64 `db:"door_height" json:"doorHeight"`
DoorWidth int64 `db:"door_width" json:"doorWidth"`
Features string `db:"features" json:"features"`
Popularity int64 `db:"popularity" json:"-"`
FeaturesArray string `db:"features_array" json:"-"`
}

// EstateSearchResponse estate/searchへのレスポンスの形式
Expand Down Expand Up @@ -798,10 +800,16 @@ func searchEstates(c echo.Context) error {
}

if c.QueryParam("features") != "" {
for _, f := range strings.Split(c.QueryParam("features"), ",") {
c := "%" + f + "%"
conditions = append(conditions, "features like ?")
params = append(params, c)
ss := strings.Split(c.QueryParam("features"), ",")
if len(ss) > 0 {
for _, s := range ss {
params = append(params, s)
}
conditions = append(
conditions,
fmt.Sprintf("features_array @> ARRAY[?%s]",
strings.Repeat(",?", len(ss)-1)),
)
}
}

Expand Down

0 comments on commit 9ca8ef7

Please sign in to comment.