87 lines
2.5 KiB
Java
87 lines
2.5 KiB
Java
package com.base.helper;
|
|
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
import com.amarsoft.are.ARE;
|
|
import com.amarsoft.are.jbo.BizObject;
|
|
import com.amarsoft.are.jbo.BizObjectManager;
|
|
import com.amarsoft.are.jbo.BizObjectQuery;
|
|
import com.amarsoft.are.jbo.JBOException;
|
|
import com.amarsoft.are.jbo.JBOFactory;
|
|
import com.amarsoft.are.jbo.JBOTransaction;
|
|
import com.base.util.BizObjectUtil;
|
|
|
|
public class UserHelper {
|
|
|
|
public static List<BizObject> getUsers(String sUserIds) {
|
|
try {
|
|
BizObjectManager bom = JBOFactory
|
|
.getBizObjectManager("jbo.sys.USER_INFO");
|
|
BizObjectQuery boq = bom.createQuery("USERID in (" + sUserIds + ")");
|
|
@SuppressWarnings("unchecked")
|
|
List<BizObject> bos = boq.getResultList(false);
|
|
return bos;
|
|
} catch (JBOException e) {
|
|
ARE.getLog().error(e);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public static Map<String, Object> getUser(String sUserId) {
|
|
try {
|
|
BizObjectManager bom = JBOFactory
|
|
.getBizObjectManager("jbo.sys.USER_INFO");
|
|
BizObjectQuery boq = bom.createQuery("USERID=:USERID").setParameter(
|
|
"USERID", sUserId);
|
|
BizObject bo = boq.getSingleResult(false);
|
|
if (bo == null)
|
|
return null;
|
|
BizObjectUtil boUtil = new BizObjectUtil();
|
|
return boUtil.bizObject2MapValue(bo);
|
|
} catch (JBOException e) {
|
|
ARE.getLog().error(e);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public static Map<String, Object> getUserByLoginId(String loginId) {
|
|
try {
|
|
BizObjectManager bom = JBOFactory
|
|
.getBizObjectManager("jbo.sys.USER_INFO");
|
|
BizObjectQuery boq = bom.createQuery("LOGINID=:LOGINID AND STATUS = '1'").setParameter(
|
|
"LOGINID", loginId);
|
|
BizObject bo = boq.getSingleResult(false);
|
|
if (bo == null)
|
|
return null;
|
|
BizObjectUtil boUtil = new BizObjectUtil();
|
|
return boUtil.bizObject2MapValue(bo);
|
|
} catch (JBOException e) {
|
|
ARE.getLog().error(e);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public static void edit(JBOTransaction tx, String sUserId, Map<String, Object> map) throws JBOException {
|
|
try {
|
|
BizObjectManager bom = JBOFactory
|
|
.getBizObjectManager("jbo.sys.USER_INFO");
|
|
BizObjectQuery boq = bom.createQuery("USERID=:USERID").setParameter(
|
|
"USERID", sUserId);
|
|
BizObject bo = boq.getSingleResult(true);
|
|
if (bo == null)
|
|
return;
|
|
|
|
for (String key : map.keySet()) {
|
|
bo.setAttributeValue(key.toUpperCase(), map.get(key));
|
|
}
|
|
|
|
tx.join(bom);
|
|
bom.saveObject(bo);
|
|
tx.commit();
|
|
} catch (JBOException e) {
|
|
ARE.getLog().error(e);
|
|
}
|
|
}
|
|
}
|