Merge remote-tracking branch 'origin/master'

# Conflicts:
#	demo/src/main/java/com/example/demo/DemoApplication.java
#	demo/src/main/java/com/example/demo/loginService/SessionFilter.java
#	demo/src/main/java/com/example/demo/loginService/UserController.java
#	demo/src/main/java/com/example/demo/searchService/controller/SearchServiceController.java
master
jyx 7 years ago
commit dc10d7fdb6

@ -103,6 +103,12 @@
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>RELEASE</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>

@ -16,7 +16,7 @@ public interface usageDateMapper {
@Select("select productNum from usageDate group by productNum order by count(productNum) DESC")
public List<Integer> selectByCount();
public List<Long> selectByCount();
@Insert("insert into usagedate(checkNum, productNum, userNum," +
" bankAccount, bankNum, year, amount, startTime)" +

@ -3,14 +3,11 @@ package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
@ServletComponentScan()
//@ComponentScan()
@ServletComponentScan("com.example.demo")
//@MapperScan("com.example.demo.Dao")
public class DemoApplication extends SpringBootServletInitializer {
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}

@ -7,6 +7,6 @@ import org.springframework.stereotype.Service;
public abstract class UserService {
public User selectUserByuserName(String userName){return null;}
public User selectUserBytelephoneNum(String telephoneNum){return null;}
public void insertUser(long userNum, String userName, String userPwd, String registerTime, String userRight){}
public void addUser(User users){}
public long count(){return 0;}
}

@ -21,7 +21,7 @@ public class UserServiceImpl extends UserService{
return this.UserMapper.selectUserBytelephoneNum(telephoneNum);
}
@Transactional(propagation=Propagation.REQUIRED,readOnly = false)
public void insertUser(User user){
public void addUser(User user){
this.UserMapper.addUser(user);
}
@Transactional(propagation=Propagation.REQUIRED,readOnly = true)

@ -51,8 +51,7 @@ public class UserController extends HttpServlet {
String userName = request.getParameter("userName");
String userPwd = request.getParameter("userPwd");
String userPwd1=request.getParameter("userPwd1");
User user=new User();
user = this.userServiceImpl.selectUserByuserName(userName);
User user = this.userServiceImpl.selectUserByuserName(userName);
long count = 0;
int result = 0;
if(user!=null){
@ -74,7 +73,7 @@ public class UserController extends HttpServlet {
}else{
result = 3;
}
if(result==1)response.sendRedirect("Register.html");
if(result==1)response.sendRedirect("RegisterSuccess.html");
else if(result==2)response.sendRedirect("userExisted.html");
else response.sendRedirect("userPwdNotSame.html");
}

@ -6,9 +6,10 @@ import com.example.demo.bean.Product;
import com.example.demo.searchService.service.ProductSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
@ -18,18 +19,20 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@Controller
public class SearchServiceController extends HttpServlet {
//@Controller
@RestController
@RequestMapping("/search")
public class SearchServiceController{
@Autowired
private ProductSearchService productSearchService;
@RequestMapping("/search")
public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {
@RequestMapping(value = "/show",method = RequestMethod.POST)
public List<Product> search(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {
response.setContentType("text/html;charset=utf-8");
List<Product> list = new ArrayList<Product>();
String productName = request.getParameter("productName");
String category = request.getParameter("category");
float intrate = Integer.parseInt(request.getParameter("intrate"));
//float intrate = Float.parseFloat(request.getParameter("intrate"));
if(productName!=null){
list = productSearchService.findByNameLike(productName);
@ -37,25 +40,22 @@ public class SearchServiceController extends HttpServlet {
}else if(category!=null){
list = productSearchService.findByCategory(category);
//按产品类别搜索
}else if(intrate!=0){
list = productSearchService.findByIntrate(intrate);
//按利率排序由低到高
// }else if(intrate!=0){
// list = productSearchService.findByIntrate(intrate);
// //按利率排序由低到高
}else{
list = productSearchService.findByCount();
//默认按产品使用的产品的数量由高到低排序
}
String json = JSONObject.toJSONString(list);
response.getWriter().print(json);
return list;
}
@PostMapping("/showIndex")
public void showPro(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException{
@RequestMapping(value = "/showIndex",method = RequestMethod.POST)
public List<Product> showPro(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException{
List<Product> products = productSearchService.findByCount();
System.out.println(products);
String json = JSONObject.toJSONString(products);
System.out.println(json);
response.setCharacterEncoding("utf-8");
response.getWriter().print(json);
return products;
//String json = JSONObject.toJSONString(list);
// response.getWriter().print(json);
}
}

@ -36,8 +36,8 @@ public class ProductSearchServiceImpl implements ProductSearchService {
public List<Product> findByCount(){
Product product = new Product();
List<Product> productList = new ArrayList<Product>();
List<Integer> listusage = usageDateMapper.selectByCount();
int[] arr = listusage.stream().mapToInt(Integer::valueOf).toArray();
List<Long> listusage = usageDateMapper.selectByCount();
long [] arr = listusage.stream().mapToLong(t->t.longValue()).toArray();
for(int i=0;i<arr.length;i++){
product = productMapper.selectProductByProductNum(arr[i]);
productList.add(product);

@ -6,6 +6,6 @@
<meta http-equiv="refresh" content="1;url=Login.html">
</head>
<body>
<script type='text/javascript'>alert("注册成功');</script>
<script type='text/javascript'>alert('注册成功,请重新登录!')</script>
</body>
</html>

@ -10,7 +10,6 @@
<style type="text/css">
.tb960x90 {display:none!important;display:none}
</style>
<script type="text/javascript" src="js/myorder.js"></script>
<script type="text/javascript" src="js/jquery.min.js" ></script>
</head>
<body>

@ -178,9 +178,9 @@
setInterval('AutoScroll("#aui-show")', 3000)
});
window.onload(function requestData(){
$(function () {
$.ajax({
url: "/showIndex",
url: "/search/showIndex",
type: "post",
dataType: "json",
success: function(data){

@ -1,9 +1,11 @@
window.onload(function requestData(){
$(function(){
$.ajax({
url: "/search",
type: "post",
data: {},
dataType: "json",
success: function(data){
console.log(data);//查看从后台传值内容
/*这个方法里是ajax发送请求成功之后执行的代码*/
showData(data);//我们仅做数据展示
},
@ -19,7 +21,7 @@ function showData(data) {
$("#content").html=null;
for (var i = 0; i < data.length; i++) {
var pro = data[i];
var str = '<a href="javascript:;" class="aui-list-item"><div class="aui-right-top"></div><div class="aui-list-head" id="proname">'+pro.productName+'</div><div class="aui-flex"><div class="aui-flex-box"><h4>'+pro.productNum+'</h4></div><div class="aui-text-time"></div><div class="aui-button-get"><button id="apply", onclick="location=\'apply.html\'">申请</button> </div></div><div class="aui-dotted"></div></a>';
str = '<a href="javascript:;" class="aui-list-item"><div class="aui-right-top"></div><div class="aui-list-head" id="proname">'+pro.productName+'</div><div class="aui-flex"><div class="aui-flex-box"><h4>'+pro.productNum+'</h4></div><div class="aui-text-time"></div><div class="aui-button-get"><button id="apply", onclick="location=\'apply.html\'">申请</button> </div></div><div class="aui-dotted"></div></a>';
$("#content").append(str);
}

@ -9,22 +9,25 @@
</head>
<body>
<form action="/search" method="post">
<div class="headBox">
<h2 class="titHead">产品信息</h2>
<h3 class="titNeck">内容简介</h3>
<h2 class="titHead">产品搜索</h2>
<!--<h3 class="titNeck">内容简介</h3>-->
<div class="search">
<input id="serch" type="text" placeholder="搜索">
<button id="btn" type="button"></button>
<input name="productName" type="text" placeholder="搜索">
<button name="btn" type="button"></button>
</div>
</div>
<div class="content">
</div>
<div class="footBox">
<input type="button" name="" id="btn2" value="确&nbsp;&nbsp;定" />
<input type="submit" name="action" id="btn2" value="确&nbsp;&nbsp;定" />
</div>
<script type="text/javascript" src="js/jquery.min.js" ></script>
</form>
<script type="text/javascript" src="js/search.js"></script>
</body>

@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<title>Title</title>
<meta http-equiv="refresh" content="1url=Login.html">
<meta http-equiv="refresh" content="1;url=Login.html">
</head>
<body>
<script type='text/javascript'>alert('密码错误!');</script>

Loading…
Cancel
Save