110 lines
3.6 KiB
Plaintext
110 lines
3.6 KiB
Plaintext
|
package th.co.muangthai.endrprint.controller;
|
||
|
|
||
|
import org.apache.log4j.Logger;
|
||
|
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 th.co.muangthai.endrprint.controller.service.ENDR300Service;
|
||
|
import th.co.muangthai.endrprint.model.bean.form.MsgErrorForm;
|
||
|
import th.co.muangthai.endrprint.model.bean.form.master.EndrPrintServerForm;
|
||
|
import th.co.muangthai.endrprint.model.bean.form.master.EndrUserLoginForm;
|
||
|
import th.co.muangthai.endrprint.util.SessionUtil;
|
||
|
import th.co.muangthai.endrprint.util.VSMUtil;
|
||
|
import javax.servlet.http.HttpServletRequest;
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.List;
|
||
|
|
||
|
/**
|
||
|
* ENDR Print management.
|
||
|
*/
|
||
|
@Controller
|
||
|
public class ENDR300Controller extends ENDR300Service {
|
||
|
static Logger log = Logger.getLogger(ENDR300Controller.class);
|
||
|
|
||
|
/**
|
||
|
* Load the information/data to start (Master ,ComboBox)
|
||
|
*
|
||
|
* @param request
|
||
|
* @return Object[] search results
|
||
|
*/
|
||
|
@RequestMapping(value = "/json/ENDR300LoadData", method = RequestMethod.POST)
|
||
|
public
|
||
|
@ResponseBody
|
||
|
Object[] loadData(HttpServletRequest request) {
|
||
|
MsgErrorForm errorForm = new MsgErrorForm();
|
||
|
errorForm.setDataDefaultOk();
|
||
|
List<EndrUserLoginForm> lst = new ArrayList<EndrUserLoginForm>();
|
||
|
|
||
|
try {
|
||
|
|
||
|
String userId = SessionUtil.getUserLoginForm().getUserId();
|
||
|
|
||
|
if (VSMUtil.isNotEmpty(userId)) {
|
||
|
lst = commonService.searchLstUserLoginBeanFormPkg(null, null, null, null);
|
||
|
} else {
|
||
|
errorForm.setErrorFlag(getBigDecimal("1"));
|
||
|
errorForm.setErrorDesc("out of session");
|
||
|
}
|
||
|
|
||
|
} catch (Exception ex) {
|
||
|
errorForm.setDataErrorException(ex);
|
||
|
log.error(ex.toString(), ex);
|
||
|
}
|
||
|
return new Object[]{errorForm, lst};
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* ENDR Print information searching regarding the condition
|
||
|
*
|
||
|
* @param request
|
||
|
* @return Object[] search results
|
||
|
*/
|
||
|
@RequestMapping(value = "/json/ENDR300SchData", method = RequestMethod.POST)
|
||
|
public
|
||
|
@ResponseBody
|
||
|
Object[] schData(HttpServletRequest request) {
|
||
|
MsgErrorForm errorForm = new MsgErrorForm();
|
||
|
errorForm.setDataDefaultOk();
|
||
|
|
||
|
List<EndrPrintServerForm> lstEndrPrintServer = new ArrayList<EndrPrintServerForm>();
|
||
|
|
||
|
try {
|
||
|
|
||
|
String schFormParam = request.getParameter("schFormParam");
|
||
|
EndrPrintServerForm schForm = gsonData.fromJson(schFormParam, EndrPrintServerForm.class);
|
||
|
|
||
|
|
||
|
lstEndrPrintServer = commonService.searchEndrPrintServerFormPkg(schForm);
|
||
|
|
||
|
} catch (Exception ex) {
|
||
|
errorForm.setDataErrorException(ex);
|
||
|
log.error(ex.toString(), ex);
|
||
|
}
|
||
|
return new Object[]{errorForm, lstEndrPrintServer};
|
||
|
}
|
||
|
|
||
|
@RequestMapping(value = "/json/ENDR300doSaveData", method = RequestMethod.POST)
|
||
|
public
|
||
|
@ResponseBody
|
||
|
Object[] ENDR300doInsertData(HttpServletRequest request) {
|
||
|
Object[] obj = new Object[2];
|
||
|
MsgErrorForm errorForm = new MsgErrorForm();
|
||
|
errorForm.setDataDefaultOk();
|
||
|
|
||
|
String saveFormParam = request.getParameter("saveFormParam");
|
||
|
EndrPrintServerForm saveForm = gsonData.fromJson(saveFormParam, EndrPrintServerForm.class);
|
||
|
try {
|
||
|
|
||
|
obj = insertOrUpdateData(saveForm);
|
||
|
|
||
|
} catch (Exception ex) {
|
||
|
errorForm.setDataErrorException(ex);
|
||
|
log.error(ex.toString(), ex);
|
||
|
obj[0] = errorForm;
|
||
|
}
|
||
|
|
||
|
return obj;
|
||
|
}
|
||
|
|
||
|
}
|