后台模板接口及设备接口

This commit is contained in:
2024-12-06 14:07:09 +08:00
parent cda0599d58
commit 18b1776ac2
9 changed files with 94 additions and 19 deletions

View File

@ -23,5 +23,7 @@ public interface TemplateMapper {
int deleteById(Long id); int deleteById(Long id);
int update(TemplateEntity task); int update(TemplateEntity task);
int updateStatus(Long id); int updateStatus(Long id);
int deleteByPid(Long pid);
int deleteByScenicId(Long scenicId);
List<TemplateRespVO> getByPid(Long id);
} }

View File

@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
/** /**
@ -21,6 +22,16 @@ public class DeviceAddOrUpdateReq {
private String name; private String name;
@ApiModelProperty("设备编号") @ApiModelProperty("设备编号")
private String no; private String no;
/**
* 经度
*/
@ApiModelProperty("经度")
private BigDecimal longitude;
/***
* 纬度
*/
@ApiModelProperty("纬度")
private BigDecimal latitude;
@ApiModelProperty("是否启用0不启用1启用") @ApiModelProperty("是否启用0不启用1启用")
private Integer status; private Integer status;
@ApiModelProperty("是否在线0不在线1在线") @ApiModelProperty("是否在线0不在线1在线")

View File

@ -6,6 +6,7 @@ import lombok.Data;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
* @Authorlongbinbin * @Authorlongbinbin
@ -17,6 +18,10 @@ import java.util.Date;
public class TemplateEntity { public class TemplateEntity {
@TableId @TableId
private Long id; private Long id;
/**
* 景区ID
*/
private Long scenicId;
/** /**
* 模版名称 * 模版名称
*/ */
@ -24,7 +29,7 @@ public class TemplateEntity {
/** /**
* 父模版ID * 父模版ID
*/ */
private Long pId; private Long pid;
/** /**
* 是否是占位素材0不是1是 * 是否是占位素材0不是1是
*/ */
@ -51,14 +56,20 @@ public class TemplateEntity {
* 帧率 * 帧率
*/ */
private Integer frameRate; private Integer frameRate;
private String coverUrl;
/** /**
* 倍速默认1 * 倍速默认1
*/ */
private BigDecimal speed; private BigDecimal speed;
/**
* 价格,单位元
*/
private BigDecimal price;
/** /**
* 是否启用0不是1是 * 是否启用0不是1是
*/ */
private Integer status; private Integer status;
private Date createTime; private Date createTime;
private Date updateTime; private Date updateTime;
private List<TemplateEntity> children;
} }

View File

@ -28,7 +28,7 @@ public class TemplateReqQuery extends BaseQueryParameterReq {
* 父模版ID * 父模版ID
*/ */
@ApiModelProperty("父模版ID") @ApiModelProperty("父模版ID")
private Long pId; private Long pid;
/** /**
* 是否是占位素材0不是1是 * 是否是占位素材0不是1是
*/ */

View File

@ -8,6 +8,7 @@ import lombok.Data;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
* @Authorlongbinbin * @Authorlongbinbin
@ -18,6 +19,9 @@ import java.util.Date;
@ApiModel("模版响应数据类") @ApiModel("模版响应数据类")
public class TemplateRespVO { public class TemplateRespVO {
private Long id; private Long id;
private Long scenicId;
@ApiModelProperty("景区名称")
private String scenicName;
/** /**
* 模版名称 * 模版名称
*/ */
@ -27,7 +31,7 @@ public class TemplateRespVO {
* 父模版ID * 父模版ID
*/ */
@ApiModelProperty("父模版ID") @ApiModelProperty("父模版ID")
private Long pId; private Long pid;
/** /**
* 是否是占位素材0不是1是 * 是否是占位素材0不是1是
*/ */
@ -65,6 +69,11 @@ public class TemplateRespVO {
*/ */
@ApiModelProperty("倍速默认1") @ApiModelProperty("倍速默认1")
private BigDecimal speed; private BigDecimal speed;
/**
* 封面
*/
@ApiModelProperty("封面")
private String coverUrl;
/** /**
* 是否启用0不是1是 * 是否启用0不是1是
*/ */
@ -74,4 +83,5 @@ public class TemplateRespVO {
private Date createTime; private Date createTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime; private Date updateTime;
private List<TemplateRespVO> children;
} }

View File

@ -9,6 +9,7 @@ import com.ycwl.basic.model.pc.device.resp.DeviceRespVO;
import com.ycwl.basic.service.pc.DeviceService; import com.ycwl.basic.service.pc.DeviceService;
import com.ycwl.basic.utils.ApiResponse; import com.ycwl.basic.utils.ApiResponse;
import com.ycwl.basic.utils.SnowFlakeUtil; import com.ycwl.basic.utils.SnowFlakeUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -45,6 +46,10 @@ public class DeviceServiceImpl implements DeviceService {
Long id = deviceReqQuery.getId(); Long id = deviceReqQuery.getId();
if (id == null) { if (id == null) {
deviceReqQuery.setId(SnowFlakeUtil.getLongId()); deviceReqQuery.setId(SnowFlakeUtil.getLongId());
if (StringUtils.isBlank(deviceReqQuery.getNo())) {
deviceReqQuery.setNo(deviceReqQuery.getId().toString());
}
deviceReqQuery.setStatus(0);
return ApiResponse.success(deviceMapper.add(deviceReqQuery)); return ApiResponse.success(deviceMapper.add(deviceReqQuery));
} else { } else {
return ApiResponse.success(deviceMapper.update(deviceReqQuery)); return ApiResponse.success(deviceMapper.update(deviceReqQuery));

View File

@ -39,13 +39,24 @@ public class TemplateServiceImpl implements TemplateService {
@Override @Override
public ApiResponse<TemplateRespVO> getById(Long id) { 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 @Override
public ApiResponse<Boolean> add(TemplateEntity template) { public ApiResponse<Boolean> add(TemplateEntity template) {
template.setId(SnowFlakeUtil.getLongId()); template.setId(SnowFlakeUtil.getLongId());
int i = templateMapper.add(template); 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) { if (i > 0) {
return ApiResponse.success(true); return ApiResponse.success(true);
}else { }else {
@ -57,6 +68,7 @@ public class TemplateServiceImpl implements TemplateService {
public ApiResponse<Integer> deleteById(Long id) { public ApiResponse<Integer> deleteById(Long id) {
int i = templateMapper.deleteById(id); int i = templateMapper.deleteById(id);
if (i > 0) { if (i > 0) {
templateMapper.deleteByPid(id);
return ApiResponse.success(i); return ApiResponse.success(i);
}else { }else {
return ApiResponse.fail("删除模版失败"); return ApiResponse.fail("删除模版失败");
@ -66,6 +78,16 @@ public class TemplateServiceImpl implements TemplateService {
@Override @Override
public ApiResponse<Boolean> update(TemplateEntity template) { public ApiResponse<Boolean> update(TemplateEntity template) {
int i = templateMapper.update(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) { if (i > 0) {
return ApiResponse.success(true); return ApiResponse.success(true);
}else { }else {

View File

@ -2,10 +2,10 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!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"> <mapper namespace="com.ycwl.basic.mapper.pc.DeviceMapper">
<insert id="add"> <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> </insert>
<update id="update"> <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>
<update id="updateStatus"> <update id="updateStatus">
update device update device

View File

@ -2,13 +2,14 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!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"> <mapper namespace="com.ycwl.basic.mapper.pc.TemplateMapper">
<insert id="add"> <insert id="add">
insert into template(id, `name`, pid, is_placeholder, source_url, luts, overlays, audios, frame_rate, speed) insert into template(id, scenic_id, `name`, pid, is_placeholder, source_url, luts, overlays, audios, cover_url, frame_rate, speed, price)
values (#{id}, #{name}, #{pid}, #{isPlaceholder}, #{sourceUrl}, #{luts}, #{overlays}, #{audios}, #{frameRate}, #{speed}) values (#{id}, #{scenicId}, #{name}, #{pid}, #{isPlaceholder}, #{sourceUrl}, #{luts}, #{overlays}, #{audios}, #{coverUrl}, #{frameRate}, #{speed}, #{price})
</insert> </insert>
<update id="update"> <update id="update">
update template update template
<set> <set>
<if test="name!= null">`name` = #{name}, </if> <if test="name!= null">`name` = #{name}, </if>
<if test="scenicId!= null">`scenic_id` = #{scenicId}, </if>
<if test="pid!= null">pid = #{pid}, </if> <if test="pid!= null">pid = #{pid}, </if>
<if test="isPlaceholder!= null">is_placeholder = #{isPlaceholder}, </if> <if test="isPlaceholder!= null">is_placeholder = #{isPlaceholder}, </if>
<if test="sourceUrl!= null">source_url = #{sourceUrl}, </if> <if test="sourceUrl!= null">source_url = #{sourceUrl}, </if>
@ -16,6 +17,8 @@
<if test="overlays!= null">overlays = #{overlays}, </if> <if test="overlays!= null">overlays = #{overlays}, </if>
<if test="audios!= null">audios = #{audios}, </if> <if test="audios!= null">audios = #{audios}, </if>
<if test="frameRate!= null">frame_rate = #{frameRate}, </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> <if test="speed!= null">speed = #{speed}, </if>
</set> </set>
where id = #{id} where id = #{id}
@ -35,21 +38,32 @@
<delete id="deleteById"> <delete id="deleteById">
delete from template where id = #{id} delete from template where id = #{id}
</delete> </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="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 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 from template t left join scenic s on s.id = t.scenic_id
<where> <where>
<if test="name!= null">and locate(#{name},`name`) > 0 </if> pid = 0
<if test="pid!= null">and pid = #{pid} </if> <if test="name!= null">and locate(#{name},t.`name`) > 0 </if>
<if test="isPlaceholder!= null">and is_placeholder = #{isPlaceholder} </if> <if test="isPlaceholder!= null">and is_placeholder = #{isPlaceholder} </if>
<if test="status!= null">and `status` = #{status} </if> <if test="status!= null">and t.`status` = #{status} </if>
<if test="startTime!= null">and create_time &gt;= #{startTime} </if> <if test="startTime!= null">and t.create_time &gt;= #{startTime} </if>
<if test="endTime!= null">and create_time &lt;= #{endTime} </if> <if test="endTime!= null">and t.create_time &lt;= #{endTime} </if>
</where> </where>
</select> </select>
<select id="getById" resultType="com.ycwl.basic.model.pc.template.resp.TemplateRespVO"> <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 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 from template t left join scenic s on s.id = t.scenic_id
where id = #{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> </select>
</mapper> </mapper>