102 lines
3.3 KiB
Plaintext
102 lines
3.3 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.ENDR700Service;
|
||
|
import th.co.muangthai.endrprint.model.bean.form.MsgErrorForm;
|
||
|
import th.co.muangthai.endrprint.model.bean.form.master.MstTeamTabForm;
|
||
|
|
||
|
import javax.servlet.http.HttpServletRequest;
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.List;
|
||
|
|
||
|
@Controller
|
||
|
public class ENDR700Controller extends ENDR700Service {
|
||
|
|
||
|
static Logger log = Logger.getLogger(ENDR700Controller.class);
|
||
|
|
||
|
/**
|
||
|
* Load the information/data to start (Master ,ComboBox)
|
||
|
*
|
||
|
* @param request
|
||
|
* @return Object[] search results
|
||
|
*/
|
||
|
@RequestMapping(value = "/json/ENDR700LoadData", method = RequestMethod.POST)
|
||
|
public
|
||
|
@ResponseBody
|
||
|
Object[] loadData(HttpServletRequest request) {
|
||
|
Object[] obj = new Object[4];
|
||
|
MsgErrorForm errorForm = new MsgErrorForm();
|
||
|
errorForm.setDataDefaultOk();
|
||
|
|
||
|
try {
|
||
|
// String userId = SessionUtil.getUserLoginForm().getUserId();
|
||
|
obj[0] = errorForm;
|
||
|
} catch (Exception ex) {
|
||
|
errorForm.setDataErrorException(ex);
|
||
|
log.error(ex.toString(), ex);
|
||
|
obj[0] = errorForm;
|
||
|
}
|
||
|
return obj;
|
||
|
}
|
||
|
|
||
|
|
||
|
@RequestMapping(value = "/json/ENDR700SchData", method = RequestMethod.POST)
|
||
|
public
|
||
|
@ResponseBody
|
||
|
Object[] schData(HttpServletRequest request) {
|
||
|
MsgErrorForm errorForm = new MsgErrorForm();
|
||
|
errorForm.setDataDefaultOk();
|
||
|
|
||
|
List<MstTeamTabForm> TeamTabList = new ArrayList<MstTeamTabForm>();
|
||
|
|
||
|
try {
|
||
|
|
||
|
String schFormParam = request.getParameter("schFormParam");
|
||
|
MstTeamTabForm schForm = gsonData.fromJson(schFormParam, MstTeamTabForm.class);
|
||
|
|
||
|
|
||
|
TeamTabList = commonService.searchMstTeamTabBeanByBean(schForm);
|
||
|
|
||
|
} catch (Exception ex) {
|
||
|
errorForm.setDataErrorException(ex);
|
||
|
log.error(ex.toString(), ex);
|
||
|
}
|
||
|
return new Object[]{errorForm, TeamTabList};
|
||
|
}
|
||
|
|
||
|
|
||
|
@RequestMapping(value = "/json/ENDR700SaveData", method = RequestMethod.POST)
|
||
|
public
|
||
|
@ResponseBody
|
||
|
MsgErrorForm saveData(HttpServletRequest request) {
|
||
|
MsgErrorForm msgErrorForm = new MsgErrorForm();
|
||
|
msgErrorForm.setDataDefaultOk();
|
||
|
try {
|
||
|
|
||
|
String saveFormParamsNewData = request.getParameter("saveFormParams");
|
||
|
String saveFlag = request.getParameter("saveFlag");
|
||
|
MstTeamTabForm newData = gsonData.fromJson(saveFormParamsNewData, MstTeamTabForm.class);
|
||
|
|
||
|
if (saveFlag.equals("I")) {
|
||
|
msgErrorForm = saveTeamTabNewData(newData);
|
||
|
} else if (saveFlag.equals("E")) {
|
||
|
String saveFormParamsOldData = request.getParameter("saveFormParams_OldData");
|
||
|
MstTeamTabForm oldData = gsonData.fromJson(saveFormParamsOldData, MstTeamTabForm.class);
|
||
|
|
||
|
msgErrorForm = saveTeamTabData(newData, oldData);
|
||
|
}
|
||
|
} catch (Exception ex) {
|
||
|
msgErrorForm.setDataErrorException(ex);
|
||
|
log.error(ex.toString(), ex);
|
||
|
}
|
||
|
return msgErrorForm;
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|