diff --git a/pom.xml b/pom.xml index 4ddbb45..000a8cf 100644 --- a/pom.xml +++ b/pom.xml @@ -54,11 +54,18 @@ spring-security-test test + org.springframework.boot spring-boot-devtools true + + + org.springframework.boot + spring-boot-starter-data-jpa + + diff --git a/src/main/java/com/codesdream/ase/configure/AppConfigure.java b/src/main/java/com/codesdream/ase/configure/AppConfigure.java new file mode 100644 index 0000000..00cd0c7 --- /dev/null +++ b/src/main/java/com/codesdream/ase/configure/AppConfigure.java @@ -0,0 +1,27 @@ +package com.codesdream.ase.configure; + +import org.springframework.context.annotation.Configuration; + +@Configuration +public class AppConfigure { + private String name = "全员育人"; + private String englishName = "All Staff Education"; + private String version = "0.0.1"; + private String organization = "码梦工坊"; + + public String getName() { + return name; + } + + public String getVersion() { + return version; + } + + public String getEnglishName() { + return englishName; + } + + public String getOrganization() { + return organization; + } +} diff --git a/src/main/java/com/codesdream/ase/configure/GlobalConfigure.java b/src/main/java/com/codesdream/ase/configure/GlobalConfigure.java new file mode 100644 index 0000000..a9fd48b --- /dev/null +++ b/src/main/java/com/codesdream/ase/configure/GlobalConfigure.java @@ -0,0 +1,20 @@ +package com.codesdream.ase.configure; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.thymeleaf.spring5.view.ThymeleafViewResolver; + +import javax.annotation.Resource; +import java.util.HashMap; +import java.util.Map; + +@Configuration +public class GlobalConfigure { + @Resource + AppConfigure appConfigure; + + public AppConfigure getAppConfigure() { + return appConfigure; + } + +} diff --git a/src/main/java/com/codesdream/ase/controller/ASEController.java b/src/main/java/com/codesdream/ase/controller/ASEController.java index c3b1024..3cf3350 100644 --- a/src/main/java/com/codesdream/ase/controller/ASEController.java +++ b/src/main/java/com/codesdream/ase/controller/ASEController.java @@ -1,14 +1,22 @@ package com.codesdream.ase.controller; +import com.codesdream.ase.configure.GlobalConfigure; import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; +import javax.annotation.Resource; +import java.security.Principal; + @Controller public class ASEController { + @Resource + GlobalConfigure globalConfigure; @RequestMapping(value = "/") - public String printIndex(){ + public String printIndex(Model model, Principal principal){ + model.addAttribute("username",principal.getName()); return "index"; } } diff --git a/src/main/java/com/codesdream/ase/model/Permit.java b/src/main/java/com/codesdream/ase/model/Permit.java new file mode 100644 index 0000000..3318763 --- /dev/null +++ b/src/main/java/com/codesdream/ase/model/Permit.java @@ -0,0 +1,94 @@ +package com.codesdream.ase.model; + +import javax.persistence.*; +import java.util.Objects; + +@Entity +@Table(name = "user_permit") +public class Permit { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private int id; + private String name; + private String description; + private String url; + private int pid; + + public Permit(){ + + } + + public Permit(String name, String description, String url, int pid) { + this.name = name; + this.description = description; + this.url = url; + this.pid = pid; + } + + public int getId() { + return id; + } + + public String getName() { + return name; + } + + public String getDescription() { + return description; + } + + public String getUrl() { + return url; + } + + public int getPid() { + return pid; + } + public void setId(int id) { + this.id = id; + } + + public void setName(String name) { + this.name = name; + } + + public void setDescription(String description) { + this.description = description; + } + + public void setUrl(String url) { + this.url = url; + } + + public void setPid(int pid) { + this.pid = pid; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Permit permit = (Permit) o; + return id == permit.id && + pid == permit.pid && + Objects.equals(name, permit.name) && + Objects.equals(description, permit.description) && + Objects.equals(url, permit.url); + } + + @Override + public int hashCode() { + return Objects.hash(id, name, description, url, pid); + } + + @Override + public String toString() { + return "Permit{" + + "id=" + id + + ", name='" + name + '\'' + + ", description='" + description + '\'' + + ", url='" + url + '\'' + + ", pid=" + pid + + '}'; + } +} diff --git a/src/main/java/com/codesdream/ase/repository/PermitRepository.java b/src/main/java/com/codesdream/ase/repository/PermitRepository.java new file mode 100644 index 0000000..acb5d47 --- /dev/null +++ b/src/main/java/com/codesdream/ase/repository/PermitRepository.java @@ -0,0 +1,12 @@ +package com.codesdream.ase.repository; + +import com.codesdream.ase.model.Permit; +import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface PermitRepository extends CrudRepository { + +} diff --git a/src/main/java/com/codesdream/ase/service/IPermitService.java b/src/main/java/com/codesdream/ase/service/IPermitService.java new file mode 100644 index 0000000..654df0e --- /dev/null +++ b/src/main/java/com/codesdream/ase/service/IPermitService.java @@ -0,0 +1,9 @@ +package com.codesdream.ase.service; + +import com.codesdream.ase.model.Permit; + +import java.util.List; + +public interface IPermitService { + List findAll(); +} diff --git a/src/main/java/com/codesdream/ase/service/PermitService.java b/src/main/java/com/codesdream/ase/service/PermitService.java new file mode 100644 index 0000000..05b93c8 --- /dev/null +++ b/src/main/java/com/codesdream/ase/service/PermitService.java @@ -0,0 +1,18 @@ +package com.codesdream.ase.service; + +import com.codesdream.ase.model.Permit; +import com.codesdream.ase.repository.PermitRepository; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.List; + +public class PermitService implements IPermitService { + + @Autowired + PermitRepository permitRepository; + + @Override + public List findAll() { + return (List) permitRepository.findAll(); + } +} diff --git a/src/main/java/com/codesdream/ase/service/UserService.java b/src/main/java/com/codesdream/ase/service/UserService.java new file mode 100644 index 0000000..29518ef --- /dev/null +++ b/src/main/java/com/codesdream/ase/service/UserService.java @@ -0,0 +1,5 @@ +package com.codesdream.ase.service; + +public interface UserService { + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index fe75398..216156f 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -6,4 +6,12 @@ spring.thymeleaf.mode=HTML spring.thymeleaf.encoding=UTF-8 spring.security.user.name=user -spring.security.user.password=123 \ No newline at end of file +spring.security.user.password=123 + +spring.jpa.generate-ddl=false +spring.jpa.show-sql=true +spring.jpa.hibernate.ddl-auto=create + +spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/ase?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC +spring.datasource.username=root +spring.datasource.password=Hy009048 diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index 18cfae2..fe8927a 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -8,7 +8,7 @@
-
+
@@ -529,7 +529,6 @@
-
diff --git a/src/main/resources/templates/layout.html b/src/main/resources/templates/layout.html index 106b524..34eaf89 100644 --- a/src/main/resources/templates/layout.html +++ b/src/main/resources/templates/layout.html @@ -425,7 +425,7 @@ -