feat: 增加cancel命令

dev
huangfeng 1 year ago
parent 1a9df3cd6f
commit bb47278e46

@ -139,26 +139,23 @@
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
SELECT LAST_INSERT_ID()
</selectKey>
insert into mntn_cmd_history (term_id, `name`, cmd,
`desc`, `status`, create_time,
publish_time)
values (#{termId,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{cmd,jdbcType=VARCHAR},
#{desc,jdbcType=VARCHAR}, #{status,jdbcType=TINYINT}, #{createTime,jdbcType=TIMESTAMP},
#{publishTime,jdbcType=TIMESTAMP})
insert into mntn_cmd_history (id, term_id, `name`,
cmd, `desc`, `status`,
create_time, publish_time)
values (#{id,jdbcType=BIGINT}, #{termId,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR},
#{cmd,jdbcType=VARCHAR}, #{desc,jdbcType=VARCHAR}, #{status,jdbcType=TINYINT},
#{createTime,jdbcType=TIMESTAMP}, #{publishTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.shxy.xymanager_common.entity.MntnCmdHistory">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
SELECT LAST_INSERT_ID()
</selectKey>
insert into mntn_cmd_history
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="termId != null">
term_id,
</if>
@ -182,6 +179,9 @@
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=BIGINT},
</if>
<if test="termId != null">
#{termId,jdbcType=INTEGER},
</if>

@ -1,7 +1,9 @@
package com.shxy.xymanager_service.impl;
import com.shxy.xymanager_common.entity.MntnCmdHistory;
import com.shxy.xymanager_common.entity.MntnCmds;
import com.shxy.xymanager_common.entity.MntnCmdsExample;
import com.shxy.xymanager_common.exception.ApiException;
import com.shxy.xymanager_common.model.CmdModel;
import com.shxy.xymanager_dao.dao.MntnCmdHistoryMapper;
import com.shxy.xymanager_dao.dao.MntnCmdsMapper;
@ -12,6 +14,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
@Service
@ -39,9 +42,30 @@ public class MntnCmdsServiceImpl implements MntnCmdsService {
public void send(CmdModel model) throws Exception {
switch (model.getAction()) {
case "cancel":
cmdsMapper.deleteByPrimaryKey(model.getId());
this.cancel(model);
break;
case "":
default:
}
}
private void cancel(CmdModel model) {
if (model.getId() == null) {
throw new ApiException("id不能为空");
}
MntnCmds item = cmdsMapper.selectByPrimaryKey(model.getId());
if (item != null) {
MntnCmdHistory history = new MntnCmdHistory();
history.setId(item.getId());
history.setCmd(item.getCmd());
history.setDesc(item.getDesc());
history.setName(item.getName());
history.setTermId(item.getTermId());
history.setCreateTime(item.getCreateTime());
history.setStatus(Byte.valueOf("2"));
history.setPublishTime(new Date());
historyMapper.insert(history);
cmdsMapper.deleteByPrimaryKey(item.getId());
}
}
}

Loading…
Cancel
Save