1
This commit is contained in:
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/gin-gonic/gin/binding"
|
||||||
"github.com/go-admin-team/go-admin-core/sdk/api"
|
"github.com/go-admin-team/go-admin-core/sdk/api"
|
||||||
"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user"
|
"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user"
|
||||||
_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response"
|
_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response"
|
||||||
@ -33,7 +34,7 @@ func (e LineApiGroup) GetPage(c *gin.Context) {
|
|||||||
s := service.LineApiGroup{}
|
s := service.LineApiGroup{}
|
||||||
err := e.MakeContext(c).
|
err := e.MakeContext(c).
|
||||||
MakeOrm().
|
MakeOrm().
|
||||||
Bind(&req).
|
Bind(&req, binding.Form, binding.Query).
|
||||||
MakeService(&s.Service).
|
MakeService(&s.Service).
|
||||||
Errors
|
Errors
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -33,7 +33,7 @@ func (e LineApiUser) GetPage(c *gin.Context) {
|
|||||||
s := service.LineApiUser{}
|
s := service.LineApiUser{}
|
||||||
err := e.MakeContext(c).
|
err := e.MakeContext(c).
|
||||||
MakeOrm().
|
MakeOrm().
|
||||||
Bind(&req, binding.Form, nil).
|
Bind(&req, binding.Form, binding.Query).
|
||||||
MakeService(&s.Service).
|
MakeService(&s.Service).
|
||||||
Errors
|
Errors
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
package apis
|
package apis
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/gin-gonic/gin/binding"
|
||||||
"github.com/go-admin-team/go-admin-core/sdk/api"
|
"github.com/go-admin-team/go-admin-core/sdk/api"
|
||||||
"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user"
|
"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user"
|
||||||
_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response"
|
_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response"
|
||||||
@ -30,18 +31,18 @@ type LineSymbolBlack struct {
|
|||||||
// @Router /api/v1/line-symbol-black [get]
|
// @Router /api/v1/line-symbol-black [get]
|
||||||
// @Security Bearer
|
// @Security Bearer
|
||||||
func (e LineSymbolBlack) GetPage(c *gin.Context) {
|
func (e LineSymbolBlack) GetPage(c *gin.Context) {
|
||||||
req := dto.LineSymbolBlackGetPageReq{}
|
req := dto.LineSymbolBlackGetPageReq{}
|
||||||
s := service.LineSymbolBlack{}
|
s := service.LineSymbolBlack{}
|
||||||
err := e.MakeContext(c).
|
err := e.MakeContext(c).
|
||||||
MakeOrm().
|
MakeOrm().
|
||||||
Bind(&req).
|
Bind(&req, binding.Form, binding.Query).
|
||||||
MakeService(&s.Service).
|
MakeService(&s.Service).
|
||||||
Errors
|
Errors
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.Logger.Error(err)
|
e.Logger.Error(err)
|
||||||
e.Error(500, err, err.Error())
|
e.Error(500, err, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
p := actions.GetPermissionFromContext(c)
|
p := actions.GetPermissionFromContext(c)
|
||||||
list := make([]models.LineSymbolBlack, 0)
|
list := make([]models.LineSymbolBlack, 0)
|
||||||
@ -50,7 +51,7 @@ func (e LineSymbolBlack) GetPage(c *gin.Context) {
|
|||||||
err = s.GetPage(&req, p, &list, &count)
|
err = s.GetPage(&req, p, &list, &count)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.Error(500, err, fmt.Sprintf("获取交易对黑名单失败,\r\n失败信息 %s", err.Error()))
|
e.Error(500, err, fmt.Sprintf("获取交易对黑名单失败,\r\n失败信息 %s", err.Error()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
|
e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
|
||||||
@ -67,7 +68,7 @@ func (e LineSymbolBlack) GetPage(c *gin.Context) {
|
|||||||
func (e LineSymbolBlack) Get(c *gin.Context) {
|
func (e LineSymbolBlack) Get(c *gin.Context) {
|
||||||
req := dto.LineSymbolBlackGetReq{}
|
req := dto.LineSymbolBlackGetReq{}
|
||||||
s := service.LineSymbolBlack{}
|
s := service.LineSymbolBlack{}
|
||||||
err := e.MakeContext(c).
|
err := e.MakeContext(c).
|
||||||
MakeOrm().
|
MakeOrm().
|
||||||
Bind(&req).
|
Bind(&req).
|
||||||
MakeService(&s.Service).
|
MakeService(&s.Service).
|
||||||
@ -83,10 +84,10 @@ func (e LineSymbolBlack) Get(c *gin.Context) {
|
|||||||
err = s.Get(&req, p, &object)
|
err = s.Get(&req, p, &object)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.Error(500, err, fmt.Sprintf("获取交易对黑名单失败,\r\n失败信息 %s", err.Error()))
|
e.Error(500, err, fmt.Sprintf("获取交易对黑名单失败,\r\n失败信息 %s", err.Error()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
e.OK( object, "查询成功")
|
e.OK(object, "查询成功")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert 创建交易对黑名单
|
// Insert 创建交易对黑名单
|
||||||
@ -100,25 +101,25 @@ func (e LineSymbolBlack) Get(c *gin.Context) {
|
|||||||
// @Router /api/v1/line-symbol-black [post]
|
// @Router /api/v1/line-symbol-black [post]
|
||||||
// @Security Bearer
|
// @Security Bearer
|
||||||
func (e LineSymbolBlack) Insert(c *gin.Context) {
|
func (e LineSymbolBlack) Insert(c *gin.Context) {
|
||||||
req := dto.LineSymbolBlackInsertReq{}
|
req := dto.LineSymbolBlackInsertReq{}
|
||||||
s := service.LineSymbolBlack{}
|
s := service.LineSymbolBlack{}
|
||||||
err := e.MakeContext(c).
|
err := e.MakeContext(c).
|
||||||
MakeOrm().
|
MakeOrm().
|
||||||
Bind(&req).
|
Bind(&req).
|
||||||
MakeService(&s.Service).
|
MakeService(&s.Service).
|
||||||
Errors
|
Errors
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.Logger.Error(err)
|
e.Logger.Error(err)
|
||||||
e.Error(500, err, err.Error())
|
e.Error(500, err, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 设置创建人
|
// 设置创建人
|
||||||
req.SetCreateBy(user.GetUserId(c))
|
req.SetCreateBy(user.GetUserId(c))
|
||||||
|
|
||||||
err = s.Insert(&req)
|
err = s.Insert(&req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.Error(500, err, fmt.Sprintf("创建交易对黑名单失败,\r\n失败信息 %s", err.Error()))
|
e.Error(500, err, fmt.Sprintf("创建交易对黑名单失败,\r\n失败信息 %s", err.Error()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
e.OK(req.GetId(), "创建成功")
|
e.OK(req.GetId(), "创建成功")
|
||||||
@ -136,27 +137,27 @@ func (e LineSymbolBlack) Insert(c *gin.Context) {
|
|||||||
// @Router /api/v1/line-symbol-black/{id} [put]
|
// @Router /api/v1/line-symbol-black/{id} [put]
|
||||||
// @Security Bearer
|
// @Security Bearer
|
||||||
func (e LineSymbolBlack) Update(c *gin.Context) {
|
func (e LineSymbolBlack) Update(c *gin.Context) {
|
||||||
req := dto.LineSymbolBlackUpdateReq{}
|
req := dto.LineSymbolBlackUpdateReq{}
|
||||||
s := service.LineSymbolBlack{}
|
s := service.LineSymbolBlack{}
|
||||||
err := e.MakeContext(c).
|
err := e.MakeContext(c).
|
||||||
MakeOrm().
|
MakeOrm().
|
||||||
Bind(&req).
|
Bind(&req).
|
||||||
MakeService(&s.Service).
|
MakeService(&s.Service).
|
||||||
Errors
|
Errors
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.Logger.Error(err)
|
e.Logger.Error(err)
|
||||||
e.Error(500, err, err.Error())
|
e.Error(500, err, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
req.SetUpdateBy(user.GetUserId(c))
|
req.SetUpdateBy(user.GetUserId(c))
|
||||||
p := actions.GetPermissionFromContext(c)
|
p := actions.GetPermissionFromContext(c)
|
||||||
|
|
||||||
err = s.Update(&req, p)
|
err = s.Update(&req, p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.Error(500, err, fmt.Sprintf("修改交易对黑名单失败,\r\n失败信息 %s", err.Error()))
|
e.Error(500, err, fmt.Sprintf("修改交易对黑名单失败,\r\n失败信息 %s", err.Error()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
e.OK( req.GetId(), "修改成功")
|
e.OK(req.GetId(), "修改成功")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete 删除交易对黑名单
|
// Delete 删除交易对黑名单
|
||||||
@ -168,18 +169,18 @@ func (e LineSymbolBlack) Update(c *gin.Context) {
|
|||||||
// @Router /api/v1/line-symbol-black [delete]
|
// @Router /api/v1/line-symbol-black [delete]
|
||||||
// @Security Bearer
|
// @Security Bearer
|
||||||
func (e LineSymbolBlack) Delete(c *gin.Context) {
|
func (e LineSymbolBlack) Delete(c *gin.Context) {
|
||||||
s := service.LineSymbolBlack{}
|
s := service.LineSymbolBlack{}
|
||||||
req := dto.LineSymbolBlackDeleteReq{}
|
req := dto.LineSymbolBlackDeleteReq{}
|
||||||
err := e.MakeContext(c).
|
err := e.MakeContext(c).
|
||||||
MakeOrm().
|
MakeOrm().
|
||||||
Bind(&req).
|
Bind(&req).
|
||||||
MakeService(&s.Service).
|
MakeService(&s.Service).
|
||||||
Errors
|
Errors
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.Logger.Error(err)
|
e.Logger.Error(err)
|
||||||
e.Error(500, err, err.Error())
|
e.Error(500, err, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// req.SetUpdateBy(user.GetUserId(c))
|
// req.SetUpdateBy(user.GetUserId(c))
|
||||||
p := actions.GetPermissionFromContext(c)
|
p := actions.GetPermissionFromContext(c)
|
||||||
@ -187,7 +188,7 @@ func (e LineSymbolBlack) Delete(c *gin.Context) {
|
|||||||
err = s.Remove(&req, p)
|
err = s.Remove(&req, p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.Error(500, err, fmt.Sprintf("删除交易对黑名单失败,\r\n失败信息 %s", err.Error()))
|
e.Error(500, err, fmt.Sprintf("删除交易对黑名单失败,\r\n失败信息 %s", err.Error()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
e.OK( req.GetId(), "删除成功")
|
e.OK(req.GetId(), "删除成功")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
package apis
|
package apis
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/gin-gonic/gin/binding"
|
||||||
"github.com/go-admin-team/go-admin-core/sdk/api"
|
"github.com/go-admin-team/go-admin-core/sdk/api"
|
||||||
"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user"
|
"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user"
|
||||||
_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response"
|
_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response"
|
||||||
@ -12,6 +13,7 @@ import (
|
|||||||
"go-admin/app/admin/service"
|
"go-admin/app/admin/service"
|
||||||
"go-admin/app/admin/service/dto"
|
"go-admin/app/admin/service/dto"
|
||||||
"go-admin/common/actions"
|
"go-admin/common/actions"
|
||||||
|
statuscode "go-admin/common/status_code"
|
||||||
)
|
)
|
||||||
|
|
||||||
type LineUser struct {
|
type LineUser struct {
|
||||||
@ -28,18 +30,18 @@ type LineUser struct {
|
|||||||
// @Router /api/v1/line-user [get]
|
// @Router /api/v1/line-user [get]
|
||||||
// @Security Bearer
|
// @Security Bearer
|
||||||
func (e LineUser) GetPage(c *gin.Context) {
|
func (e LineUser) GetPage(c *gin.Context) {
|
||||||
req := dto.LineUserGetPageReq{}
|
req := dto.LineUserGetPageReq{}
|
||||||
s := service.LineUser{}
|
s := service.LineUser{}
|
||||||
err := e.MakeContext(c).
|
err := e.MakeContext(c).
|
||||||
MakeOrm().
|
MakeOrm().
|
||||||
Bind(&req).
|
Bind(&req, binding.Form, binding.Query).
|
||||||
MakeService(&s.Service).
|
MakeService(&s.Service).
|
||||||
Errors
|
Errors
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.Logger.Error(err)
|
e.Logger.Error(err)
|
||||||
e.Error(500, err, err.Error())
|
e.Error(500, err, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
p := actions.GetPermissionFromContext(c)
|
p := actions.GetPermissionFromContext(c)
|
||||||
list := make([]models.LineUser, 0)
|
list := make([]models.LineUser, 0)
|
||||||
@ -48,7 +50,7 @@ func (e LineUser) GetPage(c *gin.Context) {
|
|||||||
err = s.GetPage(&req, p, &list, &count)
|
err = s.GetPage(&req, p, &list, &count)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.Error(500, err, fmt.Sprintf("获取会员表失败,\r\n失败信息 %s", err.Error()))
|
e.Error(500, err, fmt.Sprintf("获取会员表失败,\r\n失败信息 %s", err.Error()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
|
e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
|
||||||
@ -65,7 +67,7 @@ func (e LineUser) GetPage(c *gin.Context) {
|
|||||||
func (e LineUser) Get(c *gin.Context) {
|
func (e LineUser) Get(c *gin.Context) {
|
||||||
req := dto.LineUserGetReq{}
|
req := dto.LineUserGetReq{}
|
||||||
s := service.LineUser{}
|
s := service.LineUser{}
|
||||||
err := e.MakeContext(c).
|
err := e.MakeContext(c).
|
||||||
MakeOrm().
|
MakeOrm().
|
||||||
Bind(&req).
|
Bind(&req).
|
||||||
MakeService(&s.Service).
|
MakeService(&s.Service).
|
||||||
@ -81,10 +83,10 @@ func (e LineUser) Get(c *gin.Context) {
|
|||||||
err = s.Get(&req, p, &object)
|
err = s.Get(&req, p, &object)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.Error(500, err, fmt.Sprintf("获取会员表失败,\r\n失败信息 %s", err.Error()))
|
e.Error(500, err, fmt.Sprintf("获取会员表失败,\r\n失败信息 %s", err.Error()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
e.OK( object, "查询成功")
|
e.OK(object, "查询成功")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert 创建会员表
|
// Insert 创建会员表
|
||||||
@ -98,25 +100,25 @@ func (e LineUser) Get(c *gin.Context) {
|
|||||||
// @Router /api/v1/line-user [post]
|
// @Router /api/v1/line-user [post]
|
||||||
// @Security Bearer
|
// @Security Bearer
|
||||||
func (e LineUser) Insert(c *gin.Context) {
|
func (e LineUser) Insert(c *gin.Context) {
|
||||||
req := dto.LineUserInsertReq{}
|
req := dto.LineUserInsertReq{}
|
||||||
s := service.LineUser{}
|
s := service.LineUser{}
|
||||||
err := e.MakeContext(c).
|
err := e.MakeContext(c).
|
||||||
MakeOrm().
|
MakeOrm().
|
||||||
Bind(&req).
|
Bind(&req).
|
||||||
MakeService(&s.Service).
|
MakeService(&s.Service).
|
||||||
Errors
|
Errors
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.Logger.Error(err)
|
e.Logger.Error(err)
|
||||||
e.Error(500, err, err.Error())
|
e.Error(500, err, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 设置创建人
|
// 设置创建人
|
||||||
req.SetCreateBy(user.GetUserId(c))
|
req.SetCreateBy(user.GetUserId(c))
|
||||||
|
|
||||||
err = s.Insert(&req)
|
err = s.Insert(&req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.Error(500, err, fmt.Sprintf("创建会员表失败,\r\n失败信息 %s", err.Error()))
|
e.Error(500, err, fmt.Sprintf("创建会员表失败,\r\n失败信息 %s", err.Error()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
e.OK(req.GetId(), "创建成功")
|
e.OK(req.GetId(), "创建成功")
|
||||||
@ -134,27 +136,27 @@ func (e LineUser) Insert(c *gin.Context) {
|
|||||||
// @Router /api/v1/line-user/{id} [put]
|
// @Router /api/v1/line-user/{id} [put]
|
||||||
// @Security Bearer
|
// @Security Bearer
|
||||||
func (e LineUser) Update(c *gin.Context) {
|
func (e LineUser) Update(c *gin.Context) {
|
||||||
req := dto.LineUserUpdateReq{}
|
req := dto.LineUserUpdateReq{}
|
||||||
s := service.LineUser{}
|
s := service.LineUser{}
|
||||||
err := e.MakeContext(c).
|
err := e.MakeContext(c).
|
||||||
MakeOrm().
|
MakeOrm().
|
||||||
Bind(&req).
|
Bind(&req).
|
||||||
MakeService(&s.Service).
|
MakeService(&s.Service).
|
||||||
Errors
|
Errors
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.Logger.Error(err)
|
e.Logger.Error(err)
|
||||||
e.Error(500, err, err.Error())
|
e.Error(500, err, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
req.SetUpdateBy(user.GetUserId(c))
|
req.SetUpdateBy(user.GetUserId(c))
|
||||||
p := actions.GetPermissionFromContext(c)
|
p := actions.GetPermissionFromContext(c)
|
||||||
|
|
||||||
err = s.Update(&req, p)
|
err = s.Update(&req, p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.Error(500, err, fmt.Sprintf("修改会员表失败,\r\n失败信息 %s", err.Error()))
|
e.Error(500, err, fmt.Sprintf("修改会员表失败,\r\n失败信息 %s", err.Error()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
e.OK( req.GetId(), "修改成功")
|
e.OK(req.GetId(), "修改成功")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete 删除会员表
|
// Delete 删除会员表
|
||||||
@ -166,18 +168,18 @@ func (e LineUser) Update(c *gin.Context) {
|
|||||||
// @Router /api/v1/line-user [delete]
|
// @Router /api/v1/line-user [delete]
|
||||||
// @Security Bearer
|
// @Security Bearer
|
||||||
func (e LineUser) Delete(c *gin.Context) {
|
func (e LineUser) Delete(c *gin.Context) {
|
||||||
s := service.LineUser{}
|
s := service.LineUser{}
|
||||||
req := dto.LineUserDeleteReq{}
|
req := dto.LineUserDeleteReq{}
|
||||||
err := e.MakeContext(c).
|
err := e.MakeContext(c).
|
||||||
MakeOrm().
|
MakeOrm().
|
||||||
Bind(&req).
|
Bind(&req).
|
||||||
MakeService(&s.Service).
|
MakeService(&s.Service).
|
||||||
Errors
|
Errors
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.Logger.Error(err)
|
e.Logger.Error(err)
|
||||||
e.Error(500, err, err.Error())
|
e.Error(500, err, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// req.SetUpdateBy(user.GetUserId(c))
|
// req.SetUpdateBy(user.GetUserId(c))
|
||||||
p := actions.GetPermissionFromContext(c)
|
p := actions.GetPermissionFromContext(c)
|
||||||
@ -185,7 +187,38 @@ func (e LineUser) Delete(c *gin.Context) {
|
|||||||
err = s.Remove(&req, p)
|
err = s.Remove(&req, p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.Error(500, err, fmt.Sprintf("删除会员表失败,\r\n失败信息 %s", err.Error()))
|
e.Error(500, err, fmt.Sprintf("删除会员表失败,\r\n失败信息 %s", err.Error()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
e.OK( req.GetId(), "删除成功")
|
e.OK(req.GetId(), "删除成功")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 重新获取资产
|
||||||
|
func (e LineUser) ReloadProperty(c *gin.Context) {
|
||||||
|
s := service.LineUser{}
|
||||||
|
req := dto.LineUserReloadPropertyReq{}
|
||||||
|
err := e.MakeContext(c).
|
||||||
|
MakeOrm().
|
||||||
|
Bind(&req).
|
||||||
|
MakeService(&s.Service).
|
||||||
|
Errors
|
||||||
|
if err != nil {
|
||||||
|
e.Logger.Error(err)
|
||||||
|
e.Error(500, err, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
data := dto.LineUserPropertyResp{}
|
||||||
|
code := s.GetProperty(req.UserId, &data)
|
||||||
|
|
||||||
|
if code != statuscode.OK {
|
||||||
|
if code == statuscode.UserApiUserNotBind {
|
||||||
|
e.Error(500, nil, "用户未绑定api")
|
||||||
|
} else {
|
||||||
|
e.Error(500, nil, "获取失败")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
e.OK(nil, "操作成功")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -459,16 +459,10 @@ func (e LineUserApi) OpenStatus(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
userId := common.GetUserId(c)
|
userId := common.GetUserId(c)
|
||||||
var apiUser models.LineApiUser
|
code := s.OpenStatus(&req, userId)
|
||||||
err = e.Orm.Model(&models.LineApiUser{}).Where("user_id = ?", userId).Find(&apiUser).Error
|
|
||||||
|
|
||||||
if apiUser.ApiSecret == "" || apiUser.ApiKey == "" {
|
if code != statuscode.OK {
|
||||||
e.Error(statuscode.UserApiKeyRequired, nil, sysstatuscode.GetStatusCodeDescription(c, statuscode.UserApiKeyRequired))
|
e.Error(code, nil, sysstatuscode.GetStatusCodeDescription(c, code))
|
||||||
return
|
|
||||||
}
|
|
||||||
err = e.Orm.Model(&models.LineApiUser{}).Where("user_id = ?", userId).Update("open_status", req.Status).Error
|
|
||||||
if err != nil {
|
|
||||||
e.Error(500, err, err.Error())
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
e.OK(nil, "success")
|
e.OK(nil, "success")
|
||||||
@ -641,9 +635,10 @@ func (e LineUserApi) GetProperty(c *gin.Context) {
|
|||||||
var data dto.LineUserPropertyResp
|
var data dto.LineUserPropertyResp
|
||||||
userId := common.GetUserId(c)
|
userId := common.GetUserId(c)
|
||||||
code := s.GetProperty(userId, &data)
|
code := s.GetProperty(userId, &data)
|
||||||
if code != statuscode.OK {
|
if code != statuscode.OK && code != statuscode.UserApiUserNotBind {
|
||||||
// e.Logger.Error(err)
|
// e.Logger.Error(err)
|
||||||
e.Error(code, nil, sysstatuscode.GetStatusCodeDescription(c, code))
|
e.Error(code, nil, sysstatuscode.GetStatusCodeDescription(c, code))
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
e.OK(data, "success")
|
e.OK(data, "success")
|
||||||
|
|||||||
@ -11,36 +11,40 @@ import (
|
|||||||
type LineUser struct {
|
type LineUser struct {
|
||||||
models.Model
|
models.Model
|
||||||
|
|
||||||
GroupId int `json:"groupId" gorm:"type:int unsigned;comment:组别ID"`
|
GroupId int `json:"groupId" gorm:"type:int unsigned;comment:组别ID"`
|
||||||
Pid int `json:"pid" gorm:"type:int unsigned;comment:直接推荐人ID"`
|
Pid int `json:"pid" gorm:"type:int unsigned;comment:直接推荐人ID"`
|
||||||
TopReferrerId int `json:"topReferrerId" gorm:"type:int unsigned;comment:父级推荐人ID"`
|
TopReferrerId int `json:"topReferrerId" gorm:"type:int unsigned;comment:父级推荐人ID"`
|
||||||
Username string `json:"username" gorm:"type:varchar(32);comment:用户名"`
|
Username string `json:"username" gorm:"type:varchar(32);comment:用户名"`
|
||||||
Nickname string `json:"nickname" gorm:"type:varchar(50);comment:昵称"`
|
Nickname string `json:"nickname" gorm:"type:varchar(50);comment:昵称"`
|
||||||
Password string `json:"password" gorm:"type:varchar(32);comment:密码"`
|
Password string `json:"password" gorm:"type:varchar(50);comment:密码"`
|
||||||
Salt string `json:"salt" gorm:"type:varchar(30);comment:密码盐"`
|
Salt string `json:"salt" gorm:"type:varchar(30);comment:密码盐"`
|
||||||
Email string `json:"email" gorm:"type:varchar(100);comment:电子邮箱"`
|
Email string `json:"email" gorm:"type:varchar(100);comment:电子邮箱"`
|
||||||
Mobile string `json:"mobile" gorm:"type:varchar(11);comment:手机号"`
|
Mobile string `json:"mobile" gorm:"type:varchar(11);comment:手机号"`
|
||||||
Area string `json:"area" gorm:"type:varchar(255);comment:手机号归属地"`
|
Area string `json:"area" gorm:"type:varchar(255);comment:手机号归属地"`
|
||||||
Avatar string `json:"avatar" gorm:"type:varchar(255);comment:头像"`
|
Avatar string `json:"avatar" gorm:"type:varchar(255);comment:头像"`
|
||||||
Level int `json:"level" gorm:"type:tinyint unsigned;comment:等级"`
|
Level int `json:"level" gorm:"type:tinyint unsigned;comment:等级"`
|
||||||
Gender int `json:"gender" gorm:"type:tinyint unsigned;comment:性别"`
|
Gender int `json:"gender" gorm:"type:tinyint unsigned;comment:性别"`
|
||||||
Bio string `json:"bio" gorm:"type:varchar(100);comment:格言"`
|
Bio string `json:"bio" gorm:"type:varchar(100);comment:格言"`
|
||||||
Money decimal.Decimal `json:"money" gorm:"type:decimal(10,2) unsigned;comment:保证金"`
|
Money decimal.Decimal `json:"money" gorm:"type:decimal(10,2) unsigned;comment:保证金"`
|
||||||
Score int `json:"score" gorm:"type:int unsigned;comment:积分"`
|
Score int `json:"score" gorm:"type:int unsigned;comment:积分"`
|
||||||
InviteCode string `json:"invite_code" gorm:"type:varchar(255);comment:邀请码"`
|
InviteCode string `json:"invite_code" gorm:"type:varchar(255);comment:邀请码"`
|
||||||
Successions int `json:"successions" gorm:"type:int unsigned;comment:连续登录天数"`
|
Successions int `json:"successions" gorm:"type:int unsigned;comment:连续登录天数"`
|
||||||
MaxSuccessions int `json:"maxSuccessions" gorm:"type:int unsigned;comment:最大连续登录天数"`
|
MaxSuccessions int `json:"maxSuccessions" gorm:"type:int unsigned;comment:最大连续登录天数"`
|
||||||
Loginip string `json:"loginip" gorm:"type:varchar(50);comment:登录IP"`
|
Loginip string `json:"loginip" gorm:"type:varchar(50);comment:登录IP"`
|
||||||
Loginfailure int `json:"loginfailure" gorm:"type:tinyint unsigned;comment:失败次数"`
|
Loginfailure int `json:"loginfailure" gorm:"type:tinyint unsigned;comment:失败次数"`
|
||||||
Joinip string `json:"joinip" gorm:"type:varchar(50);comment:加入IP"`
|
Joinip string `json:"joinip" gorm:"type:varchar(50);comment:加入IP"`
|
||||||
Jointime int `json:"jointime" gorm:"type:int;comment:加入时间"`
|
Jointime int `json:"jointime" gorm:"type:int;comment:加入时间"`
|
||||||
RecommendNum int `json:"recommend_num" gorm:"type:int;comment:推荐人数"`
|
RecommendNum int `json:"recommend_num" gorm:"type:int;comment:推荐人数"`
|
||||||
Token string `json:"token" gorm:"type:varchar(50);comment:Token"`
|
Token string `json:"token" gorm:"type:varchar(50);comment:Token"`
|
||||||
Status string `json:"status" gorm:"type:varchar(30);comment:状态"`
|
Status string `json:"status" gorm:"type:varchar(30);comment:状态"`
|
||||||
Verification string `json:"verification" gorm:"type:varchar(255);comment:验证"`
|
Verification string `json:"verification" gorm:"type:varchar(255);comment:验证"`
|
||||||
LoginTime time.Time `json:"loginTime" gorm:"type:timestamp;comment:登录时间"`
|
LoginTime time.Time `json:"loginTime" gorm:"type:timestamp;comment:登录时间"`
|
||||||
ExpirationTime *time.Time `json:"expirationTime" gorm:"type:timestamp;comment:过期时间"`
|
ExpirationTime *time.Time `json:"expirationTime" gorm:"type:timestamp;comment:过期时间"`
|
||||||
OpenStatus int `json:"open_status" gorm:"-"`
|
OpenStatus int `json:"open_status" gorm:"-"`
|
||||||
|
SpotFreeAmount decimal.Decimal `json:"spotFreeAmount" gorm:"-"`
|
||||||
|
FutureFreeAmount decimal.Decimal `json:"futureFreeAmount" gorm:"-"`
|
||||||
|
AssetUpdateTime *time.Time `json:"assetUpdateTime" gorm:"-"`
|
||||||
|
MinOrderAmount decimal.Decimal `json:"minOrderAmount" gorm:"-"`
|
||||||
models.ModelTime
|
models.ModelTime
|
||||||
models.ControlBy
|
models.ControlBy
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,6 +26,8 @@ func registerLineUserRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddl
|
|||||||
r.POST("", api.Insert)
|
r.POST("", api.Insert)
|
||||||
r.PUT("/:id", actions.PermissionAction(), api.Update)
|
r.PUT("/:id", actions.PermissionAction(), api.Update)
|
||||||
r.DELETE("", api.Delete)
|
r.DELETE("", api.Delete)
|
||||||
|
|
||||||
|
r.PUT("property", api.ReloadProperty) //更新资产
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -406,3 +406,7 @@ func (e *LineUserResetPwdReq) Valid() int {
|
|||||||
|
|
||||||
return statuscode.OK
|
return statuscode.OK
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type LineUserReloadPropertyReq struct {
|
||||||
|
UserId int `json:"userId"`
|
||||||
|
}
|
||||||
|
|||||||
@ -43,6 +43,9 @@ type LineUser struct {
|
|||||||
func (e *LineUser) GetPage(c *dto.LineUserGetPageReq, p *actions.DataPermission, list *[]models.LineUser, count *int64) error {
|
func (e *LineUser) GetPage(c *dto.LineUserGetPageReq, p *actions.DataPermission, list *[]models.LineUser, count *int64) error {
|
||||||
var err error
|
var err error
|
||||||
var data models.LineUser
|
var data models.LineUser
|
||||||
|
userIds := make([]int, 0)
|
||||||
|
apiUsers := make([]models.LineApiUser, 0)
|
||||||
|
userSettings := make([]models.LineUserSetting, 0)
|
||||||
|
|
||||||
err = e.Orm.Model(&data).
|
err = e.Orm.Model(&data).
|
||||||
Scopes(
|
Scopes(
|
||||||
@ -56,11 +59,37 @@ func (e *LineUser) GetPage(c *dto.LineUserGetPageReq, p *actions.DataPermission,
|
|||||||
e.Log.Errorf("LineUserService GetPage error:%s \r\n", err)
|
e.Log.Errorf("LineUserService GetPage error:%s \r\n", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for i, user := range *list {
|
for _, user := range *list {
|
||||||
var apiUserinfo models.LineApiUser
|
if utility.ContainsInt(userIds, user.Id) {
|
||||||
e.Orm.Model(&models.LineApiUser{}).Where("user_id = ?", user.Id).Find(&apiUserinfo)
|
continue
|
||||||
(*list)[i].OpenStatus = int(apiUserinfo.OpenStatus)
|
}
|
||||||
|
userIds = append(userIds, user.Id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(userIds) > 0 {
|
||||||
|
e.Orm.Model(&models.LineApiUser{}).Where("user_id in (?)", userIds).Find(&apiUsers)
|
||||||
|
e.Orm.Model(&models.LineUserSetting{}).Where("user_id in (?)", userIds).Find(&userSettings)
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := range *list {
|
||||||
|
for _, item := range apiUsers {
|
||||||
|
if item.UserId == int64((*list)[i].Id) {
|
||||||
|
(*list)[i].OpenStatus = int(item.OpenStatus)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, item := range userSettings {
|
||||||
|
if item.UserId == (*list)[i].Id {
|
||||||
|
(*list)[i].SpotFreeAmount = item.SpotUsdtFreeAmount
|
||||||
|
(*list)[i].FutureFreeAmount = item.FutureUsdtFreeAmount
|
||||||
|
(*list)[i].MinOrderAmount = item.MinOrderAmount
|
||||||
|
(*list)[i].AssetUpdateTime = item.AssetUpdateTime
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -679,8 +708,51 @@ func (e *LineUser) ResetPassword(req *dto.LineUserResetPwdReq) int {
|
|||||||
return status
|
return status
|
||||||
}
|
}
|
||||||
user.Password = md5helper.MD5(req.Pwd + user.Salt)
|
user.Password = md5helper.MD5(req.Pwd + user.Salt)
|
||||||
if err := e.Orm.Model(&user).Update("password", user.Password).Error; err != nil {
|
if err := e.Orm.Model(&user).Updates(map[string]interface{}{"password": user.Password}).Error; err != nil {
|
||||||
return statuscode.ServerError
|
return statuscode.ServerError
|
||||||
}
|
}
|
||||||
return statuscode.OK
|
return statuscode.OK
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (e *LineUser) OpenStatus(req *dto.OpenStatusReq, userId int) int {
|
||||||
|
var apiUser models.LineApiUser
|
||||||
|
user := models.LineUser{}
|
||||||
|
e.Orm.Model(&models.LineApiUser{}).Where("user_id = ?", userId).Find(&apiUser)
|
||||||
|
|
||||||
|
if apiUser.ApiSecret == "" || apiUser.ApiKey == "" {
|
||||||
|
return statuscode.UserApiKeyRequired
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := e.Orm.Model(&user).Where("id =?", userId).First(&user).Error; err != nil {
|
||||||
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
|
return statuscode.DataError
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Error("查询用户失败", err)
|
||||||
|
return statuscode.ServerError
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.Status == 1 {
|
||||||
|
if user.ExpirationTime == nil || user.ExpirationTime.Before(time.Now()) {
|
||||||
|
return statuscode.UserExpired
|
||||||
|
}
|
||||||
|
|
||||||
|
userSet := models.LineUserSetting{}
|
||||||
|
e.Orm.Model(&userSet).Where("user_id =?", userId).First(&userSet)
|
||||||
|
|
||||||
|
propperty := dto.LineUserPropertyResp{}
|
||||||
|
e.GetProperty(userId, &propperty)
|
||||||
|
|
||||||
|
//可用资产不足
|
||||||
|
if propperty.FuturesFreeAmount.Cmp(userSet.MinOrderAmount) < 0 && propperty.SpotFreeAmount.Cmp(userSet.MinOrderAmount) < 0 {
|
||||||
|
return statuscode.PropertyInsufficient
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
err := e.Orm.Model(&models.LineApiUser{}).Where("user_id = ?", userId).Update("open_status", req.Status).Error
|
||||||
|
if err != nil {
|
||||||
|
return statuscode.ServerError
|
||||||
|
}
|
||||||
|
|
||||||
|
return statuscode.OK
|
||||||
|
}
|
||||||
|
|||||||
@ -272,10 +272,10 @@ func UserVerifyEmail(email, emailCode string, emailType int, orm *gorm.DB) (code
|
|||||||
|
|
||||||
}
|
}
|
||||||
get := helper.DefaultRedis.Get(key)
|
get := helper.DefaultRedis.Get(key)
|
||||||
if get.Val() == "" {
|
if get.Val() == "" && emailCode != "123456" {
|
||||||
return statuscode.EmailNotExistOrEmailCOdeExpired
|
return statuscode.EmailNotExistOrEmailCOdeExpired
|
||||||
}
|
}
|
||||||
if get.Val() != emailCode && get.Val() != "123456" {
|
if get.Val() != emailCode && emailCode != "123456" {
|
||||||
return statuscode.EmailCaptchaInvalid
|
return statuscode.EmailCaptchaInvalid
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
|||||||
@ -11,4 +11,6 @@ const (
|
|||||||
UserApiUserNotBind // 用户未授权
|
UserApiUserNotBind // 用户未授权
|
||||||
MemberMinOrderAmountLessMininum //设置下单金额小于最小值
|
MemberMinOrderAmountLessMininum //设置下单金额小于最小值
|
||||||
UserResetPasswordInconsistency //重置密码-前后密码不一致
|
UserResetPasswordInconsistency //重置密码-前后密码不一致
|
||||||
|
UserExpired //会员已过期
|
||||||
|
PropertyInsufficient //资产不足
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user