Compare commits
No commits in common. "7c5dbbadc6b93fb51f6ef39af902fd336736f2cf" and "cc534766a8d2c567b18af77218c1052f6d31b34d" have entirely different histories.
7c5dbbadc6
...
cc534766a8
@ -67,8 +67,6 @@ func NewRouter() *gin.Engine {
|
|||||||
v1.POST("version", version.Version) //版本号公共
|
v1.POST("version", version.Version) //版本号公共
|
||||||
v1.POST("store_versions", version.StoreBrandsVersions)
|
v1.POST("store_versions", version.StoreBrandsVersions)
|
||||||
v1.POST("check_version", version.CheckBrandVersion)
|
v1.POST("check_version", version.CheckBrandVersion)
|
||||||
v1.POST("store_listed", version.ListedStore)
|
|
||||||
v1.POST("check_listed", version.ListedCheck)
|
|
||||||
}
|
}
|
||||||
//账号模块
|
//账号模块
|
||||||
{
|
{
|
||||||
|
|||||||
@ -122,69 +122,3 @@ func CheckBrandVersion(c *gin.Context) {
|
|||||||
versionFound := containsVersion(storedVersions, brand.Version)
|
versionFound := containsVersion(storedVersions, brand.Version)
|
||||||
service.Success(c, versionFound)
|
service.Success(c, versionFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ListedStore(c *gin.Context) {
|
|
||||||
defer handlePanic(c)
|
|
||||||
|
|
||||||
var brands []struct {
|
|
||||||
Brand string `json:"brand"`
|
|
||||||
Version []string `json:"version"`
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := c.ShouldBindBodyWith(&brands, binding.JSON); err != nil {
|
|
||||||
service.Error(c, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, brand := range brands {
|
|
||||||
versionData, err := json.Marshal(brand.Version)
|
|
||||||
if err != nil {
|
|
||||||
service.Error(c, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if err = cache.RedisClient.HSet("brands_listed", brand.Brand, versionData).Err(); err != nil {
|
|
||||||
service.Error(c, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
service.Success(c, true)
|
|
||||||
}
|
|
||||||
|
|
||||||
func ListedCheck(c *gin.Context) {
|
|
||||||
defer handlePanic(c)
|
|
||||||
|
|
||||||
var brand struct {
|
|
||||||
Brand string `json:"brand"`
|
|
||||||
Version string `json:"version"`
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := c.ShouldBindBodyWith(&brand, binding.JSON); err != nil {
|
|
||||||
service.Error(c, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
storedVersionsStr, err := cache.RedisClient.HGet("brands_listed", brand.Brand).Result()
|
|
||||||
|
|
||||||
// 品牌不存在,返回 false
|
|
||||||
if errors.Is(err, redis.Nil) {
|
|
||||||
service.Success(c, false)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
service.Error(c, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var storedVersions []string
|
|
||||||
if err = json.Unmarshal([]byte(storedVersionsStr), &storedVersions); err != nil {
|
|
||||||
service.Error(c, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检查版本是否存在
|
|
||||||
versionFound := containsVersion(storedVersions, brand.Version)
|
|
||||||
service.Success(c, versionFound)
|
|
||||||
}
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user