提交 07320537 编写于 作者: R roo00

增加委托授权数据访问接口

上级 35dd8e78
var Describe = function() {
//20180730
// 20180730
}
Describe.splitValue = function(str) {
......@@ -38,7 +38,7 @@ Describe.doPost = function(address, m, data) {
xhrFields : {
'withCredentials' : true
},
data : ((m.contentType.indexOf('application/json') > -1) ? JSON.stringify(data) : data)
data : ((m.contentType.indexOf('application/json') > -1) && (!m.useStringParameter) ? JSON.stringify(data) : data)
}).always(function(resultJson) {
$('#result').html(JSON.stringify(resultJson, null, 4));
Describe.writeOut(m.outs, resultJson);
......@@ -55,7 +55,7 @@ Describe.doPost = function(address, m, data) {
xhrFields : {
'withCredentials' : true
},
data : ((m.contentType.indexOf('application/json') > -1) ? JSON.stringify(data) : data)
data : ((m.contentType.indexOf('application/json') > -1) && (!m.useStringParameter) ? JSON.stringify(data) : data)
});
}
}
......@@ -74,7 +74,7 @@ Describe.doPut = function(address, m, data) {
xhrFields : {
'withCredentials' : true
},
data : ((m.contentType.indexOf('application/json') > -1) ? JSON.stringify(data) : data)
data : ((m.contentType.indexOf('application/json') > -1) && (!m.useStringParameter) ? JSON.stringify(data) : data)
}).always(function(resultJson) {
$('#result').html(JSON.stringify(resultJson, null, 4));
Describe.writeOut(m.outs, resultJson);
......@@ -91,7 +91,7 @@ Describe.doPut = function(address, m, data) {
xhrFields : {
'withCredentials' : true
},
data : ((m.contentType.indexOf('application/json') > -1) ? JSON.stringify(data) : data)
data : ((m.contentType.indexOf('application/json') > -1) && (!m.useStringParameter) ? JSON.stringify(data) : data)
});
}
}
......@@ -269,6 +269,14 @@ Describe.prototype = {
txt += '</table>';
txt += '</fieldset>';
}
if (m.useStringParameter) {
txt += '<fieldset><legend>String</legend>';
txt += '<table><tr><td>';
txt += '<textarea id="string" style="height:300px; width:600px; padding:1px; border:1px #000000 solid"/>';
txt += '</td><td>string</td></tr>';
txt += '</table>';
txt += '</fieldset>';
}
if (m.outs && m.outs.length > 0) {
txt += '<fieldset id="outs"><legend>Out</legend>';
txt += '<table>';
......@@ -318,6 +326,8 @@ Describe.prototype = {
});
} else if (m.useJsonElementParameter) {
data = $.parseJSON($('#jsonElement').val());
} else if (m.useStringParameter) {
data = $('#string').val();
}
Describe.doPost(address, m, data);
break;
......@@ -340,6 +350,8 @@ Describe.prototype = {
});
} else if (m.useJsonElementParameter) {
data = $.parseJSON($('#jsonElement').val());
} else if (m.useStringParameter) {
data = $('#string').val();
}
Describe.doPut(address, m, data);
break;
......
var Describe = function() {
//20180730
// 20180730
}
Describe.splitValue = function(str) {
......@@ -38,7 +38,7 @@ Describe.doPost = function(address, m, data) {
xhrFields : {
'withCredentials' : true
},
data : ((m.contentType.indexOf('application/json') > -1) ? JSON.stringify(data) : data)
data : ((m.contentType.indexOf('application/json') > -1) && (!m.useStringParameter) ? JSON.stringify(data) : data)
}).always(function(resultJson) {
$('#result').html(JSON.stringify(resultJson, null, 4));
Describe.writeOut(m.outs, resultJson);
......@@ -55,7 +55,7 @@ Describe.doPost = function(address, m, data) {
xhrFields : {
'withCredentials' : true
},
data : ((m.contentType.indexOf('application/json') > -1) ? JSON.stringify(data) : data)
data : ((m.contentType.indexOf('application/json') > -1) && (!m.useStringParameter) ? JSON.stringify(data) : data)
});
}
}
......@@ -74,7 +74,7 @@ Describe.doPut = function(address, m, data) {
xhrFields : {
'withCredentials' : true
},
data : ((m.contentType.indexOf('application/json') > -1) ? JSON.stringify(data) : data)
data : ((m.contentType.indexOf('application/json') > -1) && (!m.useStringParameter) ? JSON.stringify(data) : data)
}).always(function(resultJson) {
$('#result').html(JSON.stringify(resultJson, null, 4));
Describe.writeOut(m.outs, resultJson);
......@@ -91,7 +91,7 @@ Describe.doPut = function(address, m, data) {
xhrFields : {
'withCredentials' : true
},
data : ((m.contentType.indexOf('application/json') > -1) ? JSON.stringify(data) : data)
data : ((m.contentType.indexOf('application/json') > -1) && (!m.useStringParameter) ? JSON.stringify(data) : data)
});
}
}
......@@ -269,6 +269,14 @@ Describe.prototype = {
txt += '</table>';
txt += '</fieldset>';
}
if (m.useStringParameter) {
txt += '<fieldset><legend>String</legend>';
txt += '<table><tr><td>';
txt += '<textarea id="string" style="height:300px; width:600px; padding:1px; border:1px #000000 solid"/>';
txt += '</td><td>string</td></tr>';
txt += '</table>';
txt += '</fieldset>';
}
if (m.outs && m.outs.length > 0) {
txt += '<fieldset id="outs"><legend>Out</legend>';
txt += '<table>';
......@@ -318,6 +326,8 @@ Describe.prototype = {
});
} else if (m.useJsonElementParameter) {
data = $.parseJSON($('#jsonElement').val());
} else if (m.useStringParameter) {
data = $('#string').val();
}
Describe.doPost(address, m, data);
break;
......@@ -340,6 +350,8 @@ Describe.prototype = {
});
} else if (m.useJsonElementParameter) {
data = $.parseJSON($('#jsonElement').val());
} else if (m.useStringParameter) {
data = $('#string').val();
}
Describe.doPut(address, m, data);
break;
......
......@@ -9,6 +9,7 @@ import com.x.organization.core.entity.Role;
import com.x.organization.core.entity.Unit;
import com.x.organization.core.entity.UnitAttribute;
import com.x.organization.core.entity.UnitDuty;
import com.x.organization.core.entity.accredit.Trust;
import net.sf.ehcache.Ehcache;
......@@ -16,7 +17,7 @@ public class CacheFactory {
public static Ehcache getOrganizationCache() {
return ApplicationCache.instance().getCache(Identity.class, Unit.class, UnitAttribute.class, UnitDuty.class,
Role.class, Person.class, PersonAttribute.class, Group.class);
Role.class, Person.class, PersonAttribute.class, Group.class, Trust.class);
}
public static Ehcache getIdentityCache() {
......@@ -27,6 +28,10 @@ public class CacheFactory {
return ApplicationCache.instance().getCache(Unit.class);
}
public static Ehcache getTrustCache() {
return ApplicationCache.instance().getCache(Trust.class);
}
public static Ehcache getUnitAttributeCache() {
return ApplicationCache.instance().getCache(UnitAttribute.class);
}
......@@ -60,6 +65,6 @@ public class CacheFactory {
ApplicationCache.notify(UnitDuty.class);
ApplicationCache.notify(Group.class);
ApplicationCache.notify(Role.class);
ApplicationCache.notify(Trust.class);
}
}
package com.x.organization.assemble.express.factory;
import com.x.organization.assemble.express.AbstractFactory;
import com.x.organization.assemble.express.Business;
import com.x.organization.assemble.express.CacheFactory;
import net.sf.ehcache.Ehcache;
public class TrustFactory extends AbstractFactory {
private Ehcache cache;
public TrustFactory(Business business) throws Exception {
super(business);
this.cache = CacheFactory.getTrustCache();
}
}
\ No newline at end of file
package com.x.organization.assemble.express.factory;
import com.x.organization.assemble.express.AbstractFactory;
import com.x.organization.assemble.express.Business;
public class TrustLogFactory extends AbstractFactory {
public TrustLogFactory(Business business) throws Exception {
super(business);
}
}
\ No newline at end of file
......@@ -10,6 +10,8 @@ import com.x.organization.assemble.express.jaxrs.identity.IdentityAction;
import com.x.organization.assemble.express.jaxrs.person.PersonAction;
import com.x.organization.assemble.express.jaxrs.personattribute.PersonAttributeAction;
import com.x.organization.assemble.express.jaxrs.role.RoleAction;
import com.x.organization.assemble.express.jaxrs.trust.TrustAction;
import com.x.organization.assemble.express.jaxrs.trustlog.TrustLogAction;
import com.x.organization.assemble.express.jaxrs.unit.UnitAction;
import com.x.organization.assemble.express.jaxrs.unitattribute.UnitAttributeAction;
import com.x.organization.assemble.express.jaxrs.unitduty.UnitDutyAction;
......@@ -25,6 +27,8 @@ public class ActionApplication extends AbstractActionApplication {
classes.add(UnitAction.class);
classes.add(UnitAttributeAction.class);
classes.add(UnitDutyAction.class);
classes.add(TrustAction.class);
classes.add(TrustLogAction.class);
return classes;
}
......
package com.x.organization.assemble.express.jaxrs;
import javax.servlet.annotation.WebFilter;
import com.x.base.core.project.jaxrs.CipherManagerUserJaxrsFilter;
@WebFilter(urlPatterns = "/jaxrs/trust/*", asyncSupported = true)
public class TrustJaxrsFilter extends CipherManagerUserJaxrsFilter {
}
package com.x.organization.assemble.express.jaxrs;
import javax.servlet.annotation.WebFilter;
import com.x.base.core.project.jaxrs.CipherManagerUserJaxrsFilter;
@WebFilter(urlPatterns = "/jaxrs/trustlog/*", asyncSupported = true)
public class TrustLogJaxrsFilter extends CipherManagerUserJaxrsFilter {
}
package com.x.organization.assemble.express.jaxrs.trust;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.JsonElement;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.gson.GsonPropertyObject;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.ListTools;
import com.x.organization.assemble.express.Business;
import com.x.organization.core.entity.Identity;
import com.x.organization.core.entity.accredit.Trust;
import com.x.organization.core.entity.accredit.Trust_;
import net.sf.ehcache.Element;
class ActionListWithIdentityObject extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionListWithIdentityObject.class);
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
ActionResult<List<Wo>> result = new ActionResult<>();
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), wi.getApplication(), wi.getProcess(),
StringUtils.join(wi.getIdentityList(), ","));
Element element = cache.get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((List<Wo>) element.getObjectValue());
} else {
List<Wo> wos = this.execute(business, wi);
cache.put(new Element(cacheKey, wos));
result.setData(wos);
}
return result;
}
}
public static class Wi extends GsonPropertyObject {
@FieldDescribe("应用")
private String application;
@FieldDescribe("流程")
private String process;
@FieldDescribe("身份")
private List<String> identityList = new ArrayList<>();
public List<String> getIdentityList() {
return identityList;
}
public void setIdentityList(List<String> identityList) {
this.identityList = identityList;
}
public String getApplication() {
return application;
}
public void setApplication(String application) {
this.application = application;
}
public String getProcess() {
return process;
}
public void setProcess(String process) {
this.process = process;
}
}
public static class Wo extends com.x.base.core.project.organization.Trust {
public Wo() {
}
public Wo(String fromIdentity, String toIdentity) {
this.setFromIdentity(fromIdentity);
this.setToIdentity(toIdentity);
}
}
private List<Trust> list(Business business, Wi wi) throws Exception {
List<Identity> identities = business.identity().pick(wi.getIdentityList());
List<String> ids = ListTools.extractProperty(identities, JpaObject.id_FIELDNAME, String.class, true, true);
EntityManager em = business.entityManagerContainer().get(Trust.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Trust> cq = cb.createQuery(Trust.class);
Root<Trust> root = cq.from(Trust.class);
Predicate p = cb.equal(root.get(Trust_.whole), true);
if (StringUtils.isNotEmpty(wi.getApplication())) {
p = cb.and(p,
cb.and(cb.notEqual(root.get(Trust_.whole), true),
cb.equal(root.get(Trust_.application), wi.getApplication()),
cb.or(cb.equal(root.get(Trust_.process), ""), cb.isNull(root.get(Trust_.process)))));
}
if (StringUtils.isNotEmpty(wi.getProcess())) {
p = cb.and(p, cb.and(cb.notEqual(root.get(Trust_.whole), true),
cb.equal(root.get(Trust_.process), wi.getProcess())));
}
cb.and(p, cb.isMember(root.get(Trust_.fromIdentity), cb.literal(ids)));
return em.createQuery(cq.select(root).where(p).distinct(true)).getResultList();
}
private List<Wo> execute(Business business, Wi wi) throws Exception {
List<Wo> wos = new ArrayList<>();
this.list(business, wi).stream().collect(Collectors.groupingBy(o -> o.getFromIdentity())).entrySet().stream()
.forEach(o -> {
out: for (;;) {
for (Trust t : o.getValue()) {
if ((BooleanUtils.isNotTrue(t.getWhole())) && StringUtils.isNotEmpty(t.getProcess())) {
Wo wo = new Wo(t.getFromIdentity(), t.getToIdentity());
wos.add(wo);
break out;
}
}
for (Trust t : o.getValue()) {
if ((BooleanUtils.isNotTrue(t.getWhole())) && StringUtils.isNotEmpty(t.getApplication())) {
Wo wo = new Wo(t.getFromIdentity(), t.getToIdentity());
wos.add(wo);
break out;
}
}
for (Trust t : o.getValue()) {
if (BooleanUtils.isTrue(t.getWhole())) {
Wo wo = new Wo(t.getFromIdentity(), t.getToIdentity());
wos.add(wo);
break out;
}
}
break;
}
});
return wos;
}
}
\ No newline at end of file
package com.x.organization.assemble.express.jaxrs.trust;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.gson.GsonPropertyObject;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.organization.assemble.express.Business;
import com.x.organization.assemble.express.CacheFactory;
import com.x.organization.core.entity.Unit;
import net.sf.ehcache.Ehcache;
class BaseAction extends StandardJaxrsAction {
Ehcache cache = CacheFactory.getOrganizationCache();
static class WoUnitListAbstract extends GsonPropertyObject {
@FieldDescribe("组织识别名")
private List<String> unitList = new ArrayList<>();
public List<String> getUnitList() {
return unitList;
}
public void setUnitList(List<String> unitList) {
this.unitList = unitList;
}
}
protected <T extends com.x.base.core.project.organization.Unit> T convert(Business business, Unit unit,
Class<T> clz) throws Exception {
T t = clz.newInstance();
t.setName(unit.getName());
t.setUnique(unit.getUnique());
t.setDistinguishedName(unit.getDistinguishedName());
t.setDescription(unit.getDescription());
t.setTypeList(unit.getTypeList());
t.setShortName(unit.getShortName());
t.setLevel(unit.getLevel());
t.setLevelName(unit.getLevelName());
t.setOrderNumber(unit.getOrderNumber());
t.setQiyeweixinId(unit.getQiyeweixinId());
t.setDingdingId(unit.getDingdingId());
t.setZhengwuDingdingId(unit.getZhengwuDingdingId());
if (StringUtils.isNotEmpty(unit.getSuperior())) {
Unit superior = business.unit().pick(unit.getSuperior());
if (null != superior) {
t.setSuperior(superior.getDistinguishedName());
}
}
return t;
}
}
\ No newline at end of file
package com.x.organization.assemble.express.jaxrs.trust;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.container.Suspended;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import com.google.gson.JsonElement;
import com.x.base.core.project.annotation.JaxrsDescribe;
import com.x.base.core.project.annotation.JaxrsMethodDescribe;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.http.HttpMediaType;
import com.x.base.core.project.jaxrs.ResponseFactory;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
@Path("trust")
@JaxrsDescribe("委托接口")
public class TrustAction extends StandardJaxrsAction {
private static Logger logger = LoggerFactory.getLogger(TrustAction.class);
@JaxrsMethodDescribe(value = "查找指定人员的委托办理.", action = ActionListWithIdentityObject.class)
@POST
@Path("list/identity/object")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listWithIdentityObject(@Suspended final AsyncResponse asyncResponse,
@Context HttpServletRequest request, JsonElement jsonElement) {
ActionResult<List<ActionListWithIdentityObject.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionListWithIdentityObject().execute(effectivePerson, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
}
}
\ No newline at end of file
package com.x.organization.assemble.express.jaxrs.trustlog;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.JsonElement;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.entity.tools.JpaObjectTools;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WrapBoolean;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.StringTools;
import com.x.organization.assemble.express.Business;
import com.x.organization.core.entity.Identity;
import com.x.organization.core.entity.accredit.TrustLog;
class ActionCreate extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionCreate.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
ActionResult<Wo> result = new ActionResult<>();
Business business = new Business(emc);
if (StringUtils.isEmpty(wi.getApplication())) {
throw new ExceptionEmptyApplication();
}
if (StringUtils.isEmpty(wi.getProcess())) {
throw new ExceptionEmptyProcess();
}
Identity fromIdentity = business.identity().pick(wi.getFromIdentity());
if (null == fromIdentity) {
throw new ExceptionEmptyFromIdentity();
}
Identity toIdentity = business.identity().pick(wi.getToIdentity());
if (null == toIdentity) {
throw new ExceptionEmptyToIdentity();
}
TrustLog trustLog = Wi.copier.copy(wi);
trustLog.setTitle(StringTools.utf8SubString(wi.getTitle(),
JpaObjectTools.definedLength(TrustLog.class, TrustLog.title_FIELDNAME)));
emc.beginTransaction(TrustLog.class);
emc.persist(trustLog, CheckPersistType.all);
emc.commit();
Wo wo = new Wo();
wo.setValue(true);
result.setData(wo);
return result;
}
}
public static class Wi extends TrustLog {
private static final long serialVersionUID = 4099666546308723776L;
static WrapCopier<Wi, TrustLog> copier = WrapCopierFactory.wi(Wi.class, TrustLog.class, null,
JpaObject.FieldsUnmodify);
}
public static class Wo extends WrapBoolean {
}
}
\ No newline at end of file
package com.x.organization.assemble.express.jaxrs.trustlog;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.gson.GsonPropertyObject;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.organization.assemble.express.Business;
import com.x.organization.assemble.express.CacheFactory;
import com.x.organization.core.entity.Unit;
import net.sf.ehcache.Ehcache;
class BaseAction extends StandardJaxrsAction {
Ehcache cache = CacheFactory.getOrganizationCache();
static class WoUnitListAbstract extends GsonPropertyObject {
@FieldDescribe("组织识别名")
private List<String> unitList = new ArrayList<>();
public List<String> getUnitList() {
return unitList;
}
public void setUnitList(List<String> unitList) {
this.unitList = unitList;
}
}
protected <T extends com.x.base.core.project.organization.Unit> T convert(Business business, Unit unit,
Class<T> clz) throws Exception {
T t = clz.newInstance();
t.setName(unit.getName());
t.setUnique(unit.getUnique());
t.setDistinguishedName(unit.getDistinguishedName());
t.setDescription(unit.getDescription());
t.setTypeList(unit.getTypeList());
t.setShortName(unit.getShortName());
t.setLevel(unit.getLevel());
t.setLevelName(unit.getLevelName());
t.setOrderNumber(unit.getOrderNumber());
t.setQiyeweixinId(unit.getQiyeweixinId());
t.setDingdingId(unit.getDingdingId());
t.setZhengwuDingdingId(unit.getZhengwuDingdingId());
if (StringUtils.isNotEmpty(unit.getSuperior())) {
Unit superior = business.unit().pick(unit.getSuperior());
if (null != superior) {
t.setSuperior(superior.getDistinguishedName());
}
}
return t;
}
}
\ No newline at end of file
package com.x.organization.assemble.express.jaxrs.trustlog;
import com.x.base.core.project.exception.PromptException;
class ExceptionEmptyApplication extends PromptException {
private static final long serialVersionUID = -665095222445791960L;
ExceptionEmptyApplication() {
super("应用不能为空.");
}
}
package com.x.organization.assemble.express.jaxrs.trustlog;
import com.x.base.core.project.exception.PromptException;
class ExceptionEmptyFromIdentity extends PromptException {
private static final long serialVersionUID = -665095222445791960L;
ExceptionEmptyFromIdentity() {
super("委托人不能为空.");
}
}
package com.x.organization.assemble.express.jaxrs.trustlog;
import com.x.base.core.project.exception.PromptException;
class ExceptionEmptyProcess extends PromptException {
private static final long serialVersionUID = -665095222445791960L;
ExceptionEmptyProcess() {
super("流程不能为空.");
}
}
package com.x.organization.assemble.express.jaxrs.trustlog;
import com.x.base.core.project.exception.PromptException;
class ExceptionEmptyToIdentity extends PromptException {
private static final long serialVersionUID = -665095222445791960L;
ExceptionEmptyToIdentity() {
super("被委托人不能为空.");
}
}
package com.x.organization.assemble.express.jaxrs.trustlog;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.container.Suspended;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import com.google.gson.JsonElement;
import com.x.base.core.project.annotation.JaxrsDescribe;
import com.x.base.core.project.annotation.JaxrsMethodDescribe;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.http.HttpMediaType;
import com.x.base.core.project.jaxrs.ResponseFactory;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
@Path("trustlog")
@JaxrsDescribe("委托日志接口")
public class TrustLogAction extends StandardJaxrsAction {
private static Logger logger = LoggerFactory.getLogger(TrustLogAction.class);
@JaxrsMethodDescribe(value = "创建委托日志.", action = ActionCreate.class)
@POST
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void create(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
JsonElement jsonElement) {
ActionResult<ActionCreate.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionCreate().execute(effectivePerson, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
}
}
\ No newline at end of file
var Describe = function() {
//20180730
// 20180730
}
Describe.splitValue = function(str) {
......@@ -38,7 +38,7 @@ Describe.doPost = function(address, m, data) {
xhrFields : {
'withCredentials' : true
},
data : ((m.contentType.indexOf('application/json') > -1) ? JSON.stringify(data) : data)
data : ((m.contentType.indexOf('application/json') > -1) && (!m.useStringParameter) ? JSON.stringify(data) : data)
}).always(function(resultJson) {
$('#result').html(JSON.stringify(resultJson, null, 4));
Describe.writeOut(m.outs, resultJson);
......@@ -55,7 +55,7 @@ Describe.doPost = function(address, m, data) {
xhrFields : {
'withCredentials' : true
},
data : ((m.contentType.indexOf('application/json') > -1) ? JSON.stringify(data) : data)
data : ((m.contentType.indexOf('application/json') > -1) && (!m.useStringParameter) ? JSON.stringify(data) : data)
});
}
}
......@@ -74,7 +74,7 @@ Describe.doPut = function(address, m, data) {
xhrFields : {
'withCredentials' : true
},
data : ((m.contentType.indexOf('application/json') > -1) ? JSON.stringify(data) : data)
data : ((m.contentType.indexOf('application/json') > -1) && (!m.useStringParameter) ? JSON.stringify(data) : data)
}).always(function(resultJson) {
$('#result').html(JSON.stringify(resultJson, null, 4));
Describe.writeOut(m.outs, resultJson);
......@@ -91,7 +91,7 @@ Describe.doPut = function(address, m, data) {
xhrFields : {
'withCredentials' : true
},
data : ((m.contentType.indexOf('application/json') > -1) ? JSON.stringify(data) : data)
data : ((m.contentType.indexOf('application/json') > -1) && (!m.useStringParameter) ? JSON.stringify(data) : data)
});
}
}
......@@ -269,6 +269,14 @@ Describe.prototype = {
txt += '</table>';
txt += '</fieldset>';
}
if (m.useStringParameter) {
txt += '<fieldset><legend>String</legend>';
txt += '<table><tr><td>';
txt += '<textarea id="string" style="height:300px; width:600px; padding:1px; border:1px #000000 solid"/>';
txt += '</td><td>string</td></tr>';
txt += '</table>';
txt += '</fieldset>';
}
if (m.outs && m.outs.length > 0) {
txt += '<fieldset id="outs"><legend>Out</legend>';
txt += '<table>';
......@@ -318,6 +326,8 @@ Describe.prototype = {
});
} else if (m.useJsonElementParameter) {
data = $.parseJSON($('#jsonElement').val());
} else if (m.useStringParameter) {
data = $('#string').val();
}
Describe.doPost(address, m, data);
break;
......@@ -340,6 +350,8 @@ Describe.prototype = {
});
} else if (m.useJsonElementParameter) {
data = $.parseJSON($('#jsonElement').val());
} else if (m.useStringParameter) {
data = $('#string').val();
}
Describe.doPut(address, m, data);
break;
......
package com.x.organization.service.express.test;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;
import com.x.organization.core.entity.accredit.Trust;
public class TestClient {
// @Test
// public void test() throws Exception {
// Request request = Request.Post("http://xa.ray.local:8080/x_organization_service_express/jaxrs/identity/list");
// Gson gson = XGsonBuilder.instance();
// List<String> data = new ArrayList<>();
// data.add("张三");
// data.add("赵六");
// if (null != data) {
// request.bodyString(gson.toJson(data), ContentType.APPLICATION_JSON);
// }
// String str = request.execute().returnContent().asString(Charset.forName("UTF-8"));
// System.out.println(str);
//
// }
@Test
public void test() throws Exception {
List<Trust> list = new ArrayList<>();
Trust t1 = new Trust();
t1.setApplication("applicationa");
Trust t2 = new Trust();
t2.setApplication("applicationb");
t2.setProcess("processb");
Trust t3 = new Trust();
t3.setApplication("applicationc");
t3.setProcess("processc");
t3.setWhole(true);
list.add(t1);
list.add(t2);
list.add(t3);
// list.stream().sorted((o1, o2) -> {
// if (StringUtils.isNotEmpty(o1.getProcess()) && StringUtils.isNotEmpty(o2.getProcess())) {
// return 0;
// } else if (StringUtils.isNotEmpty(o1.getProcess()) && StringUtils.isEmpty(o2.getProcess())) {
// return -1;
// } else if (StringUtils.isEmpty(o1.getProcess()) && StringUtils.isNotEmpty(o2.getProcess())) {
// return 1;
// } else if (StringUtils.isNotEmpty(o1.getApplication()) && StringUtils.isNotEmpty(o2.getApplication())) {
// return 0;
// } else if (StringUtils.isNotEmpty(o1.getApplication()) && StringUtils.isEmpty(o2.getApplication())) {
// return -1;
// } else if (StringUtils.isEmpty(o1.getApplication()) && StringUtils.isNotEmpty(o2.getApplication())) {
// return 1;
// } else {
// return 1;
// }
// }).forEach(o -> {
// System.out.println(o);
// });
Trust trust = null;
out: for (;;) {
for (Trust t : list) {
if ((BooleanUtils.isNotTrue(t.getWhole())) && StringUtils.isNotEmpty(t.getProcess())) {
trust = t;
break out;
}
}
for (Trust t : list) {
if ((BooleanUtils.isNotTrue(t.getWhole())) && StringUtils.isNotEmpty(t.getApplication())) {
trust = t;
break out;
}
}
for (Trust t : list) {
if (BooleanUtils.isTrue(t.getWhole())) {
trust = t;
break out;
}
}
break;
}
System.out.println(trust);
}
}
......@@ -12,6 +12,8 @@ import com.x.organization.assemble.personal.jaxrs.password.PasswordAction;
import com.x.organization.assemble.personal.jaxrs.person.PersonAction;
import com.x.organization.assemble.personal.jaxrs.regist.RegistAction;
import com.x.organization.assemble.personal.jaxrs.reset.ResetAction;
import com.x.organization.assemble.personal.jaxrs.trust.TrustAction;
import com.x.organization.assemble.personal.jaxrs.trustlog.TrustLogAction;
@ApplicationPath("jaxrs")
public class ActionApplication extends AbstractActionApplication {
......@@ -24,6 +26,8 @@ public class ActionApplication extends AbstractActionApplication {
classes.add(IconAction.class);
classes.add(DefinitionAction.class);
classes.add(CustomAction.class);
classes.add(TrustAction.class);
classes.add(TrustLogAction.class);
return classes;
}
}
package com.x.organization.assemble.personal.jaxrs;
import javax.servlet.annotation.WebFilter;
import com.x.base.core.project.jaxrs.AnonymousCipherManagerUserJaxrsFilter;
@WebFilter(urlPatterns = "/jaxrs/trust/*", asyncSupported = true)
public class TrustJaxrsFilter extends AnonymousCipherManagerUserJaxrsFilter {
}
package com.x.organization.assemble.personal.jaxrs;
import javax.servlet.annotation.WebFilter;
import com.x.base.core.project.jaxrs.AnonymousCipherManagerUserJaxrsFilter;
@WebFilter(urlPatterns = "/jaxrs/trustlog/*", asyncSupported = true)
public class TrustLogJaxrsFilter extends AnonymousCipherManagerUserJaxrsFilter {
}
//package com.x.organization.assemble.personal.jaxrs.person;
//
//import java.net.URLEncoder;
//import java.util.ArrayList;
//import java.util.List;
//
//import com.x.base.core.DefaultCharset;
//import com.x.base.core.bean.WrapCopier;
//import com.x.base.core.bean.WrapCopierFactory;
//import com.x.base.core.cache.ApplicationCache;
//import com.x.base.core.container.EntityManagerContainer;
//import com.x.base.core.container.factory.EntityManagerContainerFactory;
//import com.x.base.core.entity.JpaObject;
//import com.x.base.core.http.ActionResult;
//import com.x.base.core.http.EffectivePerson;
//import com.x.base.core.http.WrapOutOnline;
//import com.x.base.core.project.x_collaboration_assemble_websocket;
//import com.x.base.core.project.organization.Identity;
//import com.x.base.core.project.organization.Person;
//import com.x.base.core.project.server.Config;
//import com.x.organization.assemble.personal.Business;
//import com.x.organization.assemble.personal.ThisApplication;
//import com.x.organization.core.express.Organization;
//
//import net.sf.ehcache.Element;
//
//class ActionGetComplex extends BaseAction {
//
// ActionResult<Wo> execute(EffectivePerson effectivePerson) throws Exception {
// ActionResult<Wo> result = new ActionResult<>();
// Wo wo = null;
// if (Config.token().isInitialManager(effectivePerson.getDistinguishedName())) {
// wo = new Wo();
// Config.token().initialManagerInstance().copyTo(wo);
// } else {
// String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(),
// effectivePerson.getDistinguishedName());
// Element element = cache.get(cacheKey);
// if ((null != element) && (null != element.getObjectValue())) {
// wo = (Wo) element.getObjectValue();
// } else {
// try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
// Business business = new Business(emc);
// Person person = business.organization().person().getObject(effectivePerson.getDistinguishedName());
// if (null != person) {
// wo = Wo.copier.copy(person);
// // if (StringUtils.isEmpty(wrap.getIcon())) {
// // if (Objects.equals(wrap.getGenderType(),
// // GenderType.f)) {
// // wrap.setIcon(Person.ICON_FEMALE);
// // } else if (Objects.equals(wrap.getGenderType(),
// // GenderType.m)) {
// // wrap.setIcon(Person.ICON_MALE);
// // } else {
// // wrap.setIcon(Person.ICON_UNKOWN);
// // }
// // }
// wo.setIdentityList(this.listIdentity(business.organization(), wo.getDistinguishedName()));
// // wo.setOnlineStatus(this.getOnlineStatus(business,
// // wrap.getName()));
// cache.put(new Element(cacheKey, wo));
// }
// }
// }
// }
// result.setData(wo);
// return result;
// }
//
// public static class Wo extends Person {
//
// static WrapCopier<Person, Wo> copier = WrapCopierFactory.create(Person.class, Wo.class, null,
// JpaObject.FieldsInvisible);
//
// private List<WoIdentity> identityList = new ArrayList<>();
//
// private String onlineStatus;
//
// public String getOnlineStatus() {
// return onlineStatus;
// }
//
// public void setOnlineStatus(String onlineStatus) {
// this.onlineStatus = onlineStatus;
// }
//
// public List<WoIdentity> getIdentityList() {
// return identityList;
// }
//
// public void setIdentityList(List<WoIdentity> identityList) {
// this.identityList = identityList;
// }
//
// }
//
// public static class WoIdentity extends Identity {
//
// static WrapCopier<Identity, WoIdentity> copier = WrapCopierFactory.create(Identity.class,
// WoIdentity.class, null, JpaObject.FieldsInvisible);
//
// private List<String> unitDutyList = new ArrayList<>();
//
// public List<String> getUnitDutyList() {
// return unitDutyList;
// }
//
// public void setUnitDutyList(List<String> unitDutyList) {
// this.unitDutyList = unitDutyList;
// }
//
// }
//
// private List<WoIdentity> listIdentity(Organization organization, String personName) throws Exception {
// List<WoIdentity> list = new ArrayList<>();
// List<Identity> os = organization.identity().listObject(organization.identity().listWithPerson(personName));
// for (Identity o : os) {
// WoIdentity wo = WoIdentity.copier.copy(o);
// wo.getUnitDutyList().addAll(organization.unitDuty().listNameWithIdentity(o.getDistinguishedName()));
// list.add(wo);
// }
// return list;
// }
//
// private String getOnlineStatus(Business business, String person) throws Exception {
// WrapOutOnline online = ThisApplication.context().applications()
// .getQuery(x_collaboration_assemble_websocket.class,
// "online/person/" + URLEncoder.encode(person, DefaultCharset.name))
// .getData(WrapOutOnline.class);
// return online.getOnlineStatus();
// }
//}
package com.x.organization.assemble.personal.jaxrs.trust;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.JsonElement;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.organization.assemble.personal.Business;
import com.x.organization.assemble.personal.jaxrs.trust.ActionEdit.Wi;
import com.x.organization.core.entity.Identity;
import com.x.organization.core.entity.Person;
import com.x.organization.core.entity.accredit.Trust;
class ActionCreate extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionCreate.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
Business business = new Business(emc);
if (StringUtils.isEmpty(wi.getFromIdentity())) {
throw new ExceptionEmptyFromIdentity();
}
if (StringUtils.isEmpty(wi.getToIdentity())) {
throw new ExceptionEmptyToIdentity();
}
if (BooleanUtils.isTrue(wi.getWhole())) {
if (!this.checkWhole(business, wi)) {
throw new ExceptionWholeExist(wi.getFromIdentity());
}
} else {
if (StringUtils.isNotEmpty(wi.getApplication())) {
if (StringUtils.isNotEmpty(wi.getProcess())) {
if (!this.checkProcess(business, wi)) {
throw new ExceptionProcessExist(wi.getFromIdentity(), wi.getApplication(), wi.getProcess());
}
} else if (!this.checkApplication(business, wi)) {
throw new ExceptionApplicationExist(wi.getFromIdentity(), wi.getApplication());
}
}
}
Trust trust = new Trust();
Wi.copier.copy(wi, trust);
String fromPerson = this.getPersonDNWithIdentityDN(business, trust.getFromIdentity());
if (StringUtils.isEmpty(fromPerson)) {
throw new ExceptionPersonNotExistWithIdentity(trust.getFromIdentity());
} else {
trust.setFromPerson(fromPerson);
}
String toPerson = this.getPersonDNWithIdentityDN(business, trust.getToIdentity());
if (StringUtils.isEmpty(toPerson)) {
throw new ExceptionPersonNotExistWithIdentity(trust.getToIdentity());
} else {
trust.setToPerson(toPerson);
}
emc.beginTransaction(Trust.class);
emc.persist(trust, CheckPersistType.all);
emc.commit();
ApplicationCache.notify(Trust.class);
Wo wo = new Wo();
wo.setId(trust.getId());
result.setData(wo);
return result;
}
}
public static class Wi extends Trust {
private static final long serialVersionUID = 1571810726944802231L;
static WrapCopier<Wi, Trust> copier = WrapCopierFactory.wi(Wi.class, Trust.class, null,
JpaObject.FieldsUnmodify);
}
public static class Wo extends WoId {
}
}
package com.x.organization.assemble.personal.jaxrs.trust;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.annotation.CheckRemoveType;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WrapBoolean;
import com.x.organization.core.entity.accredit.Trust;
class ActionDelete extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Trust trust = emc.find(id, Trust.class);
if (null == trust) {
throw new ExceptionEntityNotExist(id, Trust.class);
}
if (effectivePerson.isNotManager() && effectivePerson.isNotPerson(trust.getFromPerson())) {
throw new ExceptionAccessDenied(effectivePerson, trust);
}
emc.beginTransaction(Trust.class);
emc.remove(trust, CheckRemoveType.all);
emc.commit();
ApplicationCache.notify(Trust.class);
Wo wo = new Wo();
wo.setValue(true);
result.setData(wo);
return result;
}
}
public static class Wo extends WrapBoolean {
}
}
\ No newline at end of file
package com.x.organization.assemble.personal.jaxrs.trust;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.JsonElement;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.organization.assemble.personal.Business;
import com.x.organization.core.entity.accredit.Trust;
class ActionEdit extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionEdit.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id, JsonElement jsonElement) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
Business business = new Business(emc);
Trust trust = emc.find(id, Trust.class);
if (null == trust) {
throw new ExceptionEntityNotExist(id, Trust.class);
}
if (StringUtils.isEmpty(wi.getFromIdentity())) {
throw new ExceptionEmptyFromIdentity();
}
if (StringUtils.isEmpty(wi.getToIdentity())) {
throw new ExceptionEmptyToIdentity();
}
if (BooleanUtils.isTrue(wi.getWhole())) {
if (!this.checkWhole(business, wi)) {
throw new ExceptionWholeExist(wi.getFromIdentity());
}
} else {
if (StringUtils.isNotEmpty(wi.getApplication())) {
if (StringUtils.isNotEmpty(wi.getProcess())) {
if (!this.checkProcess(business, wi)) {
throw new ExceptionProcessExist(wi.getFromIdentity(), wi.getApplication(), wi.getProcess());
}
} else if (!this.checkApplication(business, wi)) {
throw new ExceptionApplicationExist(wi.getFromIdentity(), wi.getApplication());
}
}
}
Wi.copier.copy(wi, trust);
String fromPerson = this.getPersonDNWithIdentityDN(business, trust.getFromIdentity());
if (StringUtils.isEmpty(fromPerson)) {
throw new ExceptionPersonNotExistWithIdentity(trust.getFromIdentity());
} else {
trust.setFromPerson(fromPerson);
}
String toPerson = this.getPersonDNWithIdentityDN(business, trust.getToIdentity());
if (StringUtils.isEmpty(toPerson)) {
throw new ExceptionPersonNotExistWithIdentity(trust.getToIdentity());
} else {
trust.setToPerson(toPerson);
}
emc.beginTransaction(Trust.class);
emc.persist(trust, CheckPersistType.all);
emc.commit();
ApplicationCache.notify(Trust.class);
Wo wo = new Wo();
wo.setId(trust.getId());
result.setData(wo);
return result;
}
}
public static class Wi extends Trust {
private static final long serialVersionUID = 1571810726944802231L;
static WrapCopier<Wi, Trust> copier = WrapCopierFactory.wi(Wi.class, Trust.class, null,
JpaObject.FieldsUnmodify);
}
public static class Wo extends WoId {
}
}
package com.x.organization.assemble.personal.jaxrs.trust;
import java.util.List;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.organization.core.entity.accredit.Trust;
class ActionListNext extends BaseAction {
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, String id, Integer count) throws Exception {
ActionResult<List<Wo>> result = new ActionResult<>();
if (effectivePerson.isNotManager()) {
throw new ExceptionAccessDenied(effectivePerson);
}
result = this.standardListNext(Wo.copier, id, count, JpaObject.sequence_FIELDNAME, null, null, null, null, null,
null, null, null, true, DESC);
return result;
}
public static class Wo extends Trust {
private static final long serialVersionUID = -7495725325510376323L;
public static WrapCopier<Trust, Wo> copier = WrapCopierFactory.wo(Trust.class, Wo.class,
JpaObject.singularAttributeField(Trust.class, true, true), null);
@FieldDescribe("排序号")
private Long rank;
public Long getRank() {
return rank;
}
public void setRank(Long rank) {
this.rank = rank;
}
}
}
package com.x.organization.assemble.personal.jaxrs.trust;
import java.util.List;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.organization.core.entity.accredit.Trust;
class ActionListPrev extends BaseAction {
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, String id, Integer count) throws Exception {
ActionResult<List<Wo>> result = new ActionResult<>();
if (effectivePerson.isNotManager()) {
throw new ExceptionAccessDenied(effectivePerson);
}
result = this.standardListPrev(Wo.copier, id, count, JpaObject.sequence_FIELDNAME, null, null, null, null, null,
null, null, null, true, DESC);
return result;
}
public static class Wo extends Trust {
private static final long serialVersionUID = 4663181401822986160L;
public static WrapCopier<Trust, Wo> copier = WrapCopierFactory.wo(Trust.class, Wo.class,
JpaObject.singularAttributeField(Trust.class, true, true), null);
@FieldDescribe("排序号")
private Long rank;
public Long getRank() {
return rank;
}
public void setRank(Long rank) {
this.rank = rank;
}
}
}
package com.x.organization.assemble.personal.jaxrs.trust;
import java.util.List;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.organization.assemble.personal.Business;
import com.x.organization.core.entity.accredit.Trust;
import net.sf.ehcache.Element;
class ActionListTo extends BaseAction {
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
ActionResult<List<Wo>> result = new ActionResult<>();
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(),
effectivePerson.getDistinguishedName());
Element element = business.cache().get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((List<Wo>) element.getObjectValue());
} else {
List<Wo> wos = this.list(business, effectivePerson);
business.cache().put(new Element(cacheKey, wos));
result.setData(wos);
}
return result;
}
}
private List<Wo> list(Business business, EffectivePerson effectivePerson) throws Exception {
List<Trust> os = business.entityManagerContainer().listEqual(Trust.class, Trust.toPerson_FIELDNAME,
effectivePerson.getDistinguishedName());
return Wo.copier.copy(os);
}
public static class Wo extends Trust {
private static final long serialVersionUID = 4279205128463146835L;
static WrapCopier<Trust, Wo> copier = WrapCopierFactory.wi(Trust.class, Wo.class, null,
JpaObject.FieldsUnmodify);
}
}
package com.x.organization.assemble.personal.jaxrs.trust;
import java.util.List;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.organization.assemble.personal.Business;
import com.x.organization.core.entity.accredit.Trust;
import net.sf.ehcache.Element;
class ActionListWithCurrentPerson extends BaseAction {
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
ActionResult<List<Wo>> result = new ActionResult<>();
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(),
effectivePerson.getDistinguishedName());
Element element = business.cache().get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((List<Wo>) element.getObjectValue());
} else {
List<Wo> wos = this.list(business, effectivePerson);
business.cache().put(new Element(cacheKey, wos));
result.setData(wos);
}
return result;
}
}
private List<Wo> list(Business business, EffectivePerson effectivePerson) throws Exception {
List<Trust> os = business.entityManagerContainer().listEqual(Trust.class, Trust.fromPerson_FIELDNAME,
effectivePerson.getDistinguishedName());
return Wo.copier.copy(os);
}
public static class Wo extends Trust {
private static final long serialVersionUID = 4279205128463146835L;
static WrapCopier<Trust, Wo> copier = WrapCopierFactory.wi(Trust.class, Wo.class, null,
JpaObject.FieldsUnmodify);
}
}
package com.x.organization.assemble.personal.jaxrs.trust;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.organization.assemble.personal.Business;
import com.x.organization.core.entity.Identity;
import com.x.organization.core.entity.Person;
import com.x.organization.core.entity.accredit.Trust;
import com.x.organization.core.entity.accredit.Trust_;
abstract class BaseAction extends StandardJaxrsAction {
protected boolean checkWhole(Business business, Trust trust) throws Exception {
EntityManager em = business.entityManagerContainer().get(Trust.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Long> cq = cb.createQuery(Long.class);
Root<Trust> root = cq.from(Trust.class);
Predicate p = cb.equal(root.get(Trust_.fromIdentity), trust.getFromIdentity());
p = cb.and(p, cb.equal(root.get(Trust_.whole), true));
p = cb.and(p, cb.notEqual(root.get(Trust_.id), trust.getId()));
Long count = em.createQuery(cq.select(cb.count(root)).where(p)).getSingleResult();
if (count > 0) {
return false;
} else {
return true;
}
}
protected boolean checkApplication(Business business, Trust trust) throws Exception {
EntityManager em = business.entityManagerContainer().get(Trust.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Long> cq = cb.createQuery(Long.class);
Root<Trust> root = cq.from(Trust.class);
Predicate p = cb.equal(root.get(Trust_.fromIdentity), trust.getFromIdentity());
p = cb.and(p, cb.equal(root.get(Trust_.application), trust.getApplication()));
p = cb.and(p, cb.or(cb.equal(root.get(Trust_.process), ""), cb.isNull(root.get(Trust_.process))));
p = cb.and(p, cb.notEqual(root.get(Trust_.id), trust.getId()));
Long count = em.createQuery(cq.select(cb.count(root)).where(p)).getSingleResult();
if (count > 0) {
return false;
} else {
return true;
}
}
protected boolean checkProcess(Business business, Trust trust) throws Exception {
EntityManager em = business.entityManagerContainer().get(Trust.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Long> cq = cb.createQuery(Long.class);
Root<Trust> root = cq.from(Trust.class);
Predicate p = cb.equal(root.get(Trust_.fromIdentity), trust.getFromIdentity());
p = cb.and(p, cb.equal(root.get(Trust_.application), trust.getApplication()));
p = cb.and(p, cb.equal(root.get(Trust_.process), trust.getProcess()));
p = cb.and(p, cb.notEqual(root.get(Trust_.id), trust.getId()));
Long count = em.createQuery(cq.select(cb.count(root)).where(p)).getSingleResult();
if (count > 0) {
return false;
} else {
return true;
}
}
protected String getPersonDNWithIdentityDN(Business business, String dn) throws Exception {
Identity identity = business.identity().pick(dn);
if (null != identity) {
Person person = business.person().pick(identity.getPerson());
if (null != person) {
return person.getDistinguishedName();
}
}
return null;
}
}
\ No newline at end of file
package com.x.organization.assemble.personal.jaxrs.trust;
import com.x.base.core.project.exception.PromptException;
class ExceptionApplicationExist extends PromptException {
private static final long serialVersionUID = -3885997486474873786L;
ExceptionApplicationExist(String identity, String application) {
super("身份 {} 在指定应用 {} 的委托已经存在.", identity, application);
}
}
package com.x.organization.assemble.personal.jaxrs.trust;
import com.x.base.core.project.exception.PromptException;
class ExceptionEmptyFromIdentity extends PromptException {
private static final long serialVersionUID = -3885997486474873786L;
ExceptionEmptyFromIdentity() {
super("委托身份为空.");
}
}
package com.x.organization.assemble.personal.jaxrs.trust;
import com.x.base.core.project.exception.PromptException;
class ExceptionEmptyToIdentity extends PromptException {
private static final long serialVersionUID = -3885997486474873786L;
ExceptionEmptyToIdentity() {
super("被委托身份为空.");
}
}
package com.x.organization.assemble.personal.jaxrs.trust;
import com.x.base.core.project.exception.PromptException;
class ExceptionPersonNotExistWithIdentity extends PromptException {
private static final long serialVersionUID = -3885997486474873786L;
ExceptionPersonNotExistWithIdentity(String identity) {
super("无法定位 {} 的人员.", identity);
}
}
package com.x.organization.assemble.personal.jaxrs.trust;
import com.x.base.core.project.exception.PromptException;
class ExceptionProcessExist extends PromptException {
private static final long serialVersionUID = -3885997486474873786L;
ExceptionProcessExist(String identity, String application, String process) {
super("身份 {} 在指定应用 {} 的指定 流程 {} 的委托已经存在.", identity, application, process);
}
}
package com.x.organization.assemble.personal.jaxrs.trust;
import com.x.base.core.project.exception.PromptException;
class ExceptionWholeExist extends PromptException {
private static final long serialVersionUID = -3885997486474873786L;
ExceptionWholeExist(String identity) {
super("身份 {} 的全局设置已经存在.", identity);
}
}
package com.x.organization.assemble.personal.jaxrs.trust;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.container.Suspended;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import com.google.gson.JsonElement;
import com.x.base.core.project.annotation.JaxrsDescribe;
import com.x.base.core.project.annotation.JaxrsMethodDescribe;
import com.x.base.core.project.annotation.JaxrsParameterDescribe;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.http.HttpMediaType;
import com.x.base.core.project.jaxrs.ResponseFactory;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
@Path("trust")
@JaxrsDescribe("委托操作")
public class TrustAction extends StandardJaxrsAction {
private static Logger logger = LoggerFactory.getLogger(TrustAction.class);
@JaxrsMethodDescribe(value = "管理员列示授权对象,下一页.", action = ActionListNext.class)
@GET
@Path("list/{id}/next/{count}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listNext(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("标识") @PathParam("id") String id,
@JaxrsParameterDescribe("数量") @PathParam("count") Integer count) {
ActionResult<List<ActionListNext.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionListNext().execute(effectivePerson, id, count);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
}
@JaxrsMethodDescribe(value = "管理员列示授权对象,上一页.", action = ActionListPrev.class)
@GET
@Path("list/{id}/prev/{count}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listPrev(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("标识") @PathParam("id") String id,
@JaxrsParameterDescribe("数量") @PathParam("count") Integer count) {
ActionResult<List<ActionListPrev.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionListPrev().execute(effectivePerson, id, count);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
}
@JaxrsMethodDescribe(value = "获取当前人员的委托.", action = ActionListWithCurrentPerson.class)
@GET
@Path("list/currentperson")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listWithCurrentPerson(@Suspended final AsyncResponse asyncResponse,
@Context HttpServletRequest request) {
ActionResult<List<ActionListWithCurrentPerson.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionListWithCurrentPerson().execute(effectivePerson);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
}
@JaxrsMethodDescribe(value = "获取当前人员的被委托.", action = ActionListTo.class)
@GET
@Path("list/to")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listTo(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request) {
ActionResult<List<ActionListTo.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionListTo().execute(effectivePerson);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
}
@JaxrsMethodDescribe(value = "创建委托", action = ActionCreate.class)
@POST
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void create(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
JsonElement jsonElement) {
ActionResult<ActionCreate.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionCreate().execute(effectivePerson, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
}
@JaxrsMethodDescribe(value = "更新委托", action = ActionEdit.class)
@PUT
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void edit(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("标识") @PathParam("id") String id, JsonElement jsonElement) {
ActionResult<ActionEdit.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionEdit().execute(effectivePerson, id, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
}
@JaxrsMethodDescribe(value = "删除委托", action = ActionDelete.class)
@DELETE
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void delete(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("标识") @PathParam("id") String id) {
ActionResult<ActionDelete.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionDelete().execute(effectivePerson, id);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
}
}
\ No newline at end of file
package com.x.organization.assemble.personal.jaxrs.trustlog;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.annotation.CheckRemoveType;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WrapBoolean;
import com.x.organization.core.entity.accredit.TrustLog;
class ActionDelete extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
TrustLog trustLog = emc.find(id, TrustLog.class);
if (null == trustLog) {
throw new ExceptionEntityNotExist(id, TrustLog.class);
}
if (effectivePerson.isNotManager()) {
throw new ExceptionAccessDenied(effectivePerson, trustLog);
}
emc.beginTransaction(TrustLog.class);
emc.remove(trustLog, CheckRemoveType.all);
emc.commit();
ApplicationCache.notify(TrustLog.class);
Wo wo = new Wo();
wo.setValue(true);
result.setData(wo);
return result;
}
}
public static class Wo extends WrapBoolean {
}
}
\ No newline at end of file
package com.x.organization.assemble.personal.jaxrs.trustlog;
import java.util.List;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.organization.core.entity.accredit.TrustLog;
class ActionListNext extends BaseAction {
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, String id, Integer count) throws Exception {
ActionResult<List<Wo>> result = new ActionResult<>();
if (effectivePerson.isNotManager()) {
throw new ExceptionAccessDenied(effectivePerson);
}
result = this.standardListNext(Wo.copier, id, count, JpaObject.sequence_FIELDNAME, null, null, null, null, null,
null, null, null, true, DESC);
return result;
}
public static class Wo extends TrustLog {
private static final long serialVersionUID = -7495725325510376323L;
public static WrapCopier<TrustLog, Wo> copier = WrapCopierFactory.wo(TrustLog.class, Wo.class,
JpaObject.singularAttributeField(TrustLog.class, true, true), null);
@FieldDescribe("排序号")
private Long rank;
public Long getRank() {
return rank;
}
public void setRank(Long rank) {
this.rank = rank;
}
}
}
package com.x.organization.assemble.personal.jaxrs.trustlog;
import java.util.List;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.organization.core.entity.accredit.TrustLog;
class ActionListPrev extends BaseAction {
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, String id, Integer count) throws Exception {
ActionResult<List<Wo>> result = new ActionResult<>();
if (effectivePerson.isNotManager()) {
throw new ExceptionAccessDenied(effectivePerson);
}
result = this.standardListPrev(Wo.copier, id, count, JpaObject.sequence_FIELDNAME, null, null, null, null, null,
null, null, null, true, DESC);
return result;
}
public static class Wo extends TrustLog {
private static final long serialVersionUID = 4663181401822986160L;
public static WrapCopier<TrustLog, Wo> copier = WrapCopierFactory.wo(TrustLog.class, Wo.class,
JpaObject.singularAttributeField(TrustLog.class, true, true), null);
@FieldDescribe("排序号")
private Long rank;
public Long getRank() {
return rank;
}
public void setRank(Long rank) {
this.rank = rank;
}
}
}
package com.x.organization.assemble.personal.jaxrs.trustlog;
import java.util.List;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.organization.assemble.personal.Business;
import com.x.organization.core.entity.accredit.TrustLog;
import net.sf.ehcache.Element;
class ActionListTo extends BaseAction {
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
ActionResult<List<Wo>> result = new ActionResult<>();
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(),
effectivePerson.getDistinguishedName());
Element element = business.cache().get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((List<Wo>) element.getObjectValue());
} else {
List<Wo> wos = this.list(business, effectivePerson);
business.cache().put(new Element(cacheKey, wos));
result.setData(wos);
}
return result;
}
}
private List<Wo> list(Business business, EffectivePerson effectivePerson) throws Exception {
List<TrustLog> os = business.entityManagerContainer().listEqual(TrustLog.class, TrustLog.toPerson_FIELDNAME,
effectivePerson.getDistinguishedName());
return Wo.copier.copy(os);
}
public static class Wo extends TrustLog {
private static final long serialVersionUID = 4279205128463146835L;
static WrapCopier<TrustLog, Wo> copier = WrapCopierFactory.wi(TrustLog.class, Wo.class, null,
JpaObject.FieldsUnmodify);
}
}
package com.x.organization.assemble.personal.jaxrs.trustlog;
import java.util.List;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.organization.assemble.personal.Business;
import com.x.organization.core.entity.accredit.TrustLog;
import net.sf.ehcache.Element;
class ActionListWithCurrentPerson extends BaseAction {
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
ActionResult<List<Wo>> result = new ActionResult<>();
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(),
effectivePerson.getDistinguishedName());
Element element = business.cache().get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((List<Wo>) element.getObjectValue());
} else {
List<Wo> wos = this.list(business, effectivePerson);
business.cache().put(new Element(cacheKey, wos));
result.setData(wos);
}
return result;
}
}
private List<Wo> list(Business business, EffectivePerson effectivePerson) throws Exception {
List<TrustLog> os = business.entityManagerContainer().listEqual(TrustLog.class, TrustLog.fromPerson_FIELDNAME,
effectivePerson.getDistinguishedName());
return Wo.copier.copy(os);
}
public static class Wo extends TrustLog {
private static final long serialVersionUID = 4279205128463146835L;
static WrapCopier<TrustLog, Wo> copier = WrapCopierFactory.wi(TrustLog.class, Wo.class, null,
JpaObject.FieldsUnmodify);
}
}
package com.x.organization.assemble.personal.jaxrs.trustlog;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
abstract class BaseAction extends StandardJaxrsAction {
}
\ No newline at end of file
package com.x.organization.assemble.personal.jaxrs.trustlog;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.container.Suspended;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import com.google.gson.JsonElement;
import com.x.base.core.project.annotation.JaxrsDescribe;
import com.x.base.core.project.annotation.JaxrsMethodDescribe;
import com.x.base.core.project.annotation.JaxrsParameterDescribe;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.http.HttpMediaType;
import com.x.base.core.project.jaxrs.ResponseFactory;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
@Path("trustlog")
@JaxrsDescribe("委托日志操作")
public class TrustLogAction extends StandardJaxrsAction {
private static Logger logger = LoggerFactory.getLogger(TrustLogAction.class);
@JaxrsMethodDescribe(value = "管理员列示委托日志对象,下一页.", action = ActionListNext.class)
@GET
@Path("list/{id}/next/{count}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listNext(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("标识") @PathParam("id") String id,
@JaxrsParameterDescribe("数量") @PathParam("count") Integer count) {
ActionResult<List<ActionListNext.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionListNext().execute(effectivePerson, id, count);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
}
@JaxrsMethodDescribe(value = "管理员列示委托日志对象,上一页.", action = ActionListPrev.class)
@GET
@Path("list/{id}/prev/{count}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listPrev(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("标识") @PathParam("id") String id,
@JaxrsParameterDescribe("数量") @PathParam("count") Integer count) {
ActionResult<List<ActionListPrev.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionListPrev().execute(effectivePerson, id, count);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
}
@JaxrsMethodDescribe(value = "获取当前人员的委托日志.", action = ActionListWithCurrentPerson.class)
@GET
@Path("list/currentperson")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listWithCurrentPerson(@Suspended final AsyncResponse asyncResponse,
@Context HttpServletRequest request) {
ActionResult<List<ActionListWithCurrentPerson.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionListWithCurrentPerson().execute(effectivePerson);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
}
@JaxrsMethodDescribe(value = "获取当前人员的被委托日志.", action = ActionListTo.class)
@GET
@Path("list/to")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listTo(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request) {
ActionResult<List<ActionListTo.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionListTo().execute(effectivePerson);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
}
@JaxrsMethodDescribe(value = "删除委托日志.", action = ActionDelete.class)
@DELETE
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void delete(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("标识") @PathParam("id") String id) {
ActionResult<ActionDelete.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionDelete().execute(effectivePerson, id);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
}
}
\ No newline at end of file
var Describe = function() {
//20180730
// 20180730
}
Describe.splitValue = function(str) {
......@@ -38,7 +38,7 @@ Describe.doPost = function(address, m, data) {
xhrFields : {
'withCredentials' : true
},
data : ((m.contentType.indexOf('application/json') > -1) ? JSON.stringify(data) : data)
data : ((m.contentType.indexOf('application/json') > -1) && (!m.useStringParameter) ? JSON.stringify(data) : data)
}).always(function(resultJson) {
$('#result').html(JSON.stringify(resultJson, null, 4));
Describe.writeOut(m.outs, resultJson);
......@@ -55,7 +55,7 @@ Describe.doPost = function(address, m, data) {
xhrFields : {
'withCredentials' : true
},
data : ((m.contentType.indexOf('application/json') > -1) ? JSON.stringify(data) : data)
data : ((m.contentType.indexOf('application/json') > -1) && (!m.useStringParameter) ? JSON.stringify(data) : data)
});
}
}
......@@ -74,7 +74,7 @@ Describe.doPut = function(address, m, data) {
xhrFields : {
'withCredentials' : true
},
data : ((m.contentType.indexOf('application/json') > -1) ? JSON.stringify(data) : data)
data : ((m.contentType.indexOf('application/json') > -1) && (!m.useStringParameter) ? JSON.stringify(data) : data)
}).always(function(resultJson) {
$('#result').html(JSON.stringify(resultJson, null, 4));
Describe.writeOut(m.outs, resultJson);
......@@ -91,7 +91,7 @@ Describe.doPut = function(address, m, data) {
xhrFields : {
'withCredentials' : true
},
data : ((m.contentType.indexOf('application/json') > -1) ? JSON.stringify(data) : data)
data : ((m.contentType.indexOf('application/json') > -1) && (!m.useStringParameter) ? JSON.stringify(data) : data)
});
}
}
......@@ -269,6 +269,14 @@ Describe.prototype = {
txt += '</table>';
txt += '</fieldset>';
}
if (m.useStringParameter) {
txt += '<fieldset><legend>String</legend>';
txt += '<table><tr><td>';
txt += '<textarea id="string" style="height:300px; width:600px; padding:1px; border:1px #000000 solid"/>';
txt += '</td><td>string</td></tr>';
txt += '</table>';
txt += '</fieldset>';
}
if (m.outs && m.outs.length > 0) {
txt += '<fieldset id="outs"><legend>Out</legend>';
txt += '<table>';
......@@ -318,6 +326,8 @@ Describe.prototype = {
});
} else if (m.useJsonElementParameter) {
data = $.parseJSON($('#jsonElement').val());
} else if (m.useStringParameter) {
data = $('#string').val();
}
Describe.doPost(address, m, data);
break;
......@@ -340,6 +350,8 @@ Describe.prototype = {
});
} else if (m.useJsonElementParameter) {
data = $.parseJSON($('#jsonElement').val());
} else if (m.useStringParameter) {
data = $('#string').val();
}
Describe.doPut(address, m, data);
break;
......
package com.x.organization.core.entity;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
......
......@@ -74,4 +74,15 @@ public final class PersistenceProperties extends AbstractPersistenceProperties {
public static class OauthCode {
public static final String table = "ORG_OAUTHCODE";
}
public static class Accredit {
public static class Trust {
public static final String table = "ORG_A_TRUST";
}
public static class TrustLog {
public static final String table = "ORG_A_TRUSTLOG";
}
}
}
\ No newline at end of file
package com.x.organization.core.entity.accredit;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import org.apache.openjpa.persistence.jdbc.Index;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.SliceJpaObject;
import com.x.base.core.entity.annotation.CheckPersist;
import com.x.base.core.entity.annotation.ContainerEntity;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.organization.core.entity.PersistenceProperties;
@Entity
@ContainerEntity
@Table(name = PersistenceProperties.Accredit.Trust.table, uniqueConstraints = {
@UniqueConstraint(name = PersistenceProperties.Accredit.Trust.table + JpaObject.IndexNameMiddle
+ JpaObject.DefaultUniqueConstraintSuffix, columnNames = { JpaObject.IDCOLUMN,
JpaObject.CREATETIMECOLUMN, JpaObject.UPDATETIMECOLUMN, JpaObject.SEQUENCECOLUMN }) })
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class Trust extends SliceJpaObject {
private static final long serialVersionUID = -6518383742766451210L;
private static final String TABLE = PersistenceProperties.Accredit.Trust.table;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
@FieldDescribe("数据库主键,自动生成.")
@Id
@Column(length = length_id, name = ColumnNamePrefix + id_FIELDNAME)
private String id = createId();
/* 以上为 JpaObject 默认字段 */
public void onPersist() throws Exception {
}
/** 更新运行方法 */
/** flag标志位 */
/** 默认内容结束 */
public static final String fromPerson_FIELDNAME = "fromPerson";
@FieldDescribe("人员.")
@Column(length = JpaObject.length_255B, name = ColumnNamePrefix + fromPerson_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + fromPerson_FIELDNAME)
private String fromPerson;
public static final String fromIdentity_FIELDNAME = "fromIdentity";
@FieldDescribe("身份.")
@Column(length = JpaObject.length_255B, name = ColumnNamePrefix + fromIdentity_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + fromIdentity_FIELDNAME)
private String fromIdentity;
public static final String toPerson_FIELDNAME = "toPerson";
@FieldDescribe("委托人员.")
@Column(length = JpaObject.length_255B, name = ColumnNamePrefix + toPerson_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + toPerson_FIELDNAME)
private String toPerson;
public static final String toIdentity_FIELDNAME = "toIdentity";
@FieldDescribe("委托身份.")
@Column(length = JpaObject.length_255B, name = ColumnNamePrefix + toIdentity_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + toIdentity_FIELDNAME)
private String toIdentity;
public static final String application_FIELDNAME = "application";
@FieldDescribe("应用.")
@Column(length = JpaObject.length_id, name = ColumnNamePrefix + application_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + application_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String application;
public static final String applicationName_FIELDNAME = "applicationName";
@FieldDescribe("应用名称.")
@Column(length = length_255B, name = ColumnNamePrefix + applicationName_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + applicationName_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String applicationName;
public static final String applicationAlias_FIELDNAME = "applicationAlias";
@FieldDescribe("应用别名.")
@Column(length = length_255B, name = ColumnNamePrefix + applicationAlias_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + applicationAlias_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String applicationAlias;
public static final String process_FIELDNAME = "process";
@FieldDescribe("流程ID.")
@Column(length = JpaObject.length_id, name = ColumnNamePrefix + process_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + process_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String process;
public static final String processName_FIELDNAME = "processName";
@FieldDescribe("流程名称.")
@Column(length = length_255B, name = ColumnNamePrefix + processName_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + processName_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String processName;
public static final String processAlias_FIELDNAME = "processAlias";
@FieldDescribe("流程别名.")
@Column(length = length_255B, name = ColumnNamePrefix + processAlias_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + processAlias_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String processAlias;
public static final String whole_FIELDNAME = "whole";
@FieldDescribe("全部进行授权.")
@Column(name = ColumnNamePrefix + whole_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + whole_FIELDNAME)
@CheckPersist(allowEmpty = false)
private Boolean whole;
public String getFromPerson() {
return fromPerson;
}
public void setFromPerson(String fromPerson) {
this.fromPerson = fromPerson;
}
public String getFromIdentity() {
return fromIdentity;
}
public void setFromIdentity(String fromIdentity) {
this.fromIdentity = fromIdentity;
}
public String getToPerson() {
return toPerson;
}
public void setToPerson(String toPerson) {
this.toPerson = toPerson;
}
public String getToIdentity() {
return toIdentity;
}
public void setToIdentity(String toIdentity) {
this.toIdentity = toIdentity;
}
public String getApplication() {
return application;
}
public void setApplication(String application) {
this.application = application;
}
public String getApplicationName() {
return applicationName;
}
public void setApplicationName(String applicationName) {
this.applicationName = applicationName;
}
public String getApplicationAlias() {
return applicationAlias;
}
public void setApplicationAlias(String applicationAlias) {
this.applicationAlias = applicationAlias;
}
public String getProcess() {
return process;
}
public void setProcess(String process) {
this.process = process;
}
public String getProcessName() {
return processName;
}
public void setProcessName(String processName) {
this.processName = processName;
}
public String getProcessAlias() {
return processAlias;
}
public void setProcessAlias(String processAlias) {
this.processAlias = processAlias;
}
public Boolean getWhole() {
return whole;
}
public void setWhole(Boolean whole) {
this.whole = whole;
}
}
\ No newline at end of file
package com.x.organization.core.entity.accredit;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;
import org.apache.openjpa.persistence.jdbc.Index;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.SliceJpaObject;
import com.x.base.core.entity.annotation.CheckPersist;
import com.x.base.core.entity.annotation.ContainerEntity;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.organization.core.entity.PersistenceProperties;
@Entity
@ContainerEntity
@Table(name = PersistenceProperties.Accredit.TrustLog.table, uniqueConstraints = {
@UniqueConstraint(name = PersistenceProperties.Accredit.TrustLog.table + JpaObject.IndexNameMiddle
+ JpaObject.DefaultUniqueConstraintSuffix, columnNames = { JpaObject.IDCOLUMN,
JpaObject.CREATETIMECOLUMN, JpaObject.UPDATETIMECOLUMN, JpaObject.SEQUENCECOLUMN }) })
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class TrustLog extends SliceJpaObject {
private static final long serialVersionUID = 6677140471323901242L;
private static final String TABLE = PersistenceProperties.Accredit.TrustLog.table;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
@FieldDescribe("数据库主键,自动生成.")
@Id
@Column(length = length_id, name = ColumnNamePrefix + id_FIELDNAME)
private String id = createId();
/* 以上为 JpaObject 默认字段 */
public void onPersist() throws Exception {
}
/** 更新运行方法 */
/** flag标志位 */
/** 默认内容结束 */
public static final String fromPerson_FIELDNAME = "fromPerson";
@FieldDescribe("人员.")
@Column(length = JpaObject.length_255B, name = ColumnNamePrefix + fromPerson_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + fromPerson_FIELDNAME)
private String fromPerson;
public static final String fromIdentity_FIELDNAME = "fromIdentity";
@FieldDescribe("身份.")
@Column(length = JpaObject.length_255B, name = ColumnNamePrefix + fromIdentity_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + fromIdentity_FIELDNAME)
private String fromIdentity;
public static final String toPerson_FIELDNAME = "toPerson";
@FieldDescribe("委托人员.")
@Column(length = JpaObject.length_255B, name = ColumnNamePrefix + toPerson_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + toPerson_FIELDNAME)
private String toPerson;
public static final String toIdentity_FIELDNAME = "toIdentity";
@FieldDescribe("委托身份.")
@Column(length = JpaObject.length_255B, name = ColumnNamePrefix + toIdentity_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + toIdentity_FIELDNAME)
private String toIdentity;
public static final String application_FIELDNAME = "application";
@FieldDescribe("应用.")
@Column(length = JpaObject.length_id, name = ColumnNamePrefix + application_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + application_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String application;
public static final String applicationName_FIELDNAME = "applicationName";
@FieldDescribe("应用名称.")
@Column(length = length_255B, name = ColumnNamePrefix + applicationName_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + applicationName_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String applicationName;
public static final String applicationAlias_FIELDNAME = "applicationAlias";
@FieldDescribe("应用别名.")
@Column(length = length_255B, name = ColumnNamePrefix + applicationAlias_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + applicationAlias_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String applicationAlias;
public static final String process_FIELDNAME = "process";
@FieldDescribe("流程ID.")
@Column(length = JpaObject.length_id, name = ColumnNamePrefix + process_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + process_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String process;
public static final String processName_FIELDNAME = "processName";
@FieldDescribe("流程名称.")
@Column(length = length_255B, name = ColumnNamePrefix + processName_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + processName_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String processName;
public static final String processAlias_FIELDNAME = "processAlias";
@FieldDescribe("流程别名.")
@Column(length = length_255B, name = ColumnNamePrefix + processAlias_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + processAlias_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String processAlias;
public static final String job_FIELDNAME = "job";
@FieldDescribe("任务标识.")
@Column(length = JpaObject.length_id, name = ColumnNamePrefix + job_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + job_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String job;
public static final String work_FIELDNAME = "work";
@FieldDescribe("work标识.")
@Column(length = JpaObject.length_id, name = ColumnNamePrefix + work_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + work_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String work;
public static final String trustTime_FIELDNAME = "trustTime";
@FieldDescribe("委托时间.")
@Temporal(TemporalType.TIMESTAMP)
@Column(name = ColumnNamePrefix + trustTime_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + trustTime_FIELDNAME)
@CheckPersist(allowEmpty = true)
private Date trustTime;
public static final String title_FIELDNAME = "title";
@FieldDescribe("标题.")
@Column(length = length_255B, name = ColumnNamePrefix + title_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + title_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String title;
public static final String activity_FIELDNAME = "activity";
@FieldDescribe("当前活动ID")
@Column(length = JpaObject.length_id, name = ColumnNamePrefix + activity_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + activity_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String activity;
public static final String activityName_FIELDNAME = "activityName";
@FieldDescribe("活动名称")
@Column(length = length_255B, name = ColumnNamePrefix + activityName_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + activityName_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String activityName;
public static final String activityAlias_FIELDNAME = "activityAlias";
@FieldDescribe("活动别名")
@Column(length = length_255B, name = ColumnNamePrefix + activityAlias_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + activityAlias_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String activityAlias;
public String getFromPerson() {
return fromPerson;
}
public void setFromPerson(String fromPerson) {
this.fromPerson = fromPerson;
}
public String getFromIdentity() {
return fromIdentity;
}
public void setFromIdentity(String fromIdentity) {
this.fromIdentity = fromIdentity;
}
public String getToPerson() {
return toPerson;
}
public void setToPerson(String toPerson) {
this.toPerson = toPerson;
}
public String getToIdentity() {
return toIdentity;
}
public void setToIdentity(String toIdentity) {
this.toIdentity = toIdentity;
}
public String getApplication() {
return application;
}
public void setApplication(String application) {
this.application = application;
}
public String getApplicationName() {
return applicationName;
}
public void setApplicationName(String applicationName) {
this.applicationName = applicationName;
}
public String getApplicationAlias() {
return applicationAlias;
}
public void setApplicationAlias(String applicationAlias) {
this.applicationAlias = applicationAlias;
}
public String getProcess() {
return process;
}
public void setProcess(String process) {
this.process = process;
}
public String getProcessName() {
return processName;
}
public void setProcessName(String processName) {
this.processName = processName;
}
public String getProcessAlias() {
return processAlias;
}
public void setProcessAlias(String processAlias) {
this.processAlias = processAlias;
}
public String getJob() {
return job;
}
public void setJob(String job) {
this.job = job;
}
public String getWork() {
return work;
}
public void setWork(String work) {
this.work = work;
}
public Date getTrustTime() {
return trustTime;
}
public void setTrustTime(Date trustTime) {
this.trustTime = trustTime;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getActivity() {
return activity;
}
public void setActivity(String activity) {
this.activity = activity;
}
public String getActivityName() {
return activityName;
}
public void setActivityName(String activityName) {
this.activityName = activityName;
}
public String getActivityAlias() {
return activityAlias;
}
public void setActivityAlias(String activityAlias) {
this.activityAlias = activityAlias;
}
}
\ No newline at end of file
......@@ -12,6 +12,8 @@ import com.x.organization.core.express.identity.IdentityFactory;
import com.x.organization.core.express.person.PersonFactory;
import com.x.organization.core.express.personattribute.PersonAttributeFactory;
import com.x.organization.core.express.role.RoleFactory;
import com.x.organization.core.express.trust.TrustFactory;
import com.x.organization.core.express.trustlog.TrustLogFactory;
import com.x.organization.core.express.unit.UnitFactory;
import com.x.organization.core.express.unitattribute.UnitAttributeFactory;
import com.x.organization.core.express.unitduty.UnitDutyFactory;
......@@ -96,6 +98,24 @@ public class Organization {
return unitDuty;
}
private TrustFactory trust;
public TrustFactory trust() throws Exception {
if (null == this.trust) {
this.trust = new TrustFactory(context);
}
return trust;
}
private TrustLogFactory trustLog;
public TrustLogFactory trustLog() throws Exception {
if (null == this.trustLog) {
this.trustLog = new TrustLogFactory(context);
}
return trustLog;
}
/** 根据个人身份获取组织 */
/** 表示获取第几层的组织 */
public String listSupUnit(String name, Integer nested) throws Exception {
......
package com.x.organization.core.express.trust;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.x.base.core.project.AbstractContext;
import com.x.base.core.project.organization.Trust;
class ActionListWithIdentityObject extends BaseAction {
public static List<Trust> execute(AbstractContext context, String application, String process,
Collection<String> collection) throws Exception {
Wi wi = new Wi();
List<Trust> wos = new ArrayList<>();
if ((null != collection) && (!collection.isEmpty())) {
wi.getIdentityList().addAll(collection);
wos = context.applications().postQuery(applicationClass, "trust/list/identity/object", wi)
.getDataAsList(Trust.class);
}
return wos;
}
public static class Wi extends WoAbstract {
}
}
\ No newline at end of file
package com.x.organization.core.express.trust;
import java.util.ArrayList;
import java.util.List;
import com.x.base.core.project.x_organization_assemble_express;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.gson.GsonPropertyObject;
abstract class BaseAction {
protected static Class<?> applicationClass = x_organization_assemble_express.class;
static class WoAbstract extends GsonPropertyObject {
@FieldDescribe("身份")
private List<String> identityList = new ArrayList<>();
@FieldDescribe("应用")
private String application;
@FieldDescribe("流程")
private String process;
public List<String> getIdentityList() {
return identityList;
}
public void setIdentityList(List<String> identityList) {
this.identityList = identityList;
}
public String getApplication() {
return application;
}
public void setApplication(String application) {
this.application = application;
}
public String getProcess() {
return process;
}
public void setProcess(String process) {
this.process = process;
}
}
}
package com.x.organization.core.express.trust;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import com.x.base.core.project.AbstractContext;
import com.x.base.core.project.organization.Trust;
public class TrustFactory {
public TrustFactory(AbstractContext context) {
this.context = context;
}
private AbstractContext context;
/** 根据应用和流程获取指定身份是否有委托 */
public List<Trust> listWithIdentityObject(String application, String process, String value) throws Exception {
return ActionListWithIdentityObject.execute(context, application, process, Arrays.asList(value));
}
/** 根据应用和流程获取指定身份是否有委托 */
public List<Trust> listWithIdentityObject(String application, String process, Collection<String> values)
throws Exception {
return ActionListWithIdentityObject.execute(context, application, process, values);
}
}
package com.x.organization.core.express.trustlog;
import com.x.base.core.project.AbstractContext;
import com.x.base.core.project.jaxrs.WrapBoolean;
import com.x.base.core.project.organization.TrustLog;
class ActionLog extends BaseAction {
public static boolean execute(AbstractContext context, TrustLog trustLog) throws Exception {
Wo wo = context.applications().postQuery(applicationClass, "trustlog", trustLog).getData(Wo.class);
return wo.getValue();
}
public static class Wo extends WrapBoolean {
}
}
\ No newline at end of file
package com.x.organization.core.express.trustlog;
import com.x.base.core.project.x_organization_assemble_express;
abstract class BaseAction {
protected static Class<?> applicationClass = x_organization_assemble_express.class;
}
package com.x.organization.core.express.trustlog;
import com.x.base.core.project.AbstractContext;
import com.x.base.core.project.organization.TrustLog;
public class TrustLogFactory {
public TrustLogFactory(AbstractContext context) {
this.context = context;
}
private AbstractContext context;
/** 创建委托记录 */
public boolean log(TrustLog trustLog) throws Exception {
return ActionLog.execute(context, trustLog);
}
}
var Describe = function() {
//20180730
// 20180730
}
Describe.splitValue = function(str) {
......@@ -38,7 +38,7 @@ Describe.doPost = function(address, m, data) {
xhrFields : {
'withCredentials' : true
},
data : ((m.contentType.indexOf('application/json') > -1) ? JSON.stringify(data) : data)
data : ((m.contentType.indexOf('application/json') > -1) && (!m.useStringParameter) ? JSON.stringify(data) : data)
}).always(function(resultJson) {
$('#result').html(JSON.stringify(resultJson, null, 4));
Describe.writeOut(m.outs, resultJson);
......@@ -55,7 +55,7 @@ Describe.doPost = function(address, m, data) {
xhrFields : {
'withCredentials' : true
},
data : ((m.contentType.indexOf('application/json') > -1) ? JSON.stringify(data) : data)
data : ((m.contentType.indexOf('application/json') > -1) && (!m.useStringParameter) ? JSON.stringify(data) : data)
});
}
}
......@@ -74,7 +74,7 @@ Describe.doPut = function(address, m, data) {
xhrFields : {
'withCredentials' : true
},
data : ((m.contentType.indexOf('application/json') > -1) ? JSON.stringify(data) : data)
data : ((m.contentType.indexOf('application/json') > -1) && (!m.useStringParameter) ? JSON.stringify(data) : data)
}).always(function(resultJson) {
$('#result').html(JSON.stringify(resultJson, null, 4));
Describe.writeOut(m.outs, resultJson);
......@@ -91,7 +91,7 @@ Describe.doPut = function(address, m, data) {
xhrFields : {
'withCredentials' : true
},
data : ((m.contentType.indexOf('application/json') > -1) ? JSON.stringify(data) : data)
data : ((m.contentType.indexOf('application/json') > -1) && (!m.useStringParameter) ? JSON.stringify(data) : data)
});
}
}
......@@ -269,6 +269,14 @@ Describe.prototype = {
txt += '</table>';
txt += '</fieldset>';
}
if (m.useStringParameter) {
txt += '<fieldset><legend>String</legend>';
txt += '<table><tr><td>';
txt += '<textarea id="string" style="height:300px; width:600px; padding:1px; border:1px #000000 solid"/>';
txt += '</td><td>string</td></tr>';
txt += '</table>';
txt += '</fieldset>';
}
if (m.outs && m.outs.length > 0) {
txt += '<fieldset id="outs"><legend>Out</legend>';
txt += '<table>';
......@@ -318,6 +326,8 @@ Describe.prototype = {
});
} else if (m.useJsonElementParameter) {
data = $.parseJSON($('#jsonElement').val());
} else if (m.useStringParameter) {
data = $('#string').val();
}
Describe.doPost(address, m, data);
break;
......@@ -340,6 +350,8 @@ Describe.prototype = {
});
} else if (m.useJsonElementParameter) {
data = $.parseJSON($('#jsonElement').val());
} else if (m.useStringParameter) {
data = $('#string').val();
}
Describe.doPut(address, m, data);
break;
......
var Describe = function() {
//20180730
// 20180730
}
Describe.splitValue = function(str) {
......@@ -38,7 +38,7 @@ Describe.doPost = function(address, m, data) {
xhrFields : {
'withCredentials' : true
},
data : ((m.contentType.indexOf('application/json') > -1) ? JSON.stringify(data) : data)
data : ((m.contentType.indexOf('application/json') > -1) && (!m.useStringParameter) ? JSON.stringify(data) : data)
}).always(function(resultJson) {
$('#result').html(JSON.stringify(resultJson, null, 4));
Describe.writeOut(m.outs, resultJson);
......@@ -55,7 +55,7 @@ Describe.doPost = function(address, m, data) {
xhrFields : {
'withCredentials' : true
},
data : ((m.contentType.indexOf('application/json') > -1) ? JSON.stringify(data) : data)
data : ((m.contentType.indexOf('application/json') > -1) && (!m.useStringParameter) ? JSON.stringify(data) : data)
});
}
}
......@@ -74,7 +74,7 @@ Describe.doPut = function(address, m, data) {
xhrFields : {
'withCredentials' : true
},
data : ((m.contentType.indexOf('application/json') > -1) ? JSON.stringify(data) : data)
data : ((m.contentType.indexOf('application/json') > -1) && (!m.useStringParameter) ? JSON.stringify(data) : data)
}).always(function(resultJson) {
$('#result').html(JSON.stringify(resultJson, null, 4));
Describe.writeOut(m.outs, resultJson);
......@@ -91,7 +91,7 @@ Describe.doPut = function(address, m, data) {
xhrFields : {
'withCredentials' : true
},
data : ((m.contentType.indexOf('application/json') > -1) ? JSON.stringify(data) : data)
data : ((m.contentType.indexOf('application/json') > -1) && (!m.useStringParameter) ? JSON.stringify(data) : data)
});
}
}
......@@ -269,6 +269,14 @@ Describe.prototype = {
txt += '</table>';
txt += '</fieldset>';
}
if (m.useStringParameter) {
txt += '<fieldset><legend>String</legend>';
txt += '<table><tr><td>';
txt += '<textarea id="string" style="height:300px; width:600px; padding:1px; border:1px #000000 solid"/>';
txt += '</td><td>string</td></tr>';
txt += '</table>';
txt += '</fieldset>';
}
if (m.outs && m.outs.length > 0) {
txt += '<fieldset id="outs"><legend>Out</legend>';
txt += '<table>';
......@@ -318,6 +326,8 @@ Describe.prototype = {
});
} else if (m.useJsonElementParameter) {
data = $.parseJSON($('#jsonElement').val());
} else if (m.useStringParameter) {
data = $('#string').val();
}
Describe.doPost(address, m, data);
break;
......@@ -340,6 +350,8 @@ Describe.prototype = {
});
} else if (m.useJsonElementParameter) {
data = $.parseJSON($('#jsonElement').val());
} else if (m.useStringParameter) {
data = $('#string').val();
}
Describe.doPut(address, m, data);
break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册