更新
This commit is contained in:
@@ -314,7 +314,7 @@ public class UserDao {
|
||||
public void insertUserAvatar(String username,String url){
|
||||
Connection conn = null;
|
||||
PreparedStatement preparedStatement = null;
|
||||
String sql = "UPDATE user set userAvatar = ''+?+'' WHERE userName = ? AND isValid = 1;";
|
||||
String sql = "UPDATE user set userAvatar = ? WHERE userName = ? AND isValid = 1;";
|
||||
try{
|
||||
conn = JdbcUtils.getConnection();
|
||||
preparedStatement = conn.prepareStatement(sql);
|
||||
|
@@ -161,4 +161,23 @@ public class projectEntity {
|
||||
public void setAverage(double average) {
|
||||
this.average = average;
|
||||
}
|
||||
|
||||
String username;
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
String userUri;
|
||||
|
||||
public String getUserUri() {
|
||||
return userUri;
|
||||
}
|
||||
|
||||
public void setUserUri(String userUri) {
|
||||
this.userUri = userUri;
|
||||
}
|
||||
}
|
||||
|
@@ -3,14 +3,8 @@ package com.hellogithub.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.hellogithub.dao.categoryDao;
|
||||
import com.hellogithub.dao.commentDao;
|
||||
import com.hellogithub.dao.projectDao;
|
||||
import com.hellogithub.dao.supportDao;
|
||||
import com.hellogithub.entity.categoryEntity;
|
||||
import com.hellogithub.entity.commentEntity;
|
||||
import com.hellogithub.entity.projectEntity;
|
||||
import com.hellogithub.entity.supportEntity;
|
||||
import com.hellogithub.dao.*;
|
||||
import com.hellogithub.entity.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
@@ -25,6 +19,8 @@ public class projectService {
|
||||
private supportDao supportDao = new supportDao();
|
||||
|
||||
private commentDao commentDao = new commentDao();
|
||||
|
||||
private UserDao userDao = new UserDao();
|
||||
/**
|
||||
* 按照期刊号查询
|
||||
*/
|
||||
@@ -151,7 +147,6 @@ public class projectService {
|
||||
projectEntity.setCategoryName(categoryEntity.getCategoryName());
|
||||
|
||||
List<commentEntity> commentEntityList = commentDao.selectByProjectId(id);
|
||||
|
||||
if(commentEntityList.size() != 0)
|
||||
{
|
||||
double sum = 0;
|
||||
@@ -167,6 +162,11 @@ public class projectService {
|
||||
else{
|
||||
projectEntity.setAverage(0);
|
||||
}
|
||||
String username = userDao.selectNameById(projectEntity.getUserId());
|
||||
projectEntity.setUsername(username);
|
||||
userEntity userEntity = userDao.selectUserByName(username);
|
||||
projectEntity.setUserUri(userEntity.getUserAvatar());
|
||||
|
||||
return projectEntity;
|
||||
}
|
||||
public int addProjectLookcount(String id ){
|
||||
|
@@ -39,12 +39,12 @@ public class UploadHandleServlet extends HttpServlet {
|
||||
response.setContentType("application/json;charset=UTF-8");
|
||||
PrintWriter writer = response.getWriter();
|
||||
HttpSession session = request.getSession();
|
||||
userEntity userEntity =null;
|
||||
userEntity userEntity ;
|
||||
userEntity = (userEntity)session.getAttribute("user");
|
||||
|
||||
System.out.println(userEntity == null);
|
||||
//得到上传文件的保存目录,将上传的文件存放于WEB-INF目录下,不允许外界直接访问,保证上传文件的安全
|
||||
String savePath = this.getServletContext().getRealPath(File.separator+"WEB-INF"+File.separator+"upload");
|
||||
savePath= this.getServletContext().getRealPath(File.separator+"WEB-INF"+File.separator+"upload").replace("\\out\\artifacts\\hellogithub_war_exploded\\WEB-INF\\upload","\\web\\uploadFile");
|
||||
savePath= this.getServletContext().getRealPath(File.separator+"WEB-INF"+File.separator+"upload").replace("\\out\\artifacts\\helloGithub_war_exploded\\WEB-INF\\upload","\\web\\uploadFile");
|
||||
System.out.println(savePath);
|
||||
//上传时生成的临时文件保存目录
|
||||
String tempPath = this.getServletContext().getRealPath(File.separator+"WEB-INF"+File.separator+"tmp");
|
||||
@@ -166,6 +166,7 @@ public class UploadHandleServlet extends HttpServlet {
|
||||
if(userEntity != null)
|
||||
{
|
||||
userService.updateUserAv(userEntity.getUserName(),realSavePath+"\\"+saveFilename);
|
||||
System.out.println("123");
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user