106 lines
5.0 KiB
Go
106 lines
5.0 KiB
Go
package controllers
|
||
|
||
import (
|
||
"git.rosy.net.cn/baseapi/utils"
|
||
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
||
"github.com/astaxie/beego"
|
||
)
|
||
|
||
type CmsController struct {
|
||
beego.Controller
|
||
}
|
||
|
||
// @Title 得到地点(省,城市,区)信息
|
||
// @Description 得到地点(省,城市,区)信息。
|
||
// @Param token header string true "认证token"// @Param keyword query string false "查询关键字(可以为空,为空表示不限制)"
|
||
// @Param keyword query string false "查询关键字(可以为空,为空表示不限制)"
|
||
// @Param parentCode query int false "上级地点code,这个指的是国家标准CODE(中国为:100000,北京为:110000,北京市为:110100),不是数据库中的ID"
|
||
// @Param level query int false "地点级别:省为1,市为2,区为3,注意直辖市也要分省与市级"
|
||
// @Param includeDisabled query bool false "是否包括禁用的城市(缺省不包括)"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /GetPlaces [get]
|
||
func (c *CmsController) GetPlaces() {
|
||
c.callGetPlaces(func(params *tCmsGetPlacesParams) (retVal interface{}, errCode string, err error) {
|
||
retVal, err = cms.GetPlaces(params.Ctx, params.Keyword, params.IncludeDisabled, params.MapData)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 批量修改地点信息
|
||
// @Description 只支持修改enabled, jd_code和mtps_price这三个属性
|
||
// @Param token header string true "认证token"
|
||
// @Param payload formData string true "json数据,place对象数组"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /UpdatePlaces [put]
|
||
func (c *CmsController) UpdatePlaces() {
|
||
c.callUpdatePlaces(func(params *tCmsUpdatePlacesParams) (retVal interface{}, errCode string, err error) {
|
||
placeList := make([]map[string]interface{}, 0)
|
||
if err = utils.UnmarshalUseNumber([]byte(params.Payload), &placeList); err == nil {
|
||
retVal, err = cms.UpdatePlaces(params.Ctx, placeList, params.Ctx.GetUserName())
|
||
}
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 修改地点信息
|
||
// @Description 只支持修改enabled, jd_code和mtps_price这三个属性
|
||
// @Param token header string true "认证token"
|
||
// @Param code formData int true "地点编号,注意是code不是ID,payload中的code会被忽略"
|
||
// @Param payload formData string true "json数据,place对象"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /UpdatePlace [put]
|
||
func (c *CmsController) UpdatePlace() {
|
||
c.callUpdatePlace(func(params *tCmsUpdatePlaceParams) (retVal interface{}, errCode string, err error) {
|
||
place := make(map[string]interface{}, 0)
|
||
if err = utils.UnmarshalUseNumber([]byte(params.Payload), &place); err == nil {
|
||
retVal, err = cms.UpdatePlace(params.Ctx, params.Code, place, params.Ctx.GetUserName())
|
||
}
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 得到服务相关的一些基础信息
|
||
// @Description 得到服务相关的一些基础信息,包括版本,及一些元数据信息
|
||
// @Param token header string true "认证token"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /GetServiceInfo [get]
|
||
func (c *CmsController) GetServiceInfo() {
|
||
c.callGetServiceInfo(func(params *tCmsGetServiceInfoParams) (retVal interface{}, errCode string, err error) {
|
||
retVal = cms.GetServiceInfo(params.Ctx)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 得到七牛上传服务临时token
|
||
// @Description 得到七牛上传服务临时token,当前设置为5分钟内有效。正常使用场景为每次上传资源前实时获取,而不是保存下来一直使用
|
||
// @Param token header string true "认证token"
|
||
// @Param suffix query string true "门店所属的厂商ID"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /GetQiniuUploadToken [get]
|
||
func (c *CmsController) GetQiniuUploadToken() {
|
||
c.callGetQiniuUploadToken(func(params *tCmsGetQiniuUploadTokenParams) (retVal interface{}, errCode string, err error) {
|
||
retVal, err = cms.GetQiniuUploadToken(params.Ctx, params.Suffix)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 根据坐标得到区码
|
||
// @Description 根据坐标得到区码,坐标都为火星坐标(有些市是没有区的,比如东莞,这种情况下返回的区码是一个假的区域,即市的编码加上9000000)
|
||
// @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
|
||
})
|
||
}
|