ems.web.controller.other.ResumeController.java Source code

Java tutorial

Introduction

Here is the source code for ems.web.controller.other.ResumeController.java

Source

package ems.web.controller.other;

import java.io.IOException;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import ems.web.model.dto.AcademicAblityDTO;
import ems.web.model.dto.CareerDTO;
import ems.web.model.dto.LicenseDTO;
import ems.web.model.dto.LoginCompleteDTO;
import ems.web.model.service.resume.ResumeService;

@Controller
@RequestMapping("/resume")
public class ResumeController {

    @Autowired
    ResumeService resumeServiceImpl;

    @RequestMapping("/resumeInit")
    public ModelAndView initResumeForm(HttpSession httpSession) {
        int memberCode = ((LoginCompleteDTO) httpSession.getAttribute("loginMember")).getCode();
        return new ModelAndView("/hire/hireResume")
                .addObject("academicAbility", resumeServiceImpl.selectAcademicAbility(memberCode))
                .addObject("license", resumeServiceImpl.selectLicense(memberCode))
                .addObject("career", resumeServiceImpl.selectCareer(memberCode))
                .addObject("memberData", resumeServiceImpl.getResumeInitUserData(
                        ((LoginCompleteDTO) httpSession.getAttribute("loginMember")).getId()));
    }

    @RequestMapping(value = "/spellCheck", method = RequestMethod.POST)
    @ResponseBody
    public void speelCheck(String data, HttpServletResponse response) {
        response.setCharacterEncoding("UTF-8");
        try {
            response.getWriter().println(resumeServiceImpl.spellCheck(data));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @RequestMapping(value = "/saveResume", method = RequestMethod.POST)
    public String saveResume(String ability, String academicNameAndMajor, String careerOrganization1,
            String careerWorkTerm1, String careerTask1, String careerOrganization2, String careerWorkTerm2,
            String careerTask2, String careerOrganization3, String careerWorkTerm3, String careerTask3,
            String licenseName1, String licenseRank1, String licenseIssuing1, String licenseAcquisition1,
            String licenseName2, String licenseRank2, String licenseIssuing2, String licenseAcquisition2,
            String licenseName3, String licenseRank3, String licenseIssuing3, String licenseAcquisition3,
            String skill, HttpSession session) {
        int memberCode = ((LoginCompleteDTO) session.getAttribute("loginMember")).getCode();
        String[] academicNameAndMajorArray = academicNameAndMajor.split("/");

        if (academicNameAndMajorArray.length != 0) {
            resumeServiceImpl.writeAcademicAbility(new AcademicAblityDTO(0, memberCode, ability,
                    academicNameAndMajorArray[0], academicNameAndMajorArray[1], skill, 0));
        }

        if (!careerOrganization1.equals("")) {
            resumeServiceImpl.writeCareer(
                    new CareerDTO(0, memberCode, careerOrganization1, careerWorkTerm1, careerTask1, 0));
        }
        if (!careerOrganization2.equals("")) {
            resumeServiceImpl.writeCareer(
                    new CareerDTO(0, memberCode, careerOrganization2, careerWorkTerm2, careerTask2, 0));
        }
        if (!careerOrganization3.equals("")) {
            resumeServiceImpl.writeCareer(
                    new CareerDTO(0, memberCode, careerOrganization3, careerWorkTerm3, careerTask3, 0));
        }
        if (!licenseName1.equals("")) {
            resumeServiceImpl.writeLicense(new LicenseDTO(0, memberCode, licenseName1, licenseRank1,
                    licenseIssuing1, licenseAcquisition1, 0));
        }
        if (!licenseName2.equals("")) {
            resumeServiceImpl.writeLicense(new LicenseDTO(0, memberCode, licenseName2, licenseRank2,
                    licenseIssuing2, licenseAcquisition2, 0));
        }
        if (!licenseName3.equals("")) {
            resumeServiceImpl.writeLicense(new LicenseDTO(0, memberCode, licenseName3, licenseRank3,
                    licenseIssuing3, licenseAcquisition3, 0));
        }

        return "redirect:../resume/resumeInit";
    }

    @RequestMapping(value = "/updateResume", method = RequestMethod.POST)
    public String updateResume(String ability, String academicNameAndMajor, String careerOrganization1,
            String careerWorkTerm1, String careerTask1, String careerOrganization2, String careerWorkTerm2,
            String careerTask2, String careerOrganization3, String careerWorkTerm3, String careerTask3,
            String licenseName1, String licenseRank1, String licenseIssuing1, String licenseAcquisition1,
            String licenseName2, String licenseRank2, String licenseIssuing2, String licenseAcquisition2,
            String licenseName3, String licenseRank3, String licenseIssuing3, String licenseAcquisition3,
            String skill, HttpSession session) {
        int memberCode = ((LoginCompleteDTO) session.getAttribute("loginMember")).getCode();
        String[] academicNameAndMajorArray = academicNameAndMajor.split("/");

        if (academicNameAndMajorArray.length != 0) {
            resumeServiceImpl.modifyAcademicAbility(new AcademicAblityDTO(0, memberCode, ability,
                    academicNameAndMajorArray[0], academicNameAndMajorArray[1], skill, 1));
        }

        if (!careerOrganization1.equals("")) {
            resumeServiceImpl.modifyCareer(
                    new CareerDTO(0, memberCode, careerOrganization1, careerWorkTerm1, careerTask1, 1));
        } else
            resumeServiceImpl.modifyCareer(new CareerDTO(0, memberCode, "", "", "", 1));
        if (!careerOrganization2.equals("")) {
            resumeServiceImpl.modifyCareer(
                    new CareerDTO(0, memberCode, careerOrganization2, careerWorkTerm2, careerTask2, 2));
        } else
            resumeServiceImpl.modifyCareer(new CareerDTO(0, memberCode, "", "", "", 2));
        if (!careerOrganization3.equals("")) {
            resumeServiceImpl.modifyCareer(
                    new CareerDTO(0, memberCode, careerOrganization3, careerWorkTerm3, careerTask3, 3));
        } else
            resumeServiceImpl.modifyCareer(new CareerDTO(0, memberCode, "", "", "", 3));
        if (!licenseName1.equals("")) {
            resumeServiceImpl.modifyLicense(new LicenseDTO(0, memberCode, licenseName1, licenseRank1,
                    licenseIssuing1, licenseAcquisition1, 1));
        } else
            resumeServiceImpl.modifyLicense(new LicenseDTO(0, memberCode, "", "", "", "", 1));
        if (!licenseName2.equals("")) {
            resumeServiceImpl.modifyLicense(new LicenseDTO(0, memberCode, licenseName2, licenseRank2,
                    licenseIssuing2, licenseAcquisition2, 2));
        } else
            resumeServiceImpl.modifyLicense(new LicenseDTO(0, memberCode, "", "", "", "", 2));
        if (!licenseName3.equals("")) {
            resumeServiceImpl.modifyLicense(new LicenseDTO(0, memberCode, licenseName3, licenseRank3,
                    licenseIssuing3, licenseAcquisition3, 3));
        } else
            resumeServiceImpl.modifyLicense(new LicenseDTO(0, memberCode, "", "", "", "", 3));

        return "redirect:../resume/resumeInit";
    }

}