This commit is contained in:
Putoo
2026-05-31 16:04:39 +08:00
parent 6fac30c242
commit 3e6fde3681
19 changed files with 560 additions and 16 deletions

View File

@@ -35,5 +35,11 @@ namespace Application.Domain.Entity
/// </summary>
[SugarColumn(IsNullable = true)]
public int? autoDrug { get; set; }
/// <summary>
/// 0 不限制赠送 1限制好友赠送
/// </summary>
[SugarColumn(IsNullable = true)]
public int? giveRole { get; set; }
}
}

View File

@@ -9,8 +9,10 @@ public static class GameConfig
public const int SendChatGoodsService = 10002;//金海螺
public const int UpLevAddWeight = 10;//升级增加负重
public const int GameBaseVigour = 50;//初始活力
public const int GameRelationEnemyNeedGold = 50;//添加仇人所需金元
public const int GameRelationEnemyNeedGold = 300;//添加仇人所需金元
public const int GameUpdateNickNeedGoods = 10001;//更新昵称所需道具
public const int GameUpdateSexNeedGoods = 10001;//更新性别所需道具
public const int GameUserFriendMaxCount = 50;//好友最大上限人数
public const int GameAutoBagGoodsId = 10001;//百宝箱物品ID
public const int GameAutoDrugGoodsId = 10001;//急救箱物品ID
}

View File

@@ -13,5 +13,6 @@ public static class UserEnum
ChatRole,
AutoBag,
AutoDrug,
GiveRole,
}
}

View File

