评价bug
This commit is contained in:
parent
3ec9a23bd0
commit
b8b5e16eb1
Binary file not shown.
|
@ -92,7 +92,9 @@ func build_data(code int, data []Device) []byte {
|
|||
case "其他":
|
||||
bad++
|
||||
}
|
||||
satisfaction_data.SATISFACTION = good / (good + bad)
|
||||
var data float64
|
||||
data = good / (good + bad)
|
||||
satisfaction_data.SATISFACTION = Round(data, 2)
|
||||
data_buf, _ := json.Marshal(R_data)
|
||||
return data_buf
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ type Traffic struct {
|
|||
}
|
||||
|
||||
type Satisfaction struct {
|
||||
SATISFACTION float32 `json:"satisfaction"`
|
||||
SATISFACTION float64 `json:"satisfaction"`
|
||||
}
|
||||
|
||||
type Conf struct {
|
||||
|
|
10
router.go
10
router.go
|
@ -4,6 +4,7 @@ import (
|
|||
"github.com/gin-contrib/cors"
|
||||
"github.com/gin-gonic/gin"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
"math"
|
||||
"net/http"
|
||||
"strconv"
|
||||
)
|
||||
|
@ -163,10 +164,17 @@ func renliu_api(c *gin.Context) {
|
|||
}
|
||||
|
||||
func pj_api(c *gin.Context) {
|
||||
satisfaction_data.SATISFACTION = good / (good + bad)
|
||||
var data float64
|
||||
data = good / (good + bad)
|
||||
satisfaction_data.SATISFACTION = Round(data, 2)
|
||||
c.JSON(http.StatusOK, gin.H{"status": http.StatusOK, "data": satisfaction_data})
|
||||
}
|
||||
|
||||
func Round(f float64, n int) float64 {
|
||||
n10 := math.Pow10(n)
|
||||
return math.Trunc((f+0.5/n10)*n10) / n10
|
||||
}
|
||||
|
||||
type Seat_data struct {
|
||||
POSITIONLIST []interface{} `json:"positionList"`
|
||||
HASPERSONLIST []interface{} `json:"hasPersonList"`
|
||||
|
|
Loading…
Reference in New Issue