* @throws Exception
*/
public ActionForward addUser(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,
HttpServletResponse response) throws Exception {
String currentUserName = null;
Iouser user = null;
try {
currentUserName = UserUtil.getCurrentUserName(request);
JSONObject jsonObject = readJson(request);
user = (Iouser) JSONObject.toBean(jsonObject, Iouser.class);
user.setCreatorId(new Integer(UserUtil.getCurrentUserId(request)));
// 设置电话号码
String tmpComPhone = jsonObject.get("tel_area") + "-" + jsonObject.get("tel_number") + "-"
+ jsonObject.get("tel_ext");
user.setCompanyPhone(tmpComPhone);
// 设置分组关系
Long groupId = jsonObject.getLong("groupId");
if(groupId != null) {
GroupRelation group = (GroupRelation) getBaseManager().get(GroupRelation.class, groupId);
if(group == null) {
throw new IouserException("债务人关系->分组为空");
}
user.setGroup(group);
}
getBaseManager().save(user);
log.info(currentUserName + ">新增债务人:" + user);
print(response, RESBONSE_SUCCESS + "|" + user.getId());
} catch(JSONException je) {
je.printStackTrace();
log.error(currentUserName + ">增加债务人>解析JSON数据出错:" + je.getMessage());
} catch (Exception ex) {
ex.printStackTrace();