@@ -206,6 +206,7 @@ public class UnitUserService(ISqlSugarClient DbClient, IRedisCache redis) : IUni
config.chatRole = 0;
config.autoBag = -1;
config.autoDrug = -1;
config.giveRole = 0;
db.Insertable(config).AddQueue();
//注册个人血量
@@ -355,6 +356,7 @@ public class UnitUserService(ISqlSugarClient DbClient, IRedisCache redis) : IUni
.SetColumnsIF(code == "ChatRole", it => it.chatRole == state)
.SetColumnsIF(code == "AutoBag", it => it.autoBag == state)
.SetColumnsIF(code == "AutoDrug", it => it.autoDrug == state)
.SetColumnsIF(code == "GiveRole", it => it.giveRole == state)
.Where(it => it.userId == userId).ExecuteCommandAsync() > 0;
if (result)
{

View File

@@ -0,0 +1,193 @@
using Microsoft.AspNetCore.Mvc;
namespace Application.Web.Controllers.User;
/// <summary>
/// 设置接口
/// </summary>
[ApiExplorerSettings(GroupName = "User")]
[Route("User/[controller]/[action]")]
[ApiController]
[Authorize]
public class SettingController : ControllerBase
{
private readonly IUnitUserService _userService;
private readonly IGameGoodsService _goodsService;
public SettingController(IUnitUserService userService,IGameGoodsService goodsService)
{
_userService = userService;
_goodsService = goodsService;
}
/// <summary>
/// 获取个人配置
/// </summary>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> GetUserConfig(int type)
{
int result = 0;
string userId = StateHelper.userId;
var data = await _userService.GetUserConfigInfo(userId);
switch (type)
{
case 0:
result = (int)data.friendRole;
break;
case 1:
result = (int)data.giveRole;
break;
case 2:
result = (int)data.autoBag;
break;
case 3:
result = (int)data.autoDrug;
break;
}
return PoAction.Ok(result);
}
/// <summary>
/// 设置配置
/// </summary>
/// <param name="type"></param>
/// <param name="state"></param>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> UpdateUserConfig(int type, int state)
{
string userId = StateHelper.userId;
if (type == 0)
{
int[] target = [0, 1, 2];
if (target.Contains(state))
{
if (await _userService.UpdateUserConfigInfo(userId, nameof(UserEnum.ConfigCode.FriendRole), state))
{
return PoAction.Ok(true);
}
else
{
return PoAction.Message("设置失败,请稍后尝试!");
}
}
else
{
return PoAction.Message("无效的设置!");
}
}
else if (type == 1)
{
int[] target = [0, 1];
if (target.Contains(state))
{
if (await _userService.UpdateUserConfigInfo(userId, nameof(UserEnum.ConfigCode.GiveRole), state))
{
return PoAction.Ok(true);
}
else
{
return PoAction.Message("设置失败,请稍后尝试!");
}
}
else
{
return PoAction.Message("无效的设置!");
}
}
else if (type == 2)
{
int[] target = [0, 1];
if (target.Contains(state))
{
var data = await _userService.GetUserConfigInfo(userId);
if (data.autoBag == -1)//判断物品开通
{
var goodsCount = await _goodsService.GetUserGoodsCount(userId, GameConfig.GameAutoBagGoodsId);
if (goodsCount < 1)
{
return PoAction.Message("您暂无百宝箱,无法开启!");
}
if (await _goodsService.UpdateUserGoods(userId, 0, GameConfig.GameAutoBagGoodsId, 1, "使用物品"))
{
if (await _userService.UpdateUserConfigInfo(userId, nameof(UserEnum.ConfigCode.AutoBag), state))
{
return PoAction.Ok(true);
}
else
{
return PoAction.Message("开启失败,请稍后尝试!");
}
}
else
{
return PoAction.Message("开启失败,请稍后尝试!");
}
}
if (await _userService.UpdateUserConfigInfo(userId, nameof(UserEnum.ConfigCode.AutoBag), state))
{
return PoAction.Ok(true);
}
else
{
return PoAction.Message("设置失败,请稍后尝试!");
}
}
else
{
return PoAction.Message("无效的设置!");
}
}
else if (type == 3)
{
int[] target = [0, 1];
if (target.Contains(state))
{
var data = await _userService.GetUserConfigInfo(userId);
if (data.autoBag == -1)//判断物品开通
{
var goodsCount = await _goodsService.GetUserGoodsCount(userId, GameConfig.GameAutoDrugGoodsId);
if (goodsCount < 1)
{
return PoAction.Message("您暂无急救箱,无法开启!");
}
if (await _goodsService.UpdateUserGoods(userId, 0, GameConfig.GameAutoDrugGoodsId, 1, "使用物品"))
{
if (await _userService.UpdateUserConfigInfo(userId, nameof(UserEnum.ConfigCode.AutoDrug), state))
{
return PoAction.Ok(true);
}
else
{
return PoAction.Message("开启失败,请稍后尝试!");
}
}
else
{
return PoAction.Message("开启失败,请稍后尝试!");
}
}
if (await _userService.UpdateUserConfigInfo(userId, nameof(UserEnum.ConfigCode.AutoDrug), state))
{
return PoAction.Ok(true);
}
else
{
return PoAction.Message("设置失败,请稍后尝试!");
}
}
else
{
return PoAction.Message("无效的设置!");
}
}
else
{
return PoAction.Message("暂无法设置!");
}
}
}

View File

@@ -2,7 +2,6 @@
统一配置中心
*/
export class BaseConfig {
//public static BaseUrl:string="https://localhost:7198";
public static BaseUrl:string="http://192.168.0.110:5032";
public static BaseUrl:string="https://localhost:7198";
public static BaseMediaUrl:string="https://localhost:7198";
}

View File

@@ -131,10 +131,8 @@ const ChangeChat = async (typeid: string): Promise<void> => {
//删除记录
const DelChat = async (data: any) => {
MessageExtend.ShowConfirmDialogAsyc("频道管理", `您确定要删除该发言吗?`, async () => {
MessageExtend.LoadingToast("删除中...");
let result = await ChatService.DeleteChat(data.chatId);
MessageExtend.LoadingClose();
MessageExtend.ShowConfirmDialogAsyc("频道管理", `您确定要删除该发言吗?`, async () => {
let result = await ChatService.DeleteChat(data.chatId);
if (result.code == 0) {
await BindData();
MessageExtend.Notify("删除成功!", "success");

View File

@@ -6,7 +6,7 @@
{{ cityInfo.cityName }}·{{ mapInfo.mapName }}
<Abutton @click="Refresh">刷新</Abutton>
<Abar href="/task/">任务</Abar>
<Abar href="/message/">消息{{ messageCount > 0 ? "(" + messageCount + ")" : "" }}</Abar>
<Abar href="/user/message/">消息{{ messageCount > 0 ? "(" + messageCount + ")" : "" }}</Abar>
</div>
<div class="notification">

View File

@@ -17,7 +17,7 @@
<div class="module-content" v-if="type == '0' || type == '1'">
<div class="item border-btm" v-for="(item, index) in data" :key="index">
{{ PageExtend.GetPageIndex(currentPage, 10, index + 1) }}.
<Abar :href='"/message/read?id=" + item.user.userNo'>
<Abar :href='"/user/message/read?id=" + item.user.userNo'>
{{ item.user.nick }}:{{ item.sign }}</Abar>
[<Abutton @click="delTlak(item.user.userNo)">×</Abutton>]
</div>
@@ -51,7 +51,7 @@
<div class="module-content" v-if="type == '3'">
<div class="item border-btm" v-for="(item, index) in data" :key="index">
{{ PageExtend.GetPageIndex(currentPage, 10, index + 1) }}.
<Abar :href='"/message/mail?id=" + item.mailId'>
<Abar :href='"/user/message/mail?id=" + item.mailId'>
{{ item.name }}</Abar>
<span v-if="item.isRead == 0" style="color: red;font-size: 16px;">(未读)</span>
<span v-else-if="item.isGet == 0" style="color: red;font-size: 16px;">(未领取)</span>

View File

@@ -1,6 +1,6 @@
<template>
<div class="crumb-nav-large">
<Abar href="/message/">我的邮件</Abar>&gt;邮件信息
<Abar href="/user/message/">我的邮件</Abar>&gt;邮件信息
</div>
<div class="module-title">
{{ data.name }}
@@ -55,7 +55,7 @@ const BindData = async (): Promise<void> => {
}
else {
MessageExtend.ShowDialogEvent("提示", result.msg, () => {
return PageExtend.Redirect("/message");
return PageExtend.Redirect("/user/message");
}, "确认");
}
};

View File

@@ -1,6 +1,6 @@
<template>
<div class="crumb-nav-large">
<Abar href="/message">我的消息</Abar>&gt;发送消息
<Abar href="/user/message">我的消息</Abar>&gt;发送消息
</div>
<div class="module-title" v-if="user.userNo != '0'">
<Abar :href='"/user/user?no=" + user.userNo'>{{ user.nick }}</Abar> ({{ user.userNo }})
@@ -39,7 +39,7 @@
<small>[{{ TimeExtend.Format(item.addTime, "yyyy-MM-dd HH:mm:ss") }}]</small><br />
</div>
<Abar :href='"/message/log?no="+user.userNo' v-if="logs.length > 0">查看记录&gt;&gt;</Abar>
<Abar :href='"/user/message/log?no="+user.userNo' v-if="logs.length > 0">查看记录&gt;&gt;</Abar>
</div>
</template>
<script setup lang="ts">

View File

@@ -0,0 +1,83 @@
<template>
<div class="module-title">
百宝箱设置
</div>
<div class="module-content" v-if="role == -1">
您还未开启百宝箱,
<Abutton @click="OpenSetting">立即开启</Abutton>?
</div>
<div class="module-content" v-if="role != -1">
<div class="item">
当前设置:
<span v-if="role == 0">[不自动拾取物品]</span>
<span v-if="role == 1">[自动拾取物品]</span>
</div>
<div class="common">
请选择设置:<br>
<div class="item" v-if="role != 1">
<Abutton @click="UpdateState(1)">[自动拾取物品]</Abutton>
</div>
<div class="item" v-if="role != 0">
<Abutton @click="UpdateState(0)">[不自动拾取物品]</Abutton>
</div>
</div>
<div class="item"></div>
</div>
</template>
<script setup lang="ts">
definePageMeta({
layout: layout.default,
middleware: 'page-loading'
})
const role = ref(0);
onMounted(async () => {
try {
await BindData();
}
finally {
PageLoading.Close();
}
})
const BindData = async (): Promise<void> => {
let result = await SettingService.GetUserConfig(2);
if (result.code == 0) {
role.value = result.data;
}
else {
MessageExtend.ShowDialog("提示", result.msg);
}
};
const UpdateState = async (state: number) => {
MessageExtend.LoadingToast("设置中...");
let result = await SettingService.UpdateUserConfig(2, state);
MessageExtend.LoadingClose();
if (result.code == 0) {
await BindData();
MessageExtend.Notify("操作成功!", "success");
}
else {
MessageExtend.ShowDialog("设置操作", result.msg);
}
}
const OpenSetting = async () => {
MessageExtend.ShowConfirmDialogAsyc("设置操作", `您确定要开启百宝箱吗?`, async () => {
let result = await SettingService.UpdateUserConfig(2, 1);
MessageExtend.LoadingClose();
if (result.code == 0) {
await BindData();
MessageExtend.Notify("操作成功!", "success");
}
else {
MessageExtend.ShowToast(result.msg);
}
return true;
});
}
</script>

View File

@@ -0,0 +1,83 @@
<template>
<div class="module-title">
急救箱设置
</div>
<div class="module-content" v-if="role == -1">
您还未开启急救箱,
<Abutton @click="OpenSetting">立即开启</Abutton>?
</div>
<div class="module-content" v-if="role != -1">
<div class="item">
当前设置:
<span v-if="role == 0">[不自动使用药品]</span>
<span v-if="role == 1">[自动使用物品]</span>
</div>
<div class="common">
请选择设置:<br>
<div class="item" v-if="role != 1">
<Abutton @click="UpdateState(1)">[自动使用物品]</Abutton>
</div>
<div class="item" v-if="role != 0">
<Abutton @click="UpdateState(0)">[不自动使用药品]</Abutton>
</div>
</div>
<div class="item"></div>
</div>
</template>
<script setup lang="ts">
definePageMeta({
layout: layout.default,
middleware: 'page-loading'
})
const role = ref(0);
onMounted(async () => {
try {
await BindData();
}
finally {
PageLoading.Close();
}
})
const BindData = async (): Promise<void> => {
let result = await SettingService.GetUserConfig(3);
if (result.code == 0) {
role.value = result.data;
}
else {
MessageExtend.ShowDialog("提示", result.msg);
}
};
const UpdateState = async (state: number) => {
MessageExtend.LoadingToast("设置中...");
let result = await SettingService.UpdateUserConfig(3, state);
MessageExtend.LoadingClose();
if (result.code == 0) {
await BindData();
MessageExtend.Notify("操作成功!", "success");
}
else {
MessageExtend.ShowDialog("设置操作", result.msg);
}
}
const OpenSetting = async () => {
MessageExtend.ShowConfirmDialogAsyc("设置操作", `您确定要开启急救箱吗?`, async () => {
let result = await SettingService.UpdateUserConfig(3, 1);
MessageExtend.LoadingClose();
if (result.code == 0) {
await BindData();
MessageExtend.Notify("操作成功!", "success");
}
else {
MessageExtend.ShowToast(result.msg);
}
return true;
});
}
</script>

View File

@@ -0,0 +1,68 @@
<template>
<div class="module-title">
好友权限设置
</div>
<div class="module-content">
<div class="item">
当前设置:
<span v-if="role == 0">[拒绝人添加好友]</span>
<span v-if="role == 1">[验证好友请求]</span>
<span v-if="role == 2">[允许任何添加好友]</span>
</div>
<div class="common">
请选择设置:<br>
<div class="item" v-if="role != 2">
<Abutton @click="UpdateState(2)">[允许任何添加好友]</Abutton>
</div>
<div class="item" v-if="role != 1">
<Abutton @click="UpdateState(1)">[验证好友请求]</Abutton>
</div>
<div class="item" v-if="role != 0">
<Abutton @click="UpdateState(0)">[拒绝人添加好友]</Abutton>
</div>
</div>
<div class="item"></div>
</div>
</template>
<script setup lang="ts">
definePageMeta({
layout: layout.default,
middleware: 'page-loading'
})
const role = ref(0);
onMounted(async () => {
try {
await BindData();
}
finally {
PageLoading.Close();
}
})
const BindData = async (): Promise<void> => {
let result = await SettingService.GetUserConfig(0);
if (result.code == 0) {
role.value = result.data;
}
else {
MessageExtend.ShowDialog("提示", result.msg);
}
};
const UpdateState = async (state: number) => {
MessageExtend.LoadingToast("设置中...");
let result = await SettingService.UpdateUserConfig(0,state);
MessageExtend.LoadingClose();
if (result.code == 0) {
await BindData();
MessageExtend.Notify("操作成功!", "success");
}
else {
MessageExtend.ShowDialog("设置操作", result.msg);
}
}
</script>

View File

@@ -0,0 +1,64 @@
<template>
<div class="module-title">
赠送权限设置
</div>
<div class="module-content">
<div class="item">
当前设置:
<span v-if="role == 0">[任何人可赠送]</span>
<span v-if="role == 1">[仅允许好友赠送]</span>
</div>
<div class="common">
请选择设置:<br>
<div class="item" v-if="role != 1">
<Abutton @click="UpdateState(1)">[仅允许好友赠送]</Abutton>
</div>
<div class="item" v-if="role != 0">
<Abutton @click="UpdateState(0)">[任何人可赠送]</Abutton>
</div>
</div>
<div class="item"></div>
</div>
</template>
<script setup lang="ts">
definePageMeta({
layout: layout.default,
middleware: 'page-loading'
})
const role = ref(0);
onMounted(async () => {
try {
await BindData();
}
finally {
PageLoading.Close();
}
})
const BindData = async (): Promise<void> => {
let result = await SettingService.GetUserConfig(1);
if (result.code == 0) {
role.value = result.data;
}
else {
MessageExtend.ShowDialog("提示", result.msg);
}
};
const UpdateState = async (state: number) => {
MessageExtend.LoadingToast("设置中...");
let result = await SettingService.UpdateUserConfig(1, state);
MessageExtend.LoadingClose();
if (result.code == 0) {
await BindData();
MessageExtend.Notify("操作成功!", "success");
}
else {
MessageExtend.ShowDialog("设置操作", result.msg);
}
}
</script>

View File

@@ -1 +1,29 @@
<template></template>
<template>
<div class="module-title">
设置中心
</div>
<div class="module-content">
<div class="item border-btm ">
<Abar href="/user/setting/friend">好友设置</Abar>
</div>
<div class="item border-btm ">
<Abar href="/user/setting/give">赠送设置</Abar>
</div>
<div class="item border-btm ">
<Abar href="/user/setting/bag">百宝箱设置</Abar>
</div>
<div class="item border-btm ">
<Abar href="/user/setting/drug">急救箱设置</Abar>
</div>
<div class="item border-btm ">
<Abutton>重置负重</Abutton><span style="font-size: 14px;;">(*重置负重数据)</span>
</div>
<div class="item border-btm ">
<Abutton>刷新图标</Abutton><span style="font-size: 14px;;">(*更新图标数据)</span>
</div>
</div>
</template>
<script setup lang="ts">
</script>

View File

@@ -111,7 +111,7 @@ const FriendHandle = async (): Promise<void> => {
}
const AddEnemy = async (): Promise<void> => {
MessageExtend.ShowConfirmDialogAsyc("关系操作", `您确定要添加Ta为仇人吗?(添加消耗50金元)`, async () => {
MessageExtend.ShowConfirmDialogAsyc("关系操作", `您确定要添加Ta为仇人吗?(添加消耗300金元)`, async () => {
let no = PageExtend.QueryString("no");
let result = await RelationService.AddEnemy(no);
if (result.code == 0) {

View File

@@ -0,0 +1,17 @@
export class SettingService {
/**
* 获取个人配置
* GET /User/Setting/GetUserConfig
*/
static async GetUserConfig(type: number) {
return await ApiService.Request("get", "/User/Setting/GetUserConfig", { type });
}
/**
* 设置配置
* GET /User/Setting/UpdateUserConfig
*/
static async UpdateUserConfig(type: number, state: number) {
return await ApiService.Request("get", "/User/Setting/UpdateUserConfig", { type, state });
}
}