You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
2.6 KiB
Java
78 lines
2.6 KiB
Java
package cokr.xit.base.menu.web;
|
|
|
|
import java.util.List;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
|
|
|
|
import cokr.xit.base.menu.Program;
|
|
import cokr.xit.base.menu.service.ProgramService;
|
|
import cokr.xit.foundation.data.DataObject;
|
|
import cokr.xit.foundation.web.AbstractController;
|
|
import cokr.xit.foundation.web.RequestHandlerReader;
|
|
|
|
@RequestMapping("/menu/program")
|
|
public class ProgramController extends AbstractController {
|
|
@Resource(name="programService")
|
|
private ProgramService programService;
|
|
@Autowired
|
|
private RequestMappingHandlerMapping requestHandlers;
|
|
|
|
protected ProgramService programService() {
|
|
return programService;
|
|
}
|
|
|
|
public ModelAndView main() {
|
|
ModelAndView mav = getProgramList(null, null, 1);
|
|
mav.setViewName("/menu/program/program-main");
|
|
mav.addObject("programList", toJson(mav.getModel().remove("programList")));
|
|
return mav;
|
|
}
|
|
|
|
public ModelAndView getProgramList(String by, String term, @RequestParam(required=false, defaultValue="1") Integer pageNum) {
|
|
int fetchSize = properties.getInt("pageSize");
|
|
return setCollectionInfo(
|
|
new ModelAndView("jsonView"),
|
|
programService.getProgramList(by, term, pageNum, fetchSize),
|
|
"program"
|
|
);
|
|
}
|
|
|
|
public ModelAndView isDuplicate(String filename) {
|
|
Program program = programService.getProgram(filename);
|
|
return new ModelAndView("jsonView")
|
|
.addObject("duplicate", program != null);
|
|
}
|
|
|
|
public ModelAndView create(Program program) {
|
|
boolean saved = programService.create(program);
|
|
return new ModelAndView("jsonView")
|
|
.addObject("saved", saved);
|
|
}
|
|
|
|
public ModelAndView update(Program program) {
|
|
boolean saved = programService.update(program);
|
|
return new ModelAndView("jsonView")
|
|
.addObject("saved", saved);
|
|
}
|
|
|
|
public ModelAndView remove(String... filenames) {
|
|
int affected = programService.removePrograms(filenames);
|
|
return new ModelAndView("jsonView")
|
|
.addObject("affected", affected)
|
|
.addObject("saved", affected > 0);
|
|
}
|
|
|
|
@RequestMapping(name="프로그램 URL 선택", value="/urls.do")
|
|
public ModelAndView getURLs(boolean multiple) {
|
|
List<DataObject> urls = new RequestHandlerReader().read(requestHandlers);
|
|
return new ModelAndView("menu/program/program-urls")
|
|
.addObject("multiple", multiple)
|
|
.addObject("urls", toJson(urls));
|
|
}
|
|
} |