diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Integral/SignInDto.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Integral/SignInDto.cs new file mode 100644 index 00000000..6923cf99 --- /dev/null +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Integral/SignInDto.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp.Application.Dtos; + +namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Integral +{ + public class SignInDto + { + /// + /// 签到数据 + /// + public List SignInItem { get; set; }=new List(); + + /// + /// 当前连续签到次数 + /// + public int CurrentContinuousNumber { get; set; } + } + + + public class SignInItemDto : EntityDto + { + /// + /// 签到时间 + /// + public DateTime CreationTime { get; set; } + } +} diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Integral/IntegralService.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Integral/IntegralService.cs index b8c23ed2..a2172768 100644 --- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Integral/IntegralService.cs +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Integral/IntegralService.cs @@ -4,8 +4,10 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; using Volo.Abp.Application.Services; using Volo.Abp.Users; +using Yi.Framework.Bbs.Application.Contracts.Dtos.Integral; using Yi.Framework.Bbs.Domain.Managers; namespace Yi.Framework.Bbs.Application.Services.Integral @@ -31,5 +33,43 @@ namespace Yi.Framework.Bbs.Application.Services.Integral var value = await _integralManager.SignInAsync(_currentUser.Id ?? Guid.Empty); return new { value }; } + + /// + /// 获取本月签到记录 + /// + /// + [Authorize] + [HttpGet("integral/sign-in/record")] + public async Task GetSignInRecordAsync() + { + var output = new SignInDto(); + DateTime lastMonth = DateTime.Now.AddMonths(-1); + DateTime lastDayOfMonth = new DateTime(lastMonth.Year, lastMonth.Month, 1).AddMonths(1).AddDays(-1); + DateTime startOfLastDay = new DateTime(lastDayOfMonth.Year, lastDayOfMonth.Month, lastDayOfMonth.Day, 0, 0, 0); + + //获取当前用户本月的数据+上个月最后一天的数据 + var entities = await _integralManager._signInRepository.GetListAsync(x => x.CreatorId == CurrentUser.Id + && x.CreationTime >= startOfLastDay); + + if (entities is null) + { + //返回默认值 + return output; + } + //拿到最末尾的数据 + var lastEntity = entities.OrderBy(x => x.CreationTime).LastOrDefault(); + + //判断当前时间和最后时间是否为连续的 + if (lastEntity.CreationTime.Day >= DateTime.Now.AddDays(-1).Day) + { + + output.CurrentContinuousNumber = lastEntity.ContinuousNumber; + } + + //去除上个月查询的数据 + output.SignInItem = entities.Where(x=>x.CreationTime.Month==DateTime.Now.Month) .Select(x => new SignInItemDto { Id = x.Id, CreationTime = x.CreationTime }).OrderBy(x=>x.CreationTime).ToList(); + return output; + + } } } diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/IntegralManager.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/IntegralManager.cs index 3cee684b..2d9ebb8d 100644 --- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/IntegralManager.cs +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/IntegralManager.cs @@ -10,8 +10,8 @@ namespace Yi.Framework.Bbs.Domain.Managers { public class IntegralManager : DomainService { - private ISqlSugarRepository _levelRepository; - private ISqlSugarRepository _signInRepository; + public ISqlSugarRepository _levelRepository; + public ISqlSugarRepository _signInRepository; private readonly ILocalEventBus _localEventBus; public IntegralManager(ISqlSugarRepository levelRepository, ISqlSugarRepository signInRepository, ILocalEventBus localEventBus) { diff --git a/Yi.Bbs.Vue3/src/apis/integralApi.js b/Yi.Bbs.Vue3/src/apis/integralApi.js index 0f211e68..f1441a99 100644 --- a/Yi.Bbs.Vue3/src/apis/integralApi.js +++ b/Yi.Bbs.Vue3/src/apis/integralApi.js @@ -6,3 +6,10 @@ export function signIn() { method: "post" }); } + +export function signInRecord() { + return request({ + url: "/integral/sign-in/record", + method: "get" + }); +} diff --git a/Yi.Bbs.Vue3/src/hooks/useAuths.js b/Yi.Bbs.Vue3/src/hooks/useAuths.js index ddb5b926..20f301c4 100644 --- a/Yi.Bbs.Vue3/src/hooks/useAuths.js +++ b/Yi.Bbs.Vue3/src/hooks/useAuths.js @@ -2,6 +2,7 @@ import { ElMessage, ElMessageBox } from "element-plus"; import useUserStore from "@/stores/user"; import router from "@/router"; import { Session, Local } from "@/utils/storage"; +import{computed} from 'vue' import { userLogin, getUserDetailInfo, @@ -15,6 +16,8 @@ export const AUTH_USER = "AUTH_USER"; export default function useAuths(opt) { + + const defaultOpt = { loginUrl: "/login", // 登录页跳转url 默认: /login loginReUrl: "", // 登录页登陆成功后带重定向redirect=的跳转url 默认为空 @@ -33,6 +36,14 @@ export default function useAuths(opt) { return token; }; + +const isLogin=computed(()=>{ + + var token= Local.get(TokenKey); + return token? true : false; + +}) + // 存储token到cookies const setToken = (token) => { if (token == null) { @@ -179,6 +190,7 @@ export default function useAuths(opt) { logoutFun, clearStorage, registerFun, - loginSuccess + loginSuccess, + isLogin }; } diff --git a/Yi.Bbs.Vue3/src/layout/AppHeader.vue b/Yi.Bbs.Vue3/src/layout/AppHeader.vue index 59fa9665..f69fc29b 100644 --- a/Yi.Bbs.Vue3/src/layout/AppHeader.vue +++ b/Yi.Bbs.Vue3/src/layout/AppHeader.vue @@ -86,7 +86,7 @@ import useAuths from "@/hooks/useAuths"; import { Session } from "@/utils/storage"; import signalR from "@/utils/signalR"; -const { getToken, clearStorage } = useAuths(); +const { isLogin, clearStorage } = useAuths(); const configStore = useConfigStore(); const router = useRouter(); const route = useRoute(); @@ -130,8 +130,6 @@ const search = () => { router.push(routerPer); }; -const isLogin = getToken("AccessToken") ? true : false; - const handleGitClick = () => { window.open("https://gitee.com/ccnetcore/Yi"); }; diff --git a/Yi.Bbs.Vue3/src/views/signIn/index.vue b/Yi.Bbs.Vue3/src/views/signIn/index.vue index 7efc8d03..835be56d 100644 --- a/Yi.Bbs.Vue3/src/views/signIn/index.vue +++ b/Yi.Bbs.Vue3/src/views/signIn/index.vue @@ -1,26 +1,60 @@ @@ -30,4 +64,7 @@ const signInOnclic= async()=>{ width: 100%; height: 100%; } +.is-selected { + color: #1989fa; +}