- GetCoordinateDistrictCode
This commit is contained in:
@@ -123,6 +123,10 @@ func UpdatePlace(ctx *jxcontext.Context, placeCode int, payload map[string]inter
|
||||
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 {
|
||||
return fmt.Sprintf("%x%s", md5.Sum([]byte(utils.GetUUID()+suffix)), suffix)
|
||||
|
||||
@@ -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) {
|
||||
globals.SugarLogger.Debugf("UpdateStore storeID:%d, payload:%s", storeID, utils.Format4Output(payload, false))
|
||||
|
||||
db := dao.GetDB()
|
||||
store := &model.Store{}
|
||||
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 {
|
||||
valid["name"] = jxutils.FormalizeName(valid["name"].(string))
|
||||
}
|
||||
var lng, lat float64
|
||||
if payload["lng"] != nil {
|
||||
valid["lng"] = jxutils.StandardCoordinate2Int(utils.Interface2FloatWithDefault(payload["lng"], 0.0))
|
||||
valid["lat"] = jxutils.StandardCoordinate2Int(utils.Interface2FloatWithDefault(payload["lat"], 0.0))
|
||||
lng = utils.Interface2FloatWithDefault(payload["lng"], 0.0)
|
||||
lat = utils.Interface2FloatWithDefault(payload["lat"], 0.0)
|
||||
valid["lng"] = jxutils.StandardCoordinate2Int(lng)
|
||||
valid["lat"] = jxutils.StandardCoordinate2Int(lat)
|
||||
}
|
||||
if valid["deliveryRange"] != nil {
|
||||
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 {
|
||||
db := dao.GetDB()
|
||||
dao.Begin(db)
|
||||
defer func() {
|
||||
dao.Rollback(db)
|
||||
|
||||
@@ -88,3 +88,18 @@ func (c *CmsController) GetQiniuUploadToken() {
|
||||
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
|
||||
})
|
||||
}
|
||||
|
||||
@@ -55,6 +55,14 @@ func init() {
|
||||
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.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.ControllerComments{
|
||||
Method: "GetPlaces",
|
||||
|
||||
Reference in New Issue
Block a user