🎨 updated error handling logic

This commit is contained in:
landaiqing
2024-11-18 01:12:50 +08:00
parent 78a162a19a
commit 35d2da35b2
48 changed files with 395 additions and 170 deletions

89
.idea/GOHCache.xml generated
View File

@@ -1318,7 +1318,7 @@
<entry key="file://$PROJECT_DIR$/app/core/api/common/response/response.go">
<value>
<ScannedPath>
<option name="lastModified" value="1731680080098" />
<option name="lastModified" value="1731862782491" />
</ScannedPath>
</value>
</entry>
@@ -1376,6 +1376,13 @@
</ScannedPath>
</value>
</entry>
<entry key="file://$PROJECT_DIR$/app/core/api/common/utils/xss_filter.go">
<value>
<ScannedPath>
<option name="lastModified" value="1727966485398" />
</ScannedPath>
</value>
</entry>
<entry key="file://$PROJECT_DIR$/app/core/api/core.go">
<value>
<ScannedPath>
@@ -1405,126 +1412,126 @@
<entry key="file://$PROJECT_DIR$/app/core/api/internal/handler/captcha/generate_rotate_captcha_handler.go">
<value>
<ScannedPath>
<option name="lastModified" value="1731692824890" />
<option name="lastModified" value="1731862416182" />
</ScannedPath>
</value>
</entry>
<entry key="file://$PROJECT_DIR$/app/core/api/internal/handler/captcha/generate_slide_basic_captcha_handler.go">
<value>
<ScannedPath>
<option name="lastModified" value="1731692827046" />
<option name="lastModified" value="1731862395489" />
</ScannedPath>
</value>
</entry>
<entry key="file://$PROJECT_DIR$/app/core/api/internal/handler/client/generate_client_id_handler.go">
<value>
<ScannedPath>
<option name="lastModified" value="1731692827058" />
<option name="lastModified" value="1731862584777" />
</ScannedPath>
</value>
</entry>
<entry key="file://$PROJECT_DIR$/app/core/api/internal/handler/comment/dislike_comment_handler.go">
<value>
<ScannedPath>
<option name="lastModified" value="1731724788684" />
<option name="lastModified" value="1731862584728" />
</ScannedPath>
</value>
</entry>
<entry key="file://$PROJECT_DIR$/app/core/api/internal/handler/comment/get_comment_list_handler.go">
<value>
<ScannedPath>
<option name="lastModified" value="1731693155862" />
<option name="lastModified" value="1731862645855" />
</ScannedPath>
</value>
</entry>
<entry key="file://$PROJECT_DIR$/app/core/api/internal/handler/comment/get_reply_list_handler.go">
<value>
<ScannedPath>
<option name="lastModified" value="1731692827103" />
<option name="lastModified" value="1731862645867" />
</ScannedPath>
</value>
</entry>
<entry key="file://$PROJECT_DIR$/app/core/api/internal/handler/comment/like_comment_handler.go">
<value>
<ScannedPath>
<option name="lastModified" value="1731692827085" />
<option name="lastModified" value="1731862645899" />
</ScannedPath>
</value>
</entry>
<entry key="file://$PROJECT_DIR$/app/core/api/internal/handler/comment/submit_comment_handler.go">
<value>
<ScannedPath>
<option name="lastModified" value="1731692827039" />
<option name="lastModified" value="1731862645892" />
</ScannedPath>
</value>
</entry>
<entry key="file://$PROJECT_DIR$/app/core/api/internal/handler/comment/submit_reply_comment_handler.go">
<value>
<ScannedPath>
<option name="lastModified" value="1731692827072" />
<option name="lastModified" value="1731862645872" />
</ScannedPath>
</value>
</entry>
<entry key="file://$PROJECT_DIR$/app/core/api/internal/handler/comment/submit_reply_reply_handler.go">
<value>
<ScannedPath>
<option name="lastModified" value="1731692827076" />
<option name="lastModified" value="1731862645896" />
</ScannedPath>
</value>
</entry>
<entry key="file://$PROJECT_DIR$/app/core/api/internal/handler/oauth/get_gitee_oauth_url_handler.go">
<value>
<ScannedPath>
<option name="lastModified" value="1731692827069" />
<option name="lastModified" value="1731862645886" />
</ScannedPath>
</value>
</entry>
<entry key="file://$PROJECT_DIR$/app/core/api/internal/handler/oauth/get_github_oauth_url_handler.go">
<value>
<ScannedPath>
<option name="lastModified" value="1731692827079" />
<option name="lastModified" value="1731862645860" />
</ScannedPath>
</value>
</entry>
<entry key="file://$PROJECT_DIR$/app/core/api/internal/handler/oauth/get_qq_oauth_url_handler.go">
<value>
<ScannedPath>
<option name="lastModified" value="1731692827062" />
<option name="lastModified" value="1731862645904" />
</ScannedPath>
</value>
</entry>
<entry key="file://$PROJECT_DIR$/app/core/api/internal/handler/oauth/get_wechat_qrcode_handler.go">
<value>
<ScannedPath>
<option name="lastModified" value="1731692827088" />
<option name="lastModified" value="1731862645877" />
</ScannedPath>
</value>
</entry>
<entry key="file://$PROJECT_DIR$/app/core/api/internal/handler/oauth/gitee_callback_handler.go">
<value>
<ScannedPath>
<option name="lastModified" value="1731692827066" />
<option name="lastModified" value="1731862645889" />
</ScannedPath>
</value>
</entry>
<entry key="file://$PROJECT_DIR$/app/core/api/internal/handler/oauth/github_callback_handler.go">
<value>
<ScannedPath>
<option name="lastModified" value="1731692827106" />
<option name="lastModified" value="1731862645882" />
</ScannedPath>
</value>
</entry>
<entry key="file://$PROJECT_DIR$/app/core/api/internal/handler/oauth/qq_callback_handler.go">
<value>
<ScannedPath>
<option name="lastModified" value="1731692827035" />
<option name="lastModified" value="1731862645908" />
</ScannedPath>
</value>
</entry>
<entry key="file://$PROJECT_DIR$/app/core/api/internal/handler/oauth/wechat_callback_handler.go">
<value>
<ScannedPath>
<option name="lastModified" value="1731692827100" />
<option name="lastModified" value="1731862717048" />
</ScannedPath>
</value>
</entry>
@@ -1538,56 +1545,56 @@
<entry key="file://$PROJECT_DIR$/app/core/api/internal/handler/sms/send_sms_by_aliyun_handler.go">
<value>
<ScannedPath>
<option name="lastModified" value="1731692827092" />
<option name="lastModified" value="1731862584763" />
</ScannedPath>
</value>
</entry>
<entry key="file://$PROJECT_DIR$/app/core/api/internal/handler/sms/send_sms_by_smsbao_handler.go">
<value>
<ScannedPath>
<option name="lastModified" value="1731692827023" />
<option name="lastModified" value="1731862584790" />
</ScannedPath>
</value>
</entry>
<entry key="file://$PROJECT_DIR$/app/core/api/internal/handler/sms/send_sms_by_test_handler.go">
<value>
<ScannedPath>
<option name="lastModified" value="1731692827051" />
<option name="lastModified" value="1731862584754" />
</ScannedPath>
</value>
</entry>
<entry key="file://$PROJECT_DIR$/app/core/api/internal/handler/user/account_login_handler.go">
<value>
<ScannedPath>
<option name="lastModified" value="1731692827042" />
<option name="lastModified" value="1731862584722" />
</ScannedPath>
</value>
</entry>
<entry key="file://$PROJECT_DIR$/app/core/api/internal/handler/user/get_user_device_handler.go">
<value>
<ScannedPath>
<option name="lastModified" value="1731692827027" />
<option name="lastModified" value="1731862806051" />
</ScannedPath>
</value>
</entry>
<entry key="file://$PROJECT_DIR$/app/core/api/internal/handler/user/phone_login_handler.go">
<value>
<ScannedPath>
<option name="lastModified" value="1731692827096" />
<option name="lastModified" value="1731862584794" />
</ScannedPath>
</value>
</entry>
<entry key="file://$PROJECT_DIR$/app/core/api/internal/handler/user/refresh_token_handler.go">
<value>
<ScannedPath>
<option name="lastModified" value="1731692827055" />
<option name="lastModified" value="1731862584798" />
</ScannedPath>
</value>
</entry>
<entry key="file://$PROJECT_DIR$/app/core/api/internal/handler/user/reset_password_handler.go">
<value>
<ScannedPath>
<option name="lastModified" value="1731692827082" />
<option name="lastModified" value="1731862584716" />
</ScannedPath>
</value>
</entry>
@@ -1608,7 +1615,7 @@
<entry key="file://$PROJECT_DIR$/app/core/api/internal/logic/captcha/generate_rotate_captcha_logic.go">
<value>
<ScannedPath>
<option name="lastModified" value="1731600470127" />
<option name="lastModified" value="1731861580653" />
<option name="schema">
<list>
<option value="GenerateRotateCaptchaLogic" />
@@ -1620,7 +1627,7 @@
<entry key="file://$PROJECT_DIR$/app/core/api/internal/logic/captcha/generate_slide_basic_captcha_logic.go">
<value>
<ScannedPath>
<option name="lastModified" value="1731600552304" />
<option name="lastModified" value="1731861571471" />
<option name="schema">
<list>
<option value="GenerateSlideBasicCaptchaLogic" />
@@ -1632,7 +1639,7 @@
<entry key="file://$PROJECT_DIR$/app/core/api/internal/logic/client/generate_client_id_logic.go">
<value>
<ScannedPath>
<option name="lastModified" value="1731692064183" />
<option name="lastModified" value="1731861824112" />
<option name="schema">
<list>
<option value="GenerateClientIdLogic" />
@@ -1692,7 +1699,7 @@
<entry key="file://$PROJECT_DIR$/app/core/api/internal/logic/comment/submit_comment_logic.go">
<value>
<ScannedPath>
<option name="lastModified" value="1731649071026" />
<option name="lastModified" value="1731861524784" />
<option name="schema">
<list>
<option value="SubmitCommentLogic" />
@@ -1764,7 +1771,7 @@
<entry key="file://$PROJECT_DIR$/app/core/api/internal/logic/oauth/get_wechat_qrcode_logic.go">
<value>
<ScannedPath>
<option name="lastModified" value="1731581532235" />
<option name="lastModified" value="1731863022429" />
<option name="schema">
<list>
<option value="GetWechatQrcodeLogic" />
@@ -1830,7 +1837,7 @@
<entry key="file://$PROJECT_DIR$/app/core/api/internal/logic/sms/send_sms_by_aliyun_logic.go">
<value>
<ScannedPath>
<option name="lastModified" value="1731680177200" />
<option name="lastModified" value="1731863091323" />
<option name="schema">
<list>
<option value="SendSmsByAliyunLogic" />
@@ -1842,7 +1849,7 @@
<entry key="file://$PROJECT_DIR$/app/core/api/internal/logic/sms/send_sms_by_smsbao_logic.go">
<value>
<ScannedPath>
<option name="lastModified" value="1731680177896" />
<option name="lastModified" value="1731863341454" />
<option name="schema">
<list>
<option value="SendSmsBySmsbaoLogic" />
@@ -1854,7 +1861,7 @@
<entry key="file://$PROJECT_DIR$/app/core/api/internal/logic/sms/send_sms_by_test_logic.go">
<value>
<ScannedPath>
<option name="lastModified" value="1731680225279" />
<option name="lastModified" value="1731863341469" />
<option name="schema">
<list>
<option value="SendSmsByTestLogic" />
@@ -1878,7 +1885,7 @@
<entry key="file://$PROJECT_DIR$/app/core/api/internal/logic/user/get_user_device_logic.go">
<value>
<ScannedPath>
<option name="lastModified" value="1731691399107" />
<option name="lastModified" value="1731863341465" />
<option name="schema">
<list>
<option value="GetUserDeviceLogic" />
@@ -1890,7 +1897,7 @@
<entry key="file://$PROJECT_DIR$/app/core/api/internal/logic/user/phone_login_logic.go">
<value>
<ScannedPath>
<option name="lastModified" value="1731691136669" />
<option name="lastModified" value="1731863341459" />
<option name="schema">
<list>
<option value="PhoneLoginLogic" />
@@ -1902,7 +1909,7 @@
<entry key="file://$PROJECT_DIR$/app/core/api/internal/logic/user/refresh_token_logic.go">
<value>
<ScannedPath>
<option name="lastModified" value="1731844290397" />
<option name="lastModified" value="1731863341022" />
<option name="schema">
<list>
<option value="RefreshTokenLogic" />
@@ -1914,7 +1921,7 @@
<entry key="file://$PROJECT_DIR$/app/core/api/internal/logic/user/reset_password_logic.go">
<value>
<ScannedPath>
<option name="lastModified" value="1731692064174" />
<option name="lastModified" value="1731863406383" />
<option name="schema">
<list>
<option value="ResetPasswordLogic" />
@@ -1976,7 +1983,7 @@
<entry key="file://$PROJECT_DIR$/app/core/api/internal/svc/service_context.go">
<value>
<ScannedPath>
<option name="lastModified" value="1731688482114" />
<option name="lastModified" value="1731845823841" />
<option name="schema">
<list>
<option value="ServiceContext" />
@@ -2770,7 +2777,7 @@
<entry key="file://$PROJECT_DIR$/app/core/api/repository/redis_session/init.go">
<value>
<ScannedPath>
<option name="lastModified" value="1731733975210" />
<option name="lastModified" value="1731845841399" />
</ScannedPath>
</value>
</entry>

