亲苍霞接口 - student相关

回到主页

Ajax请求头的通用设置方法:

$.ajax({
    "async": true, // 代表异步请求
    "crossDomain": true, // 代表跨域
    "url": "http://api.qincangxia.tomczm.cn/...", // "..."的部分要自己设置
    "method": "POST", // 使用post方法
    xhrFields: {
        withCredentials: true // 使得每次上传的session保持一致
    },
    "data": {
        // 数据部分,也可以使用fromData方法来解决
        "account": "jack",
        "password": "123456"
    }
}).done(function(response) {
    // 这里放 $.ajax() 执行成功后的代码
}).fail(){
    // 这里写报错后的方法,也可以视情况省略
}

student相关统一接口

接口:/student

使用方法如下显示:http://api.qincangxia.tomczm.cn/student/doLogin

注:如无特殊说明,所有发送请求的方式都是post

登录

接口:/doLogin

参数:

  1. account 账号
  2. password 密码

返回值:

// 登录成功
{
    "info": "登录成功",
    "status": "success"
}

// 登录失败
{
    "info": "账号或密码错误",
    "status": "error"
}

注销

接口:/doLogout

参数:无

返回值:

// 已登录时执行注销
{
    "info": "注销成功",
    "status": "success"
}

// 未登录时执行注销
{
    "info": "未登录,无法注销",
    "status": "notLoggedIn"
}

检查是否登录

接口:/isLogin

参数:无

返回值:

// 已登录
{
    "info": "student",
    "status": "success"
}


// 未登录
{
    "status": "notLoggedIn"
}

获取学生全部信息

接口:/getInfo

参数:无

返回值:

// 已登录的情况下
{
    "info": {
        "stuId": "3123123123", // 学号
        "stuName": "马兰", // 姓名
        "stuAcademic": "信息科学与工程学院", // 学院
        "stuMajor": "计算机科学与技术", // 专业
        "stuClass": "计算机1801", // 班级
        "monitor": "0", // 班长,1-是班长,0-不是班长
        "stuDorm": "a1-101", // 宿舍号
        "dormHeader": "0", // 舍长,1-是舍长,0-不是舍长
        "stuScore": "131" // 三个文明当前分数
    },
    "status": "success"
}

// 未登录的情况下
{
    "status": "notLoggedIn"
}

获取学生分数

接口:/getScore

参数:无

返回值:

// 已登录的情况下
{
    "info": "121",
    "status": "success"
}

// 未登录的情况下
{
    "status": "notLoggedIn"
}

获取三个文明分加减情况明细

接口:/getScoreDetailList

参数:无

返回值:

// 已登录情况下
{
    "info": [
        {
            "stuId": "3123123123",
            "insId": "19980421",
            "detailName": "被子未叠",
            "operateScore": "-3",
            "remarks": "下次要注意了",
            "operateTime": "2018-08-10 15:14:13"
        },
        {
            "stuId": "3123123123",
            "insId": "19980421",
            "detailName": "易班月明星用户",
            "operateScore": "3",
            "remarks": "2018.6月明星用户",
            "operateTime": "2018-07-10 11:24:15"
        }
    ],
    "status": "success"
}

// 未登录情况下
{
    "status": "notLoggedIn"
}

申请加分

接口:/applyScore

参数:以下是测试代码,记得在提交文件前要登录,否则会提示没有登录。

<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Demo</title>
</head>

<body>
<button id="login">登录</button>

<form id="uploadFormApplyScore" enctype="multipart/form-data">
    加分原因:<input type="text" id="detailName" name="detailName"><br>
    加分分值:<input type="text" id="detailScore" name="detailScore"><br>
    备注:<input type="text" id="remarks" name="remarks"><br>
    说明图片:<input type="file" id="myPicture" name="myPicture" accept=".jpg,.jpeg"><br>
    <input type="button" id="btn" value="提交"></button>
</form>

<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript">
    $(function() {
        $("#login").click(function() {
            var settings = {
                "async": true,
                "crossDomain": true,
                "url": "http://api.qincangxia.tomczm.cn/student/doLogin",
                "method": "POST",
                xhrFields: {
                    withCredentials: true
                },
                "data": {
                    "account": "jack",
                    "password": "123456"
                }
            }
            $.ajax(settings).done(function(response) {
                console.log(response);
            })
        })
    })

    $(function() {
        $('#btn').click(function() {
            var formData = new FormData($('#uploadFormApplyScore')[0]);
            var settings = {
                "async": true,
                "crossDomain": true,
                "url": "http://api.qincangxia.tomczm.cn/student/applyScore",
                "method": "POST",
                "processData": false,
                "contentType": false,
                "mimeType": "multipart/form-data",
                xhrFields: {
                    withCredentials: true
                },
                "data": formData
            }
            $.ajax(settings).done(function(data) {
                console.log(data);
            })
        })
    })
</script>
</body>

</html>

返回值:

// 上传成功
{
    "info": "上传成功",
    "status": "success"
}

// 未登录
{
    "status": "notLoggedIn"
}

 申诉加减分出现问题

接口:/appealScore

参数:

  1. scoreDetailId 申诉的加减分记录ID

返回值:

// 申诉成功
{
    "info": "申诉成功",
    "status": "success"
}

// 申诉失败
{
    "status": "notLoggedIn"
}

猜你喜欢

转载自blog.csdn.net/allenChenZhiMing/article/details/81544045