public ActionRes GetBookCategoryList() { var res = _bookSearchAppService.GetBookCategoryList(); res.FirstOrDefault().Active = true; return(ActionRes.Success(res)); }
/// <summary> /// 分页查询book用户数据 /// </summary> /// <param name="queryBookUser"></param> /// <returns></returns> public ActionRes GetListByPage(QueryPager_Book_User queryBookUser) { //throw new Exception("测试异常提示"); var pageResult = AllServices.BookUserService.GetByPage(queryBookUser); return(ActionRes.Success(pageResult)); }
/// <summary> /// 更新阅读时长 /// </summary> /// <param name="Id"></param> /// <param name="Duration"></param> public ActionRes UpdateDuration(string Id, int Duration) { try { AllServices.BookChapterReadRecordService.UpdateDuration(Id, Duration); } catch { } return(ActionRes.Success()); }
/// <summary> /// 查询book用户数据 /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionRes GetSingleById(string openid) { if (string.IsNullOrEmpty(openid)) { return(ActionRes.Fail("[openid]不能为空")); } var res = AllServices.BookUserService.GetSingleByOpenId(openid); return(ActionRes.Success(res)); }
public ActionRes AddReadRecord(string ids) { if (string.IsNullOrEmpty(ids)) { throw new Exception("ids is null"); } var data = AllServices.BookUserMessageReadRecordService.Add(ids.Split(",").ToList(), base.Openid); return(ActionRes.Success(data)); }
/// <summary> /// 搜索书本 /// </summary> /// <returns></returns> public ActionRes GetBookList(string q, int pn, int rule) { CheckInterfaceWhiteList(); //var res = Serializer.JsonDeserialize<ActionRes>("{\"Code\":0,\"Msg\":\"success\",\"Data\":[{\"bookname\":\"诛仙\",\"author\":\"萧鼎\",\"coverimg\":\"http://www.xxbiquge.com/cover/6/6482/6482s.jpg\",\"booktype\":\"武侠仙侠\",\"booklink\":\"http://www.xxbiquge.com/6_6482/\",\"intro\":\"这世间本是没有什么神仙的,但自太古以来,人类眼见周遭世界,诸般奇异之事,电闪雷鸣,狂风暴雨,又有天灾人祸,伤亡无数,…\",\"last_update_time\":\"2017-08-07\",\"last_update_chapter\":\"新书发布《诛仙前传:蛮荒行》\",\"chapterlink\":\"http://www.xxbiquge.com/6_6482/8201943.html\"},{\"bookname\":\"以武诛仙\",\"author\":\"大梦泣\",\"coverimg\":\"http://www.xxbiquge.com/cover/53/53999/53999s.jpg\",\"booktype\":\"武侠仙侠\",\"booklink\":\"http://www.xxbiquge.com/53_53999/\",\"intro\":\"穿越神魔世界,目睹仙神屠杀至亲,背负血海深仇,此生我修炼不为长生,不为逍遥,只为复仇,步步带血,我以武诛仙!\",\"last_update_time\":\"2017-08-22\",\"last_update_chapter\":\"新书《天蓬元帅》\",\"chapterlink\":\"http://www.xxbiquge.com/53_53999/2809582.html\"},{\"bookname\":\"一剑诛仙\",\"author\":\"猫蔻\",\"coverimg\":\"http://www.xxbiquge.com/cover/62/62538/62538s.jpg\",\"booktype\":\"女频频道\",\"booklink\":\"http://www.xxbiquge.com/62_62538/\",\"intro\":\"楚然坑了龙族一把,抢走了龙族唯一一滴真龙之血跑了。龙族大怒,发出悬赏令。然并卵——他从龙族之地逃走的时候,阵法出了问…\",\"last_update_time\":\"2017-08-22\",\"last_update_chapter\":\"129章\",\"chapterlink\":\"http://www.xxbiquge.com/62_62538/3497469.html\"},{\"bookname\":\"诛仙祭\",\"author\":\"流年花下\",\"coverimg\":\"http://www.xxbiquge.com/cover/48/48901/48901s.jpg\",\"booktype\":\"武侠仙侠\",\"booklink\":\"http://www.xxbiquge.com/48_48901/\",\"intro\":\"锲子:一眼一世界,一念一轮回...“如果这世间的秩序已经无法改变,如果这红尘的罪孽依旧要延续下去,那么就由我来亲手摧…\",\"last_update_time\":\"2017-08-22\",\"last_update_chapter\":\"第一百零六章 寻找上古幕府\",\"chapterlink\":\"http://www.xxbiquge.com/48_48901/2532266.html\"},{\"bookname\":\"逆诛仙\",\"author\":\"知邪\",\"coverimg\":\"http://www.xxbiquge.com/cover/14/14526/14526s.jpg\",\"booktype\":\"网游竞技\",\"booklink\":\"http://www.xxbiquge.com/14_14526/\",\"intro\":\"。——一句话简介:这就是前世略通皮毛的修真者误入诛仙世界的故事。PS:主角没看过诛仙233——\",\"last_update_time\":\"2017-08-21\",\"last_update_chapter\":\"第五十章 诸果之因\",\"chapterlink\":\"http://www.xxbiquge.com/14_14526/8527905.html\"},{\"bookname\":\"诛仙域\",\"author\":\"夜乌鱼\",\"coverimg\":\"http://www.xxbiquge.com/cover/27/27820/27820s.jpg\",\"booktype\":\"玄幻奇幻\",\"booklink\":\"http://www.xxbiquge.com/27_27820/\",\"intro\":\"成仙之路无尽头,神域滚滚仙血流。诸界天骄争主宰,唯我腾云傲天游。千万宇宙位面交错,构成一片神秘的世界。各界天骄汇集诛仙界,在此争霸。一名调皮捣蛋的少年,在凡尘中崛起,欲登上仙路与各界天骄争霸。\",\"last_update_time\":\"2017-08-20\",\"last_update_chapter\":\"第25章 大恐龙对秦首泉\",\"chapterlink\":\"http://www.xxbiquge.com/27_27820/1727730.html\"},{\"bookname\":\"诛仙诀\",\"author\":\"兔子吃窝边草\",\"coverimg\":\"http://www.xxbiquge.com/cover/6/6499/6499s.jpg\",\"booktype\":\"武侠仙侠\",\"booklink\":\"http://www.xxbiquge.com/6_6499/\",\"intro\":\"他是篮球的神话,他是足球界的传说,他是电影界的国王,他是音乐界的天才,他是商场的不败王者,他是黑道的三少,他是白道上…\",\"last_update_time\":\"2017-08-18\",\"last_update_chapter\":\"归来兮\",\"chapterlink\":\"http://www.xxbiquge.com/6_6499/7720948.html\"},{\"bookname\":\"诛仙图\",\"author\":\"念词\",\"coverimg\":\"http://www.xxbiquge.com/cover/40/40701/40701s.jpg\",\"booktype\":\"武侠仙侠\",\"booklink\":\"http://www.xxbiquge.com/40_40701/\",\"intro\":\"仙不将仙,天欲灭之;九天仙图,诛仙之路。我之道,顺仙则亡,逆仙成圣。我之意,破灭九天,昂首天外。缥缈修仙路,漫漫寻仙途,我欲灭天下群仙,傲睨一切!……诛仙之途舍我其谁!\",\"last_update_time\":\"2017-08-16\",\"last_update_chapter\":\"第五章 当第一\",\"chapterlink\":\"http://www.xxbiquge.com/40_40701/2136218.html\"},{\"bookname\":\"一念诛仙\",\"author\":\"离恨殇歌\",\"coverimg\":\"http://www.xxbiquge.com/cover/72/72996/72996s.jpg\",\"booktype\":\"玄幻奇幻\",\"booklink\":\"http://www.xxbiquge.com/72_72996/\",\"intro\":\"鼓乐喧。到头元知万事空,唯有亭台小溪流。只恨仇深仍未了,剑在手一念诛仙!\",\"last_update_time\":\"2017-08-09\",\"last_update_chapter\":\"第六十七章:开学跟我有什么关系\",\"chapterlink\":\"http://www.xxbiquge.com/72_72996/3873661.html\"},{\"bookname\":\"诛仙至尊\",\"author\":\"华星\",\"coverimg\":\"http://www.xxbiquge.com/cover/45/45880/45880s.jpg\",\"booktype\":\"玄幻奇幻\",\"booklink\":\"http://www.xxbiquge.com/45_45880/\",\"intro\":\"量小非君子,无毒不丈夫,我尝胆万年,决定磨刀霍霍向诸(猪)仙……辰天喃喃道。圣人不死,大盗不止;仙帝不亡,天下难定!…\",\"last_update_time\":\"2017-08-18\",\"last_update_chapter\":\"第四十三章 天下第一\",\"chapterlink\":\"http://www.xxbiquge.com/45_45880/2375954.html\"}],\"TraceIdentifier\":\"0HLE8C2VTHE12:00000001\"}"); //return res; var data = AllServices.BookSearchService.GetBookList(rule, q, pn); return(ActionRes.Success(data)); }
public ActionRes GetSystem_User(long id) { System_User system_User = db.System_User.Find(id); if (system_User == null) { return(ActionRes.Fail("")); } return(ActionRes.Success(system_User)); }
/// <summary> /// 分页查询用户数据 /// </summary> /// <param name="queryModel"></param> /// <returns></returns> public ActionRes GetListByPage(QueryPager_Sys_Account queryModel) { var pageResult = AllServices.SysAccountService.GetByPage(queryModel); foreach (var item in pageResult.List as List <Sys_Account> ) { item.Password_Salt = ""; } return(ActionRes.Success(pageResult)); }
/// <summary> /// 获取用户访问小程序数据日趋势 /// </summary> /// <returns></returns> public ActionRes GetAnalysisDailyVisitTrend(DateTime query_time) { if (query_time >= Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"))) { throw new Exception("限定只能查询今天之前的数据"); } var data = AllServices.MiniProgramService.GetAnalysisDailyVisitTrend(query_time.ToString(DateFormat), query_time.ToString(DateFormat)); return(ActionRes.Success(data)); }
// 处理并包装异常 private void HandleAndWrapException(ExceptionContext context) { // 判断被调用接口的返回值是否符合标准,不符合则直接返回 if (!ActionResultHelper.IsObjectResult(context.ActionDescriptor.GetMethodInfo().ReturnType)) { return; } // 设置 HTTP 上下文响应所返回的错误代码,由具体异常决定。 context.HttpContext.Response.StatusCode = GetStatusCode(context); //// 重新封装响应返回的具体内容。采用 AjaxResponse 进行封装 //context.Result = new ObjectResult( // new AjaxResponse( // _errorInfoBuilder.BuildForException(context.Exception), // context.Exception is AbpAuthorizationException // ) //); //自定义响应数据格式 var errInfo = _errorInfoBuilder.BuildForException(context.Exception); var sb = new StringBuilder(); if (errInfo.ValidationErrors != null) { foreach (var err in errInfo.ValidationErrors) { sb.AppendLine($"【{string.Join(',', err.Members)}】:{err.Message}"); } } else { sb.Append(context.Exception.Message); } if (context.Exception is UserFriendlyException == false) { errInfo.Code = -1; } ContentResult content = new ContentResult(); content.Content = JsonConvert.SerializeObject(ActionRes.Fail(-1, sb.ToString(), errInfo), new JsonSerializerSettings { ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver() }); context.Result = content; // 触发异常处理事件 EventBus.Trigger(this, new AbpHandledExceptionData(context.Exception)); // 处理完成,将异常上下文的内容置为空 context.Exception = null; //Handled! }
public ActionRes GetSystem_User() { var system_User = db.System_User.ToList(); if (system_User == null) { return(ActionRes.Fail("")); } return(ActionRes.Success(system_User)); }
public void OnAuthorization(AuthorizationFilterContext filterContext) { filterContextInfo = new FilterContextInfo(filterContext); if (filterContextInfo.ControllerName == "Base") { throw new Exception("禁止访问基类控制器"); } //不用检查 if (Anonymous) { return; } #region 检查认证 try { string token = filterContext.HttpContext.Request.Headers["cat-token"]; try { if (string.IsNullOrEmpty(token)) { throw new Exception("用户身份认证未通过[token不能为空],请求数据失败"); } token = AesHelper.AesDecrypt(token); var auth = Serializer.JsonDeserialize <Cat.M.Book.Models.ModelBinder.ReturnModels.BookAuth>(token); if (string.IsNullOrEmpty(auth.Openid)) { throw new Exception("用户身份认证未通过[找不到指定的openid],请求数据失败"); } } catch (Exception ex) { if (string.IsNullOrEmpty(ex.Message)) { throw new Exception("用户身份认证未通过,请求数据失败"); } else { throw ex; } } } catch (Exception ex) { Microsoft.AspNetCore.Mvc.ContentResult contentResult = new Microsoft.AspNetCore.Mvc.ContentResult(); contentResult.Content = ActionRes.Fail(ex.Message).ToJson(); filterContext.Result = contentResult; return; } #endregion }
public ActionRes Update([FromBody] Update_Sys_Interface_WhiteList_Input model) { var instance = AllServices.SysInterfaceWhiteListService.GetByKey(model.Id); if (instance == null) { throw new Exception($"没有找到指定的数据[{model.Id}]"); } var res = AllServices.SysInterfaceWhiteListService.Update(model); return(ActionRes.Success(res)); }
public ActionRes Jscode2session(string code, string appid = "") { var res = _wechatAppService.Jscode2session(code, appid); if (res.Errcode == 0) { return(ActionRes.Success(res)); } else { return(ActionRes.Fail(-1, res.Errmsg, res)); } }
/// <summary> /// 获取用户偏好 /// </summary> public ActionRes GetUserPreference() { try { var instance = AllServices.BookUserPreferenceService.GetSingleByOpenid(base.Openid); return(ActionRes.Success(instance)); } catch (Exception ex) { return(ActionRes.Success("获取偏好失败:" + ex.Message)); } }
public ActionRes Update([FromBody] Update_Book_User_Message_Input model) { var instance = AllServices.BookUserMessageService.GetByKey(model.Id); if (instance == null) { throw new Exception($"没有找到指定的数据[{model.Id}]"); } var res = AllServices.BookUserMessageService.Update(model); return(ActionRes.Success(res)); }
/// <summary> /// 获取最近的阅读 /// </summary> /// <param name="openid"></param> /// <returns></returns> public ActionRes GetRecentReadingByPage(string openid, int pn = 1, int ps = 10) { if (string.IsNullOrEmpty(openid)) { return(ActionRes.Fail("[openid]不能为空")); } ////用户信息 //var user = AllServices.BookUserService.GetSingleByOpenId(openid); var list = AllServices.BookReadRecordService.GetRecentReadingByPage(openid, pn, ps); return(ActionRes.Success(list)); }
public ActionRes CheckAuthority([FromBody] List_Input <CheckAuthorityModel> model) { if (model.list == null || model.list.Count == 0) { throw new Exception("参数有误"); } foreach (var item in model.list) { item.result = CheckAuthorityMethod(item.controller, item.method); } return(ActionRes.Success(model.list)); }
/// <summary> /// 获取用户访问小程序月留存 /// </summary> /// <returns></returns> public ActionRes GetAnalysisMonthlyRetain(DateTime begin_time, DateTime end_time) { if (begin_time >= Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-01"))) { throw new Exception("限定只能查询当月之前的数据"); } if (begin_time.Day != 1 || ((end_time - begin_time).TotalDays + 1) != DateTime.DaysInMonth(begin_time.Year, begin_time.Month)) { throw new Exception("限定查询一个自然月的数据,时间必须按照自然月的方式输入"); } var data = AllServices.MiniProgramService.GetAnalysisMonthlyRetain(begin_time.ToString(DateFormat), end_time.ToString(DateFormat)); return(ActionRes.Success(data)); }
/// <summary> /// 获取用户订单记录 /// </summary> /// <param name="requestParams"></param> /// <returns></returns> public ActionRes GetWechatPayOrderByPage(QueryPager_Wechat_PayOrder requestParams) { var pageResult = AllPublicService.WechatPayOrderService.GetByPage(requestParams); //过滤敏感信息 foreach (var item in pageResult.List as List <Wechat_PayOrder> ) { item.MchId = "******"; item.OutTradeNo = "******"; item.RequestData = ""; item.PrepayId = "******"; } return(ActionRes.Success(pageResult)); }
public async Task <ActionRes> CreateOrUpdateAsync([FromBody] CreateBookUserDto dto) { var bookUserOutput = await _bookUserAppService.GetByOpenidAsync(dto.Openid); if (bookUserOutput == null) { await _bookUserAppService.CreateAsync(dto); } else { await _bookUserAppService.UpdateAsync(ObjectMapper.Map <UpdateBookUserDto>(bookUserOutput)); } return(ActionRes.Success()); }
/// <summary> /// 获取用户访问小程序数据周趋势 /// </summary> /// <returns></returns> public ActionRes GetAnalysisWeeklyVisitTrend(DateTime begin_time, DateTime end_time) { if (end_time >= Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"))) { throw new Exception("限定只能查询之前一周的数据"); } if (((end_time - begin_time).TotalDays + 1) != 7) { throw new Exception("限定查询一个自然周的数据,时间必须按照自然周的方式输入"); } var data = AllServices.MiniProgramService.GetAnalysisWeeklyVisitTrend(begin_time.ToString(DateFormat), end_time.ToString(DateFormat)); return(ActionRes.Success(data)); }
public ActionRes GetCurrentUser() { if (HttpContext.User.Identity.IsAuthenticated) { var data = new { name = "小李", avatar = "", userid = 1 }; return(ActionRes.Success(data)); } return(ActionRes.Fail("401 not login")); }
/// <summary> /// 新增书本阅读记录 /// </summary> /// <param name="entity"></param> /// <returns></returns> public ActionRes Add(Book_Read_Record entity) { entity.Openid = base.Openid; var instance = AllServices.BookReadRecordService.GetSingle(entity.Openid, entity.Book_Name, entity.Author, entity.Rule); if (instance != null) { return(ActionRes.Success(instance)); } else { AllServices.BookReadRecordService.Add(entity); return(ActionRes.Success(entity)); } }
public ActionRes GetOpenId() { HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"]; WeChatInfo wechatInfo = Helper.GetOpenId(context.Request["js_code"]); System_User systemUser = db.System_User.Where(user => user.WxOpenId == wechatInfo.openid).FirstOrDefault(); if (systemUser != null) { return(ActionRes.Success(systemUser)); } else { return(ActionRes.Success(wechatInfo)); } }
/// <summary> /// 检查新增账户时的用户id是否已存在 /// </summary> /// <param name="id"></param> /// <param name="user_Id"></param> /// <returns></returns> public ActionRes CheckUserIdRepeat(string id, string user_Id) { if (string.IsNullOrEmpty(user_Id)) { throw new Exception("[用户id]不能为空"); } var instance = AllServices.SysAccountService.GetSingle(w => w.User_Id == user_Id); if (instance != null && instance.Id != id) { throw new Exception("已存在的用户id,不能重复添加"); } return(ActionRes.Success()); }
/// <summary> /// 支付结果通知 /// </summary> /// <returns></returns> public ActionRes Notify() { var data = AllBookServices.WechatPayService.Notify(); try { if (data.Contains("<return_code><![CDATA[SUCCESS]]></return_code>")) { } } catch (Exception ex) { Cat.M.Log.Services.AllServices.SysExceptionLogService.AddLog(M.Log.Services.Enum.ExceptionType.ServiceException, ex, "发送模板消息[支付结果通知]时异常"); } return(ActionRes.Success(data)); }
/// <summary> /// 用户阅读统计(参与阅读用户数、阅读章节数) /// </summary> /// <param name="dateType">统计类型,y、m、d</param> /// <param name="begin_time"></param> /// <param name="end_time"></param> /// <returns></returns> public ActionRes BookUserReadStatistics(string dateType, DateTime begin_time, DateTime end_time) { end_time = end_time.AddDays(1).AddMilliseconds(-1); var list = AllServices.StatisticsService.BookUserReadStatistics(dateType, begin_time, end_time); List <string> columns = GetColumns(dateType, list); var data = new { columns, data_user = list.Select(s => s.users).ToArray(), data_chapter = list.Select(s => s.chapters).ToArray(), }; return(ActionRes.Success(data)); }
/// <summary> /// 获取购买/赠送记录 /// </summary> /// <returns></returns> public ActionRes GetRecoreds(int rechargeType, int top = 10) { List <Book_User_Recharge> list = new List <Book_User_Recharge>(); if (rechargeType == 1) { list.AddRange(AllServices.BookUserRechargeService.GetRecoreds(Enums.Book.RechargeType.活动赠送, base.Openid, top)); list.AddRange(AllServices.BookUserRechargeService.GetRecoreds(Enums.Book.RechargeType.管理员赠送, base.Openid, top)); } else if (rechargeType == 2) { list.AddRange(AllServices.BookUserRechargeService.GetRecoreds(Enums.Book.RechargeType.微信支付充值, base.Openid, top)); list.AddRange(AllServices.BookUserRechargeService.GetRecoreds(Enums.Book.RechargeType.积分兑换充值, base.Openid, top)); } return(ActionRes.Success(list.OrderByDescending(o => o.Create_Time).ToList())); }
/// <summary> /// 僵尸粉与有阅读记录的用户 统计 /// </summary> /// <param name="begin_time"></param> /// <param name="end_time"></param> /// <returns></returns> public ActionRes GetByReadUserStatistics() { DateTime begin_time = DateTime.MinValue.AddMilliseconds(1); DateTime end_time = DateTime.MaxValue.AddMilliseconds(-1); //有阅读记录的用户数 int readCount = AllServices.StatisticsService.GetCountByReadUser(begin_time, end_time); //用户总数 int total = AllServices.BookUserService.GetCount(); //无有阅读记录的用户数 int no_read_count = total - readCount; var list = new List <object>(); list.Add(new { flag = "正常用户", total = readCount }); list.Add(new { flag = "僵尸用户", total = no_read_count }); return(ActionRes.Success(list)); }