Merge remote-tracking branch 'origin/master'

This commit is contained in:
joylink_zhangsai 2023-07-28 14:23:10 +08:00
commit 6552fd47cd
8 changed files with 720 additions and 37 deletions

View File

@ -48,7 +48,11 @@ func pageQueryDrafting(c *gin.Context) {
req.Default()
}
zap.S().Debug("分页查草稿参数", req)
page, _ := service.PageDraftingQuery(&req)
page, err := service.PageDraftingQuery(&req)
if err != nil {
c.JSON(http.StatusInternalServerError, err.Error())
return
}
c.JSON(http.StatusOK, page)
}
@ -70,14 +74,19 @@ func pageQueryDrafting(c *gin.Context) {
// @Router /api/v1/drafting [post]
func createDrafting(c *gin.Context) {
user, _ := c.Get(middleware.IdentityKey)
createId := user.(model.User).ID
createId := user.(*model.User).ID
req := dto.DraftingDto{}
if err := c.ShouldBind(&req); err != nil {
panic("传入参数为空")
c.JSON(http.StatusBadRequest, "传入参数错误")
return
}
zap.S().Debug("保存数据", req)
service.CreateDrafting(createId, &req)
c.Status(http.StatusOK)
data, err := service.CreateDrafting(createId, &req)
if err != nil {
c.JSON(http.StatusInternalServerError, err.Error())
return
}
c.JSON(http.StatusOK, data)
}
// 草稿另存为
@ -100,18 +109,24 @@ func createDrafting(c *gin.Context) {
func saveAsDrafting(c *gin.Context) {
id, exist := c.Params.Get("id")
if !exist {
panic("必要参数id不存在")
c.JSON(http.StatusBadRequest, "必要参数id不存在")
return
}
zap.S().Debug("传入参数id为" + id)
user, _ := c.Get(middleware.IdentityKey)
createrId := user.(model.User).ID
createrId := user.(*model.User).ID
req := dto.DraftingDto{}
if err := c.ShouldBind(&req); err != nil {
zap.S().Warn("保存数据出错", err)
c.JSON(http.StatusBadRequest, "传入参数错误")
return
}
int64Id, _ := strconv.ParseInt(id, 10, 64)
service.SaveAsDrafting(createrId, int32(int64Id), &req)
c.Status(http.StatusOK)
newData, err := service.SaveAsDrafting(createrId, int32(int64Id), &req)
if err != nil {
c.JSON(http.StatusInternalServerError, "保存数据出错")
return
}
c.JSON(http.StatusOK, newData)
}
// 查询草稿详情
@ -133,20 +148,21 @@ func saveAsDrafting(c *gin.Context) {
func queryDraftingInfo(c *gin.Context) {
id, exist := c.Params.Get("id")
if !exist {
panic("必要参数id不存在")
c.JSON(http.StatusBadRequest, "必要参数id不存在")
return
}
zap.S().Debug("传入参数id为" + id)
int64Id, _ := strconv.ParseInt(id, 10, 64)
c.JSON(http.StatusOK, service.QueryDrafting(int32(int64Id)))
}
// 草稿另存为
// 修改草稿信息
//
// @Summary 草稿另存为
// @Summary 修改草稿信息
//
// @Security JwtAuth
//
// @Description 草稿另存为
// @Description 修改草稿信息
// @Tags 草稿Api
// @Accept json
// @Produce json
@ -160,16 +176,22 @@ func queryDraftingInfo(c *gin.Context) {
func updateDraftingInfo(c *gin.Context) {
id, exist := c.Params.Get("id")
if !exist {
panic("必要参数id不存在")
c.JSON(http.StatusBadRequest, "必要参数id不存在")
return
}
zap.S().Debug("传入参数id为" + id)
req := dto.DraftingDto{}
if err := c.ShouldBind(&req); err != nil {
zap.S().Warn("保存数据出错", err)
c.JSON(http.StatusBadRequest, "保存参数出错")
return
}
int64Id, _ := strconv.ParseInt(id, 10, 64)
service.UpdateDrafting(int32(int64Id), &req)
c.Status(http.StatusOK)
result := service.UpdateDrafting(int32(int64Id), &req)
if !result {
c.JSON(http.StatusInternalServerError, "保存参数出错")
return
}
c.JSON(http.StatusOK, result)
}
// 删除草稿数据
@ -194,8 +216,10 @@ func deleteDrafting(c *gin.Context) {
idStr := c.Param("id")
id, err := strconv.Atoi(idStr)
if err != nil {
c.JSON(http.StatusBadRequest, "id参数解析错误")
panic("id参数解析错误")
}
zap.S().Debug("id查询草稿的图形数据", id)
service.DeleteDraftingById(id)
c.JSON(http.StatusOK, true)
}

View File

@ -1,22 +1,67 @@
package api
import (
"net/http"
jwt "github.com/appleboy/gin-jwt/v2"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
"joylink.club/bj-rtsts-server/db/model"
"joylink.club/bj-rtsts-server/dto"
"joylink.club/bj-rtsts-server/middleware"
"joylink.club/bj-rtsts-server/service"
"net/http"
)
func InitUserRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
unauthed := api.Group("/v1/user")
unauthed.POST("/login", login(authMiddleware))
unauthed.POST("/register", register)
authed := api.Group("/v1/user").Use(authMiddleware.MiddlewareFunc())
authed.GET("/paging", pageQueryUser)
authed.GET("/current", findUserInfo)
}
// 用户注册
//
// @Summary 用户注册
// @Description 用户注册
// @Tags 用户Api
// @Accept json
// @Produce json
// @Param loginInfo body dto.RegisterUser true "用户注册信息"
// @Success 200 {object} string
// @Failure 500 {object} dto.ErrorDto
// @Router /api/v1/user/register [post]
func register(c *gin.Context) {
user := &dto.RegisterUser{}
err := c.BindJSON(user)
if err != nil {
zap.S().Warn("用户注册失败", err)
}
service.Register(user)
c.JSON(http.StatusOK, "ok")
}
// 获取当前登录用户信息
//
// @Summary 获取当前登录用户信息
// @Description 获取当前登录用户信息
// @Tags 用户Api
// @Accept json
// @Produce json
//
// @Param Authorization header string true "JWT Token"
//
// @Success 200 {object} dto.RegisterUser
// @Failure 500 {object} dto.ErrorDto
// @Router /api/v1/user/current [get]
func findUserInfo(c *gin.Context) {
user, _ := c.Get(middleware.IdentityKey)
//createId := user.(model.User).ID
userId := user.(*model.User).ID
userInfo := service.FindUserInfo(userId)
c.JSON(http.StatusOK, userInfo)
}
// 用户登录

View File

@ -98,6 +98,15 @@ const docTemplate = `{
"草稿Api"
],
"summary": "查询草稿详情",
"parameters": [
{
"type": "integer",
"description": "草稿ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
@ -143,6 +152,13 @@ const docTemplate = `{
],
"summary": "草稿另存为",
"parameters": [
{
"type": "integer",
"description": "草稿ID",
"name": "id",
"in": "path",
"required": true
},
{
"type": "integer",
"name": "id",
@ -186,6 +202,56 @@ const docTemplate = `{
}
}
}
},
"delete": {
"security": [
{
"JwtAuth": []
}
],
"description": "删除草稿数据",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"草稿Api"
],
"summary": "删除草稿数据",
"parameters": [
{
"type": "integer",
"description": "草稿ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK"
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
}
},
"/api/v1/drafting/:id/saveAs": {
@ -207,6 +273,13 @@ const docTemplate = `{
],
"summary": "草稿另存为",
"parameters": [
{
"type": "integer",
"description": "源草稿id",
"name": "id",
"in": "path",
"required": true
},
{
"type": "integer",
"name": "id",
@ -419,6 +492,13 @@ const docTemplate = `{
],
"summary": "分页查询发布的图形数据",
"parameters": [
{
"type": "string",
"description": "JWT Token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"type": "string",
"name": "name",
@ -487,6 +567,13 @@ const docTemplate = `{
],
"summary": "从草稿发布数据",
"parameters": [
{
"type": "string",
"description": "JWT Token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"type": "integer",
"description": "草稿数据的id",
@ -550,6 +637,13 @@ const docTemplate = `{
],
"summary": "id查询发布的图形数据",
"parameters": [
{
"type": "string",
"description": "JWT Token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"type": "integer",
"description": "id",
@ -603,6 +697,13 @@ const docTemplate = `{
],
"summary": "id查询发布的图形数据",
"parameters": [
{
"type": "string",
"description": "JWT Token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"type": "integer",
"description": "id",
@ -636,6 +737,44 @@ const docTemplate = `{
}
}
},
"/api/v1/user/current": {
"get": {
"description": "获取当前登录用户信息",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"用户Api"
],
"summary": "获取当前登录用户信息",
"parameters": [
{
"type": "string",
"description": "JWT Token",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.RegisterUser"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
}
},
"/api/v1/user/login": {
"post": {
"description": "用户登录",
@ -751,6 +890,46 @@ const docTemplate = `{
}
}
}
},
"/api/v1/user/register": {
"post": {
"description": "用户注册",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"用户Api"
],
"summary": "用户注册",
"parameters": [
{
"description": "用户注册信息",
"name": "loginInfo",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.RegisterUser"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "string"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
}
}
},
"definitions": {
@ -825,6 +1004,30 @@ const docTemplate = `{
}
}
},
"dto.RegisterUser": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"mobile": {
"description": "手机号",
"type": "string"
},
"name": {
"description": "名字",
"type": "string"
},
"password": {
"description": "密码",
"type": "string"
},
"register_time": {
"description": "注册时间",
"type": "string"
}
}
},
"dto.TokenRespDto": {
"type": "object",
"properties": {

View File

@ -91,6 +91,15 @@
"草稿Api"
],
"summary": "查询草稿详情",
"parameters": [
{
"type": "integer",
"description": "草稿ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
@ -136,6 +145,13 @@
],
"summary": "草稿另存为",
"parameters": [
{
"type": "integer",
"description": "草稿ID",
"name": "id",
"in": "path",
"required": true
},
{
"type": "integer",
"name": "id",
@ -179,6 +195,56 @@
}
}
}
},
"delete": {
"security": [
{
"JwtAuth": []
}
],
"description": "删除草稿数据",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"草稿Api"
],
"summary": "删除草稿数据",
"parameters": [
{
"type": "integer",
"description": "草稿ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK"
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
}
},
"/api/v1/drafting/:id/saveAs": {
@ -200,6 +266,13 @@
],
"summary": "草稿另存为",
"parameters": [
{
"type": "integer",
"description": "源草稿id",
"name": "id",
"in": "path",
"required": true
},
{
"type": "integer",
"name": "id",
@ -412,6 +485,13 @@
],
"summary": "分页查询发布的图形数据",
"parameters": [
{
"type": "string",
"description": "JWT Token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"type": "string",
"name": "name",
@ -480,6 +560,13 @@
],
"summary": "从草稿发布数据",
"parameters": [
{
"type": "string",
"description": "JWT Token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"type": "integer",
"description": "草稿数据的id",
@ -543,6 +630,13 @@
],
"summary": "id查询发布的图形数据",
"parameters": [
{
"type": "string",
"description": "JWT Token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"type": "integer",
"description": "id",
@ -596,6 +690,13 @@
],
"summary": "id查询发布的图形数据",
"parameters": [
{
"type": "string",
"description": "JWT Token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"type": "integer",
"description": "id",
@ -629,6 +730,44 @@
}
}
},
"/api/v1/user/current": {
"get": {
"description": "获取当前登录用户信息",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"用户Api"
],
"summary": "获取当前登录用户信息",
"parameters": [
{
"type": "string",
"description": "JWT Token",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.RegisterUser"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
}
},
"/api/v1/user/login": {
"post": {
"description": "用户登录",
@ -744,6 +883,46 @@
}
}
}
},
"/api/v1/user/register": {
"post": {
"description": "用户注册",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"用户Api"
],
"summary": "用户注册",
"parameters": [
{
"description": "用户注册信息",
"name": "loginInfo",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.RegisterUser"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "string"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
}
}
},
"definitions": {
@ -818,6 +997,30 @@
}
}
},
"dto.RegisterUser": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"mobile": {
"description": "手机号",
"type": "string"
},
"name": {
"description": "名字",
"type": "string"
},
"password": {
"description": "密码",
"type": "string"
},
"register_time": {
"description": "注册时间",
"type": "string"
}
}
},
"dto.TokenRespDto": {
"type": "object",
"properties": {

View File

@ -50,6 +50,23 @@ definitions:
- page
- size
type: object
dto.RegisterUser:
properties:
id:
type: integer
mobile:
description: 手机号
type: string
name:
description: 名字
type: string
password:
description: 密码
type: string
register_time:
description: 注册时间
type: string
type: object
dto.TokenRespDto:
properties:
code:
@ -150,10 +167,48 @@ paths:
tags:
- 草稿Api
/api/v1/drafting/:id:
delete:
consumes:
- application/json
description: 删除草稿数据
parameters:
- description: 草稿ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
"401":
description: Unauthorized
schema:
$ref: '#/definitions/dto.ErrorDto'
"404":
description: Not Found
schema:
$ref: '#/definitions/dto.ErrorDto'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/dto.ErrorDto'
security:
- JwtAuth: []
summary: 删除草稿数据
tags:
- 草稿Api
get:
consumes:
- application/json
description: 查询草稿详情
parameters:
- description: 草稿ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
@ -183,6 +238,11 @@ paths:
- application/json
description: 草稿另存为
parameters:
- description: 草稿ID
in: path
name: id
required: true
type: integer
- in: query
name: id
type: integer
@ -223,6 +283,11 @@ paths:
- application/json
description: 草稿另存为
parameters:
- description: 源草稿id
in: path
name: id
required: true
type: integer
- in: query
name: id
type: integer
@ -308,6 +373,11 @@ paths:
- application/json
description: 可以通过名称过滤
parameters:
- description: JWT Token
in: header
name: Authorization
required: true
type: string
- description: id
in: path
name: id
@ -340,6 +410,11 @@ paths:
- application/json
description: 可以通过名称过滤
parameters:
- description: JWT Token
in: header
name: Authorization
required: true
type: string
- description: id
in: path
name: id
@ -427,6 +502,11 @@ paths:
- application/json
description: 可以通过名称过滤
parameters:
- description: JWT Token
in: header
name: Authorization
required: true
type: string
- in: query
name: name
type: string
@ -471,6 +551,11 @@ paths:
consumes:
- application/json
parameters:
- description: JWT Token
in: header
name: Authorization
required: true
type: string
- description: 草稿数据的id
in: query
name: draftId
@ -505,6 +590,31 @@ paths:
summary: 从草稿发布数据
tags:
- 发布的图形数据Api
/api/v1/user/current:
get:
consumes:
- application/json
description: 获取当前登录用户信息
parameters:
- description: JWT Token
in: header
name: Authorization
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/dto.RegisterUser'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/dto.ErrorDto'
summary: 获取当前登录用户信息
tags:
- 用户Api
/api/v1/user/login:
post:
consumes:
@ -581,6 +691,32 @@ paths:
summary: 分页查询用户
tags:
- 用户Api
/api/v1/user/register:
post:
consumes:
- application/json
description: 用户注册
parameters:
- description: 用户注册信息
in: body
name: loginInfo
required: true
schema:
$ref: '#/definitions/dto.RegisterUser'
produces:
- application/json
responses:
"200":
description: OK
schema:
type: string
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/dto.ErrorDto'
summary: 用户注册
tags:
- 用户Api
securityDefinitions:
JwtAuth:
in: header

View File

@ -1,5 +1,7 @@
package dto
import "joylink.club/bj-rtsts-server/db/model"
// 分页查询用户请求
type PageUserReqDto struct {
PageQueryDto
@ -8,3 +10,5 @@ type PageUserReqDto struct {
// 手机号
Mobile string `json:"mobile" form:"mobile"`
}
type RegisterUser = model.User

View File

@ -16,15 +16,18 @@ func PageDraftingQuery(query *dto.PageDraftingReqDto) (*dto.PageDto, error) {
if query.Name != "" {
dq = dq.Where(d.Name.Like(fmt.Sprintf("%%%s%%", query.Name)))
}
records, total, err := dq.Debug().FindByPage(query.Offset(), query.Size)
records, total, err := dq.Debug().Select(d.ID, d.Name, d.UpdateAt, d.CreatedAt, d.CreatorID).FindByPage(query.Offset(), query.Size)
if err != nil {
panic(err)
}
return &dto.PageDto{Total: int(total), PageQueryDto: query.PageQueryDto, Records: records}, err
return &dto.PageDto{Total: int(total), PageQueryDto: query.PageQueryDto, Records: records}, nil
}
// 创建草稿
func CreateDrafting(createId int32, dto *dto.DraftingDto) error {
func CreateDrafting(createId int32, dto *dto.DraftingDto) (*model.Drafting, error) {
if err := checkDraftingInfo(dto.Name); err != nil {
panic(err)
}
d := model.Drafting{
Name: dto.Name,
Proto: dto.Proto,
@ -32,18 +35,22 @@ func CreateDrafting(createId int32, dto *dto.DraftingDto) error {
CreatedAt: time.Now(),
UpdateAt: time.Now(),
}
return dbquery.Drafting.Save(&d)
err := dbquery.Drafting.Save(&d)
if err != nil {
panic(err)
}
return dbquery.Drafting.Where(
dbquery.Drafting.Name.Eq(dto.Name),
dbquery.Drafting.CreatorID.Eq(createId),
).Order(dbquery.Drafting.CreatedAt).Debug().First()
}
// 另存为
func SaveAsDrafting(createId int32, oldId int32, dto *dto.DraftingDto) error {
findNameQuery := dbquery.Drafting
count, err := findNameQuery.Where(findNameQuery.Name.Eq(dto.Name)).Debug().Count()
if count > 0 || err != nil {
panic("名称已存在")
func SaveAsDrafting(createId int32, oldId int32, dto *dto.DraftingDto) (*model.Drafting, error) {
if err := checkDraftingInfo(dto.Name); err != nil {
return nil, err
}
findOldQuery := dbquery.Drafting
oldD, err := findOldQuery.Where(findOldQuery.ID.Eq(oldId)).Debug().First()
oldD, err := dbquery.Drafting.Where(dbquery.Drafting.ID.Eq(oldId)).Debug().First()
if oldD == nil || err != nil {
panic(err)
}
@ -54,19 +61,25 @@ func SaveAsDrafting(createId int32, oldId int32, dto *dto.DraftingDto) error {
CreatedAt: time.Now(),
UpdateAt: time.Now(),
}
return dbquery.Drafting.Save(&newD)
if err = dbquery.Drafting.Save(&newD); err != nil {
panic(err)
}
return dbquery.Drafting.Where(
dbquery.Drafting.Name.Eq(dto.Name),
dbquery.Drafting.CreatorID.Eq(createId),
).Order(dbquery.Drafting.CreatedAt).Debug().First()
}
func QueryDrafting(id int32) model.Drafting {
func QueryDrafting(id int32) *model.Drafting {
query := dbquery.Drafting
data, err := query.Where(query.ID.Eq(id)).Debug().First()
if err != nil {
panic(err)
}
return *data
return data
}
func UpdateDrafting(id int32, dto *dto.DraftingDto) error {
func UpdateDrafting(id int32, dto *dto.DraftingDto) bool {
findOldQuery := dbquery.Drafting
oldD, err := findOldQuery.Where(findOldQuery.ID.Eq(id)).Debug().First()
if oldD == nil || err != nil {
@ -80,9 +93,24 @@ func UpdateDrafting(id int32, dto *dto.DraftingDto) error {
}
oldD.UpdateAt = time.Now()
_, error := dbquery.Drafting.Updates(oldD)
return error
if error != nil {
panic(error)
}
return true
}
func DeleteDraftingById(id int) {
_, _ = dbquery.Drafting.Debug().Where(dbquery.Drafting.ID.Eq(int32(id))).Delete()
}
func checkDraftingInfo(name string) error {
findNameQuery := dbquery.Drafting
count, err := findNameQuery.Where(findNameQuery.Name.Eq(name)).Debug().Count()
if err != nil {
panic(err)
}
if count > 0 {
panic("名称已存在")
}
return err
}

View File

@ -2,9 +2,10 @@ package service
import (
"fmt"
"go.uber.org/zap"
"joylink.club/bj-rtsts-server/db/dbquery"
"joylink.club/bj-rtsts-server/dto"
"time"
)
// 分页查询用户列表
@ -23,3 +24,42 @@ func PagingQueryUser(query *dto.PageUserReqDto) (*dto.PageDto, error) {
}
return &dto.PageDto{Total: int(total), PageQueryDto: query.PageQueryDto, Records: records}, err
}
func Register(user *dto.RegisterUser) error {
defer func() {
err := recover()
if err != nil {
zap.S().Warn("用户注册失败", err)
panic(err)
}
}()
u := dbquery.User
uq := u.Where()
uq = uq.Where(u.Mobile.Eq(user.Mobile))
findUsers, err := uq.Find()
if len(findUsers) > 0 {
panic("重复的手机号")
}
user.RegisterTime = time.Now()
u.Save(user)
return err
}
func FindUserInfo(userId int32) *dto.RegisterUser {
defer func() {
err := recover()
if err != nil {
zap.S().Warn("用户详情查找错误 userId:"+string(userId), err)
panic(err)
}
}()
u := dbquery.User
uq := u.Where()
uq = uq.Where(u.ID.Eq(userId))
user, _ := uq.First()
if user == nil {
panic("没有获取到对应的用户信息")
}
return user
}