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

ibiz4j 发布系统代码

上级 219f5a0a
......@@ -115,6 +115,44 @@ mock.onGet(new RegExp(/^\/jobsinfos\/([a-zA-Z0-9\-\;]{1,35})\/select$/)).reply((
return [status, _items];
});
// Start
mock.onPost(new RegExp(/^\/jobsinfos\/?([a-zA-Z0-9\-\;]{0,35})\/start$/)).reply((config: any) => {
console.groupCollapsed("实体:jobsinfo 方法: Start");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
const paramArray:Array<any> = ['id'];
const matchArray:any = new RegExp(/^\/jobsinfos\/([a-zA-Z0-9\-\;]{1,35})\/start$/).exec(config.url);
let tempValue: any = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => {
Object.defineProperty(tempValue, item, {
enumerable: true,
value: matchArray[index + 1]
});
});
}
//let items = mockDatas ? mockDatas : [];
//let _items = items.find((item: any) => Object.is(item.id, tempValue.id));
let data = JSON.parse(config.data);
mockDatas.forEach((item)=>{
if(item['id'] == tempValue['id'] ){
for(let value in data){
if(item.hasOwnProperty(value)){
item[value] = data[value];
}
}
}
})
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table(data);
console.groupEnd();
console.groupEnd();
return [status, data];
});
// Update
mock.onPut(new RegExp(/^\/jobsinfos\/?([a-zA-Z0-9\-\;]{0,35})$/)).reply((config: any) => {
console.groupCollapsed("实体:jobsinfo 方法: Update");
......@@ -191,6 +229,44 @@ mock.onPost(new RegExp(/^\/jobsinfos\/?([a-zA-Z0-9\-\;]{0,35})\/checkkey$/)).rep
return [status, data];
});
// Execute
mock.onPost(new RegExp(/^\/jobsinfos\/?([a-zA-Z0-9\-\;]{0,35})\/execute$/)).reply((config: any) => {
console.groupCollapsed("实体:jobsinfo 方法: Execute");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
const paramArray:Array<any> = ['id'];
const matchArray:any = new RegExp(/^\/jobsinfos\/([a-zA-Z0-9\-\;]{1,35})\/execute$/).exec(config.url);
let tempValue: any = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => {
Object.defineProperty(tempValue, item, {
enumerable: true,
value: matchArray[index + 1]
});
});
}
//let items = mockDatas ? mockDatas : [];
//let _items = items.find((item: any) => Object.is(item.id, tempValue.id));
let data = JSON.parse(config.data);
mockDatas.forEach((item)=>{
if(item['id'] == tempValue['id'] ){
for(let value in data){
if(item.hasOwnProperty(value)){
item[value] = data[value];
}
}
}
})
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table(data);
console.groupEnd();
console.groupEnd();
return [status, data];
});
// Save
mock.onPost(new RegExp(/^\/jobsinfos\/?([a-zA-Z0-9\-\;]{0,35})\/save$/)).reply((config: any) => {
console.groupCollapsed("实体:jobsinfo 方法: Save");
......@@ -271,6 +347,44 @@ mock.onPost(new RegExp(/^\/jobsinfos\/?([a-zA-Z0-9\-\;]{0,35})$/)).reply((config
return [status, mockDatas[0]];
});
// Stop
mock.onPost(new RegExp(/^\/jobsinfos\/?([a-zA-Z0-9\-\;]{0,35})\/stop$/)).reply((config: any) => {
console.groupCollapsed("实体:jobsinfo 方法: Stop");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
const paramArray:Array<any> = ['id'];
const matchArray:any = new RegExp(/^\/jobsinfos\/([a-zA-Z0-9\-\;]{1,35})\/stop$/).exec(config.url);
let tempValue: any = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => {
Object.defineProperty(tempValue, item, {
enumerable: true,
value: matchArray[index + 1]
});
});
}
//let items = mockDatas ? mockDatas : [];
//let _items = items.find((item: any) => Object.is(item.id, tempValue.id));
let data = JSON.parse(config.data);
mockDatas.forEach((item)=>{
if(item['id'] == tempValue['id'] ){
for(let value in data){
if(item.hasOwnProperty(value)){
item[value] = data[value];
}
}
}
})
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table(data);
console.groupEnd();
console.groupEnd();
return [status, data];
});
// FetchDefault
mock.onGet(new RegExp(/^\/jobsinfos\/fetchdefault$/)).reply((config: any) => {
console.groupCollapsed("实体:jobsinfo 方法: FetchDefault");
......
......@@ -51,6 +51,19 @@ export default class JobsInfoServiceBase extends EntityService {
return Http.getInstance().get(`/jobsinfos/${context.jobsinfo}/select`,isloading);
}
/**
* Start接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof JobsInfoServiceBase
*/
public async Start(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
return Http.getInstance().post(`/jobsinfos/${context.jobsinfo}/start`,data,isloading);
}
/**
* Update接口方法
*
......@@ -80,6 +93,19 @@ export default class JobsInfoServiceBase extends EntityService {
return Http.getInstance().post(`/jobsinfos/${context.jobsinfo}/checkkey`,data,isloading);
}
/**
* Execute接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof JobsInfoServiceBase
*/
public async Execute(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
return Http.getInstance().post(`/jobsinfos/${context.jobsinfo}/execute`,data,isloading);
}
/**
* Save接口方法
*
......@@ -163,6 +189,19 @@ export default class JobsInfoServiceBase extends EntityService {
return res;
}
/**
* Stop接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof JobsInfoServiceBase
*/
public async Stop(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
return Http.getInstance().post(`/jobsinfos/${context.jobsinfo}/stop`,data,isloading);
}
/**
* FetchDefault接口方法
*
......
package cn.ibizlab.core.extensions.service;
import cn.ibizlab.core.task.service.impl.JobsInfoServiceImpl;
import lombok.extern.slf4j.Slf4j;
import cn.ibizlab.core.task.domain.JobsInfo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.context.annotation.Primary;
/**
* 实体[任务信息] 自定义服务对象
*/
@Slf4j
@Primary
@Service("JobsInfoServiceEx")
public class JobsInfoServiceEx extends JobsInfoServiceImpl {
@Override
protected Class currentModelClass() {
return com.baomidou.mybatisplus.core.toolkit.ReflectionKit.getSuperClassGenericType(this.getClass().getSuperclass(), 1);
}
/**
* 自定义行为[Execute]用户扩展
* @param et
* @return
*/
@Override
@Transactional
public JobsInfo execute(JobsInfo et) {
return super.execute(et);
}
}
......@@ -25,9 +25,11 @@ import com.baomidou.mybatisplus.extension.service.IService;
*/
public interface IJobsInfoService extends IService<JobsInfo>{
JobsInfo start(JobsInfo et) ;
boolean update(JobsInfo et) ;
void updateBatch(List<JobsInfo> list) ;
boolean checkKey(JobsInfo et) ;
JobsInfo execute(JobsInfo et) ;
boolean save(JobsInfo et) ;
void saveBatch(List<JobsInfo> list) ;
JobsInfo getDraft(JobsInfo et) ;
......@@ -36,6 +38,7 @@ public interface IJobsInfoService extends IService<JobsInfo>{
JobsInfo get(BigInteger key) ;
boolean create(JobsInfo et) ;
void createBatch(List<JobsInfo> list) ;
JobsInfo stop(JobsInfo et) ;
Page<JobsInfo> searchDefault(JobsInfoSearchContext context) ;
/**
*自定义查询SQL
......
......@@ -47,6 +47,14 @@ public class JobsInfoServiceImpl extends ServiceImpl<JobsInfoMapper, JobsInfo> i
private int batchSize = 500;
@Override
@Transactional
public JobsInfo start(JobsInfo et) {
et.set("Id",null);
et.set("Status","1");
et.set("Last_time","0");
return et;
}
@Override
@Transactional
public boolean update(JobsInfo et) {
......@@ -65,6 +73,13 @@ public class JobsInfoServiceImpl extends ServiceImpl<JobsInfoMapper, JobsInfo> i
public boolean checkKey(JobsInfo et) {
return (!ObjectUtils.isEmpty(et.getId()))&&(!Objects.isNull(this.getById(et.getId())));
}
@Override
@Transactional
public JobsInfo execute(JobsInfo et) {
//自定义代码
return et;
}
@Override
@Transactional
public boolean save(JobsInfo et) {
......@@ -140,6 +155,15 @@ public class JobsInfoServiceImpl extends ServiceImpl<JobsInfoMapper, JobsInfo> i
this.saveBatch(list,batchSize);
}
@Override
@Transactional
public JobsInfo stop(JobsInfo et) {
et.set("Id",null);
et.set("Last_time","0");
et.set("Status","0");
et.set("Next_time","0");
return et;
}
/**
......
......@@ -4,7 +4,7 @@
<!--输出实体[JOBS_INFO]数据结构 -->
<changeSet author="a_A_5d9d78509" id="tab-jobs_info-43-1">
<changeSet author="a_A_5d9d78509" id="tab-jobs_info-50-1">
<createTable tableName="JOBS_INFO">
<column name="ID" remarks="" type="BIGINT">
<constraints primaryKey="true" primaryKeyName="PK_JOBS_INFO_ID"/>
......
......@@ -8,7 +8,7 @@
"delogicname":"任务信息",
"sysmoudle":{"id":"TASK","name":"task"},
"dedataset":[{"id":"Default" , "name":"DEFAULT"}],
"deaction":[{"id":"Update" , "name":"Update" , "type":"BUILTIN" },{"id":"CheckKey" , "name":"CheckKey" , "type":"BUILTIN" },{"id":"Save" , "name":"Save" , "type":"BUILTIN" },{"id":"GetDraft" , "name":"GetDraft" , "type":"BUILTIN" },{"id":"Remove" , "name":"Remove" , "type":"BUILTIN" },{"id":"Get" , "name":"Get" , "type":"BUILTIN" },{"id":"Create" , "name":"Create" , "type":"BUILTIN" }],
"deaction":[{"id":"Start" , "name":"开始" , "type":"USERUPDATE" },{"id":"Update" , "name":"Update" , "type":"BUILTIN" },{"id":"CheckKey" , "name":"CheckKey" , "type":"BUILTIN" },{"id":"Execute" , "name":"执行" , "type":"USERCUSTOM" },{"id":"Save" , "name":"Save" , "type":"BUILTIN" },{"id":"GetDraft" , "name":"GetDraft" , "type":"BUILTIN" },{"id":"Remove" , "name":"Remove" , "type":"BUILTIN" },{"id":"Get" , "name":"Get" , "type":"BUILTIN" },{"id":"Create" , "name":"Create" , "type":"BUILTIN" },{"id":"Stop" , "name":"停止" , "type":"USERUPDATE" }],
"datascope":[{"id":"all","name":"全部数据"}]
}
, {
......
......@@ -46,6 +46,18 @@ public class JobsInfoResource {
@Lazy
public JobsInfoMapping jobsinfoMapping;
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibztask-JobsInfo-Start-all')")
@ApiOperation(value = "开始", tags = {"任务信息" }, notes = "开始")
@RequestMapping(method = RequestMethod.POST, value = "/jobsinfos/{jobsinfo_id}/start")
@Transactional
public ResponseEntity<JobsInfoDTO> start(@PathVariable("jobsinfo_id") BigInteger jobsinfo_id, @RequestBody JobsInfoDTO jobsinfodto) {
JobsInfo jobsinfo = jobsinfoMapping.toDomain(jobsinfodto);
jobsinfo.setId(jobsinfo_id);
jobsinfo = jobsinfoService.start(jobsinfo);
jobsinfodto = jobsinfoMapping.toDto(jobsinfo);
return ResponseEntity.status(HttpStatus.OK).body(jobsinfodto);
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibztask-JobsInfo-Update-all')")
@ApiOperation(value = "更新任务信息", tags = {"任务信息" }, notes = "更新任务信息")
@RequestMapping(method = RequestMethod.PUT, value = "/jobsinfos/{jobsinfo_id}")
......@@ -72,6 +84,18 @@ public class JobsInfoResource {
return ResponseEntity.status(HttpStatus.OK).body(jobsinfoService.checkKey(jobsinfoMapping.toDomain(jobsinfodto)));
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibztask-JobsInfo-Execute-all')")
@ApiOperation(value = "执行", tags = {"任务信息" }, notes = "执行")
@RequestMapping(method = RequestMethod.POST, value = "/jobsinfos/{jobsinfo_id}/execute")
@Transactional
public ResponseEntity<JobsInfoDTO> execute(@PathVariable("jobsinfo_id") BigInteger jobsinfo_id, @RequestBody JobsInfoDTO jobsinfodto) {
JobsInfo jobsinfo = jobsinfoMapping.toDomain(jobsinfodto);
jobsinfo.setId(jobsinfo_id);
jobsinfo = jobsinfoService.execute(jobsinfo);
jobsinfodto = jobsinfoMapping.toDto(jobsinfo);
return ResponseEntity.status(HttpStatus.OK).body(jobsinfodto);
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibztask-JobsInfo-Save-all')")
@ApiOperation(value = "保存任务信息", tags = {"任务信息" }, notes = "保存任务信息")
@RequestMapping(method = RequestMethod.POST, value = "/jobsinfos/save")
......@@ -137,6 +161,18 @@ public class JobsInfoResource {
return ResponseEntity.status(HttpStatus.OK).body(true);
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibztask-JobsInfo-Stop-all')")
@ApiOperation(value = "停止", tags = {"任务信息" }, notes = "停止")
@RequestMapping(method = RequestMethod.POST, value = "/jobsinfos/{jobsinfo_id}/stop")
@Transactional
public ResponseEntity<JobsInfoDTO> stop(@PathVariable("jobsinfo_id") BigInteger jobsinfo_id, @RequestBody JobsInfoDTO jobsinfodto) {
JobsInfo jobsinfo = jobsinfoMapping.toDomain(jobsinfodto);
jobsinfo.setId(jobsinfo_id);
jobsinfo = jobsinfoService.stop(jobsinfo);
jobsinfodto = jobsinfoMapping.toDto(jobsinfo);
return ResponseEntity.status(HttpStatus.OK).body(jobsinfodto);
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibztask-JobsInfo-Default-all')")
@ApiOperation(value = "获取DEFAULT", tags = {"任务信息" } ,notes = "获取DEFAULT")
@RequestMapping(method= RequestMethod.GET , value="/jobsinfos/fetchdefault")
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册