Merge branch 'plp'
commit
1e26ada9ce
@ -0,0 +1,95 @@
|
||||
package cn.iocoder.yudao.module.mes.controller.admin.goview;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.goview.vo.*;
|
||||
import cn.iocoder.yudao.module.mes.dal.dataobject.goview.GoviewDO;
|
||||
import cn.iocoder.yudao.module.mes.service.goview.GoviewService;
|
||||
|
||||
@Tag(name = "管理后台 - 可视化大屏")
|
||||
@RestController
|
||||
@RequestMapping("/mes/goview")
|
||||
@Validated
|
||||
public class GoviewController {
|
||||
|
||||
@Resource
|
||||
private GoviewService goviewService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建可视化大屏")
|
||||
@PreAuthorize("@ss.hasPermission('mes:goview:create')")
|
||||
public CommonResult<Long> createGoview(@Valid @RequestBody GoviewSaveReqVO createReqVO) {
|
||||
return success(goviewService.createGoview(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新可视化大屏")
|
||||
@PreAuthorize("@ss.hasPermission('mes:goview:update')")
|
||||
public CommonResult<Boolean> updateGoview(@Valid @RequestBody GoviewSaveReqVO updateReqVO) {
|
||||
goviewService.updateGoview(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除可视化大屏")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('mes:goview:delete')")
|
||||
public CommonResult<Boolean> deleteGoview(@RequestParam("id") Long id) {
|
||||
goviewService.deleteGoview(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得可视化大屏")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('mes:goview:query')")
|
||||
public CommonResult<GoviewRespVO> getGoview(@RequestParam("id") Long id) {
|
||||
GoviewDO goview = goviewService.getGoview(id);
|
||||
return success(BeanUtils.toBean(goview, GoviewRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得可视化大屏分页")
|
||||
@PreAuthorize("@ss.hasPermission('mes:goview:query')")
|
||||
public CommonResult<PageResult<GoviewRespVO>> getGoviewPage(@Valid GoviewPageReqVO pageReqVO) {
|
||||
PageResult<GoviewDO> pageResult = goviewService.getGoviewPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, GoviewRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出可视化大屏 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('mes:goview:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportGoviewExcel(@Valid GoviewPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<GoviewDO> list = goviewService.getGoviewPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "可视化大屏.xls", "数据", GoviewRespVO.class,
|
||||
BeanUtils.toBean(list, GoviewRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
package cn.iocoder.yudao.module.mes.controller.admin.goview.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 可视化大屏分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class GoviewPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "名称", example = "赵六")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "备注", example = "你猜")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "启用状态")
|
||||
private Long state;
|
||||
|
||||
@Schema(description = "图片路径")
|
||||
private String indexImage;
|
||||
|
||||
@Schema(description = "路由路径")
|
||||
private String route;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
@Schema(description = "内容")
|
||||
private String content;
|
||||
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
package cn.iocoder.yudao.module.mes.controller.admin.goview.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 可视化大屏 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class GoviewRespVO {
|
||||
|
||||
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "11354")
|
||||
@ExcelProperty("ID")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "名称", example = "赵六")
|
||||
@ExcelProperty("名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "备注", example = "你猜")
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "启用状态")
|
||||
@ExcelProperty("启用状态")
|
||||
private Long state;
|
||||
|
||||
@Schema(description = "图片路径")
|
||||
@ExcelProperty("图片路径")
|
||||
private String indexImage;
|
||||
|
||||
@Schema(description = "路由路径")
|
||||
@ExcelProperty("路由路径")
|
||||
private String route;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "内容")
|
||||
@ExcelProperty("内容")
|
||||
private String content;
|
||||
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
package cn.iocoder.yudao.module.mes.controller.admin.goview.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 可视化大屏新增/修改 Request VO")
|
||||
@Data
|
||||
public class GoviewSaveReqVO {
|
||||
|
||||
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "11354")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "名称", example = "赵六")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "备注", example = "你猜")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "启用状态")
|
||||
private Long state;
|
||||
|
||||
@Schema(description = "图片路径")
|
||||
private String indexImage;
|
||||
|
||||
@Schema(description = "路由路径")
|
||||
private String route;
|
||||
|
||||
@Schema(description = "内容")
|
||||
private String content;
|
||||
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
package cn.iocoder.yudao.module.mes.dal.dataobject.goview;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 可视化大屏 DO
|
||||
*
|
||||
* @author 必硕科技
|
||||
*/
|
||||
@TableName("mes_goview")
|
||||
@KeySequence("mes_goview_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class GoviewDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
/**
|
||||
* 启用状态
|
||||
*/
|
||||
private Long state;
|
||||
/**
|
||||
* 图片路径
|
||||
*/
|
||||
private String indexImage;
|
||||
/**
|
||||
* 路由路径
|
||||
*/
|
||||
private String route;
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
private String content;
|
||||
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
package cn.iocoder.yudao.module.mes.dal.mysql.goview;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.mes.dal.dataobject.goview.GoviewDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.goview.vo.*;
|
||||
|
||||
/**
|
||||
* 可视化大屏 Mapper
|
||||
*
|
||||
* @author 必硕科技
|
||||
*/
|
||||
@Mapper
|
||||
public interface GoviewMapper extends BaseMapperX<GoviewDO> {
|
||||
|
||||
default PageResult<GoviewDO> selectPage(GoviewPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<GoviewDO>()
|
||||
.likeIfPresent(GoviewDO::getName, reqVO.getName())
|
||||
.eqIfPresent(GoviewDO::getRemark, reqVO.getRemark())
|
||||
.eqIfPresent(GoviewDO::getState, reqVO.getState())
|
||||
.eqIfPresent(GoviewDO::getIndexImage, reqVO.getIndexImage())
|
||||
.eqIfPresent(GoviewDO::getRoute, reqVO.getRoute())
|
||||
.betweenIfPresent(GoviewDO::getCreateTime, reqVO.getCreateTime())
|
||||
.eqIfPresent(GoviewDO::getContent, reqVO.getContent())
|
||||
.orderByDesc(GoviewDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
package cn.iocoder.yudao.module.mes.service.goview;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.goview.vo.*;
|
||||
import cn.iocoder.yudao.module.mes.dal.dataobject.goview.GoviewDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
|
||||
/**
|
||||
* 可视化大屏 Service 接口
|
||||
*
|
||||
* @author 必硕科技
|
||||
*/
|
||||
public interface GoviewService {
|
||||
|
||||
/**
|
||||
* 创建可视化大屏
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createGoview(@Valid GoviewSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新可视化大屏
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateGoview(@Valid GoviewSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除可视化大屏
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteGoview(Long id);
|
||||
|
||||
/**
|
||||
* 获得可视化大屏
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 可视化大屏
|
||||
*/
|
||||
GoviewDO getGoview(Long id);
|
||||
|
||||
/**
|
||||
* 获得可视化大屏分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 可视化大屏分页
|
||||
*/
|
||||
PageResult<GoviewDO> getGoviewPage(GoviewPageReqVO pageReqVO);
|
||||
|
||||
}
|
||||
@ -0,0 +1,74 @@
|
||||
package cn.iocoder.yudao.module.mes.service.goview;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.goview.vo.*;
|
||||
import cn.iocoder.yudao.module.mes.dal.dataobject.goview.GoviewDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import cn.iocoder.yudao.module.mes.dal.mysql.goview.GoviewMapper;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 可视化大屏 Service 实现类
|
||||
*
|
||||
* @author 必硕科技
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class GoviewServiceImpl implements GoviewService {
|
||||
|
||||
@Resource
|
||||
private GoviewMapper goviewMapper;
|
||||
|
||||
@Override
|
||||
public Long createGoview(GoviewSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
GoviewDO goview = BeanUtils.toBean(createReqVO, GoviewDO.class);
|
||||
goviewMapper.insert(goview);
|
||||
// 返回
|
||||
return goview.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateGoview(GoviewSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateGoviewExists(updateReqVO.getId());
|
||||
// 更新
|
||||
GoviewDO updateObj = BeanUtils.toBean(updateReqVO, GoviewDO.class);
|
||||
goviewMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteGoview(Long id) {
|
||||
// 校验存在
|
||||
validateGoviewExists(id);
|
||||
// 删除
|
||||
goviewMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateGoviewExists(Long id) {
|
||||
if (goviewMapper.selectById(id) == null) {
|
||||
throw exception(GOVIEW_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public GoviewDO getGoview(Long id) {
|
||||
return goviewMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<GoviewDO> getGoviewPage(GoviewPageReqVO pageReqVO) {
|
||||
return goviewMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue