• 有用吗2


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Net.Http;
    using System.Web.Http;
    using EFDAL;
    using DataModel;
    using ServiceStack.Redis;

    namespace EFExame_API.Controllers
    {
    public class WuLianWangController : ApiController
    {
    XueYuanClass dal = new XueYuanClass();

    /// <summary>
    /// 获取数据并存到redis里面
    /// </summary>
    /// <returns></returns>
    [HttpGet]
    [Route("api/GetWuLianWang")]
    public List<WuLianWangInfo> WlWinfos(string name = "")
    {
    //定义变量list接受返回的集合
    var list = new List<WuLianWangInfo>();

    //定义redis
    RedisClient redis = new RedisClient("127.0.0.1");

    //将Redis赋值给list
    list = redis.Get<List<WuLianWangInfo>>("products");

    //判断Redis是否为空或者他的个数是否为0
    if (list == null || list.Count == 0)
    {
    list = dal.WlWInfos(name);

    redis.Set("products", list);
    }

    return list;

    }

    /// <summary>
    /// 删除数据
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    [HttpGet]
    [Route("api/DeleInfo")]
    public int DeletId(int id)
    {
    return dal.DeleInfo(id);
    }

    /// <summary>
    /// 修改数据
    /// </summary>
    /// <param name="wuLianWang"></param>
    /// <returns></returns>
    [HttpPost]
    [Route("api/UpdateInfo")]
    public int UpdateInfo(WuLianWangInfo wuLianWang)
    {
    return dal.UpdateInfo(wuLianWang);
    }

    /// <summary>
    /// 根据Id获取数据
    /// </summary>
    /// <param name="Id"></param>
    /// <returns></returns>
    [HttpGet]
    [Route("api/GetId")]
    public WuLianWangInfo FanTian(int Id)
    {
    return dal.FanTian(Id);
    }

    /// <summary>
    /// 添加数据
    /// </summary>
    /// <param name="WuLian"></param>
    /// <returns></returns>
    [HttpPost]
    [Route("api/AddInfo")]
    public int AddInfo(WuLianWangInfo WuLian)
    {
    return dal.AddInfo(WuLian);
    }

    /// <summary>
    /// 调用分页存储过程
    /// </summary>
    /// <param name="Pageindex"></param>
    /// <param name="Pagesize"></param>
    /// <returns></returns>
    [HttpPost]
    [Route("api/PageProc")]
    public List<WuLianWangInfo> WPageProc(int Pageindex = 1, int Pagesize = 2)
    {
    return dal.WPageProc(Pageindex, Pagesize);
    }
    }
    }

  • 相关阅读:
    语文作业
    在Windows下为PHP5.5安装redis扩展
    PHP安全处理之Mcrypt使用总结
    CSS3 动画
    微信开发--获取用户openID
    微信公众号开发--获取用户信息
    php 中gd库的安装
    随机输入几个数,输出重复的数字和重复的次数
    永久解决"Error:java: 错误: 不支持发行版本 12"的问题
    报"java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing"的原因和如何处理
  • 原文地址:https://www.cnblogs.com/li1999/p/13446052.html
Copyright © 2020-2023  润新知