You've already forked FrameTour-BE
添加“device”相关CRUD代码
This commit is contained in:
@ -16,5 +16,5 @@ public interface BrokerMapper {
|
|||||||
int add(BrokerEntity broker);
|
int add(BrokerEntity broker);
|
||||||
int deleteById(Long id);
|
int deleteById(Long id);
|
||||||
int update(BrokerEntity broker);
|
int update(BrokerEntity broker);
|
||||||
int updateStatus();
|
int updateStatus(Long id);
|
||||||
}
|
}
|
||||||
|
23
src/main/java/com/ycwl/basic/mapper/pc/DeviceMapper.java
Normal file
23
src/main/java/com/ycwl/basic/mapper/pc/DeviceMapper.java
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
package com.ycwl.basic.mapper.pc;
|
||||||
|
|
||||||
|
import com.ycwl.basic.model.pc.broker.entity.BrokerEntity;
|
||||||
|
import com.ycwl.basic.model.pc.broker.req.BrokerReqQuery;
|
||||||
|
import com.ycwl.basic.model.pc.device.entity.DeviceEntity;
|
||||||
|
import com.ycwl.basic.model.pc.device.req.DeviceReqQuery;
|
||||||
|
import com.ycwl.basic.model.pc.device.resp.DeviceRespVO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:longbinbin
|
||||||
|
* @Date:2024/11/29 14:48
|
||||||
|
* device(设备管理)
|
||||||
|
*/
|
||||||
|
public interface DeviceMapper {
|
||||||
|
List<DeviceRespVO> list(DeviceReqQuery deviceReqQuery);
|
||||||
|
DeviceRespVO getById(Long id);
|
||||||
|
int add(DeviceEntity device);
|
||||||
|
int deleteById(Long id);
|
||||||
|
int update(DeviceEntity device);
|
||||||
|
int updateStatus(Long id);
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
package com.ycwl.basic.model.pc.device.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:longbinbin
|
||||||
|
* @Date:2024/11/29 14:50
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("device")
|
||||||
|
public class DeviceEntity {
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 景区id
|
||||||
|
*/
|
||||||
|
private Long scenicId;
|
||||||
|
/**
|
||||||
|
* 设备名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
/**
|
||||||
|
* 设备编号
|
||||||
|
*/
|
||||||
|
private String no;
|
||||||
|
/**
|
||||||
|
* 是否启用,0不启用,1启用
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
|
/**
|
||||||
|
* 是否在线,0不在线,1在线
|
||||||
|
*/
|
||||||
|
private Integer online;
|
||||||
|
private Date createAt;
|
||||||
|
private Date updateAt;
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
package com.ycwl.basic.model.pc.device.req;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:longbinbin
|
||||||
|
* @Date:2024/11/29 14:53
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ApiModel("设备查询参数")
|
||||||
|
public class DeviceReqQuery {
|
||||||
|
@ApiModelProperty("景区id")
|
||||||
|
private Long scenicId;
|
||||||
|
@ApiModelProperty("设备名称")
|
||||||
|
private String name;
|
||||||
|
@ApiModelProperty("设备编号")
|
||||||
|
private String no;
|
||||||
|
@ApiModelProperty("是否启用,0不启用,1启用")
|
||||||
|
private Integer status;
|
||||||
|
@ApiModelProperty("是否在线,0不在线,1在线")
|
||||||
|
private Integer online;
|
||||||
|
private Date startTime;
|
||||||
|
private Date endTime;
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package com.ycwl.basic.model.pc.device.resp;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:longbinbin
|
||||||
|
* @Date:2024/11/29 14:58
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ApiModel("设备列表响应参数")
|
||||||
|
public class DeviceRespVO {
|
||||||
|
private Long id;
|
||||||
|
@ApiModelProperty("景区id")
|
||||||
|
private Long scenicId;
|
||||||
|
@ApiModelProperty("设备名称")
|
||||||
|
private String name;
|
||||||
|
@ApiModelProperty("设备编号")
|
||||||
|
private String no;
|
||||||
|
@ApiModelProperty("是否启用,0不启用,1启用")
|
||||||
|
private Integer status;
|
||||||
|
@ApiModelProperty("是否在线,0不在线,1在线")
|
||||||
|
private Integer online;
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date createAt;
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date updateAt;
|
||||||
|
@ApiModelProperty("景区名称")
|
||||||
|
private String scenicName;
|
||||||
|
}
|
50
src/main/resources/mapper/pc/DeviceMapper.xml
Normal file
50
src/main/resources/mapper/pc/DeviceMapper.xml
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!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>
|
||||||
|
<update id="update">
|
||||||
|
update device set scenic_id = #{scenicId}, name = #{name}, no = #{no} where id = #{id}
|
||||||
|
</update>
|
||||||
|
<update id="updateStatus">
|
||||||
|
update device
|
||||||
|
set status = (CASE
|
||||||
|
status
|
||||||
|
WHEN 1 THEN
|
||||||
|
0
|
||||||
|
WHEN 0 THEN
|
||||||
|
1
|
||||||
|
ELSE null
|
||||||
|
END)
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
<delete id="deleteById">
|
||||||
|
delete from device where id = #{id}
|
||||||
|
</delete>
|
||||||
|
<select id="list" resultType="com.ycwl.basic.model.pc.device.resp.DeviceRespVO">
|
||||||
|
select d.id, scenic_id, d.name, no, d.status, create_at, d.update_at, s.name scenic_name
|
||||||
|
from device d
|
||||||
|
left join scenic s on d.scenic_id = s.id
|
||||||
|
<where>
|
||||||
|
<if test="name!= null and name!= ''">
|
||||||
|
and d.`name` like concat('%', #{name}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="no!= null and no!= ''">
|
||||||
|
and `no` like concat('%', #{no}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="status!= null">
|
||||||
|
and d.`status` = #{status}
|
||||||
|
</if>
|
||||||
|
<if test="scenicId!= null and scenicId!= ''">
|
||||||
|
and scenic_id = #{scenicId}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
<select id="getById" resultType="com.ycwl.basic.model.pc.device.resp.DeviceRespVO">
|
||||||
|
select d.id, scenic_id, d.name, no, d.status, create_at, d.update_at, s.name scenic_name
|
||||||
|
from device d
|
||||||
|
left join scenic s on d.scenic_id = s.id
|
||||||
|
where d.id = #{id}
|
||||||
|
</select>
|
||||||
|
</mapper>
|
Reference in New Issue
Block a user