Browse Source

1) Добавлена 2 уровень входадля всех, кроме студентов
2) Добавлена регистрация для всех (тестил вроде работает)
3) Добавлен мэпинг страниц "О нас, контакты"
4) Остается проблема с 2 уровнем входа для студентов - проблема со связанными выпадающими списками (чтобы при выборе группы подгружался список студентов). Скрипт, который должен работать не работает, покадумаю

на данный момент функционал:
1) Вход администраторов от и до
2) Вход заказчиков от и до
3) Регистрация всех от и до
4) Вход студентов 1 уровень

Кинетик 6 years ago
parent
commit
8729bd52ad

+ 7 - 0
.idea/dictionaries/.xml

@@ -0,0 +1,7 @@
+<component name="ProjectDictionaryState">
+  <dictionary name="Кинетик">
+    <words>
+      <w>registrate</w>
+    </words>
+  </dictionary>
+</component>

+ 11 - 0
src/EntitiesDao/AdminDao.java

@@ -2,6 +2,7 @@ package EntitiesDao;
 
 import HibernateEntities.ClientsEntity;
 import HibernateEntities.ModeratorsEntity;
+import HibernateEntities.StudentsEntity;
 import org.hibernate.Session;
 import org.hibernate.query.Query;
 
@@ -37,4 +38,14 @@ public class AdminDao {
         session.close();
         return adminsList;
     }
+    public static void createNewAdmin(ModeratorsEntity admin) {
+        Session session = getSession();
+        Query query = session.createQuery("select max(modId) from ModeratorsEntity ");
+        Integer res = (Integer) query.uniqueResult();
+        admin.setModId(res+1);
+        session.beginTransaction();
+        session.save(admin);
+        session.getTransaction().commit();
+        session.close();
+    }
 }

+ 10 - 0
src/EntitiesDao/ClientsDao.java

@@ -36,4 +36,14 @@ public class ClientsDao {
         session.close();
         return clientsList;
     }
+    public static void createNewClient(ClientsEntity client) {
+        Session session = getSession();
+        Query query = session.createQuery("Select max(clientId) FROM ClientsEntity ");
+        Integer res = (Integer)query.uniqueResult();
+        client.setClientId(res+1);
+        session.beginTransaction();
+        session.save(client);
+        session.getTransaction().commit();
+        session.close();
+    }
 }

+ 11 - 0
src/EntitiesDao/StudentDao.java

@@ -1,5 +1,6 @@
 package EntitiesDao;
 
+import HibernateEntities.ClientsEntity;
 import HibernateEntities.StudentsEntity;
 import org.hibernate.Session;
 import org.hibernate.query.Query;
@@ -21,4 +22,14 @@ public class StudentDao {
         session.close();
         return res;
     }
+    public static void createNewStudent(StudentsEntity student) {
+        Session session = getSession();
+        Query query = session.createQuery("Select max(studentsId) FROM StudentsEntity ");
+        Integer res = (Integer)query.uniqueResult();
+        student.setStudentsId(res+1);
+        session.beginTransaction();
+        session.save(student);
+        session.getTransaction().commit();
+        session.close();
+    }
 }

+ 8 - 0
src/controller/controller.java

@@ -121,5 +121,13 @@ public class controller {
         List<StudentsEntity> stList = loadStudent(groupId);
         return stList;
     }
+    @RequestMapping(value="/aboutUs")
+    public ModelAndView aboutUs(){
+        return new ModelAndView("aboutPage");
+    }
+    @RequestMapping(value="/contacts")
+    public ModelAndView contacts(){
+        return new ModelAndView("contactPage");
+    }
 
 }

+ 72 - 0
src/controller/registrationController.java

