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 {
|
||||
|
@ -2,10 +2,10 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ycwl.basic.mapper.pc.DeviceMapper">
|
||||
<insert id="add">
|
||||
insert into device(id, scenic_id, name, no) values (#{id}, #{scenicId}, #{name}, #{no})
|
||||
insert into device(id, scenic_id, name, no, latitude, longitude) values (#{id}, #{scenicId}, #{name}, #{no}, #{latitude}, #{longitude})
|
||||
</insert>
|
||||
<update id="update">
|
||||
update device set scenic_id = #{scenicId}, name = #{name}, no = #{no} where id = #{id}
|
||||
update device set scenic_id = #{scenicId}, name = #{name}, no = #{no}, longitude = #{longitude}, latitude = #{latitude}, update_at = now() where id = #{id}
|
||||
</update>
|
||||
<update id="updateStatus">
|
||||
update device
|
||||
|
@ -2,13 +2,14 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ycwl.basic.mapper.pc.TemplateMapper">
|
||||
<insert id="add">
|
||||
insert into template(id, `name`, pid, is_placeholder, source_url, luts, overlays, audios, frame_rate, speed)
|
||||
values (#{id}, #{name}, #{pid}, #{isPlaceholder}, #{sourceUrl}, #{luts}, #{overlays}, #{audios}, #{frameRate}, #{speed})
|
||||
insert into template(id, scenic_id, `name`, pid, is_placeholder, source_url, luts, overlays, audios, cover_url, frame_rate, speed, price)
|
||||
values (#{id}, #{scenicId}, #{name}, #{pid}, #{isPlaceholder}, #{sourceUrl}, #{luts}, #{overlays}, #{audios}, #{coverUrl}, #{frameRate}, #{speed}, #{price})
|
||||
</insert>
|
||||
<update id="update">
|
||||
update template
|
||||
<set>
|
||||
<if test="name!= null">`name` = #{name}, </if>
|
||||
<if test="scenicId!= null">`scenic_id` = #{scenicId}, </if>
|
||||
<if test="pid!= null">pid = #{pid}, </if>
|
||||
<if test="isPlaceholder!= null">is_placeholder = #{isPlaceholder}, </if>
|
||||
<if test="sourceUrl!= null">source_url = #{sourceUrl}, </if>
|
||||
@ -16,6 +17,8 @@
|
||||
<if test="overlays!= null">overlays = #{overlays}, </if>
|
||||
<if test="audios!= null">audios = #{audios}, </if>
|
||||
<if test="frameRate!= null">frame_rate = #{frameRate}, </if>
|
||||
<if test="coverUrl!= null">cover_url = #{coverUrl}, </if>
|
||||
<if test="price!= null">price = #{price}, </if>
|
||||
<if test="speed!= null">speed = #{speed}, </if>
|
||||
</set>
|
||||
where id = #{id}
|
||||
@ -35,21 +38,32 @@
|
||||
<delete id="deleteById">
|
||||
delete from template where id = #{id}
|
||||
</delete>
|
||||
<delete id="deleteByPid">
|
||||
delete from template where pid = #{id}
|
||||
</delete>
|
||||
<delete id="deleteByScenicId">
|
||||
delete from template where scenic_id = #{id}
|
||||
</delete>
|
||||
<select id="list" resultType="com.ycwl.basic.model.pc.template.resp.TemplateRespVO">
|
||||
select id, `name`, pid, is_placeholder, source_url, luts, overlays, audios, frame_rate, speed, status, create_time, update_time
|
||||
from template
|
||||
select t.id, t.scenic_id, s.name as scenic_name, t.`name`, pid, is_placeholder, source_url, luts, overlays, audios, frame_rate, speed, cover_url, t.status, t.create_time, t.update_time
|
||||
from template t left join scenic s on s.id = t.scenic_id
|
||||
<where>
|
||||
<if test="name!= null">and locate(#{name},`name`) > 0 </if>
|
||||
<if test="pid!= null">and pid = #{pid} </if>
|
||||
pid = 0
|
||||
<if test="name!= null">and locate(#{name},t.`name`) > 0 </if>
|
||||
<if test="isPlaceholder!= null">and is_placeholder = #{isPlaceholder} </if>
|
||||
<if test="status!= null">and `status` = #{status} </if>
|
||||
<if test="startTime!= null">and create_time >= #{startTime} </if>
|
||||
<if test="endTime!= null">and create_time <= #{endTime} </if>
|
||||
<if test="status!= null">and t.`status` = #{status} </if>
|
||||
<if test="startTime!= null">and t.create_time >= #{startTime} </if>
|
||||
<if test="endTime!= null">and t.create_time <= #{endTime} </if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="getById" resultType="com.ycwl.basic.model.pc.template.resp.TemplateRespVO">
|
||||
select id, `name`, pid, is_placeholder, source_url, luts, overlays, audios, frame_rate, speed, status, create_time, update_time
|
||||
from template
|
||||
where id = #{id}
|
||||
select t.id, t.scenic_id, s.name as scenic_name, t.`name`, pid, is_placeholder, source_url, luts, overlays, audios, frame_rate, speed, cover_url, t.status, t.create_time, t.update_time
|
||||
from template t left join scenic s on s.id = t.scenic_id
|
||||
where t.id = #{id}
|
||||
</select>
|
||||
<select id="getByPid" resultType="com.ycwl.basic.model.pc.template.resp.TemplateRespVO">
|
||||
select t.id, t.scenic_id, s.name as scenic_name, t.`name`, pid, is_placeholder, source_url, luts, overlays, audios, frame_rate, speed, cover_url, t.status, t.create_time, t.update_time
|
||||
from template t left join scenic s on s.id = t.scenic_id
|
||||
where pid = #{id}
|
||||
</select>
|
||||
</mapper>
|
Reference in New Issue
Block a user