mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-09-23 03:36:39 +08:00
fix: can not change user's power in admin console
This commit is contained in:
parent
491471fa10
commit
870706c4ff
@ -56,6 +56,13 @@ WeChatBot = false
|
|||||||
AccessSecret = ""
|
AccessSecret = ""
|
||||||
Bucket = ""
|
Bucket = ""
|
||||||
Domain = "" # OSS Bucket 所绑定的域名,如 https://img.r9it.com
|
Domain = "" # OSS Bucket 所绑定的域名,如 https://img.r9it.com
|
||||||
|
[OSS.AliYun]
|
||||||
|
Endpoint = "oss-cn-hangzhou.aliyuncs.com"
|
||||||
|
AccessKey = ""
|
||||||
|
AccessSecret = ""
|
||||||
|
Bucket = "chatgpt-plus"
|
||||||
|
SubDir = ""
|
||||||
|
Domain = ""
|
||||||
|
|
||||||
[[MjConfigs]]
|
[[MjConfigs]]
|
||||||
Enabled = false
|
Enabled = false
|
||||||
|
@ -151,6 +151,7 @@ type SystemConfig struct {
|
|||||||
PowerPrice float64 `json:"power_price,omitempty"` // 算力单价
|
PowerPrice float64 `json:"power_price,omitempty"` // 算力单价
|
||||||
|
|
||||||
OrderPayTimeout int `json:"order_pay_timeout,omitempty"` //订单支付超时时间
|
OrderPayTimeout int `json:"order_pay_timeout,omitempty"` //订单支付超时时间
|
||||||
|
VipInfoText string `json:"vip_info_text"` // 会员页面充值说明
|
||||||
DefaultModels []int `json:"default_models,omitempty"` // 默认开通的 AI 模型
|
DefaultModels []int `json:"default_models,omitempty"` // 默认开通的 AI 模型
|
||||||
|
|
||||||
MjPower int `json:"mj_power,omitempty"` // MJ 绘画消耗算力
|
MjPower int `json:"mj_power,omitempty"` // MJ 绘画消耗算力
|
||||||
|
@ -89,7 +89,7 @@ func (h *UserHandler) Save(c *gin.Context) {
|
|||||||
resp.ERROR(c, "user not found")
|
resp.ERROR(c, "user not found")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var changePower = user.Power != data.Power
|
var oldPower = user.Power
|
||||||
user.Username = data.Username
|
user.Username = data.Username
|
||||||
user.Status = data.Status
|
user.Status = data.Status
|
||||||
user.Vip = data.Vip
|
user.Vip = data.Vip
|
||||||
@ -98,22 +98,28 @@ func (h *UserHandler) Save(c *gin.Context) {
|
|||||||
user.ChatModels = utils.JsonEncode(data.ChatModels)
|
user.ChatModels = utils.JsonEncode(data.ChatModels)
|
||||||
user.ExpiredTime = utils.Str2stamp(data.ExpiredTime)
|
user.ExpiredTime = utils.Str2stamp(data.ExpiredTime)
|
||||||
|
|
||||||
res = h.DB.Updates(&user)
|
res = h.DB.Select("username", "status", "vip", "power", "chat_roles_json", "chat_models_json", "expired_time").Updates(&user)
|
||||||
if res.Error != nil {
|
if res.Error != nil {
|
||||||
resp.ERROR(c, "更新数据库失败!")
|
resp.ERROR(c, "更新数据库失败!")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 记录算力日志
|
// 记录算力日志
|
||||||
if changePower {
|
if oldPower != user.Power {
|
||||||
|
mark := types.PowerAdd
|
||||||
|
amount := user.Power - oldPower
|
||||||
|
if oldPower > user.Power {
|
||||||
|
mark = types.PowerSub
|
||||||
|
amount = oldPower - user.Power
|
||||||
|
}
|
||||||
h.DB.Create(&model.PowerLog{
|
h.DB.Create(&model.PowerLog{
|
||||||
UserId: user.Id,
|
UserId: user.Id,
|
||||||
Username: user.Username,
|
Username: user.Username,
|
||||||
Type: types.PowerGift,
|
Type: types.PowerGift,
|
||||||
Amount: user.Power,
|
Amount: amount,
|
||||||
Balance: user.Power,
|
Balance: user.Power,
|
||||||
Mark: types.PowerAdd,
|
Mark: mark,
|
||||||
Model: "管理员",
|
Model: "管理员",
|
||||||
Remark: fmt.Sprintf("后台管理员强制修改用户算力,修改值:%d, 管理员ID:%d", user.Power, h.GetLoginUserId(c)),
|
Remark: fmt.Sprintf("后台管理员强制修改用户算力,修改前:%d,修改后:%d, 管理员ID:%d", oldPower, user.Power, h.GetLoginUserId(c)),
|
||||||
CreatedAt: time.Now(),
|
CreatedAt: time.Now(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,13 @@ WeChatBot = false
|
|||||||
AccessSecret = ""
|
AccessSecret = ""
|
||||||
Bucket = ""
|
Bucket = ""
|
||||||
Domain = "" # OSS Bucket 所绑定的域名,如 https://img.r9it.com
|
Domain = "" # OSS Bucket 所绑定的域名,如 https://img.r9it.com
|
||||||
|
[OSS.AliYun]
|
||||||
|
Endpoint = "oss-cn-hangzhou.aliyuncs.com"
|
||||||
|
AccessKey = ""
|
||||||
|
AccessSecret = ""
|
||||||
|
Bucket = "chatgpt-plus"
|
||||||
|
SubDir = ""
|
||||||
|
Domain = ""
|
||||||
|
|
||||||
[[MjConfigs]]
|
[[MjConfigs]]
|
||||||
Enabled = false
|
Enabled = false
|
||||||
|
@ -31,10 +31,12 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
|
|
||||||
import {useRouter} from "vue-router";
|
import {useRouter} from "vue-router";
|
||||||
import {ref} from "vue";
|
import {onMounted, ref} from "vue";
|
||||||
|
import {httpGet} from "@/utils/http";
|
||||||
|
import {ElMessage} from "element-plus";
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const logo = '/images/logo.png';
|
const logo = ref('/images/logo.png');
|
||||||
const navs = ref([
|
const navs = ref([
|
||||||
{path: "/chat", icon_path: "/images/chat.png", title: "对话聊天"},
|
{path: "/chat", icon_path: "/images/chat.png", title: "对话聊天"},
|
||||||
{path: "/mj", icon_path: "/images/mj.png", title: "MJ 绘画"},
|
{path: "/mj", icon_path: "/images/mj.png", title: "MJ 绘画"},
|
||||||
@ -51,6 +53,14 @@ const changeNav = (item) => {
|
|||||||
curPath.value = item.path
|
curPath.value = item.path
|
||||||
router.push(item.path)
|
router.push(item.path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
httpGet("/api/config/get?key=system").then(res => {
|
||||||
|
logo.value = res.data['logo']
|
||||||
|
}).catch(e => {
|
||||||
|
ElMessage.error("获取系统配置失败:" + e.message)
|
||||||
|
})
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="stylus" scoped>
|
<style lang="stylus" scoped>
|
||||||
|
@ -107,7 +107,7 @@ const hits = ref(0)
|
|||||||
const regNum = ref(0)
|
const regNum = ref(0)
|
||||||
const rate = ref(0)
|
const rate = ref(0)
|
||||||
const isLogin = ref(false)
|
const isLogin = ref(false)
|
||||||
const showLoginDialog = ref(true)
|
const showLoginDialog = ref(false)
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
initData()
|
initData()
|
||||||
@ -152,6 +152,7 @@ const initData = () => {
|
|||||||
ElMessage.error("获取系统配置失败:" + e.message)
|
ElMessage.error("获取系统配置失败:" + e.message)
|
||||||
})
|
})
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
|
showLoginDialog.value = true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -36,8 +36,7 @@
|
|||||||
<div class="product-box">
|
<div class="product-box">
|
||||||
<div class="info" v-if="orderPayInfoText !== ''">
|
<div class="info" v-if="orderPayInfoText !== ''">
|
||||||
<el-alert type="success" show-icon :closable="false" effect="dark">
|
<el-alert type="success" show-icon :closable="false" effect="dark">
|
||||||
<strong>说明:</strong> 月度会员,年度会员每月赠送 {{ vipMonthPower }} 点算力,赠送算力当月有效,当月没有消费完的算力不结余到下个月。
|
<strong>说明:</strong> {{ vipInfoText }}
|
||||||
点卡充值的算力长期有效。
|
|
||||||
</el-alert>
|
</el-alert>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -208,6 +207,7 @@ const payWays = ref({})
|
|||||||
const amount = ref(0)
|
const amount = ref(0)
|
||||||
const payName = ref("支付宝")
|
const payName = ref("支付宝")
|
||||||
const curPay = ref("alipay") // 当前支付方式
|
const curPay = ref("alipay") // 当前支付方式
|
||||||
|
const vipInfoText = ref("")
|
||||||
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
@ -233,6 +233,7 @@ onMounted(() => {
|
|||||||
}
|
}
|
||||||
vipMonthPower.value = res.data['vip_month_power']
|
vipMonthPower.value = res.data['vip_month_power']
|
||||||
powerPrice.value = res.data['power_price']
|
powerPrice.value = res.data['power_price']
|
||||||
|
vipInfoText.value = res.data['vip_info_text']
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
ElMessage.error("获取系统配置失败:" + e.message)
|
ElMessage.error("获取系统配置失败:" + e.message)
|
||||||
})
|
})
|
||||||
|
@ -147,6 +147,24 @@
|
|||||||
</div>
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="会员充值说明" prop="order_pay_timeout">
|
||||||
|
<div class="tip-input">
|
||||||
|
<el-input v-model="system['vip_info_text']" placeholder=""/>
|
||||||
|
<div class="info">
|
||||||
|
<el-tooltip
|
||||||
|
effect="dark"
|
||||||
|
content="会员充值页面的充值说明文字"
|
||||||
|
raw-content
|
||||||
|
placement="right"
|
||||||
|
>
|
||||||
|
<el-icon>
|
||||||
|
<InfoFilled/>
|
||||||
|
</el-icon>
|
||||||
|
</el-tooltip>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item label="默认AI模型" prop="default_models">
|
<el-form-item label="默认AI模型" prop="default_models">
|
||||||
<template #default>
|
<template #default>
|
||||||
<div class="tip-input">
|
<div class="tip-input">
|
||||||
|
Loading…
Reference in New Issue
Block a user