|
|
|
@ -0,0 +1,51 @@
|
|
|
|
|
package top.ezzd.controller;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import javax.servlet.http.HttpSession;
|
|
|
|
|
|
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
|
|
|
|
|
import top.ezzd.pojo.User;
|
|
|
|
|
import top.ezzd.service.UserPhotoService;
|
|
|
|
|
import top.ezzd.tools.PhotoFileUtils;
|
|
|
|
|
|
|
|
|
|
@Controller
|
|
|
|
|
public class UserPhotoController {
|
|
|
|
|
/**
|
|
|
|
|
* չʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>ͼƬ
|
|
|
|
|
*/
|
|
|
|
|
@Resource
|
|
|
|
|
private UserPhotoService userPhotoServiceImpl;
|
|
|
|
|
|
|
|
|
|
@RequestMapping("showUserPhoto")
|
|
|
|
|
public String showUserPhoto(HttpSession session) {
|
|
|
|
|
User u = (User) session.getAttribute("user");
|
|
|
|
|
if (u == null) {
|
|
|
|
|
return "/dispatcher?page=login";
|
|
|
|
|
} else {
|
|
|
|
|
session.setAttribute("userPhotoList", userPhotoServiceImpl.selectPhotoById(u.getUid()));
|
|
|
|
|
return "redirect:/userPhoto/userPhotoPage.jsp";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* ɾ<EFBFBD><EFBFBD>ͼƬ
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("deletePhoto")
|
|
|
|
|
public String deletePhoto(HttpServletRequest req) {
|
|
|
|
|
String address = req.getParameter("address");
|
|
|
|
|
int photoid = Integer.parseInt(req.getParameter("photoid"));
|
|
|
|
|
int index = userPhotoServiceImpl.deletePhoto(photoid);
|
|
|
|
|
if (index == 1) {
|
|
|
|
|
String path = "/usr/local/tomcat/webapps/ROOT/UpPhoto/" + address;
|
|
|
|
|
File file = new File(path);
|
|
|
|
|
PhotoFileUtils.deleteFile(file);
|
|
|
|
|
return "showUserPhoto";
|
|
|
|
|
} else {
|
|
|
|
|
return "/dispatcher?page=uPhoto";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|