| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760 |
- package user
- import (
- "encoding/hex"
- "fmt"
- "mtp2_if/global/app"
- "mtp2_if/global/e"
- "mtp2_if/logger"
- "mtp2_if/models"
- "mtp2_if/utils"
- "net/http"
- "github.com/gin-gonic/gin"
- )
- // QueryUserReferNumReq 获取用户邀请码请求参数
- type QueryUserReferNumReq struct {
- UserID int `form:"userID" binding:"required"`
- }
- // QueryUserReferNum 获取用户邀请码
- // @Summary 获取用户邀请码
- // @Produce json
- // @Param userID query int true "用户ID"
- // @Success 200 {object} app.Response
- // @Failure 500 {object} app.Response
- // @Router /User/QueryUserReferNum [get]
- // @Tags 用户信息
- func QueryUserReferNum(c *gin.Context) {
- appG := app.Gin{C: c}
- // 获取请求参数
- var req QueryUserReferNumReq
- if err := appG.C.ShouldBindQuery(&req); err != nil {
- logger.GetLogger().Errorf("QueryUserReferNum failed: %s", err.Error())
- appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
- return
- }
- var (
- userAccount *models.Useraccount
- err error
- )
- if userAccount, err = models.GetUserAccount(req.UserID); err != nil {
- // 查询失败
- logger.GetLogger().Errorf("QueryUserReferNum failed: %s", err.Error())
- appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
- return
- }
- // 查询成功
- logger.GetLogger().Debugln("QueryUserReferNum successed: %v", userAccount.Refernum)
- appG.Response(http.StatusOK, e.SUCCESS, userAccount.Refernum)
- }
- // QueryUserInfoReq 获取用户信息请求参数
- type QueryUserInfoReq struct {
- UserID int `form:"userID" binding:"required"`
- IsDecrypt bool `form:"isDecrypt"`
- }
- // QueryUserInfo 获取用户信息
- // @Summary 获取用户信息
- // @Produce json
- // @Security ApiKeyAuth
- // @Param userID query int true "用户ID"
- // @Param isDecrypt query bool false "是否解密"
- // @Success 200 {object} models.Userinfo
- // @Failure 500 {object} app.Response
- // @Router /User/QueryUserInfo [get]
- // @Tags 用户信息
- func QueryUserInfo(c *gin.Context) {
- appG := app.Gin{C: c}
- // 获取请求参数
- var req QueryUserInfoReq
- if err := appG.C.ShouldBindQuery(&req); err != nil {
- logger.GetLogger().Errorf("QueryUserInfo failed: %s", err.Error())
- appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
- return
- }
- // 查询数据
- var (
- data *models.Userinfo
- err error
- )
- if data, err = models.GetUserInfo(req.UserID); err != nil {
- // 查询失败
- logger.GetLogger().Errorf("QueryUserInfo failed: %s", err.Error())
- appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
- return
- }
- // 解密
- if req.IsDecrypt {
- key, _ := hex.DecodeString(utils.AESSecretKey)
- // 手机号码解密
- if len(data.Mobile) > 0 {
- if phonenum, err := hex.DecodeString(data.Mobile); err == nil { // hex -> []byte
- if mobile, err := utils.AESDecrypt(phonenum, key); err == nil {
- // 脱敏
- tmp := string(mobile)
- l := len(tmp)
- if l > 7 {
- tmp = fmt.Sprintf("%s****%s", tmp[:3], tmp[l-4:])
- } else {
- tmp = fmt.Sprintf("%s****", tmp[:3])
- }
- data.Mobile = tmp
- }
- }
- }
- // 证件号码解密
- if len(data.Cardnum) > 0 {
- if cardnum, err := hex.DecodeString(data.Cardnum); err == nil { // hex -> []byte
- if c, err := utils.AESDecrypt(cardnum, key); err == nil {
- // 脱敏
- tmp := string(c)
- l := len(tmp)
- if l > 7 {
- tmp = fmt.Sprintf("%s****%s", tmp[:3], tmp[l-4:])
- } else {
- tmp = fmt.Sprintf("%s****", tmp[:3])
- }
- data.Cardnum = tmp
- }
- }
- }
- }
- // 查询成功
- logger.GetLogger().Debugln("QueryUserInfo successed: %v", data)
- appG.Response(http.StatusOK, e.SUCCESS, data)
- }
- // GetUserAuthStatusReq 获取用户实名认证状态请求参数
- type GetUserAuthStatusReq struct {
- UserID int `form:"userID" binding:"required"` // 用户ID
- }
- // GetUserAuthStatus 获取用户实名认证状态
- // @Summary 获取用户实名认证状态
- // @Produce json
- // @Security ApiKeyAuth
- // @Param userID query int true "用户ID"
- // @Success 200 {object} app.Response
- // @Failure 500 {object} app.Response
- // @Router /User/GetUserAuthStatus [get]
- // @Tags 用户信息
- func GetUserAuthStatus(c *gin.Context) {
- appG := app.Gin{C: c}
- // 获取请求参数
- var req GetUserAuthStatusReq
- if err := appG.C.ShouldBindQuery(&req); err != nil {
- logger.GetLogger().Errorf("GetUserAuthStatus failed: %s", err.Error())
- appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
- return
- }
- isAuth := false
- var (
- userAccount *models.Useraccount
- err error
- )
- if userAccount, err = models.GetUserAccount(req.UserID); err != nil {
- // 查询失败
- logger.GetLogger().Errorf("GetUserAuthStatus failed: %s", err.Error())
- appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
- return
- }
- if userAccount != nil {
- if userAccount.Hasauth == 1 {
- isAuth = true
- }
- }
- // 查询成功
- logger.GetLogger().Debugln("GetUserAuthStatus successed: %v", isAuth)
- appG.Response(http.StatusOK, e.SUCCESS, isAuth)
- }
- // GetUserAccountReq 获取用户账号信息请求参数
- type GetUserAccountReq struct {
- UserID int `form:"userID" binding:"required"` // 用户ID
- }
- // GetUserAccount 获取用户账号信息
- // @Summary 获取用户账号信息
- // @Produce json
- // @Security ApiKeyAuth
- // @Param userID query int true "用户ID"
- // @Success 200 {object} models.Useraccount
- // @Failure 500 {object} app.Response
- // @Router /User/GetUserAccount [get]
- // @Tags 用户信息
- func GetUserAccount(c *gin.Context) {
- appG := app.Gin{C: c}
- // 获取请求参数
- var req GetUserAccountReq
- if err := appG.C.ShouldBindQuery(&req); err != nil {
- logger.GetLogger().Errorf("GetUserAccount failed: %s", err.Error())
- appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
- return
- }
- var (
- userAccount *models.Useraccount
- err error
- )
- if userAccount, err = models.GetUserAccount(req.UserID); err != nil {
- // 查询失败
- logger.GetLogger().Errorf("GetUserAccount failed: %s", err.Error())
- appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
- return
- }
- // 查询成功
- logger.GetLogger().Debugln("GetUserAccount successed: %v", userAccount)
- appG.Response(http.StatusOK, e.SUCCESS, userAccount)
- }
- // LoginQueryReq 账户登录后信息查询请求参数
- type LoginQueryReq struct {
- LoginID int `form:"loginID" binding:"required"`
- }
- // LoginQueryRsp 账户登录后信息查询返回模型
- type LoginQueryRsp struct {
- UserName string `json:"username"` // 用户姓名
- LoginAccount models.Loginaccount `json:"loginAccount"` // 登录账号
- UserAccount models.Useraccount `json:"userAccount"` // 用户账号
- UserInfo models.Userinfo `json:"userInfo"` // 用户信息
- AreaRoles []models.Arearole `json:"areaRoles"` // 所属角色信息
- Markets []models.Market `json:"markets"` // 市场
- Goodsgroups []models.Goodsgroup `json:"goodsgroups"` // 商品组
- ExternalExchanges []models.Externalexchange `json:"externalExchanges"` // 外部交易所
- SystemParams []models.Systemparam `json:"systemParams"` // 系统参数
- ExchangeRateConfigs []models.Exchangerateconfig `json:"exchangeRateConfigs"` // 汇率信息
- }
- // LoginQuery 账户登录后信息查询
- // @Summary 账户登录后信息查询
- // @Produce json
- // @Security ApiKeyAuth
- // @Param loginID query int true "登录账号"
- // @Success 200 {object} LoginQueryRsp
- // @Failure 500 {object} app.Response
- // @Router /User/LoginQuery [get]
- // @Tags 用户信息
- func LoginQuery(c *gin.Context) {
- appG := app.Gin{C: c}
- // 获取请求参数
- var req LoginQueryReq
- if err := appG.C.ShouldBindQuery(&req); err != nil {
- logger.GetLogger().Errorf("LoginQuery failed: %s", err.Error())
- appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
- return
- }
- var rsp LoginQueryRsp
- // 登录账号
- loginAccount, err := models.GetLoginAccount(req.LoginID)
- if err != nil {
- // 查询失败
- logger.GetLogger().Errorf("LoginQuery failed: %s", err.Error())
- appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
- return
- }
- rsp.LoginAccount = *loginAccount
- // 用户账号
- userAccount, err := models.GetUserAccount(int(loginAccount.Userid))
- if err != nil {
- // 查询失败
- logger.GetLogger().Errorf("LoginQuery failed: %s", err.Error())
- appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
- return
- }
- rsp.UserAccount = *userAccount
- // 用户信息
- userInfo, err := models.GetUserInfo(int(loginAccount.Userid))
- if err != nil {
- // 查询失败
- logger.GetLogger().Errorf("LoginQuery failed: %s", err.Error())
- appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
- return
- }
- rsp.UserInfo = *userInfo
- // 角色信息
- var areaRole models.Arearole
- areaRoles, err := areaRole.GetAreaRolesByUserID(int(loginAccount.Userid))
- if err != nil {
- // 查询失败
- logger.GetLogger().Errorf("LoginQuery failed: %s", err.Error())
- appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
- return
- }
- rsp.AreaRoles = areaRoles
- // 有权限的市场
- markets, err := models.GetMarketsByLoginID(req.LoginID)
- if err != nil {
- // 查询失败
- logger.GetLogger().Errorf("LoginQuery failed: %s", err.Error())
- appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
- return
- }
- rsp.Markets = markets
- // 商品组
- rsp.Goodsgroups = make([]models.Goodsgroup, 0)
- if len(rsp.Markets) > 0 {
- marketIDs := make([]int, 0)
- for _, v := range rsp.Markets {
- marketIDs = append(marketIDs, int(v.MARKETID))
- }
- goodsgroups, err := models.GetGoodsgroupInMarketIDs(marketIDs)
- if err != nil {
- // 查询失败
- logger.GetLogger().Errorf("LoginQuery failed: %s", err.Error())
- appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
- return
- }
- rsp.Goodsgroups = goodsgroups
- }
- // 外部交易所
- rsp.ExternalExchanges = make([]models.Externalexchange, 0)
- if len(rsp.Goodsgroups) > 0 {
- exchangeIDs := make([]int, 0)
- // 过滤掉没有关联商品的交易所
- id := models.GetAvalidExchangeId(rsp.UserAccount.Rootuserid)
- for _, v := range rsp.Goodsgroups {
- for i := range id {
- if id[i] == v.Exexchangeid {
- exchangeIDs = append(exchangeIDs, int(v.Exexchangeid))
- }
- }
- }
- if len(exchangeIDs) > 0 {
- exExchanges, err := models.GetExExchangeByIDs(exchangeIDs)
- if err != nil {
- // 查询失败
- logger.GetLogger().Errorf("LoginQuery failed: %s", err.Error())
- appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
- return
- }
- rsp.ExternalExchanges = exExchanges
- }
- }
- // 系统参数
- systemParams, err := models.GetSystemParams()
- if err != nil {
- // 查询失败
- logger.GetLogger().Errorf("LoginQuery failed: %s", err.Error())
- appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
- return
- }
- rsp.SystemParams = systemParams
- // 用户姓名
- if len(rsp.LoginAccount.Logincode) > 0 {
- systemManager, _ := models.GetSysteMmanagerByLoginCode(rsp.LoginAccount.Logincode)
- if systemManager != nil {
- rsp.UserName = systemManager.Username
- }
- }
- var r models.Exchangerateconfig
- if rsp.ExchangeRateConfigs, err = r.GetAll(); err != nil {
- // 查询失败
- logger.GetLogger().Errorf("LoginQuery failed: %s", err.Error())
- appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
- return
- }
- // 查询成功
- logger.GetLogger().Debugln("LoginQuery successed")
- appG.Response(http.StatusOK, e.SUCCESS, rsp)
- }
- // QueryUserFavoriteGoodsesReq 获取用户商品收藏信息请求参数
- type QueryUserFavoriteGoodsesReq struct {
- UserID int `form:"userID" binding:"required"`
- }
- // QueryUserFavoriteGoodses 获取用户商品收藏信息
- // @Summary 获取用户商品收藏信息
- // @Produce json
- // @Security ApiKeyAuth
- // @Param userID query int true "用户ID"
- // @Success 200 {object} models.Userfavoritegoods
- // @Failure 500 {object} app.Response
- // @Router /User/QueryUserFavoriteGoodses [get]
- // @Tags 用户信息
- func QueryUserFavoriteGoodses(c *gin.Context) {
- appG := app.Gin{C: c}
- // 获取请求参数
- var req QueryUserFavoriteGoodsesReq
- if err := appG.C.ShouldBindQuery(&req); err != nil {
- logger.GetLogger().Errorf("QueryUserFavoriteGoodses failed: %s", err.Error())
- appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
- return
- }
- userFavoriteGoodses, err := models.GetUserFavoriteGoodses(req.UserID)
- if err != nil {
- // 查询失败
- logger.GetLogger().Errorf("GetUserAuthStatus failed: %s", err.Error())
- appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
- return
- }
- // 查询成功
- logger.GetLogger().Debugln("QueryUserFavoriteGoodses successed: %v", userFavoriteGoodses)
- appG.Response(http.StatusOK, e.SUCCESS, userFavoriteGoodses)
- }
- // UpdateUserFavoriteGoodsReq 更新用户商品收藏信息请求参数
- type UpdateUserFavoriteGoodsReq struct {
- UserID int `form:"userID" binding:"required"`
- GoodsID int `form:"goodsID" binding:"required"`
- }
- // AddUserFavoriteGoods 添加用户商品收藏信息
- // @Summary 添加用户商品收藏信息
- // @Produce json
- // @Security ApiKeyAuth
- // @Param userID query int true "用户ID"
- // @Param goodsID query int true "商品ID"
- // @Success 200 {object} app.Response
- // @Failure 500 {object} app.Response
- // @Router /User/AddUserFavoriteGoods [post]
- // @Tags 用户信息
- func AddUserFavoriteGoods(c *gin.Context) {
- appG := app.Gin{C: c}
- // 获取请求参数
- var req UpdateUserFavoriteGoodsReq
- if err := appG.C.ShouldBind(&req); err != nil {
- logger.GetLogger().Errorf("AddUserFavoriteGoods failed: %s", err.Error())
- appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
- return
- }
- if err := models.InsertUserFavoriteGoods(req.UserID, req.GoodsID); err != nil {
- // 执行失败
- logger.GetLogger().Errorf("AddUserFavoriteGoods failed: %s", err.Error())
- appG.Response(http.StatusBadRequest, e.ERROR_OPERATION_FAILED, nil)
- return
- }
- // 执行成功
- logger.GetLogger().Debugln("AddUserFavoriteGoods successed: %v", "ok")
- appG.Response(http.StatusOK, e.SUCCESS, "")
- }
- // RemoveUserFavoriteGoods 移除用户商品收藏信息
- // @Summary 移除用户商品收藏信息
- // @Produce json
- // @Security ApiKeyAuth
- // @Param userID query int true "用户ID"
- // @Param goodsID query int true "商品ID"
- // @Success 200 {object} app.Response
- // @Failure 500 {object} app.Response
- // @Router /User/RemoveUserFavoriteGoods [post]
- // @Tags 用户信息
- func RemoveUserFavoriteGoods(c *gin.Context) {
- appG := app.Gin{C: c}
- // 获取请求参数
- var req UpdateUserFavoriteGoodsReq
- if err := appG.C.ShouldBind(&req); err != nil {
- logger.GetLogger().Errorf("RemoveUserFavoriteGoods failed: %s", err.Error())
- appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
- return
- }
- if err := models.DelUserFavoriteGoods(req.UserID, req.GoodsID); err != nil {
- // 执行失败
- logger.GetLogger().Errorf("RemoveUserFavoriteGoods failed: %s", err.Error())
- appG.Response(http.StatusBadRequest, e.ERROR_OPERATION_FAILED, nil)
- return
- }
- // 执行成功
- logger.GetLogger().Debugln("RemoveUserFavoriteGoods successed: %v", "ok")
- appG.Response(http.StatusOK, e.SUCCESS, "")
- }
- // QueryMessageBoardReq 获取用户留言板信息请求参数
- type QueryMessageBoardReq struct {
- UserID int `form:"userID" binding:"required"`
- }
- // QueryMessageBoard 获取用户留言板信息
- // @Summary 获取用户留言板信息
- // @Produce json
- // @Security ApiKeyAuth
- // @Param userID query int true "用户ID"
- // @Success 200 {object} models.Messageboard
- // @Failure 500 {object} app.Response
- // @Router /User/QueryMessageBoard [get]
- // @Tags 用户信息
- func QueryMessageBoard(c *gin.Context) {
- appG := app.Gin{C: c}
- // 获取请求参数
- var req QueryMessageBoardReq
- if err := appG.C.ShouldBindQuery(&req); err != nil {
- logger.GetLogger().Errorf("QueryMessageBoard failed: %s", err.Error())
- appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
- return
- }
- messageBoards, err := models.GetMessageBoard(req.UserID)
- if err != nil {
- // 查询失败
- logger.GetLogger().Errorf("QueryMessageBoard failed: %s", err.Error())
- appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
- return
- }
- // 查询成功
- logger.GetLogger().Debugln("QueryMessageBoard successed: %v", messageBoards)
- appG.Response(http.StatusOK, e.SUCCESS, messageBoards)
- }
- // AddMessageBoardReq 添加用户留言板信息请求参数
- type AddMessageBoardReq struct {
- UserID int `form:"userID" binding:"required"`
- Message string `form:"message" binding:"required"`
- ContactNum string `form:"contactNum" binding:"required"`
- }
- // AddMessageBoard 添加用户留言板信息
- // @Summary 添加用户留言板信息
- // @Produce json
- // @Security ApiKeyAuth
- // @Param userID query int true "用户ID"
- // @Param message query string true "留言信息"
- // @Param contactNum query string true "联系电话"
- // @Success 200 {object} app.Response
- // @Failure 500 {object} app.Response
- // @Router /User/AddMessageBoard [post]
- // @Tags 用户信息
- func AddMessageBoard(c *gin.Context) {
- appG := app.Gin{C: c}
- // 获取请求参数
- var req AddMessageBoardReq
- if err := appG.C.ShouldBind(&req); err != nil {
- logger.GetLogger().Errorf("AddMessageBoard failed: %s", err.Error())
- appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
- return
- }
- if errCode := models.InsertMessageBoard(req.UserID, req.Message, req.ContactNum); errCode != 0 {
- // 执行失败
- logger.GetLogger().Errorf("AddMessageBoard failed: %s", e.GetMsg(errCode))
- appG.Response(http.StatusBadRequest, errCode, nil)
- return
- }
- // 执行成功
- logger.GetLogger().Debugln("AddMessageBoard successed: %v", "ok")
- appG.Response(http.StatusOK, e.SUCCESS, "")
- }
- // UpdateUserAccountStatusReq 更新用户状态请求参数
- type UpdateUserAccountStatusReq struct {
- UserID int `form:"userID" binding:"required"`
- AccountStatus int `form:"accountStatus" binding:"required"`
- }
- // UpdateUserAccountStatus 更新用户状态
- // @Summary 更新用户状态
- // @Produce json
- // @Security ApiKeyAuth
- // @Param userID query int true "用户ID"
- // @Param accountStatus query int true "账户状态 - 4:正常 6:注销(停用)"
- // @Success 200 {object} app.Response
- // @Failure 500 {object} app.Response
- // @Router /User/UpdateUserAccountStatus [post]
- // @Tags 用户信息
- func UpdateUserAccountStatus(c *gin.Context) {
- appG := app.Gin{C: c}
- // 获取请求参数
- var req UpdateUserAccountStatusReq
- if err := appG.C.ShouldBind(&req); err != nil {
- logger.GetLogger().Errorf("UpdateUserAccountStatus failed: %s", err.Error())
- appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
- return
- }
- if err := models.UpdateUserAccountStatus(req.UserID, req.AccountStatus); err != nil {
- // 执行失败
- logger.GetLogger().Errorf("UpdateUserAccountStatus failed: %s", err.Error())
- appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
- return
- }
- // 执行成功
- logger.GetLogger().Debugln("UpdateUserAccountStatus successed: %v", "ok")
- appG.Response(http.StatusOK, e.SUCCESS, "ok")
- }
- // UpdateUserHeadUrlReq 更新用户头像请求参数
- type UpdateUserHeadUrlReq struct {
- UserID int `json:"userID" binding:"required"`
- Headurl string `json:"headurl" binding:"required"`
- }
- // UpdateUserHeadUrl 更新用户头像
- // @Summary 更新用户头像
- // @Produce json
- // @Security ApiKeyAuth
- // @Param data body UpdateUserHeadUrlReq true "入参"
- // @Success 200 {object} app.Response
- // @Failure 500 {object} app.Response
- // @Router /User/UpdateUserHeadUrl [post]
- // @Tags 用户信息
- func UpdateUserHeadUrl(c *gin.Context) {
- appG := app.Gin{C: c}
- // 获取请求参数
- var req UpdateUserHeadUrlReq
- if err := appG.C.ShouldBindJSON(&req); err != nil {
- logger.GetLogger().Errorf("UpdateUserHeadUrlReq failed: %s", err.Error())
- appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
- return
- }
- if err := models.UpdateUserHeadUrl(req.UserID, req.Headurl); err != nil {
- // 执行失败
- logger.GetLogger().Errorf("UpdateUserHeadUrl failed: %s", err.Error())
- appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
- return
- }
- // 执行成功
- logger.GetLogger().Debugln("UpdateUserHeadUrl successed: %v", "ok")
- appG.Response(http.StatusOK, e.SUCCESS, "ok")
- }
- type QueryMdUserSwapProtocolReq struct {
- UserId int `form:"userId" binding:"required"` // 用户ID
- }
- // QueryMdUserSwapProtocol 获取用户掉期协议签署表
- // @Summary 获取用户掉期协议签署表
- // @Produce json
- // @Security ApiKeyAuth
- // @Param userId query int true "用户ID"
- // @Success 200 {array} models.Mduserswapprotocol
- // @Failure 500 {object} app.Response
- // @Router /User/QueryMdUserSwapProtocol [get]
- // @Tags 用户信息
- func QueryMdUserSwapProtocol(c *gin.Context) {
- appG := app.Gin{C: c}
- // 获取请求参数
- var req QueryMdUserSwapProtocolReq
- if err := appG.C.ShouldBindQuery(&req); err != nil {
- logger.GetLogger().Errorf("QueryMdUserSwapProtocol failed: %s", err.Error())
- appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
- return
- }
- datas, err := models.QueryMdUserSwapProtocol(req.UserId, nil)
- if err != nil {
- // 查询失败
- logger.GetLogger().Errorf("QueryMdUserSwapProtocol failed: %s", err.Error())
- appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
- return
- }
- // 查询成功
- appG.Response(http.StatusOK, e.SUCCESS, datas)
- }
- type GetTodayAccountConfigInfoReq struct {
- Accountid int64 `form:"accountid" binding:"required"` // 资金账户ID
- }
- // GetTodayAccountConfigInfo 获取资金账户今日配置信息
- // @Summary 获取资金账户今日配置信息
- // @Produce json
- // @Security ApiKeyAuth
- // @Param accountid query int true "资金账户ID"
- // @Success 200 {object} models.GetTodayAccountConfigInfoRsp
- // @Failure 500 {object} app.Response
- // @Router /User/GetTodayAccountConfigInfo [get]
- // @Tags 用户信息
- func GetTodayAccountConfigInfo(c *gin.Context) {
- appG := app.Gin{C: c}
- // 获取请求参数
- var req GetTodayAccountConfigInfoReq
- if err := appG.C.ShouldBindQuery(&req); err != nil {
- logger.GetLogger().Errorf("GetTodayAccountConfigInfo failed: %s", err.Error())
- appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
- return
- }
- datas, err := models.GetTodayAccountConfigInfo(int(req.Accountid))
- if err != nil {
- // 查询失败
- logger.GetLogger().Errorf("GetTodayAccountConfigInfo failed: %s", err.Error())
- appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
- return
- }
- // 查询成功
- appG.Response(http.StatusOK, e.SUCCESS, datas)
- }
- // UpdateUserInfoWechatAndEmailReq 更新用户微信和邮箱入参
- type UpdateUserInfoWechatAndEmailReq struct {
- UserID int `json:"userID" binding:"required"` // 用户ID
- Wechat *string `json:"wechat"` // 微信号,如不必修改则不传,传空为清除微信号
- Email *string `json:"email"` // 邮箱地址,如不必修改则不传,传空为清除邮箱地址
- }
- // UpdateUserInfoWechatAndEmail 更新用户微信和邮箱
- // @Summary 更新用户微信和邮箱
- // @Produce json
- // @Security ApiKeyAuth
- // @Param data body UpdateUserInfoWechatAndEmailReq true "入参"
- // @Success 200 {object} app.Response
- // @Failure 500 {object} app.Response
- // @Router /User/UpdateUserInfoWechatAndEmail [post]
- // @Tags 用户信息
- func UpdateUserInfoWechatAndEmail(c *gin.Context) {
- appG := app.Gin{C: c}
- // 获取请求参数
- var req UpdateUserInfoWechatAndEmailReq
- if err := appG.C.ShouldBindJSON(&req); err != nil {
- logger.GetLogger().Errorf("UpdateUserInfoWechatAndEmail failed: %s", err.Error())
- appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
- return
- }
- if err := models.UpdateUserInfoWechatAndEmail(req.Wechat, req.Email, req.UserID); err != nil {
- // 执行失败
- logger.GetLogger().Errorf("UpdateUserInfoWechatAndEmail failed: %s", err.Error())
- appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
- return
- }
- // 执行成功
- logger.GetLogger().Debugln("UpdateUserInfoWechatAndEmail successed:", "ok")
- appG.Response(http.StatusOK, e.SUCCESS, "ok")
- }
|