mirror of
https://gitee.com/blackfox/geekai.git
synced 2024-12-02 12:17:42 +08:00
feat: add nickname field for user
This commit is contained in:
parent
3d2035d08a
commit
3c6e86d04b
@ -155,7 +155,7 @@ func authorizeMiddleware(s *AppServer, client *redis.Client) gin.HandlerFunc {
|
||||
c.Request.URL.Path == "/api/invite/hits" ||
|
||||
c.Request.URL.Path == "/api/sd/jobs" ||
|
||||
c.Request.URL.Path == "/api/upload" ||
|
||||
strings.HasPrefix(c.Request.URL.Path, "/test/") ||
|
||||
strings.HasPrefix(c.Request.URL.Path, "/api/test") ||
|
||||
strings.HasPrefix(c.Request.URL.Path, "/api/function/") ||
|
||||
strings.HasPrefix(c.Request.URL.Path, "/api/sms/") ||
|
||||
strings.HasPrefix(c.Request.URL.Path, "/api/captcha/") ||
|
||||
|
@ -1,40 +1,34 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"chatplus/service"
|
||||
"chatplus/store/model"
|
||||
"chatplus/utils"
|
||||
"chatplus/utils/resp"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type TestHandler struct {
|
||||
snowflake *service.Snowflake
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewTestHandler(snowflake *service.Snowflake) *TestHandler {
|
||||
return &TestHandler{snowflake: snowflake}
|
||||
func NewTestHandler(db *gorm.DB) *TestHandler {
|
||||
return &TestHandler{db: db}
|
||||
}
|
||||
|
||||
func (h *TestHandler) TestPay(c *gin.Context) {
|
||||
//appId := "" //Appid
|
||||
//appSecret := "" //密钥
|
||||
//var host = "https://api.xunhupay.com/payment/do.html" //跳转支付页接口URL
|
||||
//client := payment.NewXunHuPay(appId, appSecret) //初始化调用
|
||||
//
|
||||
////支付参数,appid、time、nonce_str和hash这四个参数不用传,调用的时候执行方法内部已经处理
|
||||
//orderNo, _ := h.snowflake.Next()
|
||||
//params := map[string]string{
|
||||
// "version": "1.1",
|
||||
// "trade_order_id": orderNo,
|
||||
// "total_fee": "0.1",
|
||||
// "title": "测试支付",
|
||||
// "notify_url": "http://xxxxxxx.com",
|
||||
// "return_url": "http://localhost:8888",
|
||||
// "wap_name": "极客学长",
|
||||
// "callback_url": "",
|
||||
//}
|
||||
//
|
||||
//execute, err := client.Execute(host, params) //执行支付操作
|
||||
//if err != nil {
|
||||
// logger.Error(err)
|
||||
//}
|
||||
//resp.SUCCESS(c, execute)
|
||||
func (h *TestHandler) Test(c *gin.Context) {
|
||||
var users []model.User
|
||||
tx := h.db.Find(&users)
|
||||
if tx.Error != nil {
|
||||
resp.ERROR(c, tx.Error.Error())
|
||||
return
|
||||
}
|
||||
|
||||
for _, u := range users {
|
||||
u.Nickname = fmt.Sprintf("极客学长@%d", utils.RandomNumber(6))
|
||||
h.db.Updates(&u)
|
||||
}
|
||||
|
||||
resp.SUCCESS(c)
|
||||
}
|
||||
|
@ -95,6 +95,7 @@ func (h *UserHandler) Register(c *gin.Context) {
|
||||
salt := utils.RandString(8)
|
||||
user := model.User{
|
||||
Password: utils.GenPassword(data.Password, salt),
|
||||
Nickname: fmt.Sprintf("极客学长@%d", utils.RandomNumber(6)),
|
||||
Avatar: "/images/avatar/user.png",
|
||||
Salt: salt,
|
||||
Status: true,
|
||||
@ -256,6 +257,7 @@ func (h *UserHandler) Session(c *gin.Context) {
|
||||
|
||||
type userProfile struct {
|
||||
Id uint `json:"id"`
|
||||
Nickname string `json:"nickname"`
|
||||
Mobile string `json:"mobile"`
|
||||
Avatar string `json:"avatar"`
|
||||
ChatConfig types.UserChatConfig `json:"chat_config"`
|
||||
|
@ -364,8 +364,7 @@ func main() {
|
||||
|
||||
fx.Provide(handler.NewTestHandler),
|
||||
fx.Invoke(func(s *core.AppServer, h *handler.TestHandler) {
|
||||
group := s.Engine.Group("/test/")
|
||||
group.GET("pay", h.TestPay)
|
||||
s.Engine.GET("/api/test", h.Test)
|
||||
}),
|
||||
fx.Invoke(func(s *core.AppServer, db *gorm.DB) {
|
||||
err := s.Run(db)
|
||||
|
@ -3,6 +3,7 @@ package model
|
||||
type User struct {
|
||||
BaseModel
|
||||
Mobile string
|
||||
Nickname string
|
||||
Password string
|
||||
Avatar string
|
||||
Salt string // 密码盐
|
||||
|
@ -5,6 +5,7 @@ import "chatplus/core/types"
|
||||
type User struct {
|
||||
BaseVo
|
||||
Mobile string `json:"mobile"`
|
||||
Nickname string `json:"nickname"`
|
||||
Avatar string `json:"avatar"`
|
||||
Salt string `json:"salt"` // 密码盐
|
||||
TotalTokens int64 `json:"total_tokens"` // 总消耗tokens
|
||||
|
1
database/update-v3.2.4.sql
Normal file
1
database/update-v3.2.4.sql
Normal file
@ -0,0 +1 @@
|
||||
ALTER TABLE `chatgpt_users` ADD `nickname` VARCHAR(30) NOT NULL COMMENT '昵称' AFTER `mobile`;
|
@ -14,7 +14,10 @@
|
||||
</el-icon>
|
||||
</el-upload>
|
||||
</el-row>
|
||||
<el-form-item label="账户">
|
||||
<el-form-item label="昵称">
|
||||
{{ user['nickname'] }}
|
||||
</el-form-item>
|
||||
<el-form-item label="手机号">
|
||||
<span>{{ user.mobile }}</span>
|
||||
<el-tooltip
|
||||
class="box-item"
|
||||
|
@ -43,7 +43,7 @@
|
||||
<el-dropdown :hide-on-click="true" class="user-info" trigger="click" v-if="isLogin">
|
||||
<span class="el-dropdown-link">
|
||||
<el-image :src="loginUser.avatar"/>
|
||||
<span class="username">{{ '极客学长@' + loginUser.mobile }}</span>
|
||||
<span class="username">{{ loginUser.nickname }}</span>
|
||||
<el-icon><ArrowDown/></el-icon>
|
||||
</span>
|
||||
<template #dropdown>
|
||||
@ -105,12 +105,12 @@
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
<el-button type="primary" @click="newChat">
|
||||
<el-icon>
|
||||
<Plus/>
|
||||
</el-icon>
|
||||
新建对话
|
||||
</el-button>
|
||||
<el-button type="primary" @click="newChat">
|
||||
<el-icon>
|
||||
<Plus/>
|
||||
</el-icon>
|
||||
新建对话
|
||||
</el-button>
|
||||
|
||||
<el-button type="success" @click="exportChat" plain>
|
||||
<i class="iconfont icon-export"></i>
|
||||
|
Loading…
Reference in New Issue
Block a user