Skip to content

Commit

Permalink
directory content clean.
Browse files Browse the repository at this point in the history
  • Loading branch information
BG317958 committed Apr 19, 2018
1 parent ff34792 commit 46b40a7
Show file tree
Hide file tree
Showing 633 changed files with 72,160 additions and 98 deletions.
19 changes: 19 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,23 @@


</dependencies>

<build>
<finalName>horizon_build</finalName>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<port>8088</port>
<path>/</path>
<uriEncoding>UTF-8</uriEncoding>
<server>tomcat7</server>
</configuration>
</plugin>
</plugins>
</build>


</project>
5 changes: 4 additions & 1 deletion rainbow.iml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@
</sourceRoots>
</configuration>
</facet>
<facet type="Spring" name="Spring">
<configuration />
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="false">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
Expand Down
84 changes: 63 additions & 21 deletions src/main/java/controller/LoginController.java
Original file line number Diff line number Diff line change
@@ -1,57 +1,99 @@
package controller;

import com.alibaba.fastjson.JSON;
import domain.UserInfo;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.support.SessionStatus;
import service.LoginService;

import javax.servlet.http.HttpSession;

/**
* Created by pengfei on 2017/9/22.
*/
@Controller
@SessionAttributes("user")
public class LoginController {

private final static Logger logger=Logger.getLogger(LoginController.class);
private final static Logger logger = Logger.getLogger(LoginController.class);

@Autowired
private LoginService loginService;

@RequestMapping(value = "/login", method = RequestMethod.GET)
public String get(){
@RequestMapping(value = "/homePage")
public String get(HttpSession session) {
logger.info("Inside login get method");
return "home";

UserInfo currentUser = (UserInfo) session.getAttribute("user");
logger.info("Current User:" + currentUser.getName());

return "homePage";
}

//public String login(@RequestParam("name") String name, String password, ModelMap model){
//public String login(String name, String password, ModelMap model){

@RequestMapping(value = "/loginHere",method=RequestMethod.POST)
public String login(@RequestParam("name") String name, String password, ModelMap model){
@RequestMapping(value = "/loginHere")
public String login(@RequestParam("name") String name, String password, ModelMap model) {
logger.info("Login controller begin service");

model.addAttribute("password",password);
model.addAttribute("name",name);
UserInfo user = new UserInfo();
user.setName(name);
user.setPassword(password);

if(password==null)
throw new RuntimeException("Password should not be null!");
model.addAttribute("bean", user);

logger.info("Login controller end service!");
if (loginService.checkUserAccess(name, password)) {
logger.info("Login controller end service!");

return "homePage";
user.setPassword("");
model.addAttribute("user", user);

return "redirect:/homePage";
} else {
return "login";
}
}

@RequestMapping(value="/toLoginPage",method = RequestMethod.GET)
public String redirect(){
@RequestMapping(value = "/toLoginPage", method = RequestMethod.GET)
public String redirect() {
return "redirect:login";
}

@RequestMapping(value = "/visitStaticPage",method = RequestMethod.GET)
public String visitStaticPage(){
@RequestMapping(value = "/visitStaticPage", method = RequestMethod.GET)
public String visitStaticPage() {

return "redirect:/pages/static.html";
}


//Return to previous path
@ResponseBody
@RequestMapping(value = "/getUserSession")
public String getUserSession( HttpSession session) {
String result="";

Object obj=session.getAttribute("user");
if (obj instanceof String){
result= (String) obj;
}else if (obj instanceof UserInfo){
result=((UserInfo) obj).getName();
}

result= JSON.toJSONString(result);

return result;
}

@RequestMapping("/logOut")
@ResponseBody
public String logout( SessionStatus status){
status.setComplete();
return "logout";
}

}
2 changes: 2 additions & 0 deletions src/main/java/dao/UserDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ public interface UserDao {

public Object findUser(int userID);

public Object findUser(String userName);

public List findAllUser();
}
7 changes: 6 additions & 1 deletion src/main/java/dao/UserDaoImpl.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dao;

import com.alibaba.fastjson.JSON;
import domain.UserInfo;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Component;
Expand Down Expand Up @@ -32,6 +31,12 @@ public Object findUser(int userID) {

}

public Object findUser(String userName) {
UserInfo user = this.getSqlSession().selectOne("USER.findUserByName", userName);
return user;

}

public List findAllUser() {
int cnt = this.getSqlSession().selectOne("USER.count");

Expand Down
19 changes: 19 additions & 0 deletions src/main/java/domain/UserInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public class UserInfo {
private String comment;
private String password;
private String email;
private String create;
private String update;

public UserInfo() {

Expand Down Expand Up @@ -69,4 +71,21 @@ public void setEmail(String email) {
}


public String getCreate() {
return create;
}

public void setCreate(String create) {
this.create = create;
}

public String getUpdate() {
return update;
}

public void setUpdate(String update) {
this.update = update;
}


}
19 changes: 19 additions & 0 deletions src/main/java/service/LoginService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package service;

import domain.UserInfo;

import java.util.Map;

/**
* Created by pengfei on 2017/9/12.
*/
public interface LoginService {

public void addUser(UserInfo info);

public void deleteUser(UserInfo info);

public UserInfo queryUser(UserInfo info);

public boolean checkUserAccess(String userName, String pwd);
}
62 changes: 62 additions & 0 deletions src/main/java/service/LoginServiceImpl.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package service;

import Utility.RedisCache;
import com.alibaba.fastjson.JSON;
import dao.UserDao;
import domain.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
* Created by pengfei on 2017/9/12.
*/

@Service("LoginService")
public class LoginServiceImpl implements LoginService {

@Autowired
private RedisCache redisCache;

@Autowired
private UserDao userDao;

public void addUser(UserInfo info) {
this.userDao.saveUserData(info);
System.out.println("Service:add user");
}

public void deleteUser(UserInfo info) {
this.userDao.delUser(info);
System.out.println("Service:delete user");
}

public UserInfo queryUser(UserInfo info) {

//First check Redis redisCache.
String userJsonValue = (String) this.redisCache.get("user:" + info.getId());
if (!StringUtils.isEmpty(userJsonValue)) {
UserInfo result = JSON.parseObject(userJsonValue, UserInfo.class);
System.out.println("Cache got");
return result;
}

//If redis not found, check Database.
UserInfo user = (UserInfo) this.userDao.findUser(info.getId());

//Save in Redis.
this.redisCache.set("user:" + info.getId(), user);
System.out.println("DB got");
return user;
}

public boolean checkUserAccess(String userName, String pwd){
UserInfo user=(UserInfo) userDao.findUser(userName);

if (user ==null ||!user.getPassword().equals(pwd)){
return false;
}else{
return true;
}
}
}
1 change: 1 addition & 0 deletions src/main/java/service/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
/**
* Created by pengfei on 2017/9/2.
*/
@Service("UserService")
public class UserService {

private UserDao userDao;
Expand Down
10 changes: 3 additions & 7 deletions src/main/resources/mybatis/application.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
</tx:advice>

<aop:config>
<aop:pointcut id="createOperation"
expression="execution(* dao.StudentDaoImpl.declarativeTxTest(..))"/>
<aop:pointcut id="createOperation" expression="execution(* dao.StudentDaoImpl.declarativeTxTest(..))"/>

<aop:advisor advice-ref="txAdvice" pointcut-ref="createOperation"/>
</aop:config>
Expand All @@ -38,7 +37,7 @@
<property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
<property name="url" value="jdbc:mysql://localhost:3306/rainbow"></property>
<property name="username" value="root"></property>
<property name="password" value="mysql"></property>
<property name="password" value="jack_bai"></property>
</bean>

<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
Expand All @@ -51,9 +50,6 @@
</bean>

<bean id="userDAO" class="dao.UserDaoImpl" parent="abstractDAO"/>
<bean id="userService" class="service.UserService">
<property name="userDao" ref="userDAO"></property>
</bean>

<bean id="poolConfig" class="redis.clients.jedis.JedisPoolConfig">
<property name="maxIdle" value="25"/>
Expand All @@ -65,7 +61,7 @@

<bean id="pool" class="redis.clients.jedis.JedisPool">
<constructor-arg index="0" ref="poolConfig"/>
<constructor-arg index="1" value="localhost"/>
<constructor-arg index="1" value="10.45.4.45"/>
<constructor-arg index="2" value="6379"/>
<constructor-arg index="3" value="2000"/>
</bean>
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/mybatis/user-mapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
select * from userinfo where id= #{id}
</select>

<select id="findUserByName" resultType="domain.UserInfo" >
select * from userinfo where name = #{name}
</select>

<insert id="insertUser" parameterType="domain.UserInfo" useGeneratedKeys="true" keyProperty="id">
insert into userinfo (name,salary,comment) values (#{name},#{salary},#{comment})
</insert>
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/WEB-INF/errorPage/404.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/lib/bootstrap-3.3.7-dist/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>

Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/WEB-INF/errorPage/405.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/lib/bootstrap-3.3.7-dist/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>

Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/WEB-INF/errorPage/500.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/lib/bootstrap-3.3.7-dist/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>

Expand Down
8 changes: 8 additions & 0 deletions src/main/webapp/WEB-INF/js/common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function checkrst(data) {
dataobj=JSON.parse(data);
if(dataobj.rst_code === 0){
return dataobj.rst_data;
}
$.messager.alert('Warning', dataobj.rst_msg);
return false;
}
Loading

0 comments on commit 46b40a7

Please sign in to comment.