@@ -0,0 +1,72 @@
+package controller;
+
+import HibernateEntities.ClientsEntity;
+import HibernateEntities.GroupsEntity;
+import HibernateEntities.ModeratorsEntity;
+import HibernateEntities.StudentsEntity;
+import LoginEntities.LoginUser;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.servlet.ModelAndView;
+
+import java.util.List;
+
+import static EntitiesDao.AdminDao.createNewAdmin;
+import static EntitiesDao.GroupDao.getGroupList;
+import static EntitiesDao.StudentDao.createNewStudent;
+import static EntitiesDao.ClientsDao.createNewClient;
+
+/**
+ * Created by Кинетик on 02.01.2017.
+ */
+@Controller
+public class registrationController {
+    ModelAndView mvUsers = new ModelAndView();
+    {
+        mvUsers.setViewName("index");
+        mvUsers.addObject("userJSP", new LoginUser());
+    }
+    @RequestMapping(value="/registrate")
+    public ModelAndView registrationUser(){
+        return new ModelAndView("registration");
+    }
+    @RequestMapping(value="/regStudent")
+    public ModelAndView regStudentLink(){
+        ModelAndView mv = new ModelAndView("regStudentPage");
+        List<GroupsEntity> groupList = getGroupList();
+        mv.addObject("groupList",groupList);
+        mv.addObject("student", new StudentsEntity());
+        return mv;
+    }
+    @RequestMapping(value="/regClient")
+    public ModelAndView regClientLink(){
+        ModelAndView mv = new ModelAndView("regCLientPage");
+        mv.addObject("client", new ClientsEntity());
+        return mv;
+    }
+    @RequestMapping(value="/regAdmin")
+    public ModelAndView regAdminLink(){
+        ModelAndView mv = new ModelAndView("regAdminPage");
+        mv.addObject("admin",new ModeratorsEntity());
+        return mv;
+    }
+    @RequestMapping(value="/regStudentAction")
+    public ModelAndView regStudentAction(@ModelAttribute("student") StudentsEntity student){
+        createNewStudent(student);
+        mvUsers.addObject("message","registration of student done");
+        return mvUsers;
+    }
+    @RequestMapping(value="/regClientAction")
+    public ModelAndView regClientAction(@ModelAttribute("client") ClientsEntity client){
+        createNewClient(client);
+        mvUsers.addObject("message","registration of client done");
+        return mvUsers;
+    }
+    @RequestMapping(value="/regAdminAction")
+    public ModelAndView regAdminAction(@ModelAttribute("admin") ModeratorsEntity admin){
+        createNewAdmin(admin);
+        mvUsers.addObject("message","registration of admin done");
+        return mvUsers;
+    }
+}

+ 16 - 0
web/WEB-INF/views/aboutPage.jsp

@@ -0,0 +1,16 @@
+<%--
+  Created by IntelliJ IDEA.
+  User: Кинетик
+  Date: 03.01.2017
+  Time: 9:39
+  To change this template use File | Settings | File Templates.
+--%>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<html>
+<head>
+    <title>About</title>
+</head>
+<body>
+
+</body>
+</html>

+ 16 - 0
web/WEB-INF/views/contactPage.jsp

@@ -0,0 +1,16 @@
+<%--
+  Created by IntelliJ IDEA.
+  User: Кинетик
+  Date: 03.01.2017
+  Time: 9:40
+  To change this template use File | Settings | File Templates.
+--%>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<html>
+<head>
+    <title>Contacts</title>
+</head>
+<body>
+
+</body>
+</html>

+ 4 - 4
web/WEB-INF/views/index.jsp

@@ -25,10 +25,10 @@
 <div class="inner">
     <h3 class="masthead-brand">Mephorce</h3>
     <nav class="nav nav-masthead">
-        <a class="nav-link active" href="#">Войти</a>
-        <a class="nav-link" href="#">О проекте</a>
-        <a class="nav-link" href="#">Создать аккаунт</a>
-        <a class="nav-link" href="#">Контакты</a>
+        <a class="nav-link active" href="/">Войти</a>
+        <a class="nav-link" href="/aboutUs">О проекте</a>
+        <a class="nav-link" href="/registrate">Создать аккаунт</a>
+        <a class="nav-link" href="/contacts">Контакты</a>
     </nav>
 </div>
 

+ 27 - 0
web/WEB-INF/views/regAdminPage.jsp

@@ -0,0 +1,27 @@
+<%@ taglib prefix="spring" uri="http://www.springframework.org/tags/form" %>
+<%--
+  Created by IntelliJ IDEA.
+  User: Кинетик
+  Date: 02.01.2017
+  Time: 23:30
+  To change this template use File | Settings | File Templates.
+--%>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<html>
+<head>
+    <title>reg admin</title>
+</head>
+<body>
+<spring:form method="post"  modelAttribute="admin" action="regAdminAction">
+    <spring:input path="modFamily" type="text" placeholder="Фамилия"/>   <br/>
+    <spring:input path="modFirstName" type="text" placeholder="Имя"/>   <br/>
+    <spring:input path="modSecName" type="text" placeholder="Отчество"/>   <br/>
+    <spring:input path="modEmail" type="text" placeholder="E-mail"/>   <br/>
+    <spring:input path="modHometown" type="text" placeholder="Город"/>   <br/>
+    <spring:input path="modPhone" type="text" placeholder="Телефон"/>   <br/>
+    <spring:input path="modBirthdate" type="date" placeholder="День рождения"/> <br/>
+    <spring:input path="modPassword" type="password" placeholder="Пароль"/>   <br/>
+    <spring:button>Зарегистрироваться</spring:button>
+</spring:form>
+</body>
+</html>

