mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-10-08 13:16:41 +08:00
reload 增加controller 与 service
This commit is contained in:
parent
31894f40d9
commit
51bb1a42f2
@ -0,0 +1,45 @@
|
||||
package net.lab1024.smartadmin.service.module.support.reload;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import net.lab1024.smartadmin.service.common.controller.SupportBaseController;
|
||||
import net.lab1024.smartadmin.service.common.domain.ResponseDTO;
|
||||
import net.lab1024.smartadmin.service.common.swagger.SwaggerTagConst;
|
||||
import net.lab1024.smartadmin.service.module.support.reload.domain.ReloadItemUpdateDTO;
|
||||
import net.lab1024.smartadmin.service.module.support.reload.domain.ReloadItemVO;
|
||||
import net.lab1024.smartadmin.service.module.support.reload.domain.ReloadResultVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/***
|
||||
*
|
||||
* @author 开云
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = {SwaggerTagConst.Support.SMART_RELOAD})
|
||||
public class SmartReloadController extends SupportBaseController {
|
||||
|
||||
@Autowired
|
||||
private SmartReloadService smartReloadService;
|
||||
|
||||
@ApiOperation(value = "查询reload列表 by 开云")
|
||||
@GetMapping("/reload/query")
|
||||
public ResponseDTO<List<ReloadItemVO>> query() {
|
||||
return smartReloadService.query();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取reload result by 开云")
|
||||
@GetMapping("/smartReload/result/{tag}")
|
||||
public ResponseDTO<List<ReloadResultVO>> queryReloadResult(@PathVariable("tag") String tag) {
|
||||
return smartReloadService.queryReloadItemResult(tag);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "通过tag更新标识 by 开云")
|
||||
@PostMapping("/smartReload/update")
|
||||
public ResponseDTO<String> updateByTag(@RequestBody @Valid ReloadItemUpdateDTO updateDTO) {
|
||||
return smartReloadService.updateByTag(updateDTO);
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package net.lab1024.smartadmin.service.module.support.reload;
|
||||
|
||||
import net.lab1024.smartadmin.service.common.code.UserErrorCode;
|
||||
import net.lab1024.smartadmin.service.common.domain.ResponseDTO;
|
||||
import net.lab1024.smartadmin.service.module.support.reload.dao.ReloadItemDao;
|
||||
import net.lab1024.smartadmin.service.module.support.reload.dao.ReloadResultDao;
|
||||
import net.lab1024.smartadmin.service.module.support.reload.domain.ReloadItemEntity;
|
||||
import net.lab1024.smartadmin.service.module.support.reload.domain.ReloadItemUpdateDTO;
|
||||
import net.lab1024.smartadmin.service.module.support.reload.domain.ReloadItemVO;
|
||||
import net.lab1024.smartadmin.service.module.support.reload.domain.ReloadResultVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* reload Service
|
||||
*
|
||||
* @author 开云
|
||||
*/
|
||||
@Service
|
||||
public class SmartReloadService {
|
||||
|
||||
@Autowired
|
||||
private ReloadItemDao reloadItemDao;
|
||||
|
||||
@Autowired
|
||||
private ReloadResultDao reloadResultDao;
|
||||
|
||||
/**
|
||||
* 查询
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<List<ReloadItemVO>> query() {
|
||||
List<ReloadItemVO> list = reloadItemDao.query();
|
||||
return ResponseDTO.ok(list);
|
||||
}
|
||||
|
||||
public ResponseDTO<List<ReloadResultVO>> queryReloadItemResult(String tag) {
|
||||
List<ReloadResultVO> reloadResultList = reloadResultDao.query(tag);
|
||||
return ResponseDTO.ok(reloadResultList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过标签更新标识符
|
||||
*
|
||||
* @param updateDTO
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<String> updateByTag(ReloadItemUpdateDTO updateDTO) {
|
||||
ReloadItemEntity reloadItemEntity = reloadItemDao.selectById(updateDTO.getTag());
|
||||
if (null == reloadItemEntity) {
|
||||
return ResponseDTO.error(UserErrorCode.DATA_NOT_EXIST);
|
||||
}
|
||||
reloadItemEntity.setIdentification(updateDTO.getIdentification());
|
||||
reloadItemEntity.setUpdateTime(new Timestamp(System.currentTimeMillis()));
|
||||
reloadItemDao.updateById(reloadItemEntity);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
}
|
@ -2,9 +2,12 @@ package net.lab1024.smartadmin.service.module.support.reload.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import net.lab1024.smartadmin.service.module.support.reload.domain.ReloadItemEntity;
|
||||
import net.lab1024.smartadmin.service.module.support.reload.domain.ReloadItemVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* t_reload_item 数据表dao
|
||||
*
|
||||
@ -14,4 +17,6 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
@Mapper
|
||||
public interface ReloadItemDao extends BaseMapper<ReloadItemEntity> {
|
||||
|
||||
List<ReloadItemVO> query();
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package net.lab1024.smartadmin.service.module.support.reload.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import net.lab1024.smartadmin.service.module.support.reload.domain.ReloadResultEntity;
|
||||
import net.lab1024.smartadmin.service.module.support.reload.domain.ReloadResultVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -18,4 +19,5 @@ import java.util.List;
|
||||
@Mapper
|
||||
public interface ReloadResultDao extends BaseMapper<ReloadResultEntity> {
|
||||
|
||||
List<ReloadResultVO> query(@Param("tag") String tag);
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
@ -40,7 +41,7 @@ public class ReloadItemEntity {
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
private LocalDateTime createTime;
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,23 @@
|
||||
package net.lab1024.smartadmin.service.module.support.reload.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/***
|
||||
*
|
||||
* @author 开云
|
||||
*/
|
||||
@Data
|
||||
public class ReloadItemUpdateDTO {
|
||||
|
||||
@ApiModelProperty("标签")
|
||||
@NotBlank(message = "标签不能为空")
|
||||
private String tag;
|
||||
|
||||
@ApiModelProperty("状态标识")
|
||||
@NotBlank(message = "状态标识不能为空")
|
||||
private String identification;
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package net.lab1024.smartadmin.service.module.support.reload.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/***
|
||||
*
|
||||
* @author 开云
|
||||
*/
|
||||
@Data
|
||||
public class ReloadItemVO {
|
||||
|
||||
@ApiModelProperty("加载项标签")
|
||||
private String tag;
|
||||
|
||||
@ApiModelProperty("参数")
|
||||
private String args;
|
||||
|
||||
@ApiModelProperty("运行标识")
|
||||
private String identification;
|
||||
|
||||
@ApiModelProperty("更新时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@ApiModelProperty("更新时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
|
||||
}
|
@ -1,8 +1,9 @@
|
||||
package net.lab1024.smartadmin.service.module.support.reload.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* t_reload_result 数据表 实体类
|
||||
@ -42,7 +43,7 @@ public class ReloadResultEntity {
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
private LocalDateTime createTime;
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,29 @@
|
||||
package net.lab1024.smartadmin.service.module.support.reload.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/***
|
||||
*
|
||||
* @author 开云
|
||||
*/
|
||||
@Data
|
||||
public class ReloadResultVO {
|
||||
|
||||
@ApiModelProperty("加载项标签")
|
||||
private String tag;
|
||||
|
||||
@ApiModelProperty("参数")
|
||||
private String args;
|
||||
|
||||
@ApiModelProperty("运行结果")
|
||||
private Boolean result;
|
||||
|
||||
@ApiModelProperty("异常")
|
||||
private String exception;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="net.lab1024.smartadmin.service.module.support.reload.dao.ReloadItemDao">
|
||||
|
||||
<!-- 查询reload列表 -->
|
||||
<select id="query" resultType="net.lab1024.smartadmin.service.module.support.reload.domain.ReloadItemVO">
|
||||
SELECT tag,args,identification,update_time,create_time FROM t_reload_item
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="net.lab1024.smartadmin.service.module.support.reload.dao.ReloadResultDao">
|
||||
|
||||
<!-- 查询reload列表 -->
|
||||
<select id="query" resultType="net.lab1024.smartadmin.service.module.support.reload.domain.ReloadResultVO">
|
||||
SELECT tag, identification, args, result, exception, create_time FROM t_reload_result where tag = #{tag}
|
||||
</select>
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user