You've already forked FrameTour-BE
后台模板接口及设备接口
This commit is contained in:
@ -23,5 +23,7 @@ public interface TemplateMapper {
|
||||
int deleteById(Long id);
|
||||
int update(TemplateEntity task);
|
||||
int updateStatus(Long id);
|
||||
|
||||
int deleteByPid(Long pid);
|
||||
int deleteByScenicId(Long scenicId);
|
||||
List<TemplateRespVO> getByPid(Long id);
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
@ -21,6 +22,16 @@ public class DeviceAddOrUpdateReq {
|
||||
private String name;
|
||||
@ApiModelProperty("设备编号")
|
||||
private String no;
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
@ApiModelProperty("经度")
|
||||
private BigDecimal longitude;
|
||||
/***
|
||||
* 纬度
|
||||
*/
|
||||
@ApiModelProperty("纬度")
|
||||
private BigDecimal latitude;
|
||||
@ApiModelProperty("是否启用,0不启用,1启用")
|
||||
private Integer status;
|
||||
@ApiModelProperty("是否在线,0不在线,1在线")
|
||||
|
@ -6,6 +6,7 @@ import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:longbinbin
|
||||
@ -17,6 +18,10 @@ import java.util.Date;
|
||||
public class TemplateEntity {
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 景区ID
|
||||
*/
|
||||
private Long scenicId;
|
||||
/**
|
||||
* 模版名称
|
||||
*/
|
||||
@ -24,7 +29,7 @@ public class TemplateEntity {
|
||||
/**
|
||||
* 父模版ID
|
||||
*/
|
||||
private Long pId;
|
||||
private Long pid;
|
||||
/**
|
||||
* 是否是占位素材,0不是,1是
|
||||
*/
|
||||
@ -51,14 +56,20 @@ public class TemplateEntity {
|
||||
* 帧率
|
||||
*/
|
||||
private Integer frameRate;
|
||||
private String coverUrl;
|
||||
/**
|
||||
* 倍速,默认1
|
||||
*/
|
||||
private BigDecimal speed;
|
||||
/**
|
||||
* 价格,单位元
|
||||
*/
|
||||
private BigDecimal price;
|
||||
/**
|
||||
* 是否启用,0不是,1是
|
||||
*/
|
||||
private Integer status;
|
||||
private Date createTime;
|
||||
private Date updateTime;
|
||||
private List<TemplateEntity> children;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public class TemplateReqQuery extends BaseQueryParameterReq {
|
||||
* 父模版ID
|
||||
*/
|
||||
@ApiModelProperty("父模版ID")
|
||||
private Long pId;
|
||||
private Long pid;
|
||||
/**
|
||||
* 是否是占位素材,0不是,1是
|
||||
*/
|
||||
|
@ -8,6 +8,7 @@ import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:longbinbin
|
||||
@ -18,6 +19,9 @@ import java.util.Date;
|
||||
@ApiModel("模版响应数据类")
|
||||
public class TemplateRespVO {
|
||||
private Long id;
|
||||
private Long scenicId;
|
||||
@ApiModelProperty("景区名称")
|
||||
private String scenicName;
|
||||
/**
|
||||
* 模版名称
|
||||
*/
|
||||
@ -27,7 +31,7 @@ public class TemplateRespVO {
|
||||
* 父模版ID
|
||||
*/
|
||||
@ApiModelProperty("父模版ID")
|
||||
private Long pId;
|
||||
private Long pid;
|
||||
/**
|
||||
* 是否是占位素材,0不是,1是
|
||||
*/
|
||||
@ -65,6 +69,11 @@ public class TemplateRespVO {
|
||||
*/
|
||||
@ApiModelProperty("倍速,默认1")
|
||||
private BigDecimal speed;
|
||||
/**
|
||||
* 封面
|
||||
*/
|
||||
@ApiModelProperty("封面")
|
||||
private String coverUrl;
|
||||
/**
|
||||
* 是否启用,0不是,1是
|
||||
*/
|
||||
@ -74,4 +83,5 @@ public class TemplateRespVO {
|
||||
private Date createTime;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date updateTime;
|
||||
private List<TemplateRespVO> children;
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import com.ycwl.basic.model.pc.device.resp.DeviceRespVO;
|
||||
import com.ycwl.basic.service.pc.DeviceService;
|
||||
import com.ycwl.basic.utils.ApiResponse;
|
||||
import com.ycwl.basic.utils.SnowFlakeUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -45,6 +46,10 @@ public class DeviceServiceImpl implements DeviceService {
|
||||
Long id = deviceReqQuery.getId();
|
||||
if (id == null) {
|
||||
deviceReqQuery.setId(SnowFlakeUtil.getLongId());
|
||||
if (StringUtils.isBlank(deviceReqQuery.getNo())) {
|
||||
deviceReqQuery.setNo(deviceReqQuery.getId().toString());
|
||||
}
|
||||
deviceReqQuery.setStatus(0);
|
||||
return ApiResponse.success(deviceMapper.add(deviceReqQuery));
|
||||
} else {
|
||||
return ApiResponse.success(deviceMapper.update(deviceReqQuery));
|
||||
|
@ -39,13 +39,24 @@ public class TemplateServiceImpl implements TemplateService {
|
||||
|
||||
@Override
|
||||
public ApiResponse<TemplateRespVO> getById(Long id) {
|
||||
return ApiResponse.success(templateMapper.getById(id));
|
||||
TemplateRespVO data = templateMapper.getById(id);
|
||||
data.setChildren(templateMapper.getByPid(id));
|
||||
return ApiResponse.success(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResponse<Boolean> add(TemplateEntity template) {
|
||||
template.setId(SnowFlakeUtil.getLongId());
|
||||
int i = templateMapper.add(template);
|
||||
if (template.getChildren() != null) {
|
||||
template.getChildren().forEach(item -> {
|
||||
item.setId(SnowFlakeUtil.getLongId());
|
||||
item.setPid(template.getId());
|
||||
item.setScenicId(template.getScenicId());
|
||||
item.setStatus(1);
|
||||
templateMapper.add(item);
|
||||
});
|
||||
}
|
||||
if (i > 0) {
|
||||
return ApiResponse.success(true);
|
||||
}else {
|
||||
@ -57,6 +68,7 @@ public class TemplateServiceImpl implements TemplateService {
|
||||
public ApiResponse<Integer> deleteById(Long id) {
|
||||
int i = templateMapper.deleteById(id);
|
||||
if (i > 0) {
|
||||
templateMapper.deleteByPid(id);
|
||||
return ApiResponse.success(i);
|
||||
}else {
|
||||
return ApiResponse.fail("删除模版失败");
|
||||
@ -66,6 +78,16 @@ public class TemplateServiceImpl implements TemplateService {
|
||||
@Override
|
||||
public ApiResponse<Boolean> update(TemplateEntity template) {
|
||||
int i = templateMapper.update(template);
|
||||
if (template.getChildren() != null) {
|
||||
templateMapper.deleteByPid(template.getId());
|
||||
template.getChildren().forEach(item -> {
|
||||
item.setId(SnowFlakeUtil.getLongId());
|
||||
item.setPid(template.getId());
|
||||
item.setScenicId(template.getScenicId());
|
||||
item.setStatus(1);
|
||||
templateMapper.add(item);
|
||||
});
|
||||
}
|
||||
if (i > 0) {
|
||||
return ApiResponse.success(true);
|
||||
}else {
|
||||
|
Reference in New Issue
Block a user