112 lines
3.6 KiB
Plaintext
112 lines
3.6 KiB
Plaintext
package th.co.muangthai.endrprint.util;
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.web.context.request.RequestContextHolder;
|
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
|
import th.co.muangthai.endrprint.dao.serviceImp.CommonServiceImp;
|
|
import th.co.muangthai.endrprint.dao.serviceInterface.CommonServiceInterface;
|
|
import th.co.muangthai.endrprint.model.bean.form.master.EndrUserLoginForm;
|
|
import th.co.muangthai.endrprint.model.bean.master.EndrMstPathTxtFileBean;
|
|
import th.co.muangthai.endrprint.model.bean.form.*;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpSession;
|
|
import java.io.Serializable;
|
|
import java.math.BigDecimal;
|
|
import java.text.ParseException;
|
|
import java.util.Date;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
/**
|
|
* set session
|
|
*/
|
|
public class SessionUtil implements Serializable{
|
|
static CommonServiceInterface commonService = new CommonServiceImp();
|
|
|
|
public SessionUtil(){
|
|
|
|
}
|
|
|
|
/**
|
|
* get session
|
|
* @return HttpSession
|
|
*/
|
|
public static HttpSession getSession(){
|
|
ServletRequestAttributes attr = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes();
|
|
HttpSession session = attr.getRequest().getSession();
|
|
return session;
|
|
}
|
|
|
|
/**
|
|
* get user login data
|
|
* @return EndrUserLoginForm
|
|
*/
|
|
public static EndrUserLoginForm getUserLoginForm(){
|
|
EndrUserLoginForm userLoginForm = (EndrUserLoginForm)getSession().getAttribute(TextContent.sessionLogin);
|
|
return userLoginForm;
|
|
}
|
|
|
|
/**
|
|
* get path of file
|
|
* @param id - config code
|
|
* @return String url
|
|
*/
|
|
public static String getPathFile(String id){
|
|
String url = null;
|
|
try {
|
|
Object obj = getSession().getAttribute(TextContent.sessionPathFile);
|
|
if(null != obj){
|
|
Map pathFile = (Map<String,EndrMstPathTxtFileBean>)obj;
|
|
//url = pathFile.get(new BigDecimal(id)).toString();
|
|
url = null;
|
|
if(null != pathFile.get(new BigDecimal(id)))
|
|
url = pathFile.get(new BigDecimal(id)).toString();
|
|
}else{
|
|
Map pathFile = commonService.getPathFile();
|
|
//url = pathFile.get(new BigDecimal(id)).toString();
|
|
url = null;
|
|
if(null != pathFile.get(new BigDecimal(id)))
|
|
url = pathFile.get(new BigDecimal(id)).toString();
|
|
|
|
getSession().setAttribute(TextContent.sessionPathFile,pathFile);
|
|
}
|
|
return url;
|
|
}catch (Exception e){
|
|
//return null;
|
|
Map pathFile = commonService.getPathFile();
|
|
url = null;
|
|
if(null != pathFile.get(new BigDecimal(id)))
|
|
url = pathFile.get(new BigDecimal(id)).toString();
|
|
return url;
|
|
}
|
|
}
|
|
|
|
public static void main(String[] args)
|
|
{
|
|
//System.out.println(getIpClient());
|
|
|
|
|
|
/*MtemBenfService ddd = new MtemBenfService();
|
|
|
|
InfBenfForm b = new InfBenfForm();
|
|
b.setSeqNo(new BigDecimal("2"));
|
|
b.setFirstnameThai("พรพิมล");
|
|
b.setTitleCodeThai("002");
|
|
b.setLastnameThai("สวยมาก");
|
|
b.setCardNo("");
|
|
b.setPercentage(new BigDecimal("0"));
|
|
|
|
List<InfBenfForm> l = new ArrayList<InfBenfForm>();
|
|
l.add(b);
|
|
|
|
ddd.addOrUpdBenf("",
|
|
"10.22.151.131",
|
|
"test_capsil_policy_beneficiaries_update_read",
|
|
"0005400540",l);*/
|
|
|
|
//getBusinessDate();
|
|
|
|
}
|
|
} |