提交 18b00dd5 编写于 作者: ibizdev's avatar ibizdev

zhouweidong 发布系统代码 [ibiz-uaa,UAA鉴权]

上级 89bb67ee
......@@ -233,6 +233,44 @@ mock.onPost(new RegExp(/^\/sysusers\/?([a-zA-Z0-9\-\;]{0,35})\/checkkey$/)).repl
return [status, data];
});
// DeleteSysUser
mock.onPost(new RegExp(/^\/sysusers\/?([a-zA-Z0-9\-\;]{0,35})\/deletesysuser$/)).reply((config: any) => {
console.groupCollapsed("实体:sysuser 方法: DeleteSysUser");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
const paramArray:Array<any> = ['userid'];
const matchArray:any = new RegExp(/^\/sysusers\/([a-zA-Z0-9\-\;]{1,35})\/deletesysuser$/).exec(config.url);
let tempValue: any = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => {
Object.defineProperty(tempValue, item, {
enumerable: true,
value: matchArray[index + 1]
});
});
}
//let items = mockDatas ? mockDatas : [];
//let _items = items.find((item: any) => Object.is(item.userid, tempValue.userid));
let data = JSON.parse(config.data);
mockDatas.forEach((item)=>{
if(item['userid'] == tempValue['userid'] ){
for(let value in data){
if(item.hasOwnProperty(value)){
item[value] = data[value];
}
}
}
})
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table(data);
console.groupEnd();
console.groupEnd();
return [status, data];
});
// Save
mock.onPost(new RegExp(/^\/sysusers\/?([a-zA-Z0-9\-\;]{0,35})\/save$/)).reply((config: any) => {
console.groupCollapsed("实体:sysuser 方法: Save");
......
......@@ -154,6 +154,20 @@ export default class SysUserServiceBase extends EntityService {
return res;
}
/**
* DeleteSysUser接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof SysUserServiceBase
*/
public async DeleteSysUser(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let res:any = Http.getInstance().post(`/sysusers/${context.sysuser}/deletesysuser`,data,isloading);
return res;
}
/**
* Save接口方法
*
......
......@@ -37,6 +37,7 @@ public interface ISysUserService extends IService<SysUser> {
SysUser get(String key);
SysUser getDraft(SysUser et);
boolean checkKey(SysUser et);
SysUser deleteSysUser(SysUser et);
boolean save(SysUser et);
@CacheEvict(value = "sysuser",allEntries = true)
void saveBatch(List<SysUser> list);
......
......@@ -55,6 +55,10 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
@Lazy
protected cn.ibizlab.core.uaa.service.ISysUserRoleService sysuserroleService;
@Autowired
@Lazy
protected cn.ibizlab.core.uaa.service.logic.ISysUserdeleteSysUserLogic deletesysuserLogic;
@Autowired
@Lazy
protected cn.ibizlab.core.uaa.service.logic.ISysUsersaveSysUserLogic savesysuserLogic;
......@@ -131,6 +135,13 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
public boolean checkKey(SysUser et) {
return (!ObjectUtils.isEmpty(et.getUserid())) && (!Objects.isNull(this.getById(et.getUserid())));
}
@Override
@Transactional
public SysUser deleteSysUser(SysUser et) {
deletesysuserLogic.execute(et);
return et ;
}
@Override
@Transactional
public boolean save(SysUser et) {
......
package cn.ibizlab.core.uaa.service.logic;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import cn.ibizlab.core.uaa.domain.SysUser;
/**
* 关系型数据实体[deleteSysUser] 对象
*/
public interface ISysUserdeleteSysUserLogic {
void execute(SysUser et) ;
}
package cn.ibizlab.core.uaa.service.logic.impl;
import java.util.Map;
import java.util.HashMap;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.KieContainer;
import cn.ibizlab.core.uaa.service.logic.ISysUserdeleteSysUserLogic;
import cn.ibizlab.core.uaa.domain.SysUser;
/**
* 关系型数据实体[deleteSysUser] 对象
*/
@Slf4j
@Service
public class SysUserdeleteSysUserLogicImpl implements ISysUserdeleteSysUserLogic {
@Autowired
private KieContainer kieContainer;
@Autowired
private cn.ibizlab.core.uaa.service.ISysUserService sysuserservice;
public cn.ibizlab.core.uaa.service.ISysUserService getSysuserService() {
return this.sysuserservice;
}
@Autowired
private cn.ibizlab.core.uaa.service.ISysUserService iBzSysDefaultService;
public cn.ibizlab.core.uaa.service.ISysUserService getIBzSysDefaultService() {
return this.iBzSysDefaultService;
}
@Override
public void execute(SysUser et) {
KieSession kieSession = null;
try {
kieSession = kieContainer.newKieSession();
kieSession.insert(et);
kieSession.setGlobal("sysuserdeletesysuserdefault", et);
kieSession.setGlobal("sysuserservice", sysuserservice);
kieSession.setGlobal("iBzSysSysuserDefaultService", iBzSysDefaultService);
kieSession.setGlobal("curuser", cn.ibizlab.util.security.AuthenticationUser.getAuthenticationUser());
kieSession.startProcess("cn.ibizlab.core.uaa.service.logic.sysuserdeletesysuser");
} catch (Exception e) {
throw new RuntimeException("执行[删除用户信息]处理逻辑发生异常" + e);
} finally {
if(kieSession != null) {
kieSession.destroy();
}
}
}
}
......@@ -40,7 +40,7 @@ public class RocketMQListenerProcessor implements MessageListenerOrderly {
log.info("MQ消息topic={}, tags={}, 消息内容={}", topic, tags, body);
if ("deletesysuser".equalsIgnoreCase(tags)) {
cn.ibizlab.core.uaa.domain.SysUser domain = JSON.parseObject(new String(body),cn.ibizlab.core.uaa.domain.SysUser.class);
SysUserService.remove(domain);
SysUserService.deleteSysUser(domain);
}
if ("savesysuser".equalsIgnoreCase(tags)) {
cn.ibizlab.core.uaa.domain.SysUser domain = JSON.parseObject(new String(body),cn.ibizlab.core.uaa.domain.SysUser.class);
......
......@@ -64,7 +64,7 @@
"delogicname":"系统用户",
"sysmoudle":{"id":"UAA","name":"uaa"},
"dedataset":[{"id":"Default" , "name":"DEFAULT"}],
"deaction":[{"id":"Create" , "name":"Create" , "type":"BUILTIN" },{"id":"Update" , "name":"Update" , "type":"BUILTIN" },{"id":"Remove" , "name":"Remove" , "type":"BUILTIN" },{"id":"Get" , "name":"Get" , "type":"BUILTIN" },{"id":"GetDraft" , "name":"GetDraft" , "type":"BUILTIN" },{"id":"CheckKey" , "name":"CheckKey" , "type":"BUILTIN" },{"id":"Save" , "name":"Save" , "type":"BUILTIN" },{"id":"SaveSysUser" , "name":"保存用户信息" , "type":"DELOGIC" }],
"deaction":[{"id":"Create" , "name":"Create" , "type":"BUILTIN" },{"id":"Update" , "name":"Update" , "type":"BUILTIN" },{"id":"Remove" , "name":"Remove" , "type":"BUILTIN" },{"id":"Get" , "name":"Get" , "type":"BUILTIN" },{"id":"GetDraft" , "name":"GetDraft" , "type":"BUILTIN" },{"id":"CheckKey" , "name":"CheckKey" , "type":"BUILTIN" },{"id":"DeleteSysUser" , "name":"删除用户信息" , "type":"DELOGIC" },{"id":"Save" , "name":"Save" , "type":"BUILTIN" },{"id":"SaveSysUser" , "name":"保存用户信息" , "type":"DELOGIC" }],
"datascope":[{"id":"all","name":"全部数据"}, {"id":"curorg","name":"当前单位"},{"id":"porg","name":"上级单位"},{"id":"sorg","name":"下级单位"} ]
}
, {
......
package cn.ibizlab.uaa.logic.sysuserlogic.deletesysuser;
import java.util.Map;
import java.util.HashMap;
import com.alibaba.fastjson.JSONObject;
import org.springframework.util.StringUtils;
import org.springframework.util.ObjectUtils;
import cn.ibizlab.util.errors.BadRequestAlertException;
global cn.ibizlab.core.uaa.domain.SysUser sysuserdeletesysuserdefault;
global cn.ibizlab.core.uaa.service.ISysUserService sysuserservice;
global cn.ibizlab.core.uaa.service.ISysUserService iBzSysSysuserDefaultService;
global cn.ibizlab.util.security.AuthenticationUser curuser;
no-loop
//逻辑处理节点[同步删除用户]
rule "deaction1"
ruleflow-group "sysuserdeletesysuserdeaction1"
when
then
sysuserservice.remove(sysuserdeletesysuserdefault.getUserid());
update(sysuserdeletesysuserdefault);//更新fact中变量值
end
//逻辑处理节点[开始]
rule "begin"
ruleflow-group "sysuserdeletesysuserbegin"
when
then
end
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:g="http://www.jboss.org/drools/flow/gpd" xmlns:tns="http://www.jboss.org/drools" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" expressionLanguage="http://www.mvel.org/2.0" id="Definition" name="" targetNamespace="http://www.jboss.org/drools" typeLanguage="http://www.java.com/javaTypes">
<process id="cn.ibizlab.core.uaa.service.logic.sysuserdeletesysuser" isClosed="false" isExecutable="true" name="ScoreRule" processType="Private" tns:packageName="cn.ibizlab.core.uaa.service.logic.sysuserdeletesysuser">
<extensionElements>
<tns:import name="java.util.Map" />
<tns:import name="org.springframework.util.StringUtils"/>
<tns:import name="cn.ibizlab.util.helper.RuleUtils"/>
<tns:global identifier="sysuserdeletesysuserdefault" type="cn.ibizlab.core.uaa.domain.SysUser" />
</extensionElements>
<businessRuleTask activiti:exclusive="true" g:ruleFlowGroup="sysuserdeletesysuserdeaction1" id="deaction1" implementation="http://www.jboss.org/drools/rule" name="同步删除用户"/>
<endEvent id="deaction1_end" name="end"/>
<sequenceFlow id="deaction1_end_line" sourceRef="deaction1" targetRef="deaction1_end"/>
<startEvent id="begin" isInterrupting="true"/>
<sequenceFlow id="begin_deaction1" sourceRef="begin" targetRef="deaction1">
</sequenceFlow>
</process>
</definitions>
......@@ -120,6 +120,17 @@ public class SysUserResource {
return ResponseEntity.status(HttpStatus.OK).body(sysuserService.checkKey(sysuserMapping.toDomain(sysuserdto)));
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzuaa-SysUser-DeleteSysUser-all')")
@ApiOperation(value = "删除用户信息", tags = {"系统用户" }, notes = "删除用户信息")
@RequestMapping(method = RequestMethod.POST, value = "/sysusers/{sysuser_id}/deletesysuser")
public ResponseEntity<SysUserDTO> deleteSysUser(@PathVariable("sysuser_id") String sysuser_id, @RequestBody SysUserDTO sysuserdto) {
SysUser domain = sysuserMapping.toDomain(sysuserdto);
domain.setUserid(sysuser_id);
domain = sysuserService.deleteSysUser(domain);
sysuserdto = sysuserMapping.toDto(domain);
return ResponseEntity.status(HttpStatus.OK).body(sysuserdto);
}
@PreAuthorize("hasPermission(this.sysuserMapping.toDomain(#sysuserdto),'ibzuaa-SysUser-Save')")
@ApiOperation(value = "保存系统用户", tags = {"系统用户" }, notes = "保存系统用户")
@RequestMapping(method = RequestMethod.POST, value = "/sysusers/save")
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册