Merge branch 'develop_client_permission' of https://git.royalpay.com.au/git/royalv2.manage into develop_client_permission

master
wangning 6 years ago
commit 9ca8f47d09

@ -8,9 +8,7 @@ import org.hibernate.validator.constraints.NotEmpty;
* Created by yangluo on 2018/07/05.
*/
public class PartnerModuleInfo {
@NotEmpty
@JSONField(name= "Module_id")
private String moduleId;
@JSONField(name = "js_module")
private String jsModule;
@JSONField(name = "js_path")
@ -19,13 +17,6 @@ public class PartnerModuleInfo {
@JSONField(name = "initialize")
private Boolean initialize;
public String getModuleId() {
return moduleId;
}
public void setModuleId(String moduleId) {
this.moduleId = moduleId;
}
public String getJsModule() {
return jsModule;
}
@ -59,7 +50,7 @@ public class PartnerModuleInfo {
}
public void initObject(JSONObject mod) {
mod.put("id", getModuleId());
mod.put("id", mod.getLong("id"));
mod.put("js_module", getJsModule());
mod.put("js_path", getJsPath());
mod.put("remark", getRemark());

@ -10,7 +10,7 @@ import java.util.List;
/**
* Created by yangluo on 2018/07/05.
*/
public interface PartnerPermissionManager {
public interface PermissionPartnerManager {
void synchronizeFunctions();
JSONObject listFunctions();

@ -2,7 +2,7 @@ package au.com.royalpay.payment.manage.management.sysconfig.core.impls;
import au.com.royalpay.payment.manage.management.sysconfig.beans.FuncInfo;
import au.com.royalpay.payment.manage.management.sysconfig.beans.PartnerModuleInfo;
import au.com.royalpay.payment.manage.management.sysconfig.core.PartnerPermissionManager;
import au.com.royalpay.payment.manage.management.sysconfig.core.PermissionPartnerManager;
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
import au.com.royalpay.payment.manage.mappers.system.PermissionClientModuleMapper;
import au.com.royalpay.payment.manage.mappers.system.PermissionPartnerFunctionMapper;
@ -32,7 +32,7 @@ import javax.annotation.Resource;
* Created by yangluo on 2018/07/05.
*/
@Service
public class PartnerPermissionManagerImpl implements PartnerPermissionManager {
public class PermissionPartnerManagerImpl implements PermissionPartnerManager {
@Resource
private PermissionPartnerFunctionMapper permissionPartnerFunctionMapper;
@Resource
@ -136,18 +136,20 @@ public class PartnerPermissionManagerImpl implements PartnerPermissionManager {
clientMod.put("id", IdUtil.getId());
permissionClientModulesService.save(clientMod);
}
}
if (!module.getInitialize()) {
} else {
for (JSONObject clientMod : IdandMoniker) {
clientMod.put("client_id", clientMod.getString("client_id"));
clientMod.put("client_moniker", clientMod.getString("client_moniker"));
clientMod.put("module_id", nModuleId.getString("id"));
clientMod.put("is_valid", 0);
clientMod.put("is_valid", IdUtil.getId());
clientMod.put("id", IdUtil.getId());
permissionClientModuleMapper.save(clientMod);
}
}
}
}
module.initObject(mod);
permissionPartnerModuleMapper.update(mod);

@ -2,7 +2,7 @@ package au.com.royalpay.payment.manage.management.sysconfig.web;
import au.com.royalpay.payment.manage.management.sysconfig.beans.FuncInfo;
import au.com.royalpay.payment.manage.management.sysconfig.beans.PartnerModuleInfo;
import au.com.royalpay.payment.manage.management.sysconfig.core.PartnerPermissionManager;
import au.com.royalpay.payment.manage.management.sysconfig.core.PermissionPartnerManager;
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
@ -22,44 +22,44 @@ import javax.annotation.Resource;
* Created by yangluo on 2018/07/05.
*/
@RestController
@RequestMapping( value = "/sys/partnerPermission")
@RequestMapping( value = "/sys/permissionPartner")
public class SysPermissionPartnerConfigController {
@Resource
private PartnerPermissionManager patnerPermissionManager;
private PermissionPartnerManager permissionPartnerManager;
@RequestMapping(value = "/synchronize", method = RequestMethod.POST)
public void synchronizeFunctions() {
patnerPermissionManager.synchronizeFunctions();
permissionPartnerManager.synchronizeFunctions();
}
@RequestMapping(value = "/functions", method = RequestMethod.GET)
public JSONObject listFunctions() {
return patnerPermissionManager.listFunctions();
return permissionPartnerManager.listFunctions();
}
@RequestMapping(value = "/functions/{funcId}.end", method = RequestMethod.PUT)
public void updateFunctionInfo(@PathVariable String funcId, @RequestBody FuncInfo funcInfo) {
patnerPermissionManager.updateFuncInfo(funcId, funcInfo);
permissionPartnerManager.updateFuncInfo(funcId, funcInfo);
}
@RequestMapping(value = "/functions/{funcId}/modules", method = RequestMethod.PUT)
public void setFuncModule(@PathVariable String funcId, @RequestBody JSONObject module) {
patnerPermissionManager.setFunctionModule(funcId, module.getString("module_name"));
permissionPartnerManager.setFunctionModule(funcId, module.getString("module_name"));
}
@RequestMapping(value = "/modules", method = RequestMethod.GET)
public List<JSONObject> listModuless() {
return patnerPermissionManager.listModules();
return permissionPartnerManager.listModules();
}
@RequestMapping(value = "/modules/{moduleName}.end", method = RequestMethod.PUT)
public void updateModulee(@PathVariable String moduleName, @RequestBody PartnerModuleInfo module) {
patnerPermissionManager.saveOrUpdateModule(moduleName, module);
permissionPartnerManager.saveOrUpdateModule(moduleName, module);
}
@RequestMapping(value = "/modules/{moduleName}.end", method = RequestMethod.DELETE)
public void deleteModulee(@PathVariable String moduleName) {
patnerPermissionManager.checkAndDeleteModule(moduleName);
permissionPartnerManager.checkAndDeleteModule(moduleName);
}
@RequestMapping(value = "/roles/{roleMask}/functions", method = RequestMethod.GET)
@ -68,7 +68,7 @@ public class SysPermissionPartnerConfigController {
int mask = Integer.parseInt(roleMask, 2);
for (ManagerRole role : ManagerRole.values()) {
if (mask == role.getMask()) {
return patnerPermissionManager.listRoleFunctions(role);
return permissionPartnerManager.listRoleFunctions(role);
}
}
@ -83,7 +83,7 @@ public class SysPermissionPartnerConfigController {
int mask = Integer.parseInt(roleMask, 2);
for (ManagerRole role : ManagerRole.values()) {
if (mask == role.getMask()) {
patnerPermissionManager.authorizeRole(role,functions);
permissionPartnerManager.authorizeRole(role,functions);
return;
}
}

@ -19,11 +19,8 @@ public interface PermissionClientModuleMapper {
@AutoSql(type = SqlType.INSERT)
void save(JSONObject clientmodules);
@AutoSql(type = SqlType.COUNT)
@AdvanceSelect(addonWhereClause = "is_valid=1")
int count(@Param("id") String moduleId);
void delete(@Param("module_name") String moduleName);
}

@ -32,4 +32,5 @@ public interface PermissionPartnerModuleMapper {
@AutoSql(type = SqlType.SELECT)
JSONObject listModuleId(@Param("module_name") String moduleName);
}

@ -264,6 +264,10 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
private ClearingLogMapper clearingLogMapper;
@Resource
private ClientConfigMapper clientConfigMapper;
@Resource
private PermissionPartnerModuleMapper permissionPartnerModuleMapper;
@Resource
private PermissionClientModuleMapper permissionClientModuleMapper;
@ -557,11 +561,25 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
throw new BadRequestException("error.partner.valid.dumplicate_client_moniker");
}
try {
clientMapper.save(partner);
JSONObject clientConfig = new JSONObject();
clientConfig.put("client_id", partner.getIntValue("client_id"));
clientConfig.put("client_moniker", partner.getString("client_moniker"));
clientConfigService.save(clientConfig);
List<JSONObject> moduleId = permissionPartnerModuleMapper.list();
for (JSONObject moduleClientAdd : moduleId) {
moduleClientAdd.put("client_id", partner.getIntValue("client_id"));
moduleClientAdd.put("client_moniker", partner.getString("client_moniker"));
moduleClientAdd.put("module_id", moduleClientAdd.getString("id"));
moduleClientAdd.put("is_valid", 1);
permissionClientModuleMapper.save(moduleClientAdd);
}
} catch (Exception e) {
throw new BadRequestException("error.partner.valid.dumplicate_client_moniker");
}

@ -1,6 +1,6 @@
package au.com.royalpay.payment.manage.permission.manager;
import au.com.royalpay.payment.manage.management.sysconfig.core.PartnerPermissionManager;
import au.com.royalpay.payment.manage.management.sysconfig.core.PermissionPartnerManager;
import au.com.royalpay.payment.manage.management.sysconfig.core.PermissionManager;
import au.com.royalpay.payment.manage.signin.core.SignInStatusManager;
import au.com.royalpay.payment.tools.CommonConsts;
@ -35,7 +35,7 @@ public class ManagerUserInterceptor extends HandlerInterceptorAdapter implements
@Resource
private PermissionManager permissionManager;
@Resource
private PartnerPermissionManager partnerPermissionManager;
private PermissionPartnerManager permissionPartnerManager;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
@ -104,7 +104,7 @@ public class ManagerUserInterceptor extends HandlerInterceptorAdapter implements
}
}
JSONObject func = partnerPermissionManager.getPartnerFuncById(funcId);
JSONObject func = permissionPartnerManager.getPartnerFuncById(funcId);
if(func!=null && StringUtils.isNotEmpty(func.getString("module_id"))){
JSONArray arr = loginUser.getJSONArray("available_module_ids");
if (arr == null || !arr.contains(func.getString("module_id"))) {

@ -1,39 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="au.com.royalpay.payment.manage.mappers.system.PartnerPermissionFunctionMapper">
<sql id="joinModule">
SELECT
f.*,
m.js_module,
m.js_path,
m.remark mod_remark
FROM sys_permission_partner_functions f
LEFT JOIN sys_permission_partner_modules m ON m.module_name and m.id = f.module_id
</sql>
<update id="clearRolePermission">
<![CDATA[
UPDATE sys_permission_partner_functions
SET role = role & #{mask}
]]>
</update>
<update id="authorizeRole">
<![CDATA[
UPDATE sys_permission_partner_functions
SET role = role | #{mask}
WHERE func_id in
]]>
<foreach collection="func_ids" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</update>
<select id="listByRoleMask" resultType="com.alibaba.fastjson.JSONObject">
<include refid="joinModule"/>
<![CDATA[
WHERE f.role & #{mask} >0
]]>
</select>
<select id="listAll" resultType="com.alibaba.fastjson.JSONObject">
<include refid="joinModule"/>
ORDER BY f.module ASC,f.func_id ASC,f.module_id ASC
</select>
</mapper>

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="au.com.royalpay.payment.manage.mappers.system.PermissionPartnerModuleMapper">
<!-- <select id="listModuleId" resultType="com.alibaba.fastjson.JSONObject" >
select id from sys_permission_partner_modules where module_name=#{module_name}
</select>
<update id="update">
update sys_permission_partner_modules set js_module=#{js_module},remark=#{remark},js_path=#{js_path}
where module_name = #{module_name}
</update>
<insert id="save">
insert into sys_permission_partner_modules(module_name,js_module,js_path,remark) value (#{module_name},#{js_module},#{js_path},#{remark})
</insert>-->
</mapper>

@ -3,6 +3,6 @@
<mapper namespace="au.com.royalpay.payment.manage.mappers.system.PermissionClientModuleMapper">
<delete id="delete">
delete from sys_permission_partner_modules_clients
where sys_permission_partner_modules_clients.module_id = (SELECT module_id from sys_permission_partner_modules where module_name=#{module_name})
where module_id = (SELECT id from sys_permission_partner_modules where module_name=#{module_name})
</delete>
</mapper>

@ -39,21 +39,21 @@ define(['angular', 'uiRouter'], function (angular) {
templateUrl: '/static/config/sysconfigs/templates/payemnt_config.html',
controller: 'paymentConfigCtrl'
})*/
.state('sysconfig.partnerPermission', {
url: '/partnerPermission',
templateUrl: '/static/config/sysconfigs/templates/partnerPermission_config.html',
controller: 'partnerPermissionConfigRootCtrl'
}).state('sysconfig.partnerPermission.functions', {
.state('sysconfig.permissionPartner', {
url: '/permissionPartner',
templateUrl: '/static/config/sysconfigs/templates/permissionPartner_config.html',
controller: 'permissionPartnerConfigRootCtrl'
}).state('sysconfig.permissionPartner.functions', {
url: '/partnerFunctions',
templateUrl: '/static/config/sysconfigs/templates/partnerPermission_functions.html',
controller: 'partnerPermissionFuncCtrl'
}).state('sysconfig.partnerPermission.modules', {
templateUrl: '/static/config/sysconfigs/templates/permissionPartner_functions.html',
controller: 'permissionPartnerFuncCtrl'
}).state('sysconfig.permissionPartner.modules', {
url: '/partnerModules',
templateUrl: '/static/config/sysconfigs/templates/partnerPermission_modules.html',
controller: 'partnerPermissionModuleCtrl',
templateUrl: '/static/config/sysconfigs/templates/permissionPartner_modules.html',
controller: 'permissionPartnerModuleCtrl',
resolve: {
modules: ['$http', function ($http) {
return $http.get('/sys/partnerPermission/modules')
return $http.get('/sys/permissionPartner/modules')
}]
}
})
@ -326,18 +326,18 @@ define(['angular', 'uiRouter'], function (angular) {
})
}
}]);*/
app.controller('partnerPermissionConfigRootCtrl', ['$scope', '$http', '$uibModal', function ($scope, $http, $uibModal) {
app.controller('permissionPartnerConfigRootCtrl', ['$scope', '$http', '$uibModal', function ($scope, $http, $uibModal) {
$scope.authorizeRole = function (roleMask) {
$uibModal.open({
templateUrl: '/static/config/sysconfigs/templates/PartnerPermission_authorize_dialog.html',
controller: 'partnerPermissionAuthorizeDialogCtrl',
templateUrl: '/static/config/sysconfigs/templates/permissionPartner_authorize_dialog.html',
controller: 'permissionPartnerAuthorizeDialogCtrl',
size: 'lg',
resolve: {
authorized: ['$http', function ($http) {
return $http.get('/sys/partnerPermission/roles/' + roleMask + '/functions');
return $http.get('/sys/permissionPartner/roles/' + roleMask + '/functions');
}],
modules: ['$http', function ($http) {
return $http.get('/sys/partnerPermission/functions');
return $http.get('/sys/permissionPartner/functions');
}],
role: function () {
return roleMask
@ -346,13 +346,13 @@ define(['angular', 'uiRouter'], function (angular) {
});
}
}]);
app.controller('partnerPermissionAuthorizeDialogCtrl', ['$scope', '$http', 'authorized', 'modules', 'role',
app.controller('permissionPartnerAuthorizeDialogCtrl', ['$scope', '$http', 'authorized', 'modules', 'role',
function ($scope, $http, authorized, modules, role) {
$scope.authorized = authorized.data;
$scope.modules = modules.data;
$scope.submitAuthorize = function () {
$scope.errmsg = null;
$http.put('/sys/partnerPermission/roles/' + role + '/functions', $scope.authorized).then(function () {
$http.put('/sys/permissionPartner/roles/' + role + '/functions', $scope.authorized).then(function () {
$scope.$close();
}, function (resp) {
$scope.errmsg = resp.data.message;
@ -368,17 +368,17 @@ define(['angular', 'uiRouter'], function (angular) {
}
}]
);
app.controller('partnerPermissionFuncCtrl', ['$scope', '$http', '$state', '$uibModal', 'commonDialog',
app.controller('permissionPartnerFuncCtrl', ['$scope', '$http', '$state', '$uibModal', 'commonDialog',
function ($scope, $http, $state, $uibModal, commonDialog) {
$scope.loadFunctions = function () {
$http.get('/sys/partnerPermission/functions').then(function (functions) {
$http.get('/sys/permissionPartner/functions').then(function (functions) {
$scope.modFunctions = functions.data;
})
};
$scope.loadFunctions();
$scope.loadModules = function () {
$http.get('/sys/partnerPermission/modules').then(function (modules) {
$http.get('/sys/permissionPartner/modules').then(function (modules) {
$scope.modules = modules.data;
})
};
@ -387,21 +387,21 @@ define(['angular', 'uiRouter'], function (angular) {
$scope.syncFunctions = function () {
$http.post('/sys/partnerPermission/synchronize').then(function () {
$http.post('/sys/permissionPartner/synchronize').then(function () {
$scope.loadFunctions();
})
};
$scope.moveFunction = function (func) {
$uibModal.open({
templateUrl: '/static/config/sysconfigs/templates/partnerPermission_choose_module.html',
controller: 'partnerPermissionChooseModuleDialogCtrl',
templateUrl: '/static/config/sysconfigs/templates/permissionPartner_choose_module.html',
controller: 'permissionPartnerChooseModuleDialogCtrl',
resolve: {
modules: function () {
return $scope.modules;
}
}
}).result.then(function (modName) {
$http.put('/sys/partnerPermission/functions/' + func.func_id + '/modules', {module_name: modName}).then(function () {
$http.put('/sys/permissionPartner/functions/' + func.func_id + '/modules', {module_name: modName}).then(function () {
$scope.loadFunctions();
}, function (resp) {
commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'})
@ -411,7 +411,7 @@ define(['angular', 'uiRouter'], function (angular) {
$scope.editFunctionInfo = function (func) {
$uibModal.open({
templateUrl: '/static/config/sysconfigs/templates/PartnerFunc_info_edit.html',
controller: 'partnerPermissionFuncEditDialogCtrl',
controller: 'permissionPartnerFuncEditDialogCtrl',
resolve: {
func: function () {
return angular.copy(func);
@ -423,31 +423,34 @@ define(['angular', 'uiRouter'], function (angular) {
}
}]
);
app.controller('partnerPermissionChooseModuleDialogCtrl', ['$scope', '$http', 'modules', function ($scope, $http, modules) {
app.controller('permissionPartnerChooseModuleDialogCtrl', ['$scope', '$http', 'modules', function ($scope, $http, modules) {
$scope.modules = modules;
$scope.chooseModule = function (mod) {
$scope.$close(mod.module_name);
}
}]);
app.controller('partnerPermissionFuncEditDialogCtrl', ['$scope', '$http', 'func', function ($scope, $http, func) {
app.controller('permissionPartnerFuncEditDialogCtrl', ['$scope', '$http', 'func', function ($scope, $http, func) {
$scope.func = func;
$scope.modifyFunction = function () {
$scope.errmsg = null;
$http.put('/sys/partnerPermission/functions/' + func.func_id + '.end', $scope.func).then(function () {
$http.put('/sys/permissionPartner/functions/' + func.func_id + '.end', $scope.func).then(function () {
$scope.$close();
}, function (resp) {
$scope.errmsg = resp.data.message;
})
};
}]);
app.controller('partnerPermissionModuleCtrl', ['$scope', '$http', '$state', '$uibModal', 'commonDialog', 'modules',
app.controller('permissionPartnerModuleCtrl', ['$scope', '$http', '$state', '$uibModal', 'commonDialog', 'modules',
function ($scope, $http, $state, $uibModal, commonDialog, modules) {
$scope.modules = modules.data;
$scope.newPartnerModule = function () {
$uibModal.open({
templateUrl: '/static/config/sysconfigs/templates/PartnerPermission_module_dialog.html',
templateUrl: '/static/config/sysconfigs/templates/permissionPartner_module_dialog.html',
controller: 'partnerModuleNewCtrl',
resolve: {
moduleall: function () {
return $scope.modules;
},
module: function () {
return {};
}
@ -458,7 +461,7 @@ define(['angular', 'uiRouter'], function (angular) {
};
$scope.editPartnerModule = function (mod) {
$uibModal.open({
templateUrl: '/static/config/sysconfigs/templates/PartnerPermission_module_dialog.html',
templateUrl: '/static/config/sysconfigs/templates/permissionPartner_module_dialog.html',
controller: 'partnerModuleEditCtrl',
resolve: {
module: function () {
@ -475,7 +478,7 @@ define(['angular', 'uiRouter'], function (angular) {
title: 'Warning',
content: 'You are deleting an exists module. Confirm?'
}).then(function () {
$http.delete('/sys/partnerPermission/modules/' + mod.module_name + '.end').then(function () {
$http.delete('/sys/permissionPartner/modules/' + mod.module_name + '.end').then(function () {
$state.reload();
}, function (resp) {
commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'})
@ -487,46 +490,41 @@ define(['angular', 'uiRouter'], function (angular) {
app.controller('partnerModuleEditCtrl', ['$scope', '$http', 'module', function ($scope, $http, module) {
$scope.module = angular.copy(module);
$scope.nameEditable = !module.module_name;
$http.get('/sys/partnerPermission/modules/'+ $scope.module.module_id + '.num').then(function (num) {
$scope.module.initialize = num.data.bool;
})
$scope.save = function () {
$scope.errmsg = null;
$http.put('/sys/partnerPermission/modules/' + $scope.module.module_name + '.end', $scope.module).then(function () {
$http.put('/sys/permissionPartner/modules/' + $scope.module.module_name + '.end', $scope.module).then(function () {
$scope.$close();
}, function (resp) {
$scope.errmsg = resp.data.message;
})
};
}]);
app.controller('partnerModuleNewCtrl', ['$scope', '$http', 'module', function ($scope, $http, module) {
app.controller('partnerModuleNewCtrl', ['$scope', '$http', 'module','moduleall','commonDialog', function ($scope, $http, module,moduleall,commonDialog) {
$scope.module = angular.copy(module);
$scope.nameEditable = !module.module_name;
$scope.module.initialize = false;
$scope.module.initialize = true;
$scope.save = function () {
var hasOne =0;
$scope.errmsg = null;
$http.put('/sys/partnerPermission/modules/' + $scope.module.module_name + '.end', $scope.module).then(function () {
$scope.$close();
}, function (resp) {
$scope.errmsg = resp.data.message;
angular.forEach(moduleall,function (data) {
if ($scope.module.module_name == data.module_name) {
commonDialog.alert({title: 'Error', content: "Module Has Exists", type: 'error'})
hasOne=1
return hasOne;
}
})
if (hasOne != 1) {
$http.put('/sys/permissionPartner/modules/' + $scope.module.module_name + '.end', $scope.module).then(function () {
$scope.$close();
}, function (resp) {
$scope.errmsg = resp.data.message;
})
}
};
}]);
return app;
});

@ -13,7 +13,7 @@
<div class="nav-tabs-custom">
<ul class="nav nav-tabs">
<li ui-sref-active-eq="active">
<a ui-sref="sysconfig.partnerPermission">Permissions</a>
<a ui-sref="sysconfig.permissionPartner">Permissions</a>
</li>
<li ui-sref-active="active">
<a ui-sref=".functions">Functions</a>

@ -25,7 +25,7 @@
Mail Subscriptions
</a>
<a class="btn btn-app" role="button" ui-sref=".partnerPermission">
<a class="btn btn-app" role="button" ui-sref=".permissionPartner">
<i class="fa fa-key"></i>
Partner Permission Config
</a>

Loading…
Cancel
Save