Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 251354f5e2 | |||
| 3e9aa93886 | |||
| 4e6adecc1f |
71
API.md
Normal file
71
API.md
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
# V3.0 Beta API文档(不稳定)
|
||||||
|
## 登录
|
||||||
|
**请求URL:**
|
||||||
|
- ` http://s4.fjy8018.top:8085/cms/login/dologin `
|
||||||
|
|
||||||
|
**请求方式:**
|
||||||
|
- POST
|
||||||
|
|
||||||
|
**参数:**
|
||||||
|
|
||||||
|
| 参数名 | 必选 | 类型 | 说明 |
|
||||||
|
| :---------- | :--- | :----- | ---- |
|
||||||
|
| colname | 是 | string | 无 |
|
||||||
|
| colpassword | 是 | string | 无 |
|
||||||
|
|
||||||
|
|
||||||
|
**返回示例**
|
||||||
|
|
||||||
|
``` json
|
||||||
|
{
|
||||||
|
"code": 0,
|
||||||
|
"message": "成功",
|
||||||
|
"data": {
|
||||||
|
"coluserid": 1,
|
||||||
|
"colname": "root",
|
||||||
|
"colpassword": null,
|
||||||
|
"colemail": "root@gmail.com",
|
||||||
|
"colstudentno": "00001",
|
||||||
|
"colrealname": "admin"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## 指定课程和作业名,返回未交人员名单
|
||||||
|
|
||||||
|
**请求URL:**
|
||||||
|
|
||||||
|
- ` http://s4.fjy8018.top:8085/cms/home/admin/findStudentInCourseFile?Folder=第一次作业&CourseName=信息安全 `
|
||||||
|
|
||||||
|
**请求方式:**
|
||||||
|
- GET
|
||||||
|
|
||||||
|
**参数:**
|
||||||
|
|
||||||
|
| 参数名 | 必选 | 类型 | 说明 |
|
||||||
|
| :---------- | :--- | :----- | ---- |
|
||||||
|
| colname | 是 | string | 无 |
|
||||||
|
| colpassword | 是 | string | 无 |
|
||||||
|
|
||||||
|
|
||||||
|
**返回示例**
|
||||||
|
|
||||||
|
``` json
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"listid": 1,
|
||||||
|
"colstudentno": "14251101208",
|
||||||
|
"colrealname": "廖俊宝",
|
||||||
|
"sex": "男",
|
||||||
|
"registered": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"listid": 2,
|
||||||
|
"colstudentno": "15251101201",
|
||||||
|
"colrealname": "麦贵淇",
|
||||||
|
"sex": "男",
|
||||||
|
"registered": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
3
pom.xml
3
pom.xml
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<groupId>com.fjy</groupId>
|
<groupId>com.fjy</groupId>
|
||||||
<artifactId>spring</artifactId>
|
<artifactId>spring</artifactId>
|
||||||
<version>V2.9.9</version>
|
<version>V3.0.0 beta</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>spring</name>
|
<name>spring</name>
|
||||||
@@ -22,6 +22,7 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
|
<skipTests>true</skipTests>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
|
import java.text.Format;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@@ -54,7 +55,17 @@ public class DataController {
|
|||||||
|
|
||||||
@GetMapping("/home/findAllHomework")
|
@GetMapping("/home/findAllHomework")
|
||||||
public List<VWorkDetail> findAllHomework() {
|
public List<VWorkDetail> findAllHomework() {
|
||||||
List<VWorkDetail> homeworks = workDetailService.findAll();
|
Format f = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
Date today = new Date();
|
||||||
|
|
||||||
|
Calendar c = Calendar.getInstance();
|
||||||
|
c.setTime(today);
|
||||||
|
// 今天-2天,因为数据库比较是">"号,即不包含当天
|
||||||
|
c.add(Calendar.DAY_OF_MONTH, -2);
|
||||||
|
|
||||||
|
Date yesterday = c.getTime();
|
||||||
|
|
||||||
|
List<VWorkDetail> homeworks = workDetailService.findAllVWorkDetailAfterTime(f.format(yesterday));
|
||||||
if (homeworks != null) {
|
if (homeworks != null) {
|
||||||
return homeworks;
|
return homeworks;
|
||||||
}
|
}
|
||||||
@@ -99,7 +110,17 @@ public class DataController {
|
|||||||
|
|
||||||
@GetMapping("/home/findallvhomework")
|
@GetMapping("/home/findallvhomework")
|
||||||
public List<VHomework> findAllVHomework() {
|
public List<VHomework> findAllVHomework() {
|
||||||
List<VHomework> vHomeworks = homeworkService.findAllVHomework();
|
Format f = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
Date today = new Date();
|
||||||
|
|
||||||
|
Calendar c = Calendar.getInstance();
|
||||||
|
c.setTime(today);
|
||||||
|
// 今天-2天,因为数据库比较是">"号,即不包含当天
|
||||||
|
c.add(Calendar.DAY_OF_MONTH, -5);
|
||||||
|
|
||||||
|
Date yesterday = c.getTime();
|
||||||
|
|
||||||
|
List<VHomework> vHomeworks = homeworkService.findAllVHomeworkAfterTime(f.format(yesterday));
|
||||||
if (vHomeworks != null) {
|
if (vHomeworks != null) {
|
||||||
return vHomeworks;
|
return vHomeworks;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
package com.fjy.spring.controller;
|
package com.fjy.spring.controller;
|
||||||
|
|
||||||
|
import com.fjy.spring.domain.Result;
|
||||||
import com.fjy.spring.domain.TbAdmin;
|
import com.fjy.spring.domain.TbAdmin;
|
||||||
import com.fjy.spring.domain.TbLog;
|
import com.fjy.spring.domain.TbLog;
|
||||||
import com.fjy.spring.domain.TbUser;
|
import com.fjy.spring.domain.TbUser;
|
||||||
|
import com.fjy.spring.enums.ResultEnum;
|
||||||
import com.fjy.spring.properties.ServerProperties;
|
import com.fjy.spring.properties.ServerProperties;
|
||||||
import com.fjy.spring.service.AdminService;
|
import com.fjy.spring.service.AdminService;
|
||||||
import com.fjy.spring.service.LogService;
|
import com.fjy.spring.service.LogService;
|
||||||
import com.fjy.spring.service.UserService;
|
import com.fjy.spring.service.UserService;
|
||||||
import com.fjy.spring.untils.CodingUtil;
|
import com.fjy.spring.untils.CodingUtil;
|
||||||
import com.fjy.spring.untils.GetIPAddrUtil;
|
import com.fjy.spring.untils.GetIPAddrUtil;
|
||||||
|
import com.fjy.spring.untils.ResultUtil;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
@@ -27,7 +27,7 @@ import java.util.Optional;
|
|||||||
|
|
||||||
import static com.fjy.spring.constant.GlobalConstant.USER_SESSION_KEY;
|
import static com.fjy.spring.constant.GlobalConstant.USER_SESSION_KEY;
|
||||||
|
|
||||||
@Controller
|
@RestController
|
||||||
public class LoginController {
|
public class LoginController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ServerProperties serverProperties;
|
private ServerProperties serverProperties;
|
||||||
@@ -42,7 +42,7 @@ public class LoginController {
|
|||||||
HttpServletRequest request;
|
HttpServletRequest request;
|
||||||
|
|
||||||
@PostMapping("/login/dologin")
|
@PostMapping("/login/dologin")
|
||||||
public String doLogin(TbUser tbUser)throws Exception{
|
public Result doLogin(TbUser tbUser)throws Exception{
|
||||||
//加密用户密码
|
//加密用户密码
|
||||||
tbUser.setColpassword(new BigInteger(CodingUtil.encryptSHA(tbUser.getColpassword().getBytes())).toString(32));
|
tbUser.setColpassword(new BigInteger(CodingUtil.encryptSHA(tbUser.getColpassword().getBytes())).toString(32));
|
||||||
TbUser user = userService.doLoginService(tbUser.getColname(),tbUser.getColpassword());
|
TbUser user = userService.doLoginService(tbUser.getColname(),tbUser.getColpassword());
|
||||||
@@ -66,10 +66,9 @@ public class LoginController {
|
|||||||
log.setColip(GetIPAddrUtil.getIpAddr(request));
|
log.setColip(GetIPAddrUtil.getIpAddr(request));
|
||||||
logService.addLogRec(log);
|
logService.addLogRec(log);
|
||||||
|
|
||||||
return "redirect:" + request.getScheme() + "://" + request.getServerName() + ":"
|
return ResultUtil.data(ResultEnum.SUCCESS,user);
|
||||||
+ serverProperties.getPortNum() + request.getContextPath() + "/home";
|
|
||||||
}
|
}
|
||||||
return "login";
|
return ResultUtil.error(ResultEnum.LOGIN_FAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/beforeLogin")
|
@PostMapping("/beforeLogin")
|
||||||
|
|||||||
@@ -13,24 +13,24 @@ import javax.persistence.*;
|
|||||||
public class VHomework {
|
public class VHomework {
|
||||||
@Id
|
@Id
|
||||||
@Column(name = "workid")
|
@Column(name = "workid")
|
||||||
private Integer Id;
|
private Integer id;
|
||||||
|
|
||||||
@Column(name = "workname")
|
@Column(name = "workname")
|
||||||
private String Name;
|
private String name;
|
||||||
|
|
||||||
@Column(name = "worktime")
|
@Column(name = "worktime")
|
||||||
private String Time;
|
private String time;
|
||||||
|
|
||||||
@Column(name = "colfileid")
|
@Column(name = "colfileid")
|
||||||
private Integer fileid;
|
private Integer fileid;
|
||||||
|
|
||||||
@Column(name = "workfolder")
|
@Column(name = "workfolder")
|
||||||
private String Folder;
|
private String folder;
|
||||||
|
|
||||||
@Column(name = "coursename")
|
@Column(name = "coursename")
|
||||||
private String courseName;
|
private String courseName;
|
||||||
|
|
||||||
@Column(name = "workremark")
|
@Column(name = "workremark")
|
||||||
private String Remark;
|
private String remark;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package com.fjy.spring.enums;
|
|||||||
|
|
||||||
public enum ResultEnum {
|
public enum ResultEnum {
|
||||||
UNKOWN_ERROR(-1,"未知错误"),
|
UNKOWN_ERROR(-1,"未知错误"),
|
||||||
SUCCESS(0,"请求成功"),
|
SUCCESS(0,"成功"),
|
||||||
USER_NOTEXIST(601,"用户不存在"),
|
USER_NOTEXIST(601,"用户不存在"),
|
||||||
UPDATE_ERROR(602,"更新失败"),
|
UPDATE_ERROR(602,"更新失败"),
|
||||||
DELETE_ERROR(603,"删除失败"),
|
DELETE_ERROR(603,"删除失败"),
|
||||||
@@ -14,6 +14,7 @@ public enum ResultEnum {
|
|||||||
ID_NULLPOINT(609,"id为空"),
|
ID_NULLPOINT(609,"id为空"),
|
||||||
EMPTY_QUESTION(610,"该用户未设置密保问题"),
|
EMPTY_QUESTION(610,"该用户未设置密保问题"),
|
||||||
QUESTION_ERROR(611,"问题与答案不匹配"),
|
QUESTION_ERROR(611,"问题与答案不匹配"),
|
||||||
|
LOGIN_FAIL(612,"登录失败")
|
||||||
|
|
||||||
;
|
;
|
||||||
private Integer code;
|
private Integer code;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
|||||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
@Configuration
|
//@Configuration
|
||||||
public class WebAppConfig implements WebMvcConfigurer {
|
public class WebAppConfig implements WebMvcConfigurer {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3,6 +3,14 @@ package com.fjy.spring.repository;
|
|||||||
import com.fjy.spring.domain.VHomework;
|
import com.fjy.spring.domain.VHomework;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
public interface VHomeworkRepository extends JpaRepository<VHomework,Integer> {
|
public interface VHomeworkRepository extends JpaRepository<VHomework,Integer> {
|
||||||
|
/**
|
||||||
|
* 找出指定时间之前的所有作业
|
||||||
|
* @param destime
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<VHomework> findAllByTimeAfter(String destime);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,5 +3,13 @@ package com.fjy.spring.repository;
|
|||||||
import com.fjy.spring.domain.VWorkDetail;
|
import com.fjy.spring.domain.VWorkDetail;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface WorkDetailRepository extends JpaRepository<VWorkDetail,Integer> {
|
public interface WorkDetailRepository extends JpaRepository<VWorkDetail,Integer> {
|
||||||
|
/**
|
||||||
|
* 找出指定时间之前的所有作业详情
|
||||||
|
* @param worktime
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<VWorkDetail> findAllByWorktimeAfter(String worktime);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,4 +33,8 @@ public class HomeworkService {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<VHomework> findAllVHomeworkAfterTime(String time){
|
||||||
|
return vHomeworkRepository.findAllByTimeAfter(time);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,4 +15,8 @@ public class WorkDetailService {
|
|||||||
public List<VWorkDetail> findAll(){
|
public List<VWorkDetail> findAll(){
|
||||||
return workDetailRepository.findAll();
|
return workDetailRepository.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<VWorkDetail> findAllVWorkDetailAfterTime(String time){
|
||||||
|
return workDetailRepository.findAllByWorktimeAfter(time);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.fjy.spring.untils;
|
package com.fjy.spring.untils;
|
||||||
|
|
||||||
import com.fjy.spring.domain.Result;
|
import com.fjy.spring.domain.Result;
|
||||||
|
import com.fjy.spring.enums.ResultEnum;
|
||||||
|
|
||||||
public class ResultUtil {
|
public class ResultUtil {
|
||||||
public static Result error(Integer code,String msg){
|
public static Result error(Integer code,String msg){
|
||||||
@@ -16,4 +17,33 @@ public class ResultUtil {
|
|||||||
result.setData(data);
|
result.setData(data);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Result error(ResultEnum resultEnum){
|
||||||
|
Result result = new Result();
|
||||||
|
result.setCode(resultEnum.getCode());
|
||||||
|
result.setMessage(resultEnum.getMsg());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Result error(String msg){
|
||||||
|
Result result = new Result();
|
||||||
|
result.setCode(-2);
|
||||||
|
result.setMessage(msg);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Result data(ResultEnum resultEnum,Object data){
|
||||||
|
Result result = new Result();
|
||||||
|
result.setCode(resultEnum.getCode());
|
||||||
|
result.setMessage(resultEnum.getMsg());
|
||||||
|
result.setData(data);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Result success(ResultEnum resultEnum){
|
||||||
|
Result result = new Result();
|
||||||
|
result.setCode(resultEnum.getCode());
|
||||||
|
result.setMessage(resultEnum.getMsg());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package com.fjy.spring.service;
|
||||||
|
|
||||||
|
import com.fjy.spring.domain.VHomework;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.text.Format;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
public class HomeworkServiceTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void findAll() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void findAllVHomework() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void findById() {
|
||||||
|
Format f = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
|
||||||
|
Date today = new Date();
|
||||||
|
System.out.println("今天是:" + f.format(today));
|
||||||
|
|
||||||
|
Calendar c = Calendar.getInstance();
|
||||||
|
c.setTime(today);
|
||||||
|
c.add(Calendar.DAY_OF_MONTH, -1);// 今天+1天
|
||||||
|
|
||||||
|
Date tomorrow = c.getTime();
|
||||||
|
System.out.println("昨天是:" + f.format(tomorrow));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void findAllVHomeworkAfterTime() {
|
||||||
|
HomeworkService homeworkService = new HomeworkService();
|
||||||
|
List<VHomework> homeworkList = homeworkService.findAllVHomeworkAfterTime("2018-05-28");
|
||||||
|
if (homeworkList!=null){
|
||||||
|
for (VHomework vHomework : homeworkList){
|
||||||
|
System.out.println(vHomework.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user