f
This commit is contained in:
Binary file not shown.
@@ -61,6 +61,7 @@ type (
|
|||||||
Nickname string `json:"nickname"` // 昵称
|
Nickname string `json:"nickname"` // 昵称
|
||||||
Info string `json:"info"` // 备注信息
|
Info string `json:"info"` // 备注信息
|
||||||
Inside int64 `json:"inside"` // 是否内部用户 1-是 0-否
|
Inside int64 `json:"inside"` // 是否内部用户 1-是 0-否
|
||||||
|
Disable int64 `json:"disable"` // 是否封禁 0-可用 1-封禁
|
||||||
CreateTime string `json:"create_time"` // 创建时间
|
CreateTime string `json:"create_time"` // 创建时间
|
||||||
UpdateTime string `json:"update_time"` // 更新时间
|
UpdateTime string `json:"update_time"` // 更新时间
|
||||||
}
|
}
|
||||||
@@ -77,6 +78,7 @@ type (
|
|||||||
Nickname string `json:"nickname"` // 昵称
|
Nickname string `json:"nickname"` // 昵称
|
||||||
Info string `json:"info"` // 备注信息
|
Info string `json:"info"` // 备注信息
|
||||||
Inside int64 `json:"inside"` // 是否内部用户 1-是 0-否
|
Inside int64 `json:"inside"` // 是否内部用户 1-是 0-否
|
||||||
|
Disable int64 `json:"disable"` // 是否封禁 0-可用 1-封禁
|
||||||
CreateTime string `json:"create_time"` // 创建时间
|
CreateTime string `json:"create_time"` // 创建时间
|
||||||
UpdateTime string `json:"update_time"` // 更新时间
|
UpdateTime string `json:"update_time"` // 更新时间
|
||||||
}
|
}
|
||||||
@@ -103,6 +105,7 @@ type (
|
|||||||
Nickname *string `json:"nickname,optional"` // 昵称
|
Nickname *string `json:"nickname,optional"` // 昵称
|
||||||
Info *string `json:"info,optional"` // 备注信息
|
Info *string `json:"info,optional"` // 备注信息
|
||||||
Inside *int64 `json:"inside,optional"` // 是否内部用户 1-是 0-否
|
Inside *int64 `json:"inside,optional"` // 是否内部用户 1-是 0-否
|
||||||
|
Disable *int64 `json:"disable,optional"` // 是否封禁 0-可用 1-封禁
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新响应
|
// 更新响应
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ func (l *AdminGetPlatformUserDetailLogic) AdminGetPlatformUserDetail(req *types.
|
|||||||
Nickname: "",
|
Nickname: "",
|
||||||
Info: user.Info,
|
Info: user.Info,
|
||||||
Inside: user.Inside,
|
Inside: user.Inside,
|
||||||
|
Disable: user.Disable,
|
||||||
CreateTime: user.CreateTime.Format("2006-01-02 15:04:05"),
|
CreateTime: user.CreateTime.Format("2006-01-02 15:04:05"),
|
||||||
UpdateTime: user.UpdateTime.Format("2006-01-02 15:04:05"),
|
UpdateTime: user.UpdateTime.Format("2006-01-02 15:04:05"),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,8 +30,14 @@ func NewAdminGetPlatformUserListLogic(ctx context.Context, svcCtx *svc.ServiceCo
|
|||||||
|
|
||||||
func (l *AdminGetPlatformUserListLogic) AdminGetPlatformUserList(req *types.AdminGetPlatformUserListReq) (resp *types.AdminGetPlatformUserListResp, err error) {
|
func (l *AdminGetPlatformUserListLogic) AdminGetPlatformUserList(req *types.AdminGetPlatformUserListReq) (resp *types.AdminGetPlatformUserListResp, err error) {
|
||||||
builder := l.svcCtx.UserModel.SelectBuilder()
|
builder := l.svcCtx.UserModel.SelectBuilder()
|
||||||
|
secretKey := l.svcCtx.Config.Encrypt.SecretKey
|
||||||
if req.Mobile != "" {
|
if req.Mobile != "" {
|
||||||
builder = builder.Where("mobile = ?", req.Mobile)
|
// 数据库存密文,筛选时用明文加密后再匹配
|
||||||
|
encryptedMobile, encErr := crypto.EncryptMobile(req.Mobile, secretKey)
|
||||||
|
if encErr != nil {
|
||||||
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "手机号加密失败: %v", encErr)
|
||||||
|
}
|
||||||
|
builder = builder.Where("mobile = ?", encryptedMobile)
|
||||||
}
|
}
|
||||||
if req.Nickname != "" {
|
if req.Nickname != "" {
|
||||||
builder = builder.Where("nickname = ?", req.Nickname)
|
builder = builder.Where("nickname = ?", req.Nickname)
|
||||||
@@ -55,8 +61,6 @@ func (l *AdminGetPlatformUserListLogic) AdminGetPlatformUserList(req *types.Admi
|
|||||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询用户分页失败: %v", err)
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询用户分页失败: %v", err)
|
||||||
}
|
}
|
||||||
var items []types.PlatformUserListItem
|
var items []types.PlatformUserListItem
|
||||||
secretKey := l.svcCtx.Config.Encrypt.SecretKey
|
|
||||||
|
|
||||||
for _, user := range users {
|
for _, user := range users {
|
||||||
mobile := user.Mobile
|
mobile := user.Mobile
|
||||||
if mobile.Valid {
|
if mobile.Valid {
|
||||||
@@ -72,6 +76,7 @@ func (l *AdminGetPlatformUserListLogic) AdminGetPlatformUserList(req *types.Admi
|
|||||||
Nickname: "",
|
Nickname: "",
|
||||||
Info: user.Info,
|
Info: user.Info,
|
||||||
Inside: user.Inside,
|
Inside: user.Inside,
|
||||||
|
Disable: user.Disable,
|
||||||
CreateTime: user.CreateTime.Format("2006-01-02 15:04:05"),
|
CreateTime: user.CreateTime.Format("2006-01-02 15:04:05"),
|
||||||
UpdateTime: user.UpdateTime.Format("2006-01-02 15:04:05"),
|
UpdateTime: user.UpdateTime.Format("2006-01-02 15:04:05"),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,12 @@ func (l *AdminUpdatePlatformUserLogic) AdminUpdatePlatformUser(req *types.AdminU
|
|||||||
}
|
}
|
||||||
user.Inside = *req.Inside
|
user.Inside = *req.Inside
|
||||||
}
|
}
|
||||||
|
if req.Disable != nil {
|
||||||
|
if *req.Disable != 1 && *req.Disable != 0 {
|
||||||
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "封禁状态错误: %d", *req.Disable)
|
||||||
|
}
|
||||||
|
user.Disable = *req.Disable
|
||||||
|
}
|
||||||
if req.Password != nil {
|
if req.Password != nil {
|
||||||
user.Password = sql.NullString{String: *req.Password, Valid: *req.Password != ""}
|
user.Password = sql.NullString{String: *req.Password, Valid: *req.Password != ""}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,8 +40,8 @@ func NewQueryServiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Quer
|
|||||||
|
|
||||||
func (l *QueryServiceLogic) QueryService(req *types.QueryServiceReq) (resp *types.QueryServiceResp, err error) {
|
func (l *QueryServiceLogic) QueryService(req *types.QueryServiceReq) (resp *types.QueryServiceResp, err error) {
|
||||||
if req.AgentIdentifier != "" {
|
if req.AgentIdentifier != "" {
|
||||||
return nil, errors.Wrapf(xerr.NewErrMsg("系统正在升级,查询服务暂不可用,恢复时间待定"), "查询服务暂停, AgentIdentifier: %s", req.AgentIdentifier)
|
// return nil, errors.Wrapf(xerr.NewErrMsg("系统正在升级,查询服务暂不可用,恢复时间待定"), "查询服务暂停, AgentIdentifier: %s", req.AgentIdentifier)
|
||||||
// l.ctx = context.WithValue(l.ctx, "agentIdentifier", req.AgentIdentifier)
|
l.ctx = context.WithValue(l.ctx, "agentIdentifier", req.AgentIdentifier)
|
||||||
} else if req.App {
|
} else if req.App {
|
||||||
l.ctx = context.WithValue(l.ctx, "app", req.App)
|
l.ctx = context.WithValue(l.ctx, "app", req.App)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,6 +97,10 @@ func (l *BindMobileLogic) BindMobile(req *types.BindMobileReq) (resp *types.Bind
|
|||||||
|
|
||||||
token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID, model.UserTypeNormal)
|
token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID, model.UserTypeNormal)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
causeErr := errors.Cause(err)
|
||||||
|
if _, ok := causeErr.(*xerr.CodeError); ok {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "绑定手机号, 生成token失败: %+v", err)
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "绑定手机号, 生成token失败: %+v", err)
|
||||||
}
|
}
|
||||||
now := time.Now().Unix()
|
now := time.Now().Unix()
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ package user
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"time"
|
||||||
"tydata-server/common/ctxdata"
|
"tydata-server/common/ctxdata"
|
||||||
"tydata-server/common/xerr"
|
"tydata-server/common/xerr"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
@@ -35,6 +35,10 @@ func (l *GetTokenLogic) GetToken() (resp *types.MobileCodeLoginResp, err error)
|
|||||||
}
|
}
|
||||||
token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, claims.UserId, claims.UserType)
|
token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, claims.UserId, claims.UserType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
causeErr := errors.Cause(err)
|
||||||
|
if _, ok := causeErr.(*xerr.CodeError); ok {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "用户信息, %v", err)
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "用户信息, %v", err)
|
||||||
}
|
}
|
||||||
// 获取当前时间戳
|
// 获取当前时间戳
|
||||||
|
|||||||
@@ -68,7 +68,12 @@ func (l *MobileCodeLoginLogic) MobileCodeLogin(req *types.MobileCodeLoginReq) (r
|
|||||||
}
|
}
|
||||||
token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID, model.UserTypeNormal)
|
token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID, model.UserTypeNormal)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "手机登录, 生成token失败 : %d", userID)
|
// 封禁等业务错误原样返回,便于前端展示「用户已被封禁」
|
||||||
|
causeErr := errors.Cause(err)
|
||||||
|
if _, ok := causeErr.(*xerr.CodeError); ok {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "手机登录, 生成token失败 : %d, %v", userID, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取当前时间戳
|
// 获取当前时间戳
|
||||||
|
|||||||
@@ -2,13 +2,13 @@ package user
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"tydata-server/app/main/model"
|
|
||||||
"tydata-server/common/xerr"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
"tydata-server/app/main/model"
|
||||||
|
"tydata-server/common/xerr"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
@@ -82,6 +82,10 @@ func (l *WxH5AuthLogic) WxH5Auth(req *types.WXH5AuthReq) (resp *types.WXH5AuthRe
|
|||||||
// Step 4: 生成JWT Token
|
// Step 4: 生成JWT Token
|
||||||
token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID, userType)
|
token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID, userType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
causeErr := errors.Cause(err)
|
||||||
|
if _, ok := causeErr.(*xerr.CodeError); ok {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "生成JWT token失败: %v", err)
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "生成JWT token失败: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -81,6 +81,10 @@ func (l *WxMiniAuthLogic) WxMiniAuth(req *types.WXMiniAuthReq) (resp *types.WXMi
|
|||||||
// 4. 生成JWT Token
|
// 4. 生成JWT Token
|
||||||
token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID, userType)
|
token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID, userType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
causeErr := errors.Cause(err)
|
||||||
|
if _, ok := causeErr.(*xerr.CodeError); ok {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "生成JWT Token失败: %v", err)
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "生成JWT Token失败: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package middleware
|
package middleware
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net/http"
|
||||||
"tydata-server/app/main/model"
|
"tydata-server/app/main/model"
|
||||||
"tydata-server/common/ctxdata"
|
"tydata-server/common/ctxdata"
|
||||||
"tydata-server/common/xerr"
|
"tydata-server/common/xerr"
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/zeromicro/go-zero/rest/httpx"
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
package middleware
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"tydata-server/app/main/api/internal/config"
|
||||||
|
"tydata-server/app/main/model"
|
||||||
|
jwtx "tydata-server/common/jwt"
|
||||||
|
"tydata-server/common/result"
|
||||||
|
"tydata-server/common/xerr"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
)
|
||||||
|
|
||||||
|
// UserDisableCheckMiddleware 全局中间件:若当前用户已被封禁(disable=1),则拒绝请求并返回封禁原因
|
||||||
|
type UserDisableCheckMiddleware struct {
|
||||||
|
Config config.Config
|
||||||
|
UserModel model.UserModel
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewUserDisableCheckMiddleware 创建封禁检查中间件
|
||||||
|
func NewUserDisableCheckMiddleware(c config.Config, userModel model.UserModel) *UserDisableCheckMiddleware {
|
||||||
|
return &UserDisableCheckMiddleware{
|
||||||
|
Config: c,
|
||||||
|
UserModel: userModel,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle 仅对携带用户 JWT 的请求做封禁校验;无 token 或 admin token 直接放行
|
||||||
|
func (m *UserDisableCheckMiddleware) Handle(next http.HandlerFunc) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
authHeader := r.Header.Get("Authorization")
|
||||||
|
if authHeader == "" {
|
||||||
|
next(w, r)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
token := strings.TrimPrefix(authHeader, "Bearer ")
|
||||||
|
if token == authHeader {
|
||||||
|
next(w, r)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 仅使用用户端 JWT 密钥解析;管理员 token 会解析失败,直接放行由后续中间件处理
|
||||||
|
claims, err := jwtx.ParseJwtToken(token, m.Config.JwtAuth.AccessSecret)
|
||||||
|
if err != nil {
|
||||||
|
next(w, r)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查封禁状态不走缓存,封禁后立即生效,已登录用户下次请求即被拒绝
|
||||||
|
disable, err := m.UserModel.FindDisableByUserId(r.Context(), claims.UserId)
|
||||||
|
if err != nil {
|
||||||
|
next(w, r)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// disable: 0 可用,1 封禁
|
||||||
|
if disable == 1 {
|
||||||
|
errcode := xerr.USER_DISABLED
|
||||||
|
errmsg := xerr.MapErrMsg(errcode)
|
||||||
|
httpx.WriteJson(w, http.StatusForbidden, result.Error(errcode, errmsg))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
next(w, r)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,12 +2,12 @@ package service
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"database/sql"
|
||||||
"tydata-server/app/main/api/internal/config"
|
"tydata-server/app/main/api/internal/config"
|
||||||
"tydata-server/app/main/model"
|
"tydata-server/app/main/model"
|
||||||
"tydata-server/common/ctxdata"
|
"tydata-server/common/ctxdata"
|
||||||
jwtx "tydata-server/common/jwt"
|
jwtx "tydata-server/common/jwt"
|
||||||
"tydata-server/common/xerr"
|
"tydata-server/common/xerr"
|
||||||
"database/sql"
|
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
@@ -78,6 +78,17 @@ func (s *UserService) RegisterUUIDUser(ctx context.Context) (int64, error) {
|
|||||||
|
|
||||||
// generalUserToken 生成用户token
|
// generalUserToken 生成用户token
|
||||||
func (s *UserService) GeneralUserToken(ctx context.Context, userID int64, userType int64) (string, error) {
|
func (s *UserService) GeneralUserToken(ctx context.Context, userID int64, userType int64) (string, error) {
|
||||||
|
// 正式用户签发 token 前校验是否被封禁,封禁用户不允许登录
|
||||||
|
if userType == model.UserTypeNormal {
|
||||||
|
user, err := s.userModel.FindOne(ctx, userID)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
if user != nil && user.Disable == 1 {
|
||||||
|
return "", errors.Wrapf(xerr.NewErrCode(xerr.USER_DISABLED), "用户已被封禁")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
platform, err := ctxdata.GetPlatformFromCtx(ctx)
|
platform, err := ctxdata.GetPlatformFromCtx(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
|||||||
@@ -568,6 +568,7 @@ type AdminGetPlatformUserDetailResp struct {
|
|||||||
Nickname string `json:"nickname"` // 昵称
|
Nickname string `json:"nickname"` // 昵称
|
||||||
Info string `json:"info"` // 备注信息
|
Info string `json:"info"` // 备注信息
|
||||||
Inside int64 `json:"inside"` // 是否内部用户 1-是 0-否
|
Inside int64 `json:"inside"` // 是否内部用户 1-是 0-否
|
||||||
|
Disable int64 `json:"disable"` // 是否封禁 0-可用 1-封禁
|
||||||
CreateTime string `json:"create_time"` // 创建时间
|
CreateTime string `json:"create_time"` // 创建时间
|
||||||
UpdateTime string `json:"update_time"` // 更新时间
|
UpdateTime string `json:"update_time"` // 更新时间
|
||||||
}
|
}
|
||||||
@@ -949,6 +950,7 @@ type AdminUpdatePlatformUserReq struct {
|
|||||||
Nickname *string `json:"nickname,optional"` // 昵称
|
Nickname *string `json:"nickname,optional"` // 昵称
|
||||||
Info *string `json:"info,optional"` // 备注信息
|
Info *string `json:"info,optional"` // 备注信息
|
||||||
Inside *int64 `json:"inside,optional"` // 是否内部用户 1-是 0-否
|
Inside *int64 `json:"inside,optional"` // 是否内部用户 1-是 0-否
|
||||||
|
Disable *int64 `json:"disable,optional"` // 是否封禁 0-可用 1-封禁
|
||||||
}
|
}
|
||||||
|
|
||||||
type AdminUpdatePlatformUserResp struct {
|
type AdminUpdatePlatformUserResp struct {
|
||||||
@@ -1854,6 +1856,7 @@ type PlatformUserListItem struct {
|
|||||||
Nickname string `json:"nickname"` // 昵称
|
Nickname string `json:"nickname"` // 昵称
|
||||||
Info string `json:"info"` // 备注信息
|
Info string `json:"info"` // 备注信息
|
||||||
Inside int64 `json:"inside"` // 是否内部用户 1-是 0-否
|
Inside int64 `json:"inside"` // 是否内部用户 1-是 0-否
|
||||||
|
Disable int64 `json:"disable"` // 是否封禁 0-可用 1-封禁
|
||||||
CreateTime string `json:"create_time"` // 创建时间
|
CreateTime string `json:"create_time"` // 创建时间
|
||||||
UpdateTime string `json:"update_time"` // 更新时间
|
UpdateTime string `json:"update_time"` // 更新时间
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ func main() {
|
|||||||
|
|
||||||
server := rest.MustNewServer(c.RestConf)
|
server := rest.MustNewServer(c.RestConf)
|
||||||
server.Use(middleware.GlobalSourceInterceptor)
|
server.Use(middleware.GlobalSourceInterceptor)
|
||||||
|
server.Use(middleware.NewUserDisableCheckMiddleware(svcContext.Config, svcContext.UserModel).Handle)
|
||||||
defer server.Stop()
|
defer server.Stop()
|
||||||
|
|
||||||
handler.RegisterHandlers(server, svcContext)
|
handler.RegisterHandlers(server, svcContext)
|
||||||
|
|||||||
@@ -1,8 +1,14 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/stores/cache"
|
"github.com/zeromicro/go-zero/core/stores/cache"
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/sqlc"
|
||||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||||
|
|
||||||
|
"tydata-server/common/globalkey"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ UserModel = (*customUserModel)(nil)
|
var _ UserModel = (*customUserModel)(nil)
|
||||||
@@ -12,6 +18,8 @@ type (
|
|||||||
// and implement the added methods in customUserModel.
|
// and implement the added methods in customUserModel.
|
||||||
UserModel interface {
|
UserModel interface {
|
||||||
userModel
|
userModel
|
||||||
|
// FindDisableByUserId 查用户封禁状态(不走缓存,封禁中间件用)
|
||||||
|
FindDisableByUserId(ctx context.Context, id int64) (int64, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
customUserModel struct {
|
customUserModel struct {
|
||||||
@@ -19,6 +27,20 @@ type (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// FindDisableByUserId 查用户 disable 字段,不走缓存,确保封禁后立即生效
|
||||||
|
func (m *customUserModel) FindDisableByUserId(ctx context.Context, id int64) (int64, error) {
|
||||||
|
var disable int64
|
||||||
|
query := fmt.Sprintf("SELECT `disable` FROM %s WHERE `id` = ? and del_state = ? limit 1", m.table)
|
||||||
|
err := m.QueryRowNoCacheCtx(ctx, &disable, query, id, globalkey.DelStateNo)
|
||||||
|
if err != nil {
|
||||||
|
if err == sqlc.ErrNotFound {
|
||||||
|
return 0, ErrNotFound
|
||||||
|
}
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return disable, nil
|
||||||
|
}
|
||||||
|
|
||||||
// NewUserModel returns a model for the database table.
|
// NewUserModel returns a model for the database table.
|
||||||
func NewUserModel(conn sqlx.SqlConn, c cache.CacheConf) UserModel {
|
func NewUserModel(conn sqlx.SqlConn, c cache.CacheConf) UserModel {
|
||||||
return &customUserModel{
|
return &customUserModel{
|
||||||
|
|||||||
@@ -10,8 +10,6 @@ import (
|
|||||||
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"tydata-server/common/globalkey"
|
|
||||||
|
|
||||||
"github.com/Masterminds/squirrel"
|
"github.com/Masterminds/squirrel"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/zeromicro/go-zero/core/stores/builder"
|
"github.com/zeromicro/go-zero/core/stores/builder"
|
||||||
@@ -19,6 +17,7 @@ import (
|
|||||||
"github.com/zeromicro/go-zero/core/stores/sqlc"
|
"github.com/zeromicro/go-zero/core/stores/sqlc"
|
||||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||||
"github.com/zeromicro/go-zero/core/stringx"
|
"github.com/zeromicro/go-zero/core/stringx"
|
||||||
|
"tydata-server/common/globalkey"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -27,8 +26,8 @@ var (
|
|||||||
userRowsExpectAutoSet = strings.Join(stringx.Remove(userFieldNames, "`id`", "`create_time`", "`update_time`"), ",")
|
userRowsExpectAutoSet = strings.Join(stringx.Remove(userFieldNames, "`id`", "`create_time`", "`update_time`"), ",")
|
||||||
userRowsWithPlaceHolder = strings.Join(stringx.Remove(userFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?"
|
userRowsWithPlaceHolder = strings.Join(stringx.Remove(userFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?"
|
||||||
|
|
||||||
cacheHmUserIdPrefix = "cache:tydata:user:id:"
|
cacheZncUserIdPrefix = "cache:znc:user:id:"
|
||||||
cacheHmUserMobilePrefix = "cache:tydata:user:mobile:"
|
cacheZncUserMobilePrefix = "cache:znc:user:mobile:"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
@@ -68,6 +67,7 @@ type (
|
|||||||
Nickname sql.NullString `db:"nickname"`
|
Nickname sql.NullString `db:"nickname"`
|
||||||
Info string `db:"info"`
|
Info string `db:"info"`
|
||||||
Inside int64 `db:"inside"`
|
Inside int64 `db:"inside"`
|
||||||
|
Disable int64 `db:"disable"` // 0可用 1禁用
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -80,21 +80,21 @@ func newUserModel(conn sqlx.SqlConn, c cache.CacheConf) *defaultUserModel {
|
|||||||
|
|
||||||
func (m *defaultUserModel) Insert(ctx context.Context, session sqlx.Session, data *User) (sql.Result, error) {
|
func (m *defaultUserModel) Insert(ctx context.Context, session sqlx.Session, data *User) (sql.Result, error) {
|
||||||
data.DelState = globalkey.DelStateNo
|
data.DelState = globalkey.DelStateNo
|
||||||
hmUserIdKey := fmt.Sprintf("%s%v", cacheHmUserIdPrefix, data.Id)
|
zncUserIdKey := fmt.Sprintf("%s%v", cacheZncUserIdPrefix, data.Id)
|
||||||
hmUserMobileKey := fmt.Sprintf("%s%v", cacheHmUserMobilePrefix, data.Mobile)
|
zncUserMobileKey := fmt.Sprintf("%s%v", cacheZncUserMobilePrefix, data.Mobile)
|
||||||
return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||||
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?)", m.table, userRowsExpectAutoSet)
|
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, userRowsExpectAutoSet)
|
||||||
if session != nil {
|
if session != nil {
|
||||||
return session.ExecCtx(ctx, query, data.DeleteTime, data.DelState, data.Version, data.Mobile, data.Password, data.Nickname, data.Info, data.Inside)
|
return session.ExecCtx(ctx, query, data.DeleteTime, data.DelState, data.Version, data.Mobile, data.Password, data.Nickname, data.Info, data.Inside, data.Disable)
|
||||||
}
|
}
|
||||||
return conn.ExecCtx(ctx, query, data.DeleteTime, data.DelState, data.Version, data.Mobile, data.Password, data.Nickname, data.Info, data.Inside)
|
return conn.ExecCtx(ctx, query, data.DeleteTime, data.DelState, data.Version, data.Mobile, data.Password, data.Nickname, data.Info, data.Inside, data.Disable)
|
||||||
}, hmUserIdKey, hmUserMobileKey)
|
}, zncUserIdKey, zncUserMobileKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *defaultUserModel) FindOne(ctx context.Context, id int64) (*User, error) {
|
func (m *defaultUserModel) FindOne(ctx context.Context, id int64) (*User, error) {
|
||||||
hmUserIdKey := fmt.Sprintf("%s%v", cacheHmUserIdPrefix, id)
|
zncUserIdKey := fmt.Sprintf("%s%v", cacheZncUserIdPrefix, id)
|
||||||
var resp User
|
var resp User
|
||||||
err := m.QueryRowCtx(ctx, &resp, hmUserIdKey, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) error {
|
err := m.QueryRowCtx(ctx, &resp, zncUserIdKey, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) error {
|
||||||
query := fmt.Sprintf("select %s from %s where `id` = ? and del_state = ? limit 1", userRows, m.table)
|
query := fmt.Sprintf("select %s from %s where `id` = ? and del_state = ? limit 1", userRows, m.table)
|
||||||
return conn.QueryRowCtx(ctx, v, query, id, globalkey.DelStateNo)
|
return conn.QueryRowCtx(ctx, v, query, id, globalkey.DelStateNo)
|
||||||
})
|
})
|
||||||
@@ -109,9 +109,9 @@ func (m *defaultUserModel) FindOne(ctx context.Context, id int64) (*User, error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *defaultUserModel) FindOneByMobile(ctx context.Context, mobile sql.NullString) (*User, error) {
|
func (m *defaultUserModel) FindOneByMobile(ctx context.Context, mobile sql.NullString) (*User, error) {
|
||||||
hmUserMobileKey := fmt.Sprintf("%s%v", cacheHmUserMobilePrefix, mobile)
|
zncUserMobileKey := fmt.Sprintf("%s%v", cacheZncUserMobilePrefix, mobile)
|
||||||
var resp User
|
var resp User
|
||||||
err := m.QueryRowIndexCtx(ctx, &resp, hmUserMobileKey, m.formatPrimary, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) (i interface{}, e error) {
|
err := m.QueryRowIndexCtx(ctx, &resp, zncUserMobileKey, m.formatPrimary, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) (i interface{}, e error) {
|
||||||
query := fmt.Sprintf("select %s from %s where `mobile` = ? and del_state = ? limit 1", userRows, m.table)
|
query := fmt.Sprintf("select %s from %s where `mobile` = ? and del_state = ? limit 1", userRows, m.table)
|
||||||
if err := conn.QueryRowCtx(ctx, &resp, query, mobile, globalkey.DelStateNo); err != nil {
|
if err := conn.QueryRowCtx(ctx, &resp, query, mobile, globalkey.DelStateNo); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -133,15 +133,15 @@ func (m *defaultUserModel) Update(ctx context.Context, session sqlx.Session, new
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
hmUserIdKey := fmt.Sprintf("%s%v", cacheHmUserIdPrefix, data.Id)
|
zncUserIdKey := fmt.Sprintf("%s%v", cacheZncUserIdPrefix, data.Id)
|
||||||
hmUserMobileKey := fmt.Sprintf("%s%v", cacheHmUserMobilePrefix, data.Mobile)
|
zncUserMobileKey := fmt.Sprintf("%s%v", cacheZncUserMobilePrefix, data.Mobile)
|
||||||
return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||||
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, userRowsWithPlaceHolder)
|
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, userRowsWithPlaceHolder)
|
||||||
if session != nil {
|
if session != nil {
|
||||||
return session.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.Mobile, newData.Password, newData.Nickname, newData.Info, newData.Inside, newData.Id)
|
return session.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.Mobile, newData.Password, newData.Nickname, newData.Info, newData.Inside, newData.Disable, newData.Id)
|
||||||
}
|
}
|
||||||
return conn.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.Mobile, newData.Password, newData.Nickname, newData.Info, newData.Inside, newData.Id)
|
return conn.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.Mobile, newData.Password, newData.Nickname, newData.Info, newData.Inside, newData.Disable, newData.Id)
|
||||||
}, hmUserIdKey, hmUserMobileKey)
|
}, zncUserIdKey, zncUserMobileKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *defaultUserModel) UpdateWithVersion(ctx context.Context, session sqlx.Session, newData *User) error {
|
func (m *defaultUserModel) UpdateWithVersion(ctx context.Context, session sqlx.Session, newData *User) error {
|
||||||
@@ -156,15 +156,15 @@ func (m *defaultUserModel) UpdateWithVersion(ctx context.Context, session sqlx.S
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
hmUserIdKey := fmt.Sprintf("%s%v", cacheHmUserIdPrefix, data.Id)
|
zncUserIdKey := fmt.Sprintf("%s%v", cacheZncUserIdPrefix, data.Id)
|
||||||
hmUserMobileKey := fmt.Sprintf("%s%v", cacheHmUserMobilePrefix, data.Mobile)
|
zncUserMobileKey := fmt.Sprintf("%s%v", cacheZncUserMobilePrefix, data.Mobile)
|
||||||
sqlResult, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
sqlResult, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||||
query := fmt.Sprintf("update %s set %s where `id` = ? and version = ? ", m.table, userRowsWithPlaceHolder)
|
query := fmt.Sprintf("update %s set %s where `id` = ? and version = ? ", m.table, userRowsWithPlaceHolder)
|
||||||
if session != nil {
|
if session != nil {
|
||||||
return session.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.Mobile, newData.Password, newData.Nickname, newData.Info, newData.Inside, newData.Id, oldVersion)
|
return session.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.Mobile, newData.Password, newData.Nickname, newData.Info, newData.Inside, newData.Disable, newData.Id, oldVersion)
|
||||||
}
|
}
|
||||||
return conn.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.Mobile, newData.Password, newData.Nickname, newData.Info, newData.Inside, newData.Id, oldVersion)
|
return conn.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.Mobile, newData.Password, newData.Nickname, newData.Info, newData.Inside, newData.Disable, newData.Id, oldVersion)
|
||||||
}, hmUserIdKey, hmUserMobileKey)
|
}, zncUserIdKey, zncUserMobileKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -387,19 +387,19 @@ func (m *defaultUserModel) Delete(ctx context.Context, session sqlx.Session, id
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
hmUserIdKey := fmt.Sprintf("%s%v", cacheHmUserIdPrefix, id)
|
zncUserIdKey := fmt.Sprintf("%s%v", cacheZncUserIdPrefix, id)
|
||||||
hmUserMobileKey := fmt.Sprintf("%s%v", cacheHmUserMobilePrefix, data.Mobile)
|
zncUserMobileKey := fmt.Sprintf("%s%v", cacheZncUserMobilePrefix, data.Mobile)
|
||||||
_, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
_, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||||
query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
|
query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
|
||||||
if session != nil {
|
if session != nil {
|
||||||
return session.ExecCtx(ctx, query, id)
|
return session.ExecCtx(ctx, query, id)
|
||||||
}
|
}
|
||||||
return conn.ExecCtx(ctx, query, id)
|
return conn.ExecCtx(ctx, query, id)
|
||||||
}, hmUserIdKey, hmUserMobileKey)
|
}, zncUserIdKey, zncUserMobileKey)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
func (m *defaultUserModel) formatPrimary(primary interface{}) string {
|
func (m *defaultUserModel) formatPrimary(primary interface{}) string {
|
||||||
return fmt.Sprintf("%s%v", cacheHmUserIdPrefix, primary)
|
return fmt.Sprintf("%s%v", cacheZncUserIdPrefix, primary)
|
||||||
}
|
}
|
||||||
func (m *defaultUserModel) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary interface{}) error {
|
func (m *defaultUserModel) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary interface{}) error {
|
||||||
query := fmt.Sprintf("select %s from %s where `id` = ? and del_state = ? limit 1", userRows, m.table)
|
query := fmt.Sprintf("select %s from %s where `id` = ? and del_state = ? limit 1", userRows, m.table)
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ const PARAM_VERIFICATION_ERROR uint32 = 100007
|
|||||||
const CUSTOM_ERROR uint32 = 100008
|
const CUSTOM_ERROR uint32 = 100008
|
||||||
const USER_NOT_FOUND uint32 = 100009
|
const USER_NOT_FOUND uint32 = 100009
|
||||||
const USER_NEED_BIND_MOBILE uint32 = 100010
|
const USER_NEED_BIND_MOBILE uint32 = 100010
|
||||||
|
const USER_DISABLED uint32 = 100011 // 用户已被封禁
|
||||||
|
|
||||||
const LOGIN_FAILED uint32 = 200001
|
const LOGIN_FAILED uint32 = 200001
|
||||||
const LOGIC_QUERY_WAIT uint32 = 200002
|
const LOGIC_QUERY_WAIT uint32 = 200002
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ func init() {
|
|||||||
message[TOKEN_GENERATE_ERROR] = "生成token失败"
|
message[TOKEN_GENERATE_ERROR] = "生成token失败"
|
||||||
message[DB_ERROR] = "系统维护升级中,请稍后再试"
|
message[DB_ERROR] = "系统维护升级中,请稍后再试"
|
||||||
message[DB_UPDATE_AFFECTED_ZERO_ERROR] = "更新数据影响行数为0"
|
message[DB_UPDATE_AFFECTED_ZERO_ERROR] = "更新数据影响行数为0"
|
||||||
|
message[USER_DISABLED] = "用户已被封禁"
|
||||||
}
|
}
|
||||||
|
|
||||||
func MapErrMsg(errcode uint32) string {
|
func MapErrMsg(errcode uint32) string {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# 设置输出编码为UTF-8
|
# 设置输出编码为UTF-8
|
||||||
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
||||||
# 数据库连接信息 - 修改了URL格式
|
# 数据库连接信息 - 修改了URL格式
|
||||||
$DB_URL = "tydata:5vg67b3UNHu8@(127.0.0.1:21001)/tydata"
|
$DB_URL = "znc:5vg67b3UNHu823@tcp(localhost:21101)/znc"
|
||||||
$OUTPUT_DIR = "./model"
|
$OUTPUT_DIR = "./model"
|
||||||
$TEMPLATE_DIR = "../template"
|
$TEMPLATE_DIR = "../template"
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@ $tables = @(
|
|||||||
# "agent_audit",
|
# "agent_audit",
|
||||||
# "agent_closure",
|
# "agent_closure",
|
||||||
# "agent_commission"
|
# "agent_commission"
|
||||||
"agent_wallet_transaction"
|
# "agent_wallet_transaction"
|
||||||
# "agent_commission_deduction"
|
# "agent_commission_deduction"
|
||||||
# "agent_link",
|
# "agent_link",
|
||||||
# "agent_membership_config",
|
# "agent_membership_config",
|
||||||
@@ -37,7 +37,7 @@ $tables = @(
|
|||||||
# "query_cleanup_log"
|
# "query_cleanup_log"
|
||||||
# "query_cleanup_detail"
|
# "query_cleanup_detail"
|
||||||
# "query_cleanup_config"
|
# "query_cleanup_config"
|
||||||
# "user"
|
"user"
|
||||||
# "user_auth"
|
# "user_auth"
|
||||||
# "user_temp"
|
# "user_temp"
|
||||||
# "example"
|
# "example"
|
||||||
@@ -60,5 +60,5 @@ $tables = @(
|
|||||||
|
|
||||||
# 为每个表生成模型
|
# 为每个表生成模型
|
||||||
foreach ($table in $tables) {
|
foreach ($table in $tables) {
|
||||||
goctl model mysql datasource -url="tydata:5vg67b3UNHu8@tcp(127.0.0.1:21001)/tydata" -table="$table" -dir="./model" --home="../template" -cache=true --style=goZero
|
goctl model mysql datasource -url="znc:5vg67b3UNHu823@tcp(localhost:21101)/znc" -table="$table" -dir="./model" --home="../template" -cache=true --style=goZero
|
||||||
}
|
}
|
||||||
|
|||||||
2
deploy/sql/user_add_disable.sql
Normal file
2
deploy/sql/user_add_disable.sql
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
-- 为用户表添加 disable 字段:0 可用,1 禁用,默认 0
|
||||||
|
ALTER TABLE `user` ADD COLUMN `disable` tinyint NOT NULL DEFAULT 0 COMMENT '0可用 1禁用' AFTER `inside`;
|
||||||
@@ -80,27 +80,6 @@ services:
|
|||||||
- mysql
|
- mysql
|
||||||
networks:
|
networks:
|
||||||
- znc_net
|
- znc_net
|
||||||
|
|
||||||
main:
|
|
||||||
container_name: znc_main
|
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
dockerfile: app/main/api/Dockerfile
|
|
||||||
ports:
|
|
||||||
- "21105:8888"
|
|
||||||
volumes:
|
|
||||||
- ./data/authorization_docs:/app/data/authorization_docs:rw
|
|
||||||
environment:
|
|
||||||
- TZ=Asia/Shanghai
|
|
||||||
- ENV=development
|
|
||||||
command: sh -c "echo '等待 Redis 启动...' && until nc -z znc_redis 6379; do echo '等待 Redis 端口开放...'; sleep 1; done && echo 'Redis 端口已开放,等待服务完全就绪...' && sleep 10 && echo '启动应用' && ./main"
|
|
||||||
depends_on:
|
|
||||||
- mysql
|
|
||||||
- redis
|
|
||||||
networks:
|
|
||||||
- znc_net
|
|
||||||
restart: always
|
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
znc_net:
|
znc_net:
|
||||||
driver: bridge
|
driver: bridge
|
||||||
|
|||||||
Reference in New Issue
Block a user