Merge branch 'master' of http://git.hchbox.com/yuyou/eladmin into master

# Conflicts:
#	eladmin-system/src/main/java/me/zhengjie/modules/taskrecord/domain/TaskRecord.java
#	eladmin-system/src/main/java/me/zhengjie/modules/taskrecord/rest/TaskRecordController.java
增加校验接口逻辑
master
土豆兄弟 4 years ago
commit b21eed4d72

@ -17,6 +17,7 @@ public enum ResponseCode {
// 请求参数校验
ILLEGAL_ARGUMENT(1,"请求参数格式错误"),
EMPTY_ARGUMENT(1,"请求参数为空"),
NO_MATCH_ARGUMENT_SET(1,"不能满足要求的参数设置"),
// 请求结果性的错误
NODATA_ERROR(1,"查询结果为空"),
TASK_BUILD_ERROR(1,"任务建立失败"),

@ -31,7 +31,7 @@ import java.io.Serializable;
* @website https://el-admin.vip
* @description /
* @author x
* @date 2020-09-08
* @date 2020-09-09
**/
@Entity
@Data
@ -56,21 +56,17 @@ public class TaskRecord implements Serializable {
@Column(name = "task_name")
@ApiModelProperty(value = "任务名称")
@NotBlank
private String taskName;
@Column(name = "time_period",nullable = false)
@NotNull
@Column(name = "time_period")
@ApiModelProperty(value = "任务保存周期")
private Integer timePeriod;
@Column(name = "is_build",nullable = false)
@NotNull
@Column(name = "is_build")
@ApiModelProperty(value = "任务是否建立成功")
private Integer isBuild;
@Column(name = "is_send",nullable = false)
@NotNull
@Column(name = "is_send")
@ApiModelProperty(value = "发送状态记录")
private Integer isSend;
@ -78,10 +74,6 @@ public class TaskRecord implements Serializable {
@ApiModelProperty(value = "操作人")
private String oprationName;
@Column(name = "desc",nullable = false)
@ApiModelProperty(value = "自定义内容补充")
private String desc;
@Column(name = "local_file_path")
@ApiModelProperty(value = "本地生成待发送文件路径")
private String localFilePath;
@ -90,6 +82,18 @@ public class TaskRecord implements Serializable {
@ApiModelProperty(value = "查询参数暂存")
private String params;
@Column(name = "total")
@ApiModelProperty(value = "该任务生成总记录数")
private Long total;
@Column(name = "send_total")
@ApiModelProperty(value = "上次发送总记录数")
private Long sendTotal;
@Column(name = "description")
@ApiModelProperty(value = "自定义内容补充")
private String description;
public void copy(TaskRecord source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}

@ -22,7 +22,7 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @website https://el-admin.vip
* @author x
* @date 2020-09-08
* @date 2020-09-09
**/
public interface TaskRecordRepository extends JpaRepository<TaskRecord, Integer>, JpaSpecificationExecutor<TaskRecord> {
}

@ -41,7 +41,7 @@ import javax.servlet.http.HttpServletResponse;
/**
* @website https://el-admin.vip
* @author x
* @date 2020-09-08
* @date 2020-09-09
**/
@RestController
@RequiredArgsConstructor
@ -112,8 +112,9 @@ public class TaskRecordController {
if (CollectionUtils.isEmpty(idList)){
return new ResponseEntity<>(CommonResponse.createByError(ResponseCode.EMPTY_ARGUMENT), HttpStatus.OK);
}
// 调用发送课包任务,开始发送
sendRecordTask.doRunTask(idList);
return new ResponseEntity<>(HttpStatus.OK);
return new ResponseEntity<>(CommonResponse.createBySuccess(), HttpStatus.OK);
}
/**
@ -127,7 +128,7 @@ public class TaskRecordController {
@ApiOperation("发送课包数目校验")
@PreAuthorize("@el.check('taskRecord:list')")
@PostMapping(value = "/checkSendTotal")
public ResponseEntity<Object> checkSendTotal(@RequestParam(value = "sendTotal", defaultValue = "0") Integer sendTotal,
public ResponseEntity<Object> checkSendTotal(@RequestParam(value = "sendTotal", defaultValue = "0") Long sendTotal,
@RequestParam(value = "id")Integer id){
if (sendTotal == null || id == null){
return new ResponseEntity<>(CommonResponse.createByError(ResponseCode.EMPTY_ARGUMENT), HttpStatus.OK);
@ -137,15 +138,21 @@ public class TaskRecordController {
if (dto == null){
return new ResponseEntity<>(CommonResponse.createByError(ResponseCode.NO_RELEVANT_CONTENT_WAS_FOUND), HttpStatus.OK);
}
// (本次发送数目 + 最后一次发送数目) < 该任务课包总条数
// TODO: 2020/9/9 0009 编写相关逻辑代码
return new ResponseEntity<>(HttpStatus.OK);
// 满足要求的公式 (本次发送数目 + 最后一次发送数目) < 该任务课包总条数
if (!isMatchCheckNum(dto, sendTotal)){
return new ResponseEntity<>(CommonResponse.createByError(ResponseCode.NO_MATCH_ARGUMENT_SET), HttpStatus.OK);
}
return new ResponseEntity<>(CommonResponse.createBySuccess(), HttpStatus.OK);
}
private boolean isMatchCheckNum(TaskRecordDto dto, Long sendTotal){
Long total = dto.getTotal();
Long send = dto.getSendTotal();
if ((sendTotal + send) < total){
return Boolean.TRUE;
}
return Boolean.FALSE;
}
@Log("任务课包任务合并")
@ApiOperation("任务课包任务合并")
@ -156,4 +163,4 @@ public class TaskRecordController {
return new ResponseEntity<>(HttpStatus.OK);
}
// ================ 自定义功能实现 end ================
}
}

@ -28,7 +28,7 @@ import javax.servlet.http.HttpServletResponse;
* @website https://el-admin.vip
* @description
* @author x
* @date 2020-09-08
* @date 2020-09-09
**/
public interface TaskRecordService {

@ -23,7 +23,7 @@ import java.io.Serializable;
* @website https://el-admin.vip
* @description /
* @author x
* @date 2020-09-08
* @date 2020-09-09
**/
@Data
public class TaskRecordDto implements Serializable {
@ -52,12 +52,18 @@ public class TaskRecordDto implements Serializable {
/** 操作人 */
private String oprationName;
/** 自定义内容补充 */
private String desc;
/** 本地生成待发送文件路径 */
private String localFilePath;
/** 查询参数暂存 */
private String params;
/** 该任务生成总记录数 */
private Long total;
/** 上次发送总记录数 */
private Long sendTotal;
/** 自定义内容补充 */
private String description;
}

@ -22,7 +22,7 @@ import me.zhengjie.annotation.Query;
/**
* @website https://el-admin.vip
* @author x
* @date 2020-09-08
* @date 2020-09-09
**/
@Data
public class TaskRecordQueryCriteria{

@ -41,7 +41,7 @@ import java.util.LinkedHashMap;
* @website https://el-admin.vip
* @description
* @author x
* @date 2020-09-08
* @date 2020-09-09
**/
@Service
@RequiredArgsConstructor
@ -103,9 +103,11 @@ public class TaskRecordServiceImpl implements TaskRecordService {
map.put("任务是否建立成功", taskRecord.getIsBuild());
map.put("发送状态记录", taskRecord.getIsSend());
map.put("操作人", taskRecord.getOprationName());
map.put("自定义内容补充", taskRecord.getDesc());
map.put("本地生成待发送文件路径", taskRecord.getLocalFilePath());
map.put("查询参数暂存", taskRecord.getParams());
map.put("该任务生成总记录数", taskRecord.getTotal());
map.put("上次发送总记录数", taskRecord.getSendTotal());
map.put("自定义内容补充", taskRecord.getDescription());
list.add(map);
}
FileUtil.downloadExcel(list, response);

@ -24,7 +24,7 @@ import org.mapstruct.ReportingPolicy;
/**
* @website https://el-admin.vip
* @author x
* @date 2020-09-08
* @date 2020-09-09
**/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface TaskRecordMapper extends BaseMapper<TaskRecordDto, TaskRecord> {

Loading…
Cancel
Save