/** * 更新字典分組 * @return */
public EasyResult actionForGroupadd() {
JSONObject json = new JSONObject();
JSONObject entInfo = this.getJSONObject();
UserModel user = UserUtil.getUser(getRequest());
String depCode = user.getEpCode();
json.put("NAME", entInfo.getString("dict.NAME"));
json.put("CODE", entInfo.getString("dict.CODE"));
json.put("BAKUP", entInfo.getString("dict.BAKUP"));
json.put("SORT_NUM", entInfo.getString("dict.SORT_NUM"));
json.put("MODULE", entInfo.getString("dict.MODULE"));
json.put("ENABLE_STATUS", entInfo.getString("dict.ENABLE_STATUS"));
json.put("TYPE", entInfo.getString("dict.TYPE"));
if ("".equals(entInfo.getString("dict.ID"))) {
json.put("ID", RandomKit.randomStr());
json.put("CREATE_ACC", UserUtil.getUser(this.getRequest()).getUserAcc());
json.put("CREATE_TIME", EasyDate.getCurrentDateString());
json.put("CREATE_DEPT",UserUtil.getUser(this.getRequest()).getDept().getDeptCode());
json.put("EP_CODE", UserUtil.getUser(this.getRequest()).getEpCode());
} else {
json.put("UPDATE_ACC", UserUtil.getUser(this.getRequest()).getUserAcc());
json.put("UPDATE_TIME", EasyDate.getCurrentDateString());
json.put("ID", entInfo.getString("dict.ID"));
}
EasyRecord record = new EasyRecord(this.getTableName("C_CF_DICTGROUP"), "ID").setColumns(json);
try {
if ("".equals(entInfo.getString("dict.ID"))) {
String sql="SELECT COUNT(1) AS COUNT FROM "+this.getTableName("C_CF_DICTGROUP")+" WHERE EP_CODE=? AND CODE=?";
int queryForInt = this.getQuery().queryForInt(sql, new Object[]{depCode,entInfo.getString("dict.CODE")});
if(queryForInt==0){
this.getQuery().save(record);
DictCacheMgr.reloadSingleGroup(depCode, entInfo.getString("dict.CODE"),user.getSchemaName());
return EasyResult.ok("", "新增成功!");
}else{
return EasyResult.error(500, "已存在該編號");
}
} else {
this.getQuery().update(record);
DictCacheMgr.reloadSingleGroup(depCode, entInfo.getString("dict.CODE"),user.getSchemaName());
return EasyResult.ok("", "修改爲功!");
}
} catch (Exception e) {
this.error("操做失敗,緣由:" + e.getMessage(), e);
return EasyResult.error(500, "操做失敗,緣由:" + e.getMessage());
}
}
複製代碼
剖析:java
Js數據的錄入:略jsp中的dict.ID由param傳來???sql
字典的使用json