【236】java基于SpringBoot学生成绩管理系统
开发工具:idea 或eclipse
数据库mysql5.7+
数据库链接工具:navcat,小海豚等
技术:SpringBoot
package com.example.demo.controller;
import com.example.demo.bean.Gonggao;
import com.example.demo.bean.User;
import com.example.demo.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpSession;
import java.util.List;
@Controller
public class IndexController {
@Autowired
IndexService service;
@Autowired
GonggaoService gonggaoService;
@Autowired
RepairService repairService;
@Autowired
TousuService tousuService;
@Autowired
UserService userService;
@Autowired
User_PaymentService user_paymentService;
@Autowired
RoomService roomService;
@Autowired
CarService carService;
@GetMapping("/login")
public String login() {
return "page/template/login";
}
@GetMapping("/index")
public String index() {
return "index";
}
@GetMapping("/console")
public String console(Model model) {
int gonggaoCount = gonggaoService.getCount();
int repairCount = repairService.getCount();
int tousuCount = tousuService.getCount();
int userCount = userService.getCount();
int roomCount = roomService.getCount();
int roomFreeCount = roomService.getFreeCount();
int carCount = carService.getCount();
int carFreeCount = carService.getFreeCount();
int paymentCount = user_paymentService.getCount();
int paymentFreeCount = user_paymentService.getFreeCount();
model.addAttribute("gonggaoCount",gonggaoCount);
model.addAttribute("repairCount",repairCount);
model.addAttribute("tousuCount",tousuCount);
model.addAttribute("userCount",userCount);
model.addAttribute("roomCount",roomCount);
model.addAttribute("roomFreeCount",roomFreeCount);
model.addAttribute("carCount",carCount);
model.addAttribute("carFreeCount",carFreeCount);
model.addAttribute("paymentCount",paymentCount);
model.addAttribute("paymentFreeCount",paymentFreeCount);
return "page/console/console";
}
@GetMapping("/tpl-theme")
public String tpl(){
return "page/tpl/tpl-theme";
}
@GetMapping("/tpl-password")
public String password(){
return "page/tpl/tpl-password";
}
@GetMapping("/tpl-user-password")
public String reader_password(){
return "page/tpl/tpl-user-password";
}
@GetMapping("/tpl-note")
public String note(){
return "page/tpl/tpl-note";
}
@GetMapping("/user-info")
public String userinfo(){
return "page/template/user-info";
}
@GetMapping("/building")
public String building(){
return "page/template/building";
}
@GetMapping("/danyuan")
public String danyuan(){
return "page/template/danyuan";
}
@GetMapping("/room")
public String room(){
return "page/template/room";
}
@GetMapping("/gonggao")
public String gonggao(){
return "page/template/gonggao";
}
@GetMapping("/repair")
public String repair(){
return "page/template/repair";
}
@GetMapping("/tousu")
public String tousu(){
return "page/template/tousu";
}
@GetMapping("/payment")
public String payment(){
return "page/template/payment";
}
@GetMapping("/car")
public String car(){
return "page/template/car";
}
@GetMapping("/user")
public String user(){
return "page/template/user";
}
@GetMapping("/user/login")
public String userlogin(){
return "page/system/login";
}
@GetMapping("/user/index")
public String userindex(){
return "page/system/index";
}
@GetMapping("/user/console")
public String userconsole(Model model,HttpSession session){
User user = (User) session.getAttribute("user");
Gonggao gonggao = gonggaoService.getGonggao();
int repairCount = repairService.getCount();
int tousuCount = tousuService.getCount();
int paymentCount = user_paymentService.getCount();
int userRepair = repairService.getCountByUserId(user.getId());
int userTousu = tousuService.getCountByUserId(user.getId());
int userPayment = user_paymentService.getCountByUserId(user.getId());
model.addAttribute("gonggao",gonggao);
model.addAttribute("userTousu",userTousu);
model.addAttribute("userRepair",userRepair);
model.addAttribute("userPayment",userPayment);
model.addAttribute("repairCount",repairCount);
model.addAttribute("tousuCount",tousuCount);
model.addAttribute("paymentCount",paymentCount);
return "page/system/console";
}
@GetMapping("/paymentDetail")
public String paymentDetail(){
return "page/template/paymentDetail";
}
}
package com.example.demo.controller;
import com.example.demo.bean.Repair;
import com.example.demo.bean.ResBody;
import com.example.demo.bean.Tousu;
import com.example.demo.bean.User;
import com.example.demo.service.RepairService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.List;
@RestController
public class RepairController {
@Autowired
RepairService service;
@GetMapping("/api/getAllRepairs")
public ResBody getAllRepairs(@RequestParam int page,
@RequestParam int limit) {
ResBody resBody = new ResBody();
int count = service.getCount();
List<Repair> list= service.getAllRepairs(page, limit);
resBody.setCount(count);
resBody.setData(list);
resBody.setCode(0);
return resBody;
}
@GetMapping("/api/getAllRepairsByUser")
public ResBody getAllRepairsByUser(@RequestParam int page,
@RequestParam int limit, HttpSession session){
ResBody resBody = new ResBody();
User user = (User) session.getAttribute("user");
int count = service.getCountByUserId(user.getId());
List<Repair> list= service.getAllRepairsByUser(page, limit,user.getId());
resBody.setCount(count);
resBody.setData(list);
resBody.setCode(0);
return resBody;
}
@PostMapping("/api/addRepair")
public ResBody addRepair(@RequestBody Repair repair,HttpSession session) {
ResBody resBody = new ResBody();
User user = (User) session.getAttribute("user");
if (user!=null){
repair.setUser_id(user.getId());
}
int i = service.addRepair(repair);
if (i == 1){
resBody.setCode(200);
resBody.setMsg("添加成功");
}else{
resBody.setCode(500);
resBody.setMsg("添加失败");
}
return resBody;
}
@PostMapping("/api/updateRepair")
public ResBody updateRepair(@RequestBody Repair repair) {
ResBody resBody = new ResBody();
int i = service.updateRepair(repair);
if (i == 1){
resBody.setCode(200);
resBody.setMsg("修改成功");
}else{
resBody.setCode(500);
resBody.setMsg("修改失败");
}
return resBody;
}
@GetMapping("/api/delRepair")
public ResBody delRepair(@RequestParam int id) {
ResBody resBody = new ResBody();
int i = service.delRepair(id);
if (i == 1){
resBody.setCode(200);
resBody.setMsg("删除成功");
}else{
resBody.setCode(500);
resBody.setMsg("删除失败");
}
return resBody;
}
@GetMapping("/api/findRepair")
public ResBody findRepair(@RequestParam int page,
@RequestParam int limit,
@RequestParam String name) {
ResBody resBody = new ResBody();
int count = 0;
List<Repair> list= new ArrayList<>();
if (name.isEmpty()){
count = service.getCount();
list= service.getAllRepairs(page, limit);
}else {
count = service.getCount(name);
list= service.findRepair(page, limit,name);
}
resBody.setCount(count);
resBody.setData(list);
resBody.setCode(0);
return resBody;
}
}