- GetCoordinateDistrictCode

This commit is contained in:
gazebo
2018-11-23 11:02:38 +08:00
parent fc1e2ded61
commit 033f5670a9
4 changed files with 48 additions and 4 deletions

View File

@@ -123,6 +123,10 @@ func UpdatePlace(ctx *jxcontext.Context, placeCode int, payload map[string]inter
return UpdatePlaces(ctx, []map[string]interface{}{payload}, userName) return UpdatePlaces(ctx, []map[string]interface{}{payload}, userName)
} }
func GetCoordinateDistrictCode(ctx *jxcontext.Context, lng, lat float64) (code int, err error) {
return api.AutonaviAPI.GetCoordinateDistrictCode(lng, lat), nil
}
///// /////
func genPicFileName(suffix string) string { func genPicFileName(suffix string) string {
return fmt.Sprintf("%x%s", md5.Sum([]byte(utils.GetUUID()+suffix)), suffix) return fmt.Sprintf("%x%s", md5.Sum([]byte(utils.GetUUID()+suffix)), suffix)

View File

@@ -265,21 +265,38 @@ func GetVendorStore(ctx *jxcontext.Context, vendorStoreID string, vendorID int)
func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interface{}, userName string) (num int64, err error) { func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interface{}, userName string) (num int64, err error) {
globals.SugarLogger.Debugf("UpdateStore storeID:%d, payload:%s", storeID, utils.Format4Output(payload, false)) globals.SugarLogger.Debugf("UpdateStore storeID:%d, payload:%s", storeID, utils.Format4Output(payload, false))
db := dao.GetDB()
store := &model.Store{} store := &model.Store{}
store.ID = storeID store.ID = storeID
valid := dao.NormalMakeMapByStructObject(payload, store, userName) if err = dao.GetEntity(db, store); err != nil {
return 0, err
}
valid := dao.StrictMakeMapByStructObject(payload, store, userName)
if valid["name"] != nil { if valid["name"] != nil {
valid["name"] = jxutils.FormalizeName(valid["name"].(string)) valid["name"] = jxutils.FormalizeName(valid["name"].(string))
} }
var lng, lat float64
if payload["lng"] != nil { if payload["lng"] != nil {
valid["lng"] = jxutils.StandardCoordinate2Int(utils.Interface2FloatWithDefault(payload["lng"], 0.0)) lng = utils.Interface2FloatWithDefault(payload["lng"], 0.0)
valid["lat"] = jxutils.StandardCoordinate2Int(utils.Interface2FloatWithDefault(payload["lat"], 0.0)) lat = utils.Interface2FloatWithDefault(payload["lat"], 0.0)
valid["lng"] = jxutils.StandardCoordinate2Int(lng)
valid["lat"] = jxutils.StandardCoordinate2Int(lat)
} }
if valid["deliveryRange"] != nil { if valid["deliveryRange"] != nil {
valid["deliveryRange"] = strings.Trim(valid["deliveryRange"].(string), ";") valid["deliveryRange"] = strings.Trim(valid["deliveryRange"].(string), ";")
} }
// districtCode := 0
// if valid["districtCode"] != nil {
// districtCode = int(utils.MustInterface2Int64(valid["districtCode"]))
// }
// if districtCode == 0 && store.DistrictCode == 0 {
// if lng == 0 {
// lng = jxutils.IntCoordinate2Standard(store.Lng)
// lat = jxutils.IntCoordinate2Standard(store.Lat)
// }
// valid["districtCode"] = api.AutonaviAPI.GetCoordinateDistrictCode(lng, lat)
// }
if len(valid) > 0 { if len(valid) > 0 {
db := dao.GetDB()
dao.Begin(db) dao.Begin(db)
defer func() { defer func() {
dao.Rollback(db) dao.Rollback(db)

View File

@@ -88,3 +88,18 @@ func (c *CmsController) GetQiniuUploadToken() {
return retVal, "", err return retVal, "", err
}) })
} }
// @Title 根据坐标得到区码
// @Description 根据坐标得到区码,坐标都为火星坐标
// @Param token header string true "认证token"
// @Param lng query number true "经度"
// @Param lat query number true "纬度"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetCoordinateDistrictCode [get]
func (c *CmsController) GetCoordinateDistrictCode() {
c.callGetCoordinateDistrictCode(func(params *tCmsGetCoordinateDistrictCodeParams) (retVal interface{}, errCode string, err error) {
retVal, err = cms.GetCoordinateDistrictCode(params.Ctx, params.Lng, params.Lat)
return retVal, "", err
})
}

View File

@@ -55,6 +55,14 @@ func init() {
MethodParams: param.Make(), MethodParams: param.Make(),
Params: nil}) Params: nil})
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:CmsController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:CmsController"],
beego.ControllerComments{
Method: "GetCoordinateDistrictCode",
Router: `/GetCoordinateDistrictCode`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:CmsController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:CmsController"], beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:CmsController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:CmsController"],
beego.ControllerComments{ beego.ControllerComments{
Method: "GetPlaces", Method: "GetPlaces",