120
app/core/api/Dockerfile Normal file
View File

@@ -0,0 +1,120 @@
# to build this docker image:
# docker build -f Dockerfile -t schisandra-cloud-album-server .
# docker build --build-arg OPENCV_VERSION="4.x" --build-arg OPENCV_FILE="https://github.com/opencv/opencv/archive/refs/heads/4.x.zip" --build-arg OPENCV_CONTRIB_FILE="https://github.com/opencv/opencv_contrib/archive/refs/heads/4.x.zip" -f Dockerfile -t schisandra-cloud-album-server .
FROM ubuntu:20.04 AS opencv-builder
LABEL maintainer="landaiqing <<landaiqing@126.com>>"
RUN sed -i 's|http://archive.ubuntu.com/ubuntu/|http://mirrors.aliyun.com/ubuntu/|g' /etc/apt/sources.list
ENV TZ=Europe/Madrid
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt-get update && apt-get install -y --no-install-recommends --fix-missing \
tzdata git build-essential cmake pkg-config wget unzip libgtk2.0-dev \
curl ca-certificates libcurl4-openssl-dev libssl-dev \
libavcodec-dev libavformat-dev libswscale-dev libtbb2 libtbb-dev \
libharfbuzz-dev libfreetype6-dev \
libjpeg-turbo8-dev libpng-dev libtiff-dev libdc1394-22-dev nasm && \
rm -rf /var/lib/apt/lists/*
ARG OPENCV_VERSION="4.10.0"
ENV OPENCV_VERSION=$OPENCV_VERSION
ARG OPENCV_FILE="https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip"
ENV OPENCV_FILE=$OPENCV_FILE
ARG OPENCV_CONTRIB_FILE="https://github.com/opencv/opencv_contrib/archive/${OPENCV_VERSION}.zip"
ENV OPENCV_CONTRIB_FILE=$OPENCV_CONTRIB_FILE
RUN curl -Lo opencv.zip ${OPENCV_FILE} && \
unzip -q opencv.zip && \
curl -Lo opencv_contrib.zip ${OPENCV_CONTRIB_FILE} && \
unzip -q opencv_contrib.zip && \
rm opencv.zip opencv_contrib.zip && \
cd opencv-${OPENCV_VERSION} && \
mkdir build && cd build && \
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D WITH_IPP=OFF \
-D WITH_OPENGL=OFF \
-D WITH_QT=OFF \
-D WITH_FREETYPE=ON \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-${OPENCV_VERSION}/modules \
-D OPENCV_ENABLE_NONFREE=ON \
-D WITH_JASPER=OFF \
-D WITH_TBB=ON \
-D BUILD_JPEG=ON \
-D WITH_SIMD=ON \
-D ENABLE_LIBJPEG_TURBO_SIMD=ON \
-D BUILD_DOCS=OFF \
-D BUILD_EXAMPLES=OFF \
-D BUILD_TESTS=OFF \
-D BUILD_PERF_TESTS=ON \
-D BUILD_opencv_java=NO \
-D BUILD_opencv_python=NO \
-D BUILD_opencv_python2=NO \
-D BUILD_opencv_python3=NO \
-D OPENCV_GENERATE_PKGCONFIG=ON .. && \
make -j $(nproc --all) && \
make preinstall && make install && ldconfig && \
cd / && rm -rf opencv*
FROM golang:1.23.1-alpine AS go-builder
RUN apk add --no-cache gcc musl-dev libgcc libstdc++ cmake
WORKDIR /app
COPY . .
ENV CGO_ENABLED=1
ENV CGO_CFLAGS="-I/usr/local/include/opencv4"
ENV CGO_LDFLAGS="-L/usr/local/lib -lopencv_core -lopencv_imgproc -lopencv_highgui"
ENV GOOS=linux
ENV GOARCH=amd64
ENV GOPROXY=https://goproxy.cn,direct
COPY --from=opencv-builder /usr/local/lib /usr/local/lib
COPY --from=opencv-builder /usr/local/include/opencv4 /usr/local/include/opencv4
RUN go mod download
RUN go build -o schisandra-cloud-album-server
FROM alpine:latest
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
RUN apk add --no-cache tzdata
ENV TZ=Asia/Shanghai
WORKDIR /app
COPY --from=go-builder /app/schisandra-cloud-album-server .
COPY --from=go-builder /app/config.yaml .
COPY --from=go-builder /app/resource ./resource
COPY --from=go-builder /app/config/rbac_model.conf ./config/rbac_model.conf
COPY --from=opencv-builder /usr/local/lib /usr/local/lib
COPY --from=opencv-builder /usr/local/include/opencv4 /usr/local/include/opencv4
EXPOSE 80
CMD ["./schisandra-cloud-album-server"]

View File

@@ -21,7 +21,6 @@ func Success() *types.Response {
return &types.Response{
Code: 200,
Message: "success",
Data: nil,
}
}
@@ -30,7 +29,6 @@ func SuccessWithMessage(message string) *types.Response {
return &types.Response{
Code: 200,
Message: message,
Data: nil,
}
}
@@ -39,7 +37,6 @@ func Error() *types.Response {
return &types.Response{
Code: 500,
Message: "error",
Data: nil,
}
}
@@ -48,7 +45,6 @@ func ErrorWithCode(code int64) *types.Response {
return &types.Response{
Code: code,
Message: "error",
Data: nil,
}
}
@@ -57,7 +53,6 @@ func ErrorWithCodeMessage(code int64, message string) *types.Response {
return &types.Response{
Code: code,
Message: message,
Data: nil,
}
}
@@ -66,7 +61,6 @@ func ErrorWithMessage(message string) *types.Response {
return &types.Response{
Code: 500,
Message: message,
Data: nil,
}
}
@@ -76,6 +70,5 @@ func ErrorWithI18n(ctx context.Context, msgId string) *types.Response {
return &types.Response{
Code: 500,
Message: message,
Data: nil,
}
}

View File

@@ -0,0 +1,11 @@
package utils
import "github.com/microcosm-cc/bluemonday"
// XssFilter Xss 过滤器
func XssFilter(str string) string {
p := bluemonday.NewPolicy()
p.AllowElements("br", "img")
p.AllowAttrs("style", "src", "alt", "width", "height", "loading").OnElements("img")
return p.Sanitize(str)
}

View File

@@ -6,6 +6,7 @@ import (
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/rest/httpx"
"schisandra-album-cloud-microservices/app/core/api/common/response"
"schisandra-album-cloud-microservices/app/core/api/internal/logic/captcha"
"schisandra-album-cloud-microservices/app/core/api/internal/svc"
)
@@ -16,7 +17,11 @@ func GenerateRotateCaptchaHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
resp, err := l.GenerateRotateCaptcha()
if err != nil {
logx.Error(err)
httpx.WriteJsonCtx(r.Context(), w, http.StatusInternalServerError, resp)
httpx.WriteJsonCtx(
r.Context(),
w,
http.StatusInternalServerError,
response.ErrorWithI18n(r.Context(), "system.error"))
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}

View File

@@ -6,6 +6,7 @@ import (
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/rest/httpx"
"schisandra-album-cloud-microservices/app/core/api/common/response"
"schisandra-album-cloud-microservices/app/core/api/internal/logic/captcha"
"schisandra-album-cloud-microservices/app/core/api/internal/svc"
)
@@ -16,7 +17,11 @@ func GenerateSlideBasicCaptchaHandler(svcCtx *svc.ServiceContext) http.HandlerFu
resp, err := l.GenerateSlideBasicCaptcha()
if err != nil {
logx.Error(err)
httpx.WriteJsonCtx(r.Context(), w, http.StatusInternalServerError, resp)
httpx.WriteJsonCtx(
r.Context(),
w,
http.StatusInternalServerError,
response.ErrorWithI18n(r.Context(), "system.error"))
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}

View File

@@ -6,6 +6,7 @@ import (
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/rest/httpx"
"schisandra-album-cloud-microservices/app/core/api/common/response"
"schisandra-album-cloud-microservices/app/core/api/common/utils"
"schisandra-album-cloud-microservices/app/core/api/internal/logic/client"
"schisandra-album-cloud-microservices/app/core/api/internal/svc"
@@ -18,7 +19,11 @@ func GenerateClientIdHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
resp, err := l.GenerateClientId(clientIP)
if err != nil {
logx.Error(err)
httpx.WriteJsonCtx(r.Context(), w, http.StatusInternalServerError, resp)
httpx.WriteJsonCtx(
r.Context(),
w,
http.StatusInternalServerError,
response.ErrorWithI18n(r.Context(), "system.error"))
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}

View File

@@ -6,6 +6,7 @@ import (
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/rest/httpx"
"schisandra-album-cloud-microservices/app/core/api/common/response"
"schisandra-album-cloud-microservices/app/core/api/internal/logic/comment"
"schisandra-album-cloud-microservices/app/core/api/internal/svc"
"schisandra-album-cloud-microservices/app/core/api/internal/types"
@@ -23,7 +24,11 @@ func DislikeCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
resp, err := l.DislikeComment(&req)
if err != nil {
logx.Error(err)
httpx.WriteJsonCtx(r.Context(), w, http.StatusInternalServerError, resp)
httpx.WriteJsonCtx(
r.Context(),
w,
http.StatusInternalServerError,
response.ErrorWithI18n(r.Context(), "system.error"))
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}

View File

@@ -6,6 +6,7 @@ import (
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/rest/httpx"
"schisandra-album-cloud-microservices/app/core/api/common/response"
"schisandra-album-cloud-microservices/app/core/api/internal/logic/comment"
"schisandra-album-cloud-microservices/app/core/api/internal/svc"
"schisandra-album-cloud-microservices/app/core/api/internal/types"
@@ -23,7 +24,11 @@ func GetCommentListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
resp, err := l.GetCommentList(&req)
if err != nil {
logx.Error(err)
httpx.WriteJsonCtx(r.Context(), w, http.StatusInternalServerError, resp)
httpx.WriteJsonCtx(
r.Context(),
w,
http.StatusInternalServerError,
response.ErrorWithI18n(r.Context(), "system.error"))
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}

View File

@@ -6,6 +6,7 @@ import (
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/rest/httpx"
"schisandra-album-cloud-microservices/app/core/api/common/response"
"schisandra-album-cloud-microservices/app/core/api/internal/logic/comment"
"schisandra-album-cloud-microservices/app/core/api/internal/svc"
"schisandra-album-cloud-microservices/app/core/api/internal/types"
@@ -23,7 +24,11 @@ func GetReplyListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
resp, err := l.GetReplyList(&req)
if err != nil {
logx.Error(err)
httpx.WriteJsonCtx(r.Context(), w, http.StatusInternalServerError, resp)
httpx.WriteJsonCtx(
r.Context(),
w,
http.StatusInternalServerError,
response.ErrorWithI18n(r.Context(), "system.error"))
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}

View File

@@ -6,6 +6,7 @@ import (
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/rest/httpx"
"schisandra-album-cloud-microservices/app/core/api/common/response"
"schisandra-album-cloud-microservices/app/core/api/internal/logic/comment"
"schisandra-album-cloud-microservices/app/core/api/internal/svc"
"schisandra-album-cloud-microservices/app/core/api/internal/types"
@@ -23,7 +24,11 @@ func LikeCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
resp, err := l.LikeComment(&req)
if err != nil {
logx.Error(err)
httpx.WriteJsonCtx(r.Context(), w, http.StatusInternalServerError, resp)
httpx.WriteJsonCtx(
r.Context(),
w,
http.StatusInternalServerError,
response.ErrorWithI18n(r.Context(), "system.error"))
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}

View File

@@ -6,6 +6,7 @@ import (
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/rest/httpx"
"schisandra-album-cloud-microservices/app/core/api/common/response"
"schisandra-album-cloud-microservices/app/core/api/internal/logic/comment"
"schisandra-album-cloud-microservices/app/core/api/internal/svc"
"schisandra-album-cloud-microservices/app/core/api/internal/types"
@@ -23,7 +24,11 @@ func SubmitCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
resp, err := l.SubmitComment(&req)
if err != nil {
logx.Error(err)
httpx.WriteJsonCtx(r.Context(), w, http.StatusInternalServerError, resp)
httpx.WriteJsonCtx(
r.Context(),
w,
http.StatusInternalServerError,
response.ErrorWithI18n(r.Context(), "system.error"))
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}

View File

@@ -6,6 +6,7 @@ import (
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/rest/httpx"
"schisandra-album-cloud-microservices/app/core/api/common/response"
"schisandra-album-cloud-microservices/app/core/api/internal/logic/comment"
"schisandra-album-cloud-microservices/app/core/api/internal/svc"
"schisandra-album-cloud-microservices/app/core/api/internal/types"
@@ -23,7 +24,11 @@ func SubmitReplyCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
resp, err := l.SubmitReplyComment(&req)
if err != nil {
logx.Error(err)
httpx.WriteJsonCtx(r.Context(), w, http.StatusInternalServerError, resp)
httpx.WriteJsonCtx(
r.Context(),
w,
http.StatusInternalServerError,
response.ErrorWithI18n(r.Context(), "system.error"))
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}

View File

@@ -6,6 +6,7 @@ import (
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/rest/httpx"
"schisandra-album-cloud-microservices/app/core/api/common/response"
"schisandra-album-cloud-microservices/app/core/api/internal/logic/comment"
"schisandra-album-cloud-microservices/app/core/api/internal/svc"
"schisandra-album-cloud-microservices/app/core/api/internal/types"
@@ -23,7 +24,11 @@ func SubmitReplyReplyHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
resp, err := l.SubmitReplyReply(&req)
if err != nil {
logx.Error(err)
httpx.WriteJsonCtx(r.Context(), w, http.StatusInternalServerError, resp)
httpx.WriteJsonCtx(
r.Context(),
w,
http.StatusInternalServerError,
response.ErrorWithI18n(r.Context(), "system.error"))
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}

View File

@@ -6,6 +6,7 @@ import (
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/rest/httpx"
"schisandra-album-cloud-microservices/app/core/api/common/response"
"schisandra-album-cloud-microservices/app/core/api/internal/logic/oauth"
"schisandra-album-cloud-microservices/app/core/api/internal/svc"
)
@@ -16,7 +17,11 @@ func GetGiteeOauthUrlHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
resp, err := l.GetGiteeOauthUrl()
if err != nil {
logx.Error(err)
httpx.WriteJsonCtx(r.Context(), w, http.StatusInternalServerError, resp)
httpx.WriteJsonCtx(
r.Context(),
w,
http.StatusInternalServerError,
response.ErrorWithI18n(r.Context(), "system.error"))
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}

View File

@@ -6,6 +6,7 @@ import (
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/rest/httpx"
"schisandra-album-cloud-microservices/app/core/api/common/response"
"schisandra-album-cloud-microservices/app/core/api/internal/logic/oauth"
"schisandra-album-cloud-microservices/app/core/api/internal/svc"
"schisandra-album-cloud-microservices/app/core/api/internal/types"
@@ -23,7 +24,11 @@ func GetGithubOauthUrlHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
resp, err := l.GetGithubOauthUrl(&req)
if err != nil {
logx.Error(err)
httpx.WriteJsonCtx(r.Context(), w, http.StatusInternalServerError, resp)
httpx.WriteJsonCtx(
r.Context(),
w,
http.StatusInternalServerError,
response.ErrorWithI18n(r.Context(), "system.error"))
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}

View File

@@ -6,6 +6,7 @@ import (
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/rest/httpx"
"schisandra-album-cloud-microservices/app/core/api/common/response"
"schisandra-album-cloud-microservices/app/core/api/internal/logic/oauth"
"schisandra-album-cloud-microservices/app/core/api/internal/svc"
"schisandra-album-cloud-microservices/app/core/api/internal/types"
@@ -23,7 +24,11 @@ func GetQqOauthUrlHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
resp, err := l.GetQqOauthUrl(&req)
if err != nil {
logx.Error(err)
httpx.WriteJsonCtx(r.Context(), w, http.StatusInternalServerError, resp)
httpx.WriteJsonCtx(
r.Context(),
w,
http.StatusInternalServerError,
response.ErrorWithI18n(r.Context(), "system.error"))
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}

View File

@@ -6,6 +6,7 @@ import (
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/rest/httpx"
"schisandra-album-cloud-microservices/app/core/api/common/response"
"schisandra-album-cloud-microservices/app/core/api/internal/logic/oauth"
"schisandra-album-cloud-microservices/app/core/api/internal/svc"
"schisandra-album-cloud-microservices/app/core/api/internal/types"
@@ -23,7 +24,11 @@ func GetWechatQrcodeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
resp, err := l.GetWechatQrcode(r, &req)
if err != nil {
logx.Error(err)
httpx.WriteJsonCtx(r.Context(), w, http.StatusInternalServerError, resp)
httpx.WriteJsonCtx(
r.Context(),
w,
http.StatusInternalServerError,
response.ErrorWithI18n(r.Context(), "system.error"))
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}

View File

@@ -1,12 +1,12 @@
package oauth
import (
"errors"
"net/http"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/rest/httpx"
"schisandra-album-cloud-microservices/app/core/api/common/response"
"schisandra-album-cloud-microservices/app/core/api/internal/logic/oauth"
"schisandra-album-cloud-microservices/app/core/api/internal/svc"
"schisandra-album-cloud-microservices/app/core/api/internal/types"
@@ -24,7 +24,11 @@ func GiteeCallbackHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
err := l.GiteeCallback(w, r, &req)
if err != nil {
logx.Error(err)
httpx.ErrorCtx(r.Context(), w, errors.New("server error"))
httpx.WriteJsonCtx(
r.Context(),
w,
http.StatusInternalServerError,
response.ErrorWithI18n(r.Context(), "system.error"))
} else {
httpx.Ok(w)
}

View File

@@ -1,12 +1,12 @@
package oauth
import (
"errors"
"net/http"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/rest/httpx"
"schisandra-album-cloud-microservices/app/core/api/common/response"
"schisandra-album-cloud-microservices/app/core/api/internal/logic/oauth"
"schisandra-album-cloud-microservices/app/core/api/internal/svc"
"schisandra-album-cloud-microservices/app/core/api/internal/types"
@@ -24,7 +24,11 @@ func GithubCallbackHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
err := l.GithubCallback(w, r, &req)
if err != nil {
logx.Error(err)
httpx.ErrorCtx(r.Context(), w, errors.New("server error"))
httpx.WriteJsonCtx(
r.Context(),
w,
http.StatusInternalServerError,
response.ErrorWithI18n(r.Context(), "system.error"))
} else {
httpx.Ok(w)
}

View File

@@ -1,12 +1,12 @@
package oauth
import (
"errors"
"net/http"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/rest/httpx"
"schisandra-album-cloud-microservices/app/core/api/common/response"
"schisandra-album-cloud-microservices/app/core/api/internal/logic/oauth"
"schisandra-album-cloud-microservices/app/core/api/internal/svc"
"schisandra-album-cloud-microservices/app/core/api/internal/types"
@@ -24,7 +24,11 @@ func QqCallbackHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
err := l.QqCallback(w, r, &req)
if err != nil {
logx.Error(err)
httpx.ErrorCtx(r.Context(), w, errors.New("server error"))
httpx.WriteJsonCtx(
r.Context(),
w,
http.StatusInternalServerError,
response.ErrorWithI18n(r.Context(), "system.error"))
} else {
httpx.Ok(w)
}

View File

@@ -1,12 +1,12 @@
package oauth
import (
"errors"
"net/http"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/rest/httpx"
"schisandra-album-cloud-microservices/app/core/api/common/response"
"schisandra-album-cloud-microservices/app/core/api/internal/logic/oauth"
"schisandra-album-cloud-microservices/app/core/api/internal/svc"
)
@@ -17,7 +17,11 @@ func WechatCallbackHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
err := l.WechatCallback(w, r)
if err != nil {
logx.Error(err)
httpx.ErrorCtx(r.Context(), w, errors.New("server error"))
httpx.WriteJsonCtx(
r.Context(),
w,
http.StatusInternalServerError,
response.ErrorWithI18n(r.Context(), "system.error"))
} else {
httpx.Ok(w)
}

View File

@@ -6,6 +6,7 @@ import (
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/rest/httpx"
"schisandra-album-cloud-microservices/app/core/api/common/response"
"schisandra-album-cloud-microservices/app/core/api/internal/logic/sms"
"schisandra-album-cloud-microservices/app/core/api/internal/svc"
"schisandra-album-cloud-microservices/app/core/api/internal/types"
@@ -23,7 +24,11 @@ func SendSmsByAliyunHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
resp, err := l.SendSmsByAliyun(&req)
if err != nil {
logx.Error(err)
httpx.WriteJsonCtx(r.Context(), w, http.StatusInternalServerError, resp)
httpx.WriteJsonCtx(
r.Context(),
w,
http.StatusInternalServerError,
response.ErrorWithI18n(r.Context(), "system.error"))
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}

View File

@@ -6,6 +6,7 @@ import (
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/rest/httpx"
"schisandra-album-cloud-microservices/app/core/api/common/response"
"schisandra-album-cloud-microservices/app/core/api/internal/logic/sms"
"schisandra-album-cloud-microservices/app/core/api/internal/svc"
"schisandra-album-cloud-microservices/app/core/api/internal/types"
@@ -23,7 +24,11 @@ func SendSmsBySmsbaoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
resp, err := l.SendSmsBySmsbao(&req)
if err != nil {
logx.Error(err)
httpx.WriteJsonCtx(r.Context(), w, http.StatusInternalServerError, resp)
httpx.WriteJsonCtx(
r.Context(),
w,
http.StatusInternalServerError,
response.ErrorWithI18n(r.Context(), "system.error"))
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}

View File

@@ -6,6 +6,7 @@ import (
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/rest/httpx"
"schisandra-album-cloud-microservices/app/core/api/common/response"
"schisandra-album-cloud-microservices/app/core/api/internal/logic/sms"
"schisandra-album-cloud-microservices/app/core/api/internal/svc"
"schisandra-album-cloud-microservices/app/core/api/internal/types"
@@ -23,7 +24,11 @@ func SendSmsByTestHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
resp, err := l.SendSmsByTest(&req)
if err != nil {
logx.Error(err)
httpx.WriteJsonCtx(r.Context(), w, http.StatusInternalServerError, resp)
httpx.WriteJsonCtx(
r.Context(),
w,
http.StatusInternalServerError,
response.ErrorWithI18n(r.Context(), "system.error"))
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}

View File

@@ -6,6 +6,7 @@ import (
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/rest/httpx"
"schisandra-album-cloud-microservices/app/core/api/common/response"
"schisandra-album-cloud-microservices/app/core/api/internal/logic/user"
"schisandra-album-cloud-microservices/app/core/api/internal/svc"
"schisandra-album-cloud-microservices/app/core/api/internal/types"
@@ -23,7 +24,11 @@ func AccountLoginHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
resp, err := l.AccountLogin(w, r, &req)
if err != nil {
logx.Error(err)
httpx.WriteJsonCtx(r.Context(), w, http.StatusInternalServerError, resp)
httpx.WriteJsonCtx(
r.Context(),
w,
http.StatusInternalServerError,
response.ErrorWithI18n(r.Context(), "system.error"))
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}

View File

@@ -1,12 +1,12 @@
package user
import (
"errors"
"net/http"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/rest/httpx"
"schisandra-album-cloud-microservices/app/core/api/common/response"
"schisandra-album-cloud-microservices/app/core/api/internal/logic/user"
"schisandra-album-cloud-microservices/app/core/api/internal/svc"
)
@@ -17,7 +17,11 @@ func GetUserDeviceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
err := l.GetUserDevice(r)
if err != nil {
logx.Error(err)
httpx.ErrorCtx(r.Context(), w, errors.New("server error"))
httpx.WriteJsonCtx(
r.Context(),
w,
http.StatusInternalServerError,
response.ErrorWithI18n(r.Context(), "system.error"))
} else {
httpx.Ok(w)
}

View File

@@ -6,6 +6,7 @@ import (
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/rest/httpx"
"schisandra-album-cloud-microservices/app/core/api/common/response"
"schisandra-album-cloud-microservices/app/core/api/internal/logic/user"
"schisandra-album-cloud-microservices/app/core/api/internal/svc"
"schisandra-album-cloud-microservices/app/core/api/internal/types"
@@ -23,7 +24,11 @@ func PhoneLoginHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
resp, err := l.PhoneLogin(r, w, &req)
if err != nil || resp.Code == 500 {
logx.Error(err)
httpx.WriteJsonCtx(r.Context(), w, http.StatusInternalServerError, resp)
httpx.WriteJsonCtx(
r.Context(),
w,
http.StatusInternalServerError,
response.ErrorWithI18n(r.Context(), "system.error"))
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}

View File

@@ -6,6 +6,7 @@ import (
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/rest/httpx"
"schisandra-album-cloud-microservices/app/core/api/common/response"
"schisandra-album-cloud-microservices/app/core/api/internal/logic/user"
"schisandra-album-cloud-microservices/app/core/api/internal/svc"
)
@@ -16,7 +17,11 @@ func RefreshTokenHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
resp, err := l.RefreshToken(r)
if err != nil {
logx.Error(err)
httpx.WriteJsonCtx(r.Context(), w, http.StatusInternalServerError, resp)
httpx.WriteJsonCtx(
r.Context(),
w,
http.StatusInternalServerError,
response.ErrorWithI18n(r.Context(), "system.error"))
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}

View File

@@ -6,6 +6,7 @@ import (
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/rest/httpx"
"schisandra-album-cloud-microservices/app/core/api/common/response"
"schisandra-album-cloud-microservices/app/core/api/internal/logic/user"
"schisandra-album-cloud-microservices/app/core/api/internal/svc"
"schisandra-album-cloud-microservices/app/core/api/internal/types"
@@ -23,7 +24,11 @@ func ResetPasswordHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
resp, err := l.ResetPassword(&req)
if err != nil {
logx.Error(err)
httpx.WriteJsonCtx(r.Context(), w, http.StatusInternalServerError, resp)
httpx.WriteJsonCtx(
r.Context(),
w,
http.StatusInternalServerError,
response.ErrorWithI18n(r.Context(), "system.error"))
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}

View File

@@ -28,7 +28,7 @@ func NewGenerateRotateCaptchaLogic(ctx context.Context, svcCtx *svc.ServiceConte
func (l *GenerateRotateCaptchaLogic) GenerateRotateCaptcha() (resp *types.Response, err error) {
captcha, err := generate.GenerateRotateCaptcha(l.svcCtx.RotateCaptcha, l.svcCtx.RedisClient, l.ctx)
if err != nil {
return response.Error(), err
return nil, err
}
return response.SuccessWithData(captcha), nil
}

View File

@@ -28,7 +28,7 @@ func NewGenerateSlideBasicCaptchaLogic(ctx context.Context, svcCtx *svc.ServiceC
func (l *GenerateSlideBasicCaptchaLogic) GenerateSlideBasicCaptcha() (resp *types.Response, err error) {
captcha, err := generate.GenerateSlideBasicCaptcha(l.svcCtx.SlideCaptcha, l.svcCtx.RedisClient, l.ctx)
if err != nil {
return response.Error(), err
return nil, err
}
return response.SuccessWithData(captcha), nil
}

View File

@@ -36,7 +36,7 @@ func (l *GenerateClientIdLogic) GenerateClientId(clientIP string) (resp *types.R
}
simpleUuid := kgo.SimpleUuid()
if err = l.svcCtx.RedisClient.SetEx(l.ctx, constant.UserClientPrefix+clientIP, simpleUuid, time.Hour*24*7).Err(); err != nil {
return response.Error(), err
return nil, err
}
return response.SuccessWithData(simpleUuid), nil
}

View File

@@ -3,6 +3,8 @@ package comment
import (
"context"
"schisandra-album-cloud-microservices/app/core/api/common/captcha/verify"
"schisandra-album-cloud-microservices/app/core/api/common/response"
"schisandra-album-cloud-microservices/app/core/api/internal/svc"
"schisandra-album-cloud-microservices/app/core/api/internal/types"
@@ -24,7 +26,11 @@ func NewSubmitCommentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Sub
}
func (l *SubmitCommentLogic) SubmitComment(req *types.CommentRequest) (resp *types.Response, err error) {
// todo: add your logic here and delete this line
res := verify.VerifySlideCaptcha(l.ctx, l.svcCtx.RedisClient, req.Point, req.Key)
if !res {
return response.ErrorWithI18n(l.ctx, "captcha.verificationFailure"), nil
}
return
}

View File

@@ -40,7 +40,7 @@ func (l *GetWechatQrcodeLogic) GetWechatQrcode(r *http.Request, req *types.OAuth
if qrcode != "" {
data := new(response.ResponseQRCodeCreate)
if err = json.Unmarshal([]byte(qrcode), data); err != nil {
return response2.Error(), err
return nil, err
}
return response2.SuccessWithData(data.Url), nil
}
@@ -48,16 +48,16 @@ func (l *GetWechatQrcodeLogic) GetWechatQrcode(r *http.Request, req *types.OAuth
// 生成临时二维码
data, err := l.svcCtx.WechatPublic.QRCode.Temporary(l.ctx, req.Client_id, 7*24*3600)
if err != nil {
return response2.Error(), err
return nil, err
}
// 序列化数据并存储到Redis
serializedData, err := json.Marshal(data)
if err != nil {
return response2.Error(), err
return nil, err
}
if err = l.svcCtx.RedisClient.Set(l.ctx, key, serializedData, time.Hour*24*7).Err(); err != nil {
return response2.Error(), err
return nil, err
}
return response2.SuccessWithData(data.Url), nil

View File

@@ -56,7 +56,7 @@ func (l *SendSmsByAliyunLogic) SendSmsByAliyun(req *types.SmsSendRequest) (resp
code := utils.GenValidateCode(6)
wrong := l.svcCtx.RedisClient.Set(l.ctx, constant.UserSmsRedisPrefix+req.Phone, code, time.Minute).Err()
if wrong != nil {
return response.ErrorWithI18n(l.ctx, "sms.smsSendFailed"), wrong
return nil, wrong
}
_, err = sms.Send(req.Phone, gosms.MapStringAny{
"content": "您的验证码是:****。请不要把验证码泄露给其他人。",
@@ -67,7 +67,7 @@ func (l *SendSmsByAliyunLogic) SendSmsByAliyun(req *types.SmsSendRequest) (resp
},
}, nil)
if err != nil {
return response.ErrorWithI18n(l.ctx, "sms.smsSendFailed"), err
return nil, err
}
return response.Success(), nil
}

View File

@@ -54,13 +54,13 @@ func (l *SendSmsBySmsbaoLogic) SendSmsBySmsbao(req *types.SmsSendRequest) (resp
code := utils.GenValidateCode(6)
wrong := l.svcCtx.RedisClient.Set(l.ctx, constant.UserSmsRedisPrefix+req.Phone, code, time.Minute).Err()
if wrong != nil {
return response.ErrorWithI18n(l.ctx, "sms.smsSendFailed"), wrong
return nil, wrong
}
_, err = sms.Send(req.Phone, gosms.MapStringAny{
"content": "您的验证码是:" + code + "。请不要把验证码泄露给其他人。",
}, nil)
if err != nil {
return response.ErrorWithI18n(l.ctx, "sms.smsSendFailed"), err
return nil, err
}
return response.Success(), nil
}

View File

@@ -44,7 +44,7 @@ func (l *SendSmsByTestLogic) SendSmsByTest(req *types.SmsSendRequest) (resp *typ
code := utils.GenValidateCode(6)
wrong := l.svcCtx.RedisClient.Set(l.ctx, constant.UserSmsRedisPrefix+req.Phone, code, time.Minute).Err()
if wrong != nil {
return response.ErrorWithI18n(l.ctx, "sms.smsSendFailed"), wrong
return nil, wrong
}
return response.Success(), nil
}

View File

@@ -2,7 +2,6 @@ package user
import (
"context"
"encoding/json"
"errors"
"net/http"
@@ -13,7 +12,6 @@ import (
"schisandra-album-cloud-microservices/app/core/api/common/constant"
"schisandra-album-cloud-microservices/app/core/api/common/utils"
"schisandra-album-cloud-microservices/app/core/api/internal/svc"
"schisandra-album-cloud-microservices/app/core/api/internal/types"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuserdevice"
)
@@ -37,17 +35,12 @@ func (l *GetUserDeviceLogic) GetUserDevice(r *http.Request) error {
if err != nil {
return err
}
sessionData, ok := session.Values[constant.SESSION_KEY]
uid, ok := session.Values["uid"].(string)
if !ok {
return errors.New("user session not found")
}
var data types.SessionData
err = json.Unmarshal(sessionData.([]byte), &data)
if err != nil {
return err
}
res := GetUserLoginDevice(data.UID, r, l.svcCtx.Ip2Region, l.svcCtx.MySQLClient, l.ctx)
res := GetUserLoginDevice(uid, r, l.svcCtx.Ip2Region, l.svcCtx.MySQLClient, l.ctx)
if !res {
return errors.New("user device not found")
}
@@ -63,7 +56,6 @@ func GetUserLoginDevice(userId string, r *http.Request, ip2location *xdb.Searche
ip := utils.GetClientIP(r)
location, err := ip2location.SearchByStr(ip)
if err != nil {
logx.Error(err)
return false
}
location = utils.RemoveZeroAndAdjust(location)

View File

@@ -46,7 +46,7 @@ func (l *PhoneLoginLogic) PhoneLogin(r *http.Request, w http.ResponseWriter, req
user, err := l.svcCtx.MySQLClient.ScaAuthUser.Query().Where(scaauthuser.Phone(req.Phone), scaauthuser.Deleted(0)).First(l.ctx)
tx, wrong := l.svcCtx.MySQLClient.Tx(l.ctx)
if wrong != nil {
return response.ErrorWithI18n(l.ctx, "login.loginFailed"), err
return nil, err
}
if ent.IsNotFound(err) {
uid := idgen.NextId()
@@ -64,12 +64,12 @@ func (l *PhoneLoginLogic) PhoneLogin(r *http.Request, w http.ResponseWriter, req
Save(l.ctx)
if fault != nil {
err = tx.Rollback()
return response.ErrorWithI18n(l.ctx, "login.registerError"), err
return nil, err
}
_, err = l.svcCtx.CasbinEnforcer.AddRoleForUser(uidStr, constant.User)
if err != nil {
err = tx.Rollback()
return response.ErrorWithI18n(l.ctx, "login.registerError"), err
return nil, err
}
data, result := HandleUserLogin(addUser, l.svcCtx, req.AutoLogin, r, w, l.ctx)
if !result {

View File

@@ -32,7 +32,7 @@ func NewRefreshTokenLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Refr
func (l *RefreshTokenLogic) RefreshToken(r *http.Request) (resp *types.Response, err error) {
session, err := l.svcCtx.Session.Get(r, constant.SESSION_KEY)
if err != nil {
return response.ErrorWithCode(403), err
return nil, err
}
refreshSessionToken, ok := session.Values["refresh_token"].(string)
if !ok {
@@ -49,7 +49,7 @@ func (l *RefreshTokenLogic) RefreshToken(r *http.Request) (resp *types.Response,
redisTokenData := types.RedisToken{}
err = json.Unmarshal([]byte(tokenData), &redisTokenData)
if err != nil {
return response.ErrorWithCode(403), err
return nil, err
}
if redisTokenData.RefreshToken != refreshSessionToken {
return response.ErrorWithCode(403), nil
@@ -72,7 +72,7 @@ func (l *RefreshTokenLogic) RefreshToken(r *http.Request) (resp *types.Response,
}
err = l.svcCtx.RedisClient.Set(l.ctx, constant.UserTokenPrefix+refreshToken.UserID, redisToken, time.Hour*24*7).Err()
if err != nil {
return response.ErrorWithCode(403), err
return nil, err
}
return response.SuccessWithData(accessToken), nil

View File

@@ -47,19 +47,19 @@ func (l *ResetPasswordLogic) ResetPassword(req *types.ResetPasswordRequest) (res
}
// 验证码检查通过后立即删除或标记为已使用
if err = l.svcCtx.RedisClient.Del(l.ctx, constant.UserSmsRedisPrefix+req.Phone).Err(); err != nil {
return response.ErrorWithI18n(l.ctx, "login.captchaError"), err
return nil, err
}
user, err := l.svcCtx.MySQLClient.ScaAuthUser.Query().Where(scaauthuser.Phone(req.Phone), scaauthuser.Deleted(constant.NotDeleted)).First(l.ctx)
if err != nil && ent.IsNotFound(err) {
return response.ErrorWithI18n(l.ctx, "login.userNotRegistered"), err
return response.ErrorWithI18n(l.ctx, "login.userNotRegistered"), nil
}
encrypt, err := utils.Encrypt(req.Password)
if err != nil {
return response.ErrorWithI18n(l.ctx, "login.resetPasswordError"), err
return nil, err
}
err = user.Update().SetPassword(encrypt).Exec(l.ctx)
if err != nil {
return response.ErrorWithI18n(l.ctx, "login.resetPasswordError"), err
return nil, err
}
return response.Success(), nil
}

View File

@@ -45,14 +45,15 @@ type ServiceContext struct {
func NewServiceContext(c config.Config) *ServiceContext {
casbinEnforcer := casbinx.NewCasbin(c.Mysql.DataSource)
redisClient := redisx.NewRedis(c.Redis.Host, c.Redis.Pass, c.Redis.DB)
return &ServiceContext{
Config: c,
SecurityHeadersMiddleware: middleware.NewSecurityHeadersMiddleware().Handle,
CasbinVerifyMiddleware: middleware.NewCasbinVerifyMiddleware(casbinEnforcer).Handle,
MySQLClient: mysql.NewMySQL(c.Mysql.DataSource),
RedisClient: redisx.NewRedis(c.Redis.Host, c.Redis.Pass, c.Redis.DB),
RedisClient: redisClient,
MongoClient: mongodb.NewMongoDB(c.Mongo.Uri, c.Mongo.Username, c.Mongo.Password, c.Mongo.AuthSource, c.Mongo.Database),
Session: redis_session.NewRedisSession(c.Redis.Host, c.Redis.Pass),
Session: redis_session.NewRedisSession(redisClient),
Ip2Region: ip2region.NewIP2Region(),
CasbinEnforcer: casbinEnforcer,
WechatPublic: wechat_public.NewWechatPublic(c.Wechat.AppID, c.Wechat.AppSecret, c.Wechat.Token, c.Wechat.AESKey, c.Redis.Host, c.Redis.Pass, c.Redis.DB),

View File

@@ -13,12 +13,7 @@ import (
"schisandra-album-cloud-microservices/app/core/api/internal/types"
)
func NewRedisSession(addr string, password string) *redisstore.RedisStore {
client := redis.NewClient(&redis.Options{
Addr: addr,
Password: password,
DB: 0,
})
func NewRedisSession(client *redis.Client) *redisstore.RedisStore {
store, err := redisstore.NewRedisStore(context.Background(), client)
if err != nil {
panic(err)

View File

@@ -1,3 +1,5 @@
[system]
error = "system error"
[captcha]
verificationFailure = "verification failure!"
[login]

View File

@@ -1,3 +1,5 @@
[system]
error = "系统错误!"
[captcha]
verificationFailure = "验证失败!"
[login]

20
go.mod
View File

@@ -4,22 +4,30 @@ go 1.23.3
require (
entgo.io/ent v0.14.1
github.com/ArtisanCloud/PowerLibs/v3 v3.2.6
github.com/ArtisanCloud/PowerWeChat/v3 v3.2.55
github.com/casbin/casbin/v2 v2.100.0
github.com/ccpwcn/kgo v1.2.3
github.com/chenmingyong0423/go-mongox/v2 v2.0.0-beta1
github.com/go-sql-driver/mysql v1.8.1
github.com/golang-jwt/jwt/v5 v5.2.1
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
github.com/gorilla/sessions v1.2.0
github.com/lionsoul2014/ip2region/binding/golang v0.0.0-20240510055607-89e20ab7b6c6
github.com/lxzan/gws v1.8.8
github.com/microcosm-cc/bluemonday v1.0.27
github.com/mssola/useragent v1.0.0
github.com/nicksnyder/go-i18n/v2 v2.4.1
github.com/pelletier/go-toml/v2 v2.2.2
github.com/pkg/errors v0.9.1
github.com/pkg6/go-sms v0.1.2
github.com/rbcervilla/redisstore/v9 v9.0.0
github.com/redis/go-redis/v9 v9.7.0
github.com/wenlng/go-captcha-assets v1.0.1
github.com/wenlng/go-captcha/v2 v2.0.1
github.com/yitter/idgenerator-go v1.3.1
github.com/zeromicro/go-zero v1.7.3
github.com/zmexing/go-sensitive-word v1.3.0
go.mongodb.org/mongo-driver/v2 v2.0.0-beta2
golang.org/x/crypto v0.29.0
golang.org/x/text v0.20.0
@@ -29,12 +37,11 @@ require (
require (
ariga.io/atlas v0.19.1-0.20240203083654-5948b60a8e43 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/ArtisanCloud/PowerLibs/v3 v3.2.6 // indirect
github.com/ArtisanCloud/PowerSocialite/v3 v3.0.7 // indirect
github.com/ArtisanCloud/PowerWeChat/v3 v3.2.55 // indirect
github.com/agext/levenshtein v1.2.1 // indirect
github.com/andybalholm/brotli v1.1.1 // indirect
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
github.com/aymerick/douceur v0.2.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bmatcuk/doublestar/v4 v4.6.1 // indirect
github.com/casbin/govaluate v1.2.0 // indirect
@@ -46,21 +53,19 @@ require (
github.com/dolthub/maphash v0.1.0 // indirect
github.com/fatih/color v1.17.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/go-bindata/go-bindata v3.1.2+incompatible // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/inflect v0.19.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.20.0 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/pprof v0.0.0-20241101162523-b92577c0c142 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/css v1.0.1 // indirect
github.com/gorilla/securecookie v1.1.1 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
@@ -69,7 +74,6 @@ require (
github.com/imroc/req/v3 v3.48.0 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/lxzan/gws v1.8.8 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 // indirect
@@ -79,7 +83,6 @@ require (
github.com/orcaman/concurrent-map/v2 v2.0.1 // indirect
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
github.com/pkg6/go-requests v0.2.2 // indirect
github.com/pkg6/go-sms v0.1.2 // indirect
github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.55.0 // indirect
@@ -88,13 +91,11 @@ require (
github.com/quic-go/quic-go v0.48.1 // indirect
github.com/refraction-networking/utls v1.6.7 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/wenlng/go-captcha-assets v1.0.1 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect
github.com/zclconf/go-cty v1.8.0 // indirect
github.com/zmexing/go-sensitive-word v1.3.0 // indirect
go.opentelemetry.io/otel v1.32.0 // indirect
go.opentelemetry.io/otel/exporters/jaeger v1.17.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 // indirect
@@ -106,7 +107,6 @@ require (
go.opentelemetry.io/otel/sdk v1.32.0 // indirect
go.opentelemetry.io/otel/trace v1.32.0 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/automaxprocs v1.6.0 // indirect
go.uber.org/mock v0.5.0 // indirect
go.uber.org/multierr v1.11.0 // indirect

51
go.sum
View File

@@ -20,6 +20,8 @@ github.com/andybalholm/brotli v1.1.1 h1:PR2pgnyFznKEugtsUo0xLdDop5SKXd5Qf5ysW+7X
github.com/andybalholm/brotli v1.1.1/go.mod h1:05ib4cKhjx3OQYUY22hTVd34Bc8upXjOLL2rKwwZBoA=
github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw=
github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo=
github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=
github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/bmatcuk/doublestar/v4 v4.6.1 h1:FH9SifrbvJhnlQpztAx++wlkk70QBf0iBWDwNy7PA4I=
@@ -55,7 +57,6 @@ github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4=
github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI=
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
github.com/go-bindata/go-bindata v3.1.2+incompatible h1:5vjJMVhowQdPzjE1LdxyFF7YFTXg5IgGVW4gBr5IbvE=
github.com/go-bindata/go-bindata v3.1.2+incompatible/go.mod h1:xK8Dsgwmeed+BBsSy2XTopBn/8uK2HWuGSnA11C3Joo=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
@@ -74,8 +75,6 @@ github.com/go-playground/validator/v10 v10.20.0 h1:K9ISHbSaI0lyB2eWMPJo+kOS/FBEx
github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y=
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls=
github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68=
@@ -100,6 +99,8 @@ github.com/google/pprof v0.0.0-20241101162523-b92577c0c142 h1:sAGdeJj0bnMgUNVeUp
github.com/google/pprof v0.0.0-20241101162523-b92577c0c142/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/css v1.0.1 h1:ntNaBIghp6JmvWnxbZKANoLyuXTPZ4cAMlo6RyhlbO8=
github.com/gorilla/css v1.0.1/go.mod h1:BvnYkspnSzMmwRK+b8/xgNPLiIuNZr6vbZBTPQ2A3b0=
github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ=
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
github.com/gorilla/sessions v1.2.0 h1:S7P+1Hm5V/AT9cjEcUD5uDaQSX0OE577aCXgoaKpYbQ=
@@ -117,10 +118,6 @@ github.com/hashicorp/hcl/v2 v2.13.0 h1:0Apadu1w6M11dyGFxWnmhhcMjkbAiKCv7G1r/2QgC
github.com/hashicorp/hcl/v2 v2.13.0/go.mod h1:e4z5nxYlWNPdDSNYX+ph14EvWYMFm3eP0zIUqPc2jr0=
github.com/imroc/req/v3 v3.48.0 h1:IYuMGetuwLzOOTzDCquDqs912WNwpsPK0TBXWPIvoqg=
github.com/imroc/req/v3 v3.48.0/go.mod h1:weam9gmyb00QnOtu6HXSnk44dNFkIUQb5QdMx13FeUU=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=
github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
@@ -143,10 +140,10 @@ github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovk
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y=
github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
github.com/microcosm-cc/bluemonday v1.0.27 h1:MpEUotklkwCSLeH+Qdx1VJgNqLlpY2KXwXFM08ygZfk=
github.com/microcosm-cc/bluemonday v1.0.27/go.mod h1:jFi9vgW+H7c3V0lb6nR74Ib/DIB5OBs92Dimizgw2cA=
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 h1:DpOJ2HYzCv8LZP15IdmG+YdwD2luVPHITV96TkirNBM=
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
github.com/mssola/useragent v1.0.0 h1:WRlDpXyxHDNfvZaPEut5Biveq86Ze4o4EMffyMxmH5o=
@@ -155,10 +152,10 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/nicksnyder/go-i18n/v2 v2.4.1 h1:zwzjtX4uYyiaU02K5Ia3zSkpJZrByARkRB4V3YPrr0g=
github.com/nicksnyder/go-i18n/v2 v2.4.1/go.mod h1:++Pl70FR6Cki7hdzZRnEEqdc2dJt+SAGotyFg/SvZMk=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/onsi/ginkgo/v2 v2.21.0 h1:7rg/4f3rB88pb5obDgNZrNHrQ4e6WpjonchcpuBRnZM=
github.com/onsi/ginkgo/v2 v2.21.0/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo=
github.com/onsi/gomega v1.34.2 h1:pNCwDkzrsv7MS9kpaQvVb1aVLahQXyJ/Tv5oAZMI3i8=
github.com/onsi/gomega v1.34.2/go.mod h1:v1xfxRgk0KIsG+QOdm7p8UosrOzPYRo60fd3B/1Dukc=
github.com/openzipkin/zipkin-go v0.4.3 h1:9EGwpqkgnwdEIJ+Od7QVSEIH+ocmm5nPat0G7sjsSdg=
github.com/openzipkin/zipkin-go v0.4.3/go.mod h1:M9wCJZFWCo2RiY+o1eBCEMe0Dp2S5LDHcMZmk3RmK7c=
github.com/orcaman/concurrent-map/v2 v2.0.1 h1:jOJ5Pg2w1oeB6PeDurIYf6k9PQ+aTITr/6lP/L/zp6c=
@@ -195,24 +192,17 @@ github.com/redis/go-redis/v9 v9.7.0 h1:HhLSs+B6O021gwzl+locl0zEDnyNkxMtf/Z3NNBMa
github.com/redis/go-redis/v9 v9.7.0/go.mod h1:f6zhXITC7JUJIlPEiBOTXxJgPLdZcA93GewI7inzyWw=
github.com/refraction-networking/utls v1.6.7 h1:zVJ7sP1dJx/WtVuITug3qYUq034cDq9B2MR1K67ULZM=
github.com/refraction-networking/utls v1.6.7/go.mod h1:BC3O4vQzye5hqpmDTWUqi4P5DDhzJfkV1tdqtawQIH0=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
@@ -230,6 +220,7 @@ github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY=
github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4=
github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6c8=
github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM=
github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU=
github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E=
github.com/yitter/idgenerator-go v1.3.1 h1:GjVi2BupiDb1IXaXqrkOJE4p6qKdj3NaM3GdAjWok14=
github.com/yitter/idgenerator-go v1.3.1/go.mod h1:VVjbqFjGUsIkaXVkXEdmx1LiXUL3K1NvyxWPJBPbBpE=
@@ -244,8 +235,6 @@ github.com/zmexing/go-sensitive-word v1.3.0 h1:dB9S9kNklksOODGLLAov0RaVCwC2w9Kwx
github.com/zmexing/go-sensitive-word v1.3.0/go.mod h1:wkNIpkq1iPOe3l7l83zvnnV5mm20jfj2x8V8kjOTsUM=
go.mongodb.org/mongo-driver/v2 v2.0.0-beta2 h1:PRtbRKwblE8ZfI8qOhofcjn9y8CmKZI7trS5vDMeJX0=
go.mongodb.org/mongo-driver/v2 v2.0.0-beta2/go.mod h1:UGLb3ZgEzaY0cCbJpH9UFt9B6gEXiTPzsnJS38nBeoU=
go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo=
go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo=
go.opentelemetry.io/otel v1.32.0 h1:WnBN+Xjcteh0zdk01SVqV55d/m62NJLJdIyb4y/WO5U=
go.opentelemetry.io/otel v1.32.0/go.mod h1:00DCVSB0RQcnzlwyTfqtxSm+DRr9hpYrHjNGiBHVQIg=
go.opentelemetry.io/otel/exporters/jaeger v1.17.0 h1:D7UpUy2Xc2wsi1Ras6V40q806WM07rqoCWzXu7Sqy+4=
@@ -260,28 +249,18 @@ go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.24.0 h1:s0PHtIkN+3xrbDO
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.24.0/go.mod h1:hZlFbDbRt++MMPCCfSJfmhkGIWnX1h3XjkfxZUjLrIA=
go.opentelemetry.io/otel/exporters/zipkin v1.24.0 h1:3evrL5poBuh1KF51D9gO/S+N/1msnm4DaBqs/rpXUqY=
go.opentelemetry.io/otel/exporters/zipkin v1.24.0/go.mod h1:0EHgD8R0+8yRhUYJOGR8Hfg2dpiJQxDOszd5smVO9wM=
go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI=
go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco=
go.opentelemetry.io/otel/metric v1.32.0 h1:xV2umtmNcThh2/a/aCP+h64Xx5wsj8qqnkYZktzNa0M=
go.opentelemetry.io/otel/metric v1.32.0/go.mod h1:jH7CIbbK6SH2V2wE16W05BHCtIDzauciCRLoc/SyMv8=
go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucgoDw=
go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg=
go.opentelemetry.io/otel/sdk v1.32.0 h1:RNxepc9vK59A8XsgZQouW8ue8Gkb4jpWtJm9ge5lEG4=
go.opentelemetry.io/otel/sdk v1.32.0/go.mod h1:LqgegDBjKMmb2GC6/PrTnteJG39I8/vJCAP9LlJXEjU=
go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI=
go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU=
go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQDe03fM=
go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8=
go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0=
go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8=
go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
go.uber.org/automaxprocs v1.6.0 h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs=
go.uber.org/automaxprocs v1.6.0/go.mod h1:ifeIMSnPZuznNm6jmdzmU3/bfk01Fe2fotchwEFJ8r8=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU=
go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc=
go.uber.org/mock v0.5.0 h1:KAMbZvZPyBPWgD14IrIQ38QCyjwpvVVV6K/bHl1IwQU=
go.uber.org/mock v0.5.0/go.mod h1:ge71pBPLYDk7QIi1LupWxdAykm7KIEFchiOqd6z7qMM=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
@@ -290,8 +269,6 @@ go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ=
golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg=
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f h1:XdNn9LlyWAhLVp6P/i8QYBW+hlyhrhei9uErw2B5GJo=
@@ -301,8 +278,6 @@ golang.org/x/image v0.22.0 h1:UtK5yLUzilVrkjMAZAZ34DXGpASN8i8pj8g+O+yd10g=
golang.org/x/image v0.22.0/go.mod h1:9hPFhljd4zZ1GNSIZJ49sqbp45GKK9t6w+iXvGqZUz4=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0=
golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4=
golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
@@ -312,8 +287,6 @@ golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo=
golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -329,8 +302,6 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
@@ -346,13 +317,13 @@ golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug=
golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4=
golang.org/x/time v0.7.0 h1:ntUhktv3OPE6TgYxXWv9vKvUSJyIFJlyohwbkEwPrKQ=
golang.org/x/time v0.7.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24=
golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ=
golang.org/x/tools v0.27.0 h1:qEKojBykQkQ4EynWy4S8Weg69NumxKdn40Fce3uc/8o=
golang.org/x/tools v0.27.0/go.mod h1:sUi0ZgbwW9ZPAq26Ekut+weQPR5eIM6GQLQ1Yjm1H0Q=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=