diff --git a/pom.xml b/pom.xml index 057256f..024f723 100644 --- a/pom.xml +++ b/pom.xml @@ -111,7 +111,7 @@ org.projectlombok lombok 1.16.10 - s + diff --git a/src/main/java/com/codesdream/ase/AseApplication.java b/src/main/java/com/codesdream/ase/AseApplication.java index d06b3f4..9130640 100644 --- a/src/main/java/com/codesdream/ase/AseApplication.java +++ b/src/main/java/com/codesdream/ase/AseApplication.java @@ -2,7 +2,6 @@ package com.codesdream.ase; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; @SpringBootApplication public class AseApplication { diff --git a/src/main/java/com/codesdream/ase/controller/ASEErrorController.java b/src/main/java/com/codesdream/ase/controller/ASEErrorController.java new file mode 100644 index 0000000..189d0cd --- /dev/null +++ b/src/main/java/com/codesdream/ase/controller/ASEErrorController.java @@ -0,0 +1,30 @@ +package com.codesdream.ase.controller; + +import org.springframework.boot.web.servlet.error.ErrorController; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.RequestMapping; + +import javax.servlet.http.HttpServletRequest; + +@Controller +public class ASEErrorController implements ErrorController { + + @RequestMapping("/error") + public String handleError(HttpServletRequest request, Model model){ + Integer statusCode = (Integer) request.getAttribute("javax.servlet.error.status_code"); + Exception exception = (Exception) request.getAttribute("javax.servlet.error.exception"); + + // 页面未找到 + if(statusCode == 404){ + return "not_found"; + } + + return"error"; + } + + @Override + public String getErrorPath() { + return "/error"; + } +} diff --git a/src/main/java/com/codesdream/ase/model/permission/UserDetail.java b/src/main/java/com/codesdream/ase/model/permission/UserDetail.java index 8930313..52f7fb8 100644 --- a/src/main/java/com/codesdream/ase/model/permission/UserDetail.java +++ b/src/main/java/com/codesdream/ase/model/permission/UserDetail.java @@ -29,4 +29,10 @@ public class UserDetail { // 所属专业 @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) private BaseMajor baseMajor; + + // 真实姓名 + private String realName; + + // 学生ID + private String studentID; } diff --git a/src/main/java/com/codesdream/ase/service/UserService.java b/src/main/java/com/codesdream/ase/service/UserService.java index 8ff8f86..6863e65 100644 --- a/src/main/java/com/codesdream/ase/service/UserService.java +++ b/src/main/java/com/codesdream/ase/service/UserService.java @@ -34,14 +34,14 @@ public class UserService implements IUserService { @Override public User save(User user) { + // 查找用户名是否已经被注册 if(userRepository.findByUsername(user.getUsername()).isPresent()) throw new RuntimeException("Username Already Exists"); user.setPassword(asePasswordEncoder.encode(user.getPassword())); - user.setEnabled(true); - user.setDeleted(false); return userRepository.save(user); } + // 获得一个默认初始化的用户对象 @Override public User getDefaultUser() { return new User(); diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index f04afda..be36823 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -7,7 +7,7 @@ spring.thymeleaf.encoding=UTF-8 spring.jpa.generate-ddl=false spring.jpa.show-sql=true -spring.jpa.hibernate.ddl-auto=create +spring.jpa.hibernate.ddl-auto=update spring.jooq.sql-dialect=org.hibernate.dialect.MySQL5InnoDBDialect spring.jpa.open-in-view=true spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true @@ -15,3 +15,6 @@ spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true spring.datasource.url=jdbc:mysql://${MYSQL_HOST:119.23.9.34}:3306/ase?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC spring.datasource.username=codedream spring.datasource.password=codedreampasswd + +server.error.whitelabel.enabled=false + diff --git a/src/main/resources/templates/error.html b/src/main/resources/templates/error.html index 672d490..3c55a1c 100644 --- a/src/main/resources/templates/error.html +++ b/src/main/resources/templates/error.html @@ -1,12 +1,7 @@ - + - - - - - -
error diff --git a/src/main/resources/templates/not_found.html b/src/main/resources/templates/not_found.html index f892a34..1890621 100644 --- a/src/main/resources/templates/not_found.html +++ b/src/main/resources/templates/not_found.html @@ -1,12 +1,7 @@ - + - - - - - -
notfound