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

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

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