提交修改

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; 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) { public static R ok(String msg) {
R r = new R(); R r = new R();

View File

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

View File

@ -1,7 +1,6 @@
package com.lz.modules.app.controller; package com.lz.modules.app.controller;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.lz.common.cli.LineStatus;
import com.lz.common.constant.CacheConstants; import com.lz.common.constant.CacheConstants;
import com.lz.common.utils.Md5Utils; import com.lz.common.utils.Md5Utils;
import com.lz.common.utils.R; import com.lz.common.utils.R;
@ -25,12 +24,10 @@ import com.lz.modules.third.utils.TaskConvertUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.crypto.hash.Sha256Hash; import org.apache.shiro.crypto.hash.Sha256Hash;
import org.springframework.beans.factory.annotation.Autowired; 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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@ -66,6 +63,7 @@ public class ThirdTaskController {
} }
log.info("commandDto:" + JSON.toJSONString(commandDto)); log.info("commandDto:" + JSON.toJSONString(commandDto));
Tuple tuple = TaskCommand.parse(commandDto.getCommand()); Tuple tuple = TaskCommand.parse(commandDto.getCommand());
log.info("parse data :" + JSON.toJSONString(tuple));
OneTuple<Integer> parseData = tuple.getData(); OneTuple<Integer> parseData = tuple.getData();
if (parseData.getFirst() == 488) { // 命令解析失败 if (parseData.getFirst() == 488) { // 命令解析失败
TwoTuple<Integer, String> twoTuple = tuple.getData(); TwoTuple<Integer, String> twoTuple = tuple.getData();
@ -84,13 +82,15 @@ public class ThirdTaskController {
if (!flag) { if (!flag) {
return R.error("请先输入 list record"); return R.error("请先输入 list record");
} }
return resultTaskService.addOrUpdateTask(user, taskInfo.getSecond()); resultTaskService.addOrUpdateTask(user, taskInfo.getSecond());
return R.ok(250, "添加任务成功");
case 3: //update task case 3: //update task
flag = updateIndex(user, taskInfo.getSecond()); flag = updateIndex(user, taskInfo.getSecond());
if (!flag) { if (!flag) {
return R.error("请先输入 list task"); return R.error("请先输入 list task");
} }
return resultTaskService.addOrUpdateTask(user, taskInfo.getSecond()); resultTaskService.addOrUpdateTask(user, taskInfo.getSecond());
return R.ok(250, "更新任务成功");
case 4: //list record case 4: //list record
List<ResultDto> listRecords = resultDetailService.listRecord(user); List<ResultDto> listRecords = resultDetailService.listRecord(user);
taskRespService.deleteInsertLastResult(user, listRecords); //保存索引和 id对应关系 taskRespService.deleteInsertLastResult(user, listRecords); //保存索引和 id对应关系
@ -117,6 +117,7 @@ public class ThirdTaskController {
} }
return false; return false;
} }
public SysUserEntity checkLogin(String token) { public SysUserEntity checkLogin(String token) {
Object object = redisCacheUtil.getObject(token); Object object = redisCacheUtil.getObject(token);
if (object != null) { if (object != null) {

View File

@ -1,18 +1,8 @@
package com.lz.modules.app.dto; package com.lz.modules.app.dto;
import com.alibaba.fastjson.JSON;
import com.lz.common.annotation.TaskHeader; 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 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 @Data
public class ResultDto { public class ResultDto {
@TaskHeader(value = "index", order = 0) @TaskHeader(value = "index", order = 0)
@ -25,6 +15,7 @@ public class ResultDto {
private String rate; private String rate;
public ResultDto() { public ResultDto() {
} }
public ResultDto(@TaskHeader("索引") Integer index, @TaskHeader("Id") Long id, @TaskHeader("内容") String content) { 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 String option;
private Long id ; private Long id ;
private String name; private String name;
private Integer rate ; private String rate ;
private String mark; private String mark;
} }

View File

@ -342,7 +342,8 @@ public class ResultTaskServiceImpl extends ServiceImpl<ResultTaskMapper, ResultT
resultUpdateTaskReq.setRemark(second.getMark()); resultUpdateTaskReq.setRemark(second.getMark());
resultUpdateTaskReq.setTaskId(second.getId()); resultUpdateTaskReq.setTaskId(second.getId());
resultUpdateTaskReq.setName(second.getName()); 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()); ResultTask resultTask = resultTaskMapper.selectResultTaskById(second.getId());
if(resultTask!=null){ if(resultTask!=null){
resultUpdateTaskReq.setDetailId(resultTask.getDetailId()); resultUpdateTaskReq.setDetailId(resultTask.getDetailId());

View File

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

View File

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

View File

@ -8,7 +8,7 @@
<result column="is_delete" property="isDelete"/> <result column="is_delete" property="isDelete"/>
<result column="gmt_create" property="gmtCreate"/> <result column="gmt_create" property="gmtCreate"/>
<result column="gmt_modified" property="gmtModified"/> <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="user_id" property="userId"/>
<result column="result_id" property="resultId"/> <result column="result_id" property="resultId"/>
<result column="content" property="content"/> <result column="content" property="content"/>
@ -17,9 +17,12 @@
<!-- 通用查询结果列 --> <!-- 通用查询结果列 -->
<sql id="Base_Column_List"> <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> </sql>
<select id="selectTaskRespById" resultType="TaskResp" > <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> </select>
@ -27,7 +30,7 @@
<insert id="insertTaskResp" parameterType="TaskResp" useGeneratedKeys="true" keyProperty="id" > <insert id="insertTaskResp" parameterType="TaskResp" useGeneratedKeys="true" keyProperty="id" >
insert into lz_task_resp( insert into lz_task_resp(
<if test="index != null">index, </if> <if test="indexId != null">index_id, </if>
<if test="userId != null">user_id, </if> <if test="userId != null">user_id, </if>
<if test="resultId != null">result_id, </if> <if test="resultId != null">result_id, </if>
<if test="content != null">content, </if> <if test="content != null">content, </if>
@ -35,7 +38,7 @@
gmt_create, gmt_create,
gmt_modified gmt_modified
)values( )values(
<if test="index != null">#{ index}, </if> <if test="indexId != null">#{ indexId}, </if>
<if test="userId != null">#{ userId}, </if> <if test="userId != null">#{ userId}, </if>
<if test="resultId != null">#{ resultId}, </if> <if test="resultId != null">#{ resultId}, </if>
<if test="content != null">#{ content}, </if> <if test="content != null">#{ content}, </if>
@ -52,7 +55,7 @@
<trim prefix="set" suffixOverrides=","> <trim prefix="set" suffixOverrides=",">
<if test="isDelete != null">is_delete = #{isDelete},</if> <if test="isDelete != null">is_delete = #{isDelete},</if>
<if test="gmtCreate != null">gmt_create = #{gmtCreate},</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="userId != null">user_id = #{userId},</if>
<if test="resultId != null">result_id = #{resultId},</if> <if test="resultId != null">result_id = #{resultId},</if>
<if test="content != null">content = #{content}</if> <if test="content != null">content = #{content}</if>
@ -68,7 +71,7 @@
set set
is_delete = #{isDelete}, is_delete = #{isDelete},
gmt_create = #{gmtCreate}, gmt_create = #{gmtCreate},
index = #{index}, index_id = #{indexId},
user_id = #{userId}, user_id = #{userId},
result_id = #{resultId}, result_id = #{resultId},
content = #{content} content = #{content}
@ -85,9 +88,8 @@
delete from lz_task_resp where user_id = #{userId} delete from lz_task_resp where user_id = #{userId}
</delete> </delete>
<select id="selectTaskRespByUserIdIndex" resultType="com.lz.modules.third.entity.TaskResp"> <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> </select>