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

ibiz4j 发布系统代码 [ibiz-task,任务调度]

上级 3752c911
......@@ -20,11 +20,14 @@ import javax.validation.constraints.Size;
import cn.ibizlab.util.domain.DTOBase;
import cn.ibizlab.util.domain.DTOClient;
import lombok.Data;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* 服务DTO对象[JobsLockDTO]
*/
@Data
@ApiModel("任务锁")
public class JobsLockDTO extends DTOBase implements Serializable {
private static final long serialVersionUID = 1L;
......@@ -36,6 +39,7 @@ public class JobsLockDTO extends DTOBase implements Serializable {
@JSONField(name = "id")
@JsonProperty("id")
@Size(min = 0, max = 100, message = "内容长度必须小于等于[100]")
@ApiModelProperty("主键ID")
private String id;
/**
......@@ -46,6 +50,7 @@ public class JobsLockDTO extends DTOBase implements Serializable {
@JsonProperty("name")
@NotBlank(message = "[名称]不允许为空!")
@Size(min = 0, max = 30, message = "内容长度必须小于等于[30]")
@ApiModelProperty("名称")
private String name;
/**
......@@ -56,6 +61,7 @@ public class JobsLockDTO extends DTOBase implements Serializable {
@JsonProperty("owner")
@NotBlank(message = "[持有者]不允许为空!")
@Size(min = 0, max = 100, message = "内容长度必须小于等于[100]")
@ApiModelProperty("持有者")
private String owner;
/**
......@@ -66,6 +72,7 @@ public class JobsLockDTO extends DTOBase implements Serializable {
@JSONField(name = "create_time" , format="yyyy-MM-dd HH:mm:ss")
@JsonProperty("create_time")
@NotNull(message = "[创建时间]不允许为空!")
@ApiModelProperty("创建时间")
private Timestamp createTime;
......
......@@ -20,11 +20,14 @@ import javax.validation.constraints.Size;
import cn.ibizlab.util.domain.DTOBase;
import cn.ibizlab.util.domain.DTOClient;
import lombok.Data;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* 服务DTO对象[JobsLogDTO]
*/
@Data
@ApiModel("任务调度日志")
public class JobsLogDTO extends DTOBase implements Serializable {
private static final long serialVersionUID = 1L;
......@@ -36,6 +39,7 @@ public class JobsLogDTO extends DTOBase implements Serializable {
@JSONField(name = "id")
@JsonProperty("id")
@Size(min = 0, max = 100, message = "内容长度必须小于等于[100]")
@ApiModelProperty("主键ID")
private String id;
/**
......@@ -46,6 +50,7 @@ public class JobsLogDTO extends DTOBase implements Serializable {
@JsonProperty("job_id")
@NotBlank(message = "[任务ID]不允许为空!")
@Size(min = 0, max = 100, message = "内容长度必须小于等于[100]")
@ApiModelProperty("任务ID")
private String jobId;
/**
......@@ -55,6 +60,7 @@ public class JobsLogDTO extends DTOBase implements Serializable {
@JSONField(name = "address")
@JsonProperty("address")
@Size(min = 0, max = 255, message = "内容长度必须小于等于[255]")
@ApiModelProperty("执行地址")
private String address;
/**
......@@ -64,6 +70,7 @@ public class JobsLogDTO extends DTOBase implements Serializable {
@JSONField(name = "handler")
@JsonProperty("handler")
@Size(min = 0, max = 255, message = "内容长度必须小于等于[255]")
@ApiModelProperty("执行器任务HANDLER")
private String handler;
/**
......@@ -73,6 +80,7 @@ public class JobsLogDTO extends DTOBase implements Serializable {
@JSONField(name = "param")
@JsonProperty("param")
@Size(min = 0, max = 512, message = "内容长度必须小于等于[512]")
@ApiModelProperty("执行器任务参数")
private String param;
/**
......@@ -82,6 +90,7 @@ public class JobsLogDTO extends DTOBase implements Serializable {
@JSONField(name = "fail_retry_count")
@JsonProperty("fail_retry_count")
@NotNull(message = "[失败重试次数]不允许为空!")
@ApiModelProperty("失败重试次数")
private Integer failRetryCount;
/**
......@@ -91,6 +100,7 @@ public class JobsLogDTO extends DTOBase implements Serializable {
@JSONField(name = "trigger_code")
@JsonProperty("trigger_code")
@NotNull(message = "[触发器调度返回码]不允许为空!")
@ApiModelProperty("触发器调度返回码")
private Integer triggerCode;
/**
......@@ -101,6 +111,7 @@ public class JobsLogDTO extends DTOBase implements Serializable {
@JsonProperty("trigger_type")
@NotBlank(message = "[触发器调度类型]不允许为空!")
@Size(min = 0, max = 30, message = "内容长度必须小于等于[30]")
@ApiModelProperty("触发器调度类型")
private String triggerType;
/**
......@@ -110,6 +121,7 @@ public class JobsLogDTO extends DTOBase implements Serializable {
@JSONField(name = "trigger_msg")
@JsonProperty("trigger_msg")
@Size(min = 0, max = 1048576, message = "内容长度必须小于等于[1048576]")
@ApiModelProperty("触发器调度信息")
private String triggerMsg;
/**
......@@ -120,6 +132,7 @@ public class JobsLogDTO extends DTOBase implements Serializable {
@JSONField(name = "create_time" , format="yyyy-MM-dd HH:mm:ss")
@JsonProperty("create_time")
@NotNull(message = "[创建时间]不允许为空!")
@ApiModelProperty("创建时间")
private Timestamp createTime;
......
......@@ -20,11 +20,14 @@ import javax.validation.constraints.Size;
import cn.ibizlab.util.domain.DTOBase;
import cn.ibizlab.util.domain.DTOClient;
import lombok.Data;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* 服务DTO对象[JobsRegistryDTO]
*/
@Data
@ApiModel("任务注册信息")
public class JobsRegistryDTO extends DTOBase implements Serializable {
private static final long serialVersionUID = 1L;
......@@ -36,6 +39,7 @@ public class JobsRegistryDTO extends DTOBase implements Serializable {
@JSONField(name = "id")
@JsonProperty("id")
@Size(min = 0, max = 100, message = "内容长度必须小于等于[100]")
@ApiModelProperty("主键ID")
private String id;
/**
......@@ -46,6 +50,7 @@ public class JobsRegistryDTO extends DTOBase implements Serializable {
@JsonProperty("app")
@NotBlank(message = "[服务名]不允许为空!")
@Size(min = 0, max = 100, message = "内容长度必须小于等于[100]")
@ApiModelProperty("服务名")
private String app;
/**
......@@ -56,6 +61,7 @@ public class JobsRegistryDTO extends DTOBase implements Serializable {
@JsonProperty("address")
@NotBlank(message = "[执行地址]不允许为空!")
@Size(min = 0, max = 255, message = "内容长度必须小于等于[255]")
@ApiModelProperty("执行地址")
private String address;
/**
......@@ -65,6 +71,7 @@ public class JobsRegistryDTO extends DTOBase implements Serializable {
@JSONField(name = "status")
@JsonProperty("status")
@NotNull(message = "[状态]不允许为空!")
@ApiModelProperty("状态")
private Integer status;
/**
......@@ -75,6 +82,7 @@ public class JobsRegistryDTO extends DTOBase implements Serializable {
@JSONField(name = "update_time" , format="yyyy-MM-dd HH:mm:ss")
@JsonProperty("update_time")
@NotNull(message = "[更新时间]不允许为空!")
@ApiModelProperty("更新时间")
private Timestamp updateTime;
......
......@@ -27,6 +27,16 @@ import java.util.Map;
@Component
public class DEFieldDefaultValueAspect
{
/**
* 操作用户标识
*/
final static String TAG_PERSONID = "SRF_PERSONID";
/**
* 操作用户名称
*/
final static String TAG_PERSONNAME = "SRF_PERSONNAME";
/**
* 新建数据切入点
* @param point
......@@ -221,16 +231,16 @@ public class DEFieldDefaultValueAspect
switch(preFieldType) {
case CREATEMAN:
et.set(fieldname, curUser.getUserid());
et.set(fieldname, StringUtils.isEmpty(curUser.getUserid()) ? et.get(TAG_PERSONID) : curUser.getUserid());
break;
case CREATEMANNAME:
et.set(fieldname, curUser.getPersonname());
et.set(fieldname, StringUtils.isEmpty(curUser.getPersonname()) ? et.get(TAG_PERSONNAME) : curUser.getPersonname());
break;
case UPDATEMAN:
et.set(fieldname, curUser.getUserid());
et.set(fieldname, StringUtils.isEmpty(curUser.getUserid()) ? et.get(TAG_PERSONID) : curUser.getUserid());
break;
case UPDATEMANNAME:
et.set(fieldname, curUser.getPersonname());
et.set(fieldname, StringUtils.isEmpty(curUser.getPersonname()) ? et.get(TAG_PERSONNAME) : curUser.getPersonname());
break;
case CREATEDATE:
et.set(fieldname, new Timestamp(new Date().getTime()));
......
......@@ -2,6 +2,7 @@ package cn.ibizlab.util.client;
import cn.ibizlab.util.security.AuthenticationUser;
import cn.ibizlab.util.security.AuthorizationLogin;
import org.springframework.util.MultiValueMap;
import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSONObject;
......
......@@ -5,6 +5,7 @@ import cn.ibizlab.util.security.AuthorizationLogin;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import org.springframework.util.MultiValueMap;
import com.alibaba.fastjson.JSONObject;
@FeignClient(value = "${ibiz.ref.service.uaa:ibzuaa-api}",contextId = "uaa",fallback = IBZUAAFallback.class)
......
......@@ -7,6 +7,7 @@ import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.util.ObjectUtils;
import java.sql.Timestamp;
......@@ -231,6 +232,15 @@ public class AuthenticationUser implements UserDetails
return authuserdetail;
}
public static AuthenticationUser setAuthenticationUser(String userId , String userName) {
AuthenticationUser user = new AuthenticationUser();
user.setUserid(userId);
user.setPersonname(userName);
UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(user, null, user.getAuthorities());
SecurityContextHolder.getContext().setAuthentication(authentication);
return user;
}
public Map <String,Object> getSessionParams()
{
if(this.sessionParams==null)
......
......@@ -4,11 +4,17 @@ import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.util.ObjectUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.util.Enumeration;
import java.util.LinkedHashMap;
/**
* feign请求拦截器
......@@ -19,23 +25,23 @@ public class FeignRequestInterceptor implements RequestInterceptor {
private final Logger logger = LoggerFactory.getLogger(getClass());
@Override
public void apply(RequestTemplate requestTemplate) {
ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
if(requestAttributes!=null){
if (requestAttributes != null) {
HttpServletRequest request = requestAttributes.getRequest();
Enumeration<String> headerNames = request.getHeaderNames();
if (headerNames != null) {
while (headerNames.hasMoreElements()) {
String name = headerNames.nextElement();
if(name.equalsIgnoreCase("transfer-encoding")){
if (name.equalsIgnoreCase("transfer-encoding")) {
continue;
}
String values = request.getHeader(name);
requestTemplate.header(name, values);
}
logger.info("feign interceptor header:{}",requestTemplate);
logger.info("feign interceptor header:{}", requestTemplate);
}
}
}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册