完成管理员主页的数据读取

This commit is contained in:
F嘉阳
2018-02-08 22:31:27 +08:00
parent f43146a590
commit 246f9d7e00
14 changed files with 544 additions and 103 deletions

View File

@@ -1,12 +1,15 @@
package com.fjy.spring.controller;
import com.fjy.spring.domain.VFeedBack;
import com.fjy.spring.domain.VLog;
import com.fjy.spring.domain.VWorkDetail;
import com.fjy.spring.enums.ResultEnum;
import com.fjy.spring.exception.UserException;
import com.fjy.spring.service.FeedBackService;
import com.fjy.spring.service.LogService;
import com.fjy.spring.service.WorkDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@@ -17,6 +20,12 @@ public class DataController {
@Autowired
private WorkDetailService workDetailService;
@Autowired
private LogService logService;
@Autowired
private FeedBackService feedBackService;
@GetMapping("/home/findAllHomework")
public List<VWorkDetail> findAllHomework(){
List<VWorkDetail> homeworks = workDetailService.findAll();
@@ -26,4 +35,24 @@ public class DataController {
new UserException(ResultEnum.EMPTY_DATA);
return null;
}
@GetMapping("/home/findvlog")
public List<VLog> findlog(){
List<VLog> vlogs = logService.findvlog();
if (vlogs!=null){
return vlogs;
}
new UserException(ResultEnum.EMPTY_DATA);
return null;
}
@GetMapping("/home/findvfeedback")
public List<VFeedBack> findAllVFeedback(){
List<VFeedBack> feedBacks = feedBackService.findAllVFeedback();
if (feedBacks!=null){
return feedBacks;
}
new UserException(ResultEnum.EMPTY_DATA);
return null;
}
}

View File

@@ -35,6 +35,11 @@ public class NavController {
return "/home/about";
}
@GetMapping(value = {"/admin"})
public String toAdminPage(){
return "/home/admin";
}
@GetMapping(value = {"/home/user"})
public String toUserPage(){
return "/home/user";

View File

@@ -0,0 +1,56 @@
package com.fjy.spring.domain;
import org.hibernate.annotations.Immutable;
import org.hibernate.annotations.Subselect;
import javax.persistence.*;
@Entity
@Immutable
@Subselect("SELECT * FROM v_feedback")
public class VFeedBack {
@Id
@Column(name = "feedbackid")
private Integer id;
@Column(name = "colname")
private String username;
@Column(name = "feedbackcontent")
private String content;
@Column(name = "issuetime")
private String time;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
}

View File

@@ -0,0 +1,62 @@
package com.fjy.spring.domain;
import org.hibernate.annotations.Immutable;
import org.hibernate.annotations.Subselect;
import javax.persistence.*;
@Entity
@Immutable
@Subselect("SELECT *FROM v_log LIMIT 0, 20")
public class VLog {
@Id
private Integer logid;
private String colname;
private String coltime;
private String colip;
private String colheader;
public Integer getLogid() {
return logid;
}
public void setLogid(Integer logid) {
this.logid = logid;
}
public String getColname() {
return colname;
}
public void setColname(String colname) {
this.colname = colname;
}
public String getColtime() {
return coltime;
}
public void setColtime(String coltime) {
this.coltime = coltime;
}
public String getColip() {
return colip;
}
public void setColip(String colip) {
this.colip = colip;
}
public String getColheader() {
return colheader;
}
public void setColheader(String colheader) {
this.colheader = colheader;
}
}

View File

@@ -6,7 +6,7 @@ import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
/*@Configuration*/
public class WebAppConfig implements WebMvcConfigurer {
/**

View File

@@ -0,0 +1,9 @@
package com.fjy.spring.repository;
import com.fjy.spring.domain.VFeedBack;
import org.springframework.data.jpa.repository.JpaRepository;
public interface VFeedBackRepository extends JpaRepository<VFeedBack,Integer> {
}

View File

@@ -0,0 +1,8 @@
package com.fjy.spring.repository;
import com.fjy.spring.domain.VLog;
import org.springframework.data.jpa.repository.JpaRepository;
public interface VLogRepository extends JpaRepository<VLog,Integer> {
}

View File

@@ -1,17 +1,24 @@
package com.fjy.spring.service;
import com.fjy.spring.domain.TbFeedBack;
import com.fjy.spring.domain.VFeedBack;
import com.fjy.spring.enums.ResultEnum;
import com.fjy.spring.exception.UserException;
import com.fjy.spring.repository.TbFeedBackRepository;
import com.fjy.spring.repository.VFeedBackRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class FeedBackService {
@Autowired
TbFeedBackRepository feedBackRepository;
@Autowired
VFeedBackRepository vFeedBackRepository;
public boolean addContent(TbFeedBack feedBack){
TbFeedBack feed=feedBackRepository.save(feedBack);
if (feed!=null){
@@ -20,4 +27,8 @@ public class FeedBackService {
new UserException(ResultEnum.ADD_ERROR);
return false;
}
public List<VFeedBack> findAllVFeedback(){
return vFeedBackRepository.findAll();
}
}

View File

@@ -1,16 +1,27 @@
package com.fjy.spring.service;
import com.fjy.spring.domain.TbLog;
import com.fjy.spring.domain.VLog;
import com.fjy.spring.repository.TbLogRepository;
import com.fjy.spring.repository.VLogRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class LogService {
@Autowired
private TbLogRepository tbLogRepository;
@Autowired
private VLogRepository vLogRepository;
public void addLogRec(TbLog tbLog){
tbLogRepository.save(tbLog);
}
public List<VLog> findvlog(){
return vLogRepository.findAll();
}
}