项目-字典-更新字典分组

318 阅读1分钟
	/**
	 * 更新字典分组
	 * @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());
		}
	}

剖析:

Js数据的录入:略

jsp中的dict.ID由param传来???


字典的使用