+ 25 - 0
web/WEB-INF/views/regClientPage.jsp

@@ -0,0 +1,25 @@
+<%@ taglib prefix="spring" uri="http://www.springframework.org/tags/form" %>
+<%--
+  Created by IntelliJ IDEA.
+  User: Кинетик
+  Date: 02.01.2017
+  Time: 23:30
+  To change this template use File | Settings | File Templates.
+--%>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<html>
+<head>
+    <title>reg client</title>
+</head>
+<body>
+<body>
+<spring:form method="post"  modelAttribute="client" action="regClientAction">
+    <spring:input path="clFamily" type="text" placeholder="Фамилия"/>   <br/>
+    <spring:input path="clFirstName" type="text" placeholder="Имя"/>   <br/>
+    <spring:input path="clSecName" type="text" placeholder="Отчество"/>   <br/>
+    <spring:input path="clPassword" type="password" placeholder="Пароль"/>   <br/>
+    <spring:button>Зарегистрироваться</spring:button>
+</spring:form>
+</body>
+</body>
+</html>

+ 30 - 0
web/WEB-INF/views/regStudentPage.jsp

@@ -0,0 +1,30 @@
+<%@ taglib prefix="spring" uri="http://www.springframework.org/tags/form" %>
+<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
+<%--
+  Created by IntelliJ IDEA.
+  User: Кинетик
+  Date: 02.01.2017
+  Time: 23:29
+  To change this template use File | Settings | File Templates.
+--%>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<html>
+<head>
+    <title>student form</title>
+</head>
+<body>
+<spring:form method="post"  modelAttribute="student" action="regStudentAction">
+    <spring:input path="stFamily" type="text" placeholder="Фамилия"/>   <br/>
+    <spring:input path="stFirstName" type="text" placeholder="Имя"/>   <br/>
+    <spring:input path="stSecName" type="text" placeholder="Отчество"/>   <br/>
+    <spring:input path="stPkNumber" type="password" placeholder="Пароль"/>   <br/>
+    <form:select id="groupId" path="stGroup">
+        <c:forEach items="${groupList}" var="group">
+            <form:option value="${group.groupId}" >${group.groupName}</form:option>
+        </c:forEach><br/>
+    </form:select>
+    <spring:button>Зарегистрироваться</spring:button>
+</spring:form>
+</body>
+</html>

+ 18 - 0
web/WEB-INF/views/registration.jsp

@@ -0,0 +1,18 @@
+<%@ taglib prefix="spring" uri="http://www.springframework.org/tags/form" %>
+<%--
+  Created by IntelliJ IDEA.
+  User: Кинетик
+  Date: 02.01.2017
+  Time: 23:09
+  To change this template use File | Settings | File Templates.
+--%>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<html>
+<head>
+    <title>First step regit page</title>
+</head>
+<body>
+    <a href="/regStudent">Исполнитель</a>
+    <a href="/regAdmin">Администратор</a>
+    <a href="/regClient">Заказчик</a>
+</html>

+ 8 - 2
web/WEB-INF/views/studentBar.jsp

@@ -23,11 +23,17 @@
     $(document).ready(function() {
         $('#groupId').change(
             function() {
-                $.getJSON('${loadStudentsByGroup}', {
-                    groupId : $(this).value(),
+                $.get('${loadStudentsByGroup}', {
+                    groupId : $(this).val(),
                     ajax : 'true'
                 }, function(data) {
                     var html = '<option value="">Первый элемент</option>';
+                    var len = data.length;
+                    for ( var i = 0; i < len; i++) {
+                        html += '<option value="' + data[i].studentsId + '">'
+                            + data[i].stFamily + '</option>';
+                    }
+                    html += '</option>';
                     $('#studentId').html(html);
                 });
             });