mirror of
https://gitee.com/iteaj/iboot.git
synced 2026-08-30 17:20:20 +08:00
完善大屏功能
This commit is contained in:
+2
-3
@@ -3,7 +3,7 @@ INSERT INTO `sys_menu` VALUES (1480,'产品数据',1421,88,'/iot/collectData/pro
|
||||
|
||||
# 2025-06-04
|
||||
create table isv_project (
|
||||
id bigint auto_increment,
|
||||
id char(36),
|
||||
project_name varchar(64) null comment '项目名称',
|
||||
state int null comment '状态',
|
||||
index_image varchar(256) null comment '项目封面',
|
||||
@@ -11,6 +11,5 @@ create table isv_project (
|
||||
is_delete int null comment '是否删除',
|
||||
content json null comment '项目内容',
|
||||
create_time datetime default now() not null comment '创建时间',
|
||||
constraint isv_project_pk
|
||||
primary key (id)
|
||||
constraint isv_project_pk primary key (id)
|
||||
) comment '大屏项目';
|
||||
@@ -98,8 +98,8 @@ public class LocalUploadService implements UploadService, InitializingBean {
|
||||
uploadRootUri = uploadRootUri.replaceAll("\\*", "");
|
||||
}
|
||||
|
||||
if(uploadRootUri.endsWith(File.separator)) {
|
||||
this.uploadRootUri = uploadRootUri.substring(0, uploadRootUri.length()-1);
|
||||
if(uploadRootUri.endsWith("/")) {
|
||||
uploadRootUri = uploadRootUri.substring(0, uploadRootUri.length()-1);
|
||||
}
|
||||
|
||||
this.uploadRootUri = uploadRootUri;
|
||||
|
||||
+3
-14
@@ -1,13 +1,9 @@
|
||||
package com.iteaj.iboot.plugin.iotview;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.iteaj.framework.result.AbstractResult;
|
||||
import com.iteaj.framework.result.HttpResult;
|
||||
import com.iteaj.framework.result.PageResult;
|
||||
import com.iteaj.framework.result.Result;
|
||||
import com.iteaj.iboot.plugin.iotview.entity.Project;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
@@ -17,7 +13,9 @@ import lombok.experimental.Accessors;
|
||||
@Accessors(chain = true)
|
||||
public class IotViewResult extends AbstractResult {
|
||||
|
||||
private long count;
|
||||
public IotViewResult(Result result) {
|
||||
this(result.getData(), result.getMessage(), result.getCode());
|
||||
}
|
||||
|
||||
protected IotViewResult(String message, long code) {
|
||||
super(message, code);
|
||||
@@ -27,15 +25,6 @@ public class IotViewResult extends AbstractResult {
|
||||
super(data, message, code);
|
||||
}
|
||||
|
||||
public static <T> Result<T> build(Result<T> result) {
|
||||
if(result instanceof PageResult) {
|
||||
final Page data = (Page)((PageResult) result).getData();
|
||||
return new IotViewResult(data.getRecords(), result.getMessage(), result.getCode())
|
||||
.setCount(data.getTotal());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return getMessage();
|
||||
}
|
||||
|
||||
+54
-8
@@ -1,9 +1,11 @@
|
||||
package com.iteaj.iboot.plugin.iotview.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import com.iteaj.framework.logger.Logger;
|
||||
import com.iteaj.framework.result.Result;
|
||||
import com.iteaj.framework.security.Logical;
|
||||
import com.iteaj.framework.spi.file.UploadResult;
|
||||
import com.iteaj.framework.spi.file.UploadService;
|
||||
import com.iteaj.iboot.plugin.iotview.IotViewResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.iteaj.framework.security.CheckPermission;
|
||||
@@ -12,6 +14,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.iteaj.iboot.plugin.iotview.entity.Project;
|
||||
import com.iteaj.iboot.plugin.iotview.service.IProjectService;
|
||||
import com.iteaj.framework.BaseController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* 大屏项目管理
|
||||
@@ -22,9 +25,11 @@ import com.iteaj.framework.BaseController;
|
||||
@RequestMapping("/isv/project")
|
||||
public class ProjectController extends BaseController {
|
||||
|
||||
private final UploadService uploadService;
|
||||
private final IProjectService projectService;
|
||||
|
||||
public ProjectController(IProjectService projectService) {
|
||||
public ProjectController(UploadService uploadService, IProjectService projectService) {
|
||||
this.uploadService = uploadService;
|
||||
this.projectService = projectService;
|
||||
}
|
||||
|
||||
@@ -37,7 +42,7 @@ public class ProjectController extends BaseController {
|
||||
@Logger("浏览大屏项目功能")
|
||||
@CheckPermission({"isv:project:view"})
|
||||
public Result<IPage<Project>> list(Page<Project> page, Project entity) {
|
||||
return IotViewResult.build(this.projectService.page(page, entity));
|
||||
return new IotViewResult(this.projectService.page(page, entity));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,14 +56,36 @@ public class ProjectController extends BaseController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增或者更新记录
|
||||
* 创建项目
|
||||
* @param entity
|
||||
*/
|
||||
@PostMapping("/create")
|
||||
@Logger("创建大屏项目")
|
||||
@CheckPermission(value = {"isv:project:add"})
|
||||
public Result<Boolean> create(@RequestBody Project entity) {
|
||||
return new IotViewResult(this.projectService.save(entity));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新大屏记录
|
||||
* @param entity
|
||||
*/
|
||||
@PostMapping("/saveOrUpdate")
|
||||
@PostMapping("/edit")
|
||||
@Logger("新增或者更新大屏项目记录")
|
||||
@CheckPermission(value = {"isv:project:edit", "isv:project:add"}, logical = Logical.OR)
|
||||
public Result<Boolean> saveOrUpdate(@RequestBody Project entity) {
|
||||
return this.projectService.saveOrUpdate(entity);
|
||||
@CheckPermission(value = {"isv:project:edit"})
|
||||
public Result<Boolean> edit(@RequestBody Project entity) {
|
||||
return new IotViewResult(this.projectService.updateById(entity));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取大屏详情记录
|
||||
* @param projectId
|
||||
*/
|
||||
@GetMapping("/getData")
|
||||
@Logger("新增或者更新大屏项目记录")
|
||||
public Result<Project> detail(String projectId) {
|
||||
return new IotViewResult(this.projectService.getById(projectId));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,5 +98,24 @@ public class ProjectController extends BaseController {
|
||||
public Result<Boolean> remove(@RequestBody List<Long> idList) {
|
||||
return this.projectService.removeByIds(idList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传大屏略缩图
|
||||
* @param id
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("upload")
|
||||
public Result<String> upload(String id, MultipartFile file) {
|
||||
try {
|
||||
final UploadResult isv = uploadService.upload(file.getInputStream(), file.getOriginalFilename(), id, "/isv");
|
||||
final Project project = new Project().setIndexImage(isv.getUrl());
|
||||
project.setId(id);
|
||||
projectService.updateById(project);
|
||||
return IotViewResult.Success(isv.getUrl());
|
||||
} catch (IOException e) {
|
||||
return IotViewResult.Fail("上传失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+12
-6
@@ -1,12 +1,14 @@
|
||||
package com.iteaj.iboot.plugin.iotview.entity;
|
||||
|
||||
import com.iteaj.framework.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.util.Date;
|
||||
import com.iteaj.framework.Entity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 大屏项目
|
||||
@@ -16,13 +18,15 @@ import lombok.experimental.Accessors;
|
||||
* @since 2025-06-04
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
@TableName("isv_project")
|
||||
public class Project extends BaseEntity {
|
||||
public class Project implements Entity<String> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.ASSIGN_UUID)
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 项目名称
|
||||
*/
|
||||
@@ -58,5 +62,7 @@ public class Project extends BaseEntity {
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
|
||||
+18
@@ -1,5 +1,7 @@
|
||||
package com.iteaj.iboot.plugin.iotview.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.iteaj.framework.result.BooleanResult;
|
||||
import com.iteaj.iboot.plugin.iotview.entity.Project;
|
||||
import com.iteaj.iboot.plugin.iotview.mapper.ProjectMapper;
|
||||
import com.iteaj.iboot.plugin.iotview.service.IProjectService;
|
||||
@@ -17,4 +19,20 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class ProjectServiceImpl extends BaseServiceImpl<ProjectMapper, Project> implements IProjectService {
|
||||
|
||||
@Override
|
||||
public BooleanResult save(Project entity) {
|
||||
entity.setState(-1);
|
||||
this.getOne(Wrappers.<Project>lambdaQuery().eq(Project::getProjectName, entity.getProjectName()))
|
||||
.ifPresentThrow("项目名称已经存在");
|
||||
return super.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BooleanResult updateById(Project entity) {
|
||||
this.getOne(Wrappers.<Project>lambdaQuery()
|
||||
.eq(Project::getId, entity.getId())
|
||||
.eq(Project::getProjectName, entity.getProjectName()))
|
||||
.ifPresentThrow("项目名称已经存在");
|
||||
return super.updateById(entity);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user