diff --git a/src/main/java/top/ezzd/controller b/src/main/java/top/ezzd/controller deleted file mode 100644 index 82c7ff3..0000000 --- a/src/main/java/top/ezzd/controller +++ /dev/null @@ -1,138 +0,0 @@ -package top.ezzd.controller; - -import java.io.File; -import java.io.IOException; -import java.util.UUID; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - -import org.apache.commons.io.FileUtils; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.multipart.MultipartFile; - -import top.ezzd.pojo.Apply; -import top.ezzd.pojo.Department; -import top.ezzd.pojo.User; -import top.ezzd.service.ApplyService; -import top.ezzd.service.DepartmentService; -import top.ezzd.service.UserService; - -@Controller -/** - * �����Ǵ����û�����������Ŀ������� - * - * @author SmallHappy - * - */ -public class ApplyController { - @Resource - private ApplyService applyServiceImpl; - @Resource - private UserService userServiceImpl; - @Resource - private DepartmentService departmentServiceImpl; - // private Apply apply = new Apply(); - - /** - * �����û������� - * - * @param file - * @param session - * @param req - * @return - */ - @RequestMapping("apply") - // MultipartFile file, - public String apply(MultipartFile file, HttpSession session, HttpServletRequest req, Apply apply,HttpServletResponse resp) { - // �ж��û��Ƿ��¼ �ж�session���Ƿ���user���� - User u = (User) session.getAttribute("user"); - - // û��user��������ת����½���� - if (u == null) { - String loginUrl = resp.encodeRedirectURL("/dispatcher?page=login"); - return "redirect:"+loginUrl; - } else { - // ��ȡ�û����� - //String name = req.getParameter("name"); - // ���û��ϴ�����Ƭ�Զ�����������Ӳ���� - // System.out.println(file.getOriginalFilename().equals("")); - if (file.getOriginalFilename() != null && file.getOriginalFilename() != "") { - // �� - String fileName = UUID.randomUUID().toString() - + file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")); - // ��ȡ��ǰ��Ŀ·����ַ - String path = req.getServletContext().getRealPath("UpPhoto") + "/" + fileName; - // System.out.println(path); - try { - // �����������־û���Ӳ�� - FileUtils.copyInputStreamToFile(file.getInputStream(), new File(path)); - } catch (IOException e) { - e.printStackTrace(); - } - //����Ϣ��װ��apply������ - apply.setUname(u.getUname()); - apply.setPhotopath(path); - // ����ҵ������ - int index = applyServiceImpl.insertApply(apply); - if (index > 0) { - // ���ݿ����ݸ��³ɹ�����ö�Ӧ��ҵ����޸��û�������״̬ - userServiceImpl.updateApply(u.getUname()); - String applyPageUrl = resp.encodeRedirectURL("/applyPage"); - - return "redirect:"+applyPageUrl; - } else { - String Url_500 = resp.encodeRedirectURL("/dispatcher?page=500"); - return "redirect:"+Url_500; - } - } else { - String Url_500 = resp.encodeRedirectURL("/dispatcher?page=500"); - return "redirect:"+Url_500; - } - } - } - - /** - * �����ύ����Ŀ����� - * - * @param session - * @return - */ - @RequestMapping("applyPage") - public String applyPage(HttpSession session,HttpServletResponse resp) { - String applyUrl = resp.encodeRedirectURL("/dispatcher?page=apply"); - // ��session�л�ȡuser - User user = (User) session.getAttribute("user"); - // �ж��û��Ƿ��¼ - // System.out.println(user); - if (user == null) { - String loginUrl = resp.encodeRedirectURL("/dispatcher?page=login"); - return "redirect:"+loginUrl; - } - // �ж��û��Ƿ��ύ������ - Apply apply = applyServiceImpl.selectApplyByUname(user.getUname()); - // �ж��û�������״̬�Ƿ�Ϊ�� - if (apply != null) { - // ��apply��Ϣ����session�� - session.setAttribute("apply", apply); - // �ж��û��Ƿ��ύ������ - - if (!apply.getApplystatus().equals("1")) { - - return "redirect:"+applyUrl; - } - // ��ȡ�û����û��� - String uname = apply.getUname(); - //����uname��ѯ�û��IJ�����Ϣ - Department de = departmentServiceImpl.selectDeByUname(uname); - // ���û��IJ�����Ϣ����session�� - session.setAttribute("de", de); - - return "redirect:"+applyUrl; - } - return "redirect:"+applyUrl; - } -} \ No newline at end of file