提交修改

This commit is contained in:
quyixiao 2021-01-26 11:55:52 +08:00
commit 73a3ded29d
9 changed files with 67 additions and 71 deletions

View File

@ -60,6 +60,13 @@ public class R extends HashMap<String, Object> {
return r;
}
public static R ok(int code, String msg) {
R r = new R();
r.put("code", code);
r.put("msg", msg);
r.setSuccess(false);
return r;
}
public static R ok(String msg) {
R r = new R();

View File

@ -91,10 +91,7 @@ public class TaskCommand {
if (c == 'n') {
taskDto.setName(know);
} else if (c == 'r') {
if (!NumberUtil.isNumeric(know)) {
return new Tuple(488, "r 参数必需是一个正整数");
}
taskDto.setRate(NumberUtil.objToIntDefault(know, 0));
taskDto.setRate(know);
} else if (c == 'm') {
taskDto.setMark(know);
}else{
@ -105,10 +102,7 @@ public class TaskCommand {
if (StringUtil.isBlank(taskDto.getName())) {
taskDto.setName(notKnow);
} else if (taskDto.getRate() == null) {
if (!NumberUtil.isNumeric(notKnow)) {
return new Tuple(488, "进度必需是一个正整数");
}
taskDto.setRate(NumberUtil.objToIntDefault(notKnow, 0));
taskDto.setRate(notKnow);
} else if (StringUtil.isEmpty(taskDto.getMark())) {
taskDto.setMark(notKnow);
}

View File

@ -1,7 +1,6 @@
package com.lz.modules.app.controller;
import com.alibaba.fastjson.JSON;
import com.lz.common.cli.LineStatus;
import com.lz.common.constant.CacheConstants;
import com.lz.common.utils.Md5Utils;
import com.lz.common.utils.R;
@ -25,12 +24,10 @@ import com.lz.modules.third.utils.TaskConvertUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.crypto.hash.Sha256Hash;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -59,16 +56,17 @@ public class ThirdTaskController {
private TaskRespService taskRespService;
@RequestMapping("/handler")
public R handler(@RequestBody CommandDto commandDto) throws Exception{
public R handler(@RequestBody CommandDto commandDto) throws Exception {
SysUserEntity user = checkLogin(commandDto.getToken());
if (user == null) {
return R.error(499, "登陆己经过期");
}
log.info("commandDto:" + JSON.toJSONString(commandDto));
Tuple tuple = TaskCommand.parse(commandDto.getCommand());
log.info("parse data :" + JSON.toJSONString(tuple));
OneTuple<Integer> parseData = tuple.getData();
if (parseData.getFirst() == 488) { // 命令解析失败
TwoTuple<Integer,String> twoTuple = tuple.getData();
TwoTuple<Integer, String> twoTuple = tuple.getData();
return R.error(twoTuple.getSecond());
}
TwoTuple<Integer, TaskDto> taskInfo = tuple.getData();
@ -76,25 +74,27 @@ public class ThirdTaskController {
switch (parseData.getFirst()) {
case 1: //list task
List<ResultDto> list = resultTaskService.listResultTask(user);
taskRespService.deleteInsertLastResult(user,list); //保存索引和 id对应关系
TwoTuple<List<String>,List<List<String>>> data = TaskConvertUtils.convert(list).getData();
taskRespService.deleteInsertLastResult(user, list); //保存索引和 id对应关系
TwoTuple<List<String>, List<List<String>>> data = TaskConvertUtils.convert(list).getData();
return R.ok().put("header", data.getFirst()).put("data", data.getSecond());
case 2: //add task
flag = updateIndex(user, taskInfo.getSecond());
if(!flag){
if (!flag) {
return R.error("请先输入 list record");
}
return resultTaskService.addOrUpdateTask(user, taskInfo.getSecond());
resultTaskService.addOrUpdateTask(user, taskInfo.getSecond());
return R.ok(250, "添加任务成功");
case 3: //update task
flag = updateIndex(user, taskInfo.getSecond());
if(!flag){
if (!flag) {
return R.error("请先输入 list task");
}
return resultTaskService.addOrUpdateTask(user, taskInfo.getSecond());
resultTaskService.addOrUpdateTask(user, taskInfo.getSecond());
return R.ok(250, "更新任务成功");
case 4: //list record
List<ResultDto> listRecords = resultDetailService.listRecord(user);
taskRespService.deleteInsertLastResult(user,listRecords); //保存索引和 id对应关系
TwoTuple<List<String>,List<List<String>>> recordData = TaskConvertUtils.convert(listRecords).getData();
taskRespService.deleteInsertLastResult(user, listRecords); //保存索引和 id对应关系
TwoTuple<List<String>, List<List<String>>> recordData = TaskConvertUtils.convert(listRecords).getData();
return R.ok().put("header", recordData.getFirst()).put("data", recordData.getSecond());
case 5: //TODO add record
break;
@ -109,14 +109,15 @@ public class ThirdTaskController {
}
public boolean updateIndex(SysUserEntity userEntity ,TaskDto taskDto){
TaskResp taskResp = taskRespService.selectTaskRespByUserIdIndex(userEntity.getUserId(),taskDto.getId());
if(taskResp !=null){
public boolean updateIndex(SysUserEntity userEntity, TaskDto taskDto) {
TaskResp taskResp = taskRespService.selectTaskRespByUserIdIndex(userEntity.getUserId(), taskDto.getId());
if (taskResp != null) {
taskDto.setId(taskResp.getResultId());
return true;
}
return false;
}
public SysUserEntity checkLogin(String token) {
Object object = redisCacheUtil.getObject(token);
if (object != null) {

View File

@ -1,18 +1,8 @@
package com.lz.modules.app.dto;
import com.alibaba.fastjson.JSON;
import com.lz.common.annotation.TaskHeader;
import com.lz.modules.app.utils.t.Tuple;
import com.lz.modules.app.utils.t.TwoTuple;
import lombok.Data;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
@Data
public class ResultDto {
@TaskHeader(value = "index", order = 0)
@ -25,6 +15,7 @@ public class ResultDto {
private String rate;
public ResultDto() {
}
public ResultDto(@TaskHeader("索引") Integer index, @TaskHeader("Id") Long id, @TaskHeader("内容") String content) {

View File

@ -7,6 +7,6 @@ public class TaskDto {
private String option;
private Long id ;
private String name;
private Integer rate ;
private String rate ;
private String mark;
}

View File

@ -342,7 +342,8 @@ public class ResultTaskServiceImpl extends ServiceImpl<ResultTaskMapper, ResultT
resultUpdateTaskReq.setRemark(second.getMark());
resultUpdateTaskReq.setTaskId(second.getId());
resultUpdateTaskReq.setName(second.getName());
resultUpdateTaskReq.setProcessRate(BigDecimal.valueOf(second.getRate()));
String a = second.getRate();
resultUpdateTaskReq.setProcessRate(new BigDecimal(0));
ResultTask resultTask = resultTaskMapper.selectResultTaskById(second.getId());
if(resultTask!=null){
resultUpdateTaskReq.setDetailId(resultTask.getDetailId());

View File

@ -10,7 +10,7 @@ import java.util.Date;
* <p>
* </p>*用户执行命令的最后一个值表
* @author quyixiao
* @since 2021-01-22
* @since 2021-01-26
*/
@Data
@ -30,8 +30,8 @@ public class TaskResp implements java.io.Serializable {
@ApiModelProperty(value = "最后修改时间", name = "gmtModified")
private Date gmtModified;
//索引
@ApiModelProperty(value = "索引 ", name = "index")
private Integer index;
@ApiModelProperty(value = "索引 ", name = "indexId")
private Integer indexId;
//用户 id
@ApiModelProperty(value = "用户 id", name = "userId")
private Long userId;
@ -105,15 +105,15 @@ public class TaskResp implements java.io.Serializable {
* 索引
* @return
*/
public Integer getIndex() {
return index;
public Integer getIndexId() {
return indexId;
}
/**
* 索引
* @param index
* @param indexId
*/
public void setIndex(Integer index) {
this.index = index;
public void setIndexId(Integer indexId) {
this.indexId = indexId;
}
/**
@ -168,7 +168,7 @@ public class TaskResp implements java.io.Serializable {
",isDelete=" + isDelete +
",gmtCreate=" + gmtCreate +
",gmtModified=" + gmtModified +
",index=" + index +
",indexId=" + indexId +
",userId=" + userId +
",resultId=" + resultId +
",content=" + content +

View File

@ -67,7 +67,7 @@ public class TaskRespServiceImpl extends ServiceImpl<TaskRespMapper, TaskResp> i
taskRespMapper.deleteTaskRespByUserId(user.getUserId());
for(ResultDto resultDto : list){
TaskResp taskResp = new TaskResp();
taskResp.setIndex(resultDto.getIndex());
taskResp.setIndexId(resultDto.getIndex());
taskResp.setResultId(resultDto.getId());
taskResp.setUserId(user.getUserId());
taskResp.setContent(resultDto.getContent());

View File

@ -8,7 +8,7 @@
<result column="is_delete" property="isDelete"/>
<result column="gmt_create" property="gmtCreate"/>
<result column="gmt_modified" property="gmtModified"/>
<result column="index" property="index"/>
<result column="index_id" property="indexId"/>
<result column="user_id" property="userId"/>
<result column="result_id" property="resultId"/>
<result column="content" property="content"/>
@ -17,45 +17,48 @@
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id AS id, is_delete AS isDelete, gmt_create AS gmtCreate, gmt_modified AS gmtModified, index AS index, user_id AS userId, result_id AS resultId, content AS content
id AS id, is_delete AS isDelete, gmt_create AS gmtCreate, gmt_modified AS gmtModified, index_id AS indexId, user_id AS userId, result_id AS resultId, content AS content
</sql>
<select id="selectTaskRespById" resultType="TaskResp" >
select * from lz_task_resp where id=#{id} and is_delete = 0 limit 1
select * from lz_task_resp where id=#{id} and is_delete = 0 limit 1
</select>
<insert id="insertTaskResp" parameterType="TaskResp" useGeneratedKeys="true" keyProperty="id" >
insert into lz_task_resp(
<if test="index != null">index, </if>
<if test="userId != null">user_id, </if>
<if test="resultId != null">result_id, </if>
<if test="content != null">content, </if>
is_delete,
gmt_create,
gmt_modified
<if test="indexId != null">index_id, </if>
<if test="userId != null">user_id, </if>
<if test="resultId != null">result_id, </if>
<if test="content != null">content, </if>
is_delete,
gmt_create,
gmt_modified
)values(
<if test="index != null">#{ index}, </if>
<if test="userId != null">#{ userId}, </if>
<if test="resultId != null">#{ resultId}, </if>
<if test="content != null">#{ content}, </if>
0,
now(),
now()
<if test="indexId != null">#{ indexId}, </if>
<if test="userId != null">#{ userId}, </if>
<if test="resultId != null">#{ resultId}, </if>
<if test="content != null">#{ content}, </if>
0,
now(),
now()
)
</insert>
<update id="updateTaskRespById" parameterType="TaskResp" >
update
lz_task_resp
lz_task_resp
<trim prefix="set" suffixOverrides=",">
<if test="isDelete != null">is_delete = #{isDelete},</if>
<if test="gmtCreate != null">gmt_create = #{gmtCreate},</if>
<if test="index != null">index = #{index},</if>
<if test="indexId != null">index_id = #{indexId},</if>
<if test="userId != null">user_id = #{userId},</if>
<if test="resultId != null">result_id = #{resultId},</if>
<if test="content != null">content = #{content}</if>
<if test="content != null">content = #{content}</if>
</trim>
,gmt_modified = now()
where id = #{id}
@ -64,11 +67,11 @@
<update id="updateCoverTaskRespById" parameterType="TaskResp" >
update
lz_task_resp
set
lz_task_resp
set
is_delete = #{isDelete},
gmt_create = #{gmtCreate},
index = #{index},
index_id = #{indexId},
user_id = #{userId},
result_id = #{resultId},
content = #{content}
@ -85,9 +88,8 @@
delete from lz_task_resp where user_id = #{userId}
</delete>
<select id="selectTaskRespByUserIdIndex" resultType="com.lz.modules.third.entity.TaskResp">
select * from lz_task_resp where index=#{index} and user_id = #{userId} and is_delete = 0 limit 1
select * from lz_task_resp where index_id=#{index} and user_id = #{userId} and is_delete = 0 limit 1
</select>