148 lines
6.2 KiB
Go
148 lines
6.2 KiB
Go
package controllers
|
||
|
||
import (
|
||
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
||
"git.rosy.net.cn/jx-callback/business/jxstore/initdata"
|
||
"git.rosy.net.cn/jx-callback/business/jxutils/datares"
|
||
"github.com/astaxie/beego"
|
||
)
|
||
|
||
type CmsController struct {
|
||
beego.Controller
|
||
}
|
||
|
||
// @Title 新增配置
|
||
// @Description 新增配置
|
||
// @Param token header string true "认证token"
|
||
// @Param type formData string true "配置类型(当前只支持PricePack)"
|
||
// @Param key formData string true "配置名"
|
||
// @Param value formData string true "配置值"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /NewConfig [post]
|
||
func (c *CmsController) NewConfig() {
|
||
c.callNewConfig(func(params *tCmsNewConfigParams) (retVal interface{}, errCode string, err error) {
|
||
err = cms.AddConfig(params.Ctx, params.Key, params.Type, params.Value)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 删除配置
|
||
// @Description 删除配置
|
||
// @Param token header string true "认证token"
|
||
// @Param type query string true "配置类型(当前只支持PricePack)"
|
||
// @Param key query string true "配置名"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /DeleteConfig [delete]
|
||
func (c *CmsController) DeleteConfig() {
|
||
c.callDeleteConfig(func(params *tCmsDeleteConfigParams) (retVal interface{}, errCode string, err error) {
|
||
err = cms.DeleteConfig(params.Ctx, params.Key, params.Type)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 修改配置
|
||
// @Description 修改配置
|
||
// @Param token header string true "认证token"
|
||
// @Param type formData string true "配置类型(当前只支持PricePack)"
|
||
// @Param key formData string true "配置名"
|
||
// @Param value formData string true "配置值"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /UpdateConfig [put]
|
||
func (c *CmsController) UpdateConfig() {
|
||
c.callUpdateConfig(func(params *tCmsUpdateConfigParams) (retVal interface{}, errCode string, err error) {
|
||
retVal, err = cms.UpdateConfig(params.Ctx, params.Key, params.Type, params.Value)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 查询配置
|
||
// @Description 查询配置
|
||
// @Param token header string fasle "认证token"
|
||
// @Param type query string false "配置类型(当前只支持PricePack)"
|
||
// @Param key query string false "配置名"
|
||
// @Param keyword query string false "关键字"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /QueryConfigs [get]
|
||
func (c *CmsController) QueryConfigs() {
|
||
c.callQueryConfigs(func(params *tCmsQueryConfigsParams) (retVal interface{}, errCode string, err error) {
|
||
retVal, err = cms.QueryConfigs(params.Key, params.Type, params.Keyword)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 得到七牛上传服务临时token
|
||
// @Description 得到七牛上传服务临时token,当前设置为5分钟内有效。正常使用场景为每次上传资源前实时获取,而不是保存下来一直使用,如果hashCode有值,且本地有,可能直接返回URL
|
||
// @Param token header string true "认证token"
|
||
// @Param suffix query string true "前缀"
|
||
// @Param hashCode query string false "图片hash"
|
||
// @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 = datares.GetQiniuUploadToken(params.Ctx, params.Suffix, params.HashCode)
|
||
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 init place
|
||
// @Description init place
|
||
// @Param token header string true "认证token"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /InitPlace [post]
|
||
func (c *CmsController) InitPlace() {
|
||
c.callInitPlace(func(params *tCmsInitPlaceParams) (retVal interface{}, errCode string, err error) {
|
||
err = initdata.InitPlace(params.Ctx)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 得到地点(省,城市,区)信息
|
||
// @Description 得到地点(省,城市,区)信息。
|
||
// @Param token header string false "认证token"
|
||
// @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 code formData int true "地点编号,注意是code不是ID"
|
||
// @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) {
|
||
|
||
return retVal, "", err
|
||
})
|
||
}
|