修复用户信息修改页面数据绑定方式,改为使用axios进行数据获取和绑定

This commit is contained in:
F嘉阳
2018-02-23 10:49:55 +08:00
parent 3abbd49f65
commit c91ee252a3
7 changed files with 168 additions and 15 deletions

View File

@@ -9,8 +9,12 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import static com.fjy.spring.constant.GlobalConstant.USER_SESSION_KEY;
@RestController
public class DataController {
@@ -38,6 +42,9 @@ public class DataController {
@Autowired
private VUserfileService vUserfileService;
@Resource
HttpServletRequest httpServletRequest;
@GetMapping("/home/findAllHomework")
public List<VWorkDetail> findAllHomework(){
List<VWorkDetail> homeworks = workDetailService.findAll();
@@ -108,4 +115,10 @@ public class DataController {
new UserException(ResultEnum.EMPTY_DATA);
return null;
}
@GetMapping("/home/userinfo")
public VUserinfo findUserInfo(){
TbUser user= (TbUser)httpServletRequest.getSession().getAttribute(USER_SESSION_KEY);
return userService.findUserInfo(user.getColuserid());
}
}

View File

@@ -0,0 +1,74 @@
package com.fjy.spring.domain;
import org.hibernate.annotations.Immutable;
import org.hibernate.annotations.Subselect;
import javax.persistence.Entity;
import javax.persistence.Id;
@Entity
@Immutable
@Subselect("SELECT * FROM v_userinfo")
public class VUserinfo {
@Id
private Integer coluserid;
private String colname;
private String colemail;
private String colstudentno;
private String colrealname;
public Integer getColuserid() {
return coluserid;
}
public void setColuserid(Integer coluserid) {
this.coluserid = coluserid;
}
public String getColname() {
return colname;
}
public void setColname(String colname) {
this.colname = colname;
}
public String getColemail() {
return colemail;
}
public void setColemail(String colemail) {
this.colemail = colemail;
}
public String getColstudentno() {
return colstudentno;
}
public void setColstudentno(String colstudentno) {
this.colstudentno = colstudentno;
}
public String getColrealname() {
return colrealname;
}
public void setColrealname(String colrealname) {
this.colrealname = colrealname;
}
@Override
public String toString() {
return "VUserinfo{" +
"coluserid=" + coluserid +
", colname='" + colname + '\'' +
", colemail='" + colemail + '\'' +
", colstudentno='" + colstudentno + '\'' +
", colrealname='" + colrealname + '\'' +
'}';
}
}

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,8 @@
package com.fjy.spring.repository;
import com.fjy.spring.domain.VUserinfo;
import org.springframework.data.jpa.repository.JpaRepository;
public interface VUserinfoRepository extends JpaRepository<VUserinfo,Integer> {
}

View File

@@ -1,9 +1,11 @@
package com.fjy.spring.service;
import com.fjy.spring.domain.TbUser;
import com.fjy.spring.domain.VUserinfo;
import com.fjy.spring.enums.ResultEnum;
import com.fjy.spring.exception.UserException;
import com.fjy.spring.repository.TbUserRepository;
import com.fjy.spring.repository.VUserinfoRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -16,6 +18,9 @@ public class UserService {
@Autowired
private TbUserRepository tbUserRepository;
@Autowired
private VUserinfoRepository vUserinfoRepository;
public TbUser doLoginService(String name,String password){
TbUser user = (TbUser)tbUserRepository.findByColname(name).get();
@@ -44,4 +49,8 @@ public class UserService {
return tbUserRepository.findAll();
}
public VUserinfo findUserInfo(Integer coluserid){
return vUserinfoRepository.findById(coluserid).get();
}
}