当前位置:主页 > 新蒲京澳门app下载正文

新蒲京澳门app下载_一起听吧网进入

03月18日作者:黑曼巴


Ibatis调用存储历程

procedure.xml的ibatis设置设置设备摆设摆设文件如下:

JAVA调用实现PermissionDAOIbatisImpl.java如下:

// 授权设备给用户

public static final String SHARE_DEVICE_TO_PERSO新蒲京澳门app下载N =新蒲京澳门app下载 "PROCEDURE.shareDeviceToPerson";

/**

* 授权某个设备给某个用户

* @param userPermission

*/

public boolean s新蒲京澳门app下载hareDeviceToPerson(UserPermission userPermission) {

Map map = new HashMap();

boolean flag = false;

map.put("deviceId", userPermission.getDeviceId());

map.put("deviceType", userPermission.getDeviceType());

map.put("userId", userPermission.getUserId());

map.put("permissionType", userPermission.getPermissionType());

try {

getSqlMapClientTemplate().insert(SHARE_DEVICE_TO_PERSON, map);

String result = (String) map.get("result");

//获得返回值

if (StringUtil.isNotBlank(result) && "2".equalsIgnoreCase(result)) {

flag = true;

}

} catch (新蒲京澳门app下载Exception e) {

throw new DaoException("DAOException: " + e);

}

return flag;

}

存储历程的实今世码,嘿嘿。完全不懂得,今后有时机进修一下存储历程

create or replace procedure share_dev_prv_to_person(deviceIdin varchar2,

typein varchar2,

permission in varchar2,

userIdin varchar2,

resultout varchar2) as

/**

deviceId 设备id

tyoe设备类型

permission 权限类型

userId用户id

*/

v_role_idvarchar2(31);

v_organ_idvarchar2(31);

v_permission_idvarchar2(31);

v_typevarchar2(31);

v_permission_type varchar2(200);

v_is_existsint;

begin

result := '1';

select encodeID(TROLE_SEQ.nextval) into v_role_id from dual;

--convert type

if type = 1 then

v_type := 'general_camera_vic';

elsif type = 2 then

v_type := 'ip_camera_vic';

elsif type = 3 then

v_type := 'alarm_input_channel';

elsif type = 4 then

v_type := 'alarm_output_channel';

end if;

--convert permission type

if permission = 1 then

v_permission_type := 'vic_realtime_video_play_operation';

elsif permission = 2 then

v_permission_type := 'aic_operation';

elsif permission = 3 then

v_permission_type := 'aoc_open_close_operation';

end if;

-- insert role

begin

select id

into v_role_id

from T_ROLE

where F_NAME = deviceId || '角色' || type || '_' || permission;

select 1

into v_is_exists

from permissionpp,

T_ROLErole,

R_USER_ROLEru,

R_ROLE_PERMISSION rrp

where role.f_name = deviceId || '角色' || type || '_' || permission

and ru.user_id = userId

and rrp.ROLE_ID = role.id

and rrp.PERMISSION_ID = pp.id;

exception

when No_data_found then

dbms_output.put_line('no role founed!!');

select organ_id into v_organ_id from t_user where id = userId;

INSERT INTO T_ROLE

(ID, F_NAME, NOTE, ORGAN_ID, CREATE_PERSON)

VALUES

(v_role_id,

deviceId || '角色' || type || '_' || permission,

deviceId || '角色' || type || '_' || permissio新蒲京澳门app下载n,

v_organ_id,

userId);

-- grant role permission

select id

into v_permission_id

from permission t

where t.resource_id = deviceId

and t.operation = v_permission_type

and t.resource_type = v_type;

INSERT INTO R_ROLE_PERMISSION

(PERMISSION_ID, ROLE_ID)

VALUES

(v_permission_id, v_role_id);

-- grant role to other person

INSERT INTO R_USER_ROLE

(ROLE_ID, USER_ID)

VALUES

(v_role_id, userId);

end;

commit;

result := '2';

end;

最近关注

热点内容

更多