elonX/api/userConfig/userConfig.go
2025-02-20 16:47:08 +08:00

52 lines
1.5 KiB
Go

package userConfig
import (
"epur-pay/model"
"epur-pay/pkg/dapi"
"epur-pay/pkg/utils"
)
// GetUserConfig 查看商户自定义配置
// @Summary 查看商户自定义配置
// @Description 获取商户自定义的配置
// @Tags 商户配置
// @Accept json
// @Produce json
// @Success 200 {object} GetUserConfigResponse "成功返回商户的配置信息"
// @Router /api/v1/user/config/get [post]
func GetUserConfig(a *dapi.ApiBase) error {
//获取uid
config := model.UserConfig{}
response := GetUserConfigResponse{}
// 查询数据库获取商户信息
utils.Error(a.Ts.Table(config.TableName()).Where("uid", a.User.Uid).Scan(&response.Data).Error)
response.ResponseCommon = a.NewSuccessResponseCommon()
return a.ReturnSuccessCustomResponse(response)
}
type GetUserConfigResponse struct {
*dapi.ResponseCommon
Data struct {
} `json:"data"`
}
type UpdUserConfigParams struct {
Data model.UserConfig
}
// UpdateUserConfig 修改商户自定义配置信息
// @Summary 修改商户自定义配置
// @Description 更新商户的配置信息
// @Tags 商户配置
// @Accept json
// @Produce json
// @Param body body UpdUserConfigParams true "TBD"
// @Success 200 {object} dapi.ResponseCommon "TBD"
// @Router /api/v1/user/config/upd [post]
func UpdUserConfig(a *dapi.ApiBase, params *UpdUserConfigParams) error {
// 更新商户配置
utils.Error(a.Ts.Table(model.UserConfig{}.TableName()).
Where("uid", a.User.Uid).FirstOrCreate(&params.Data).Error)
return a.ReturnSuccessResponse()
}