Commit dd50eab5 authored by 马33's avatar 马33

设备列表增加SN搜索条件

parent 166dc5af
......@@ -78,20 +78,22 @@ public class DeviceController {
*/
@ApiOperation(value = "获取设备列表接口", notes = "用于获取设备列表")
@GetMapping("list")
@MyLog(title = "获取设备列表", optParam = "#{pageNo},#{pageSize},#{appName},#{userName},#{status}", businessType = BusinessType.SELECT)
@MyLog(title = "获取设备列表", optParam = "#{pageNo},#{pageSize},#{appName},#{userName},#{sn},#{status}", businessType = BusinessType.SELECT)
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNo", value = "当前在第几页", required = true, dataType = "int"),
@ApiImplicitParam(name = "pageSize", value = "每页显示多少页", required = true, dataType = "int"),
@ApiImplicitParam(name = "appName", value = "应用名"),
@ApiImplicitParam(name = "userName", value = "用户名"),
@ApiImplicitParam(name = "sn", value = "设备编码"),
@ApiImplicitParam(name = "status", value = "状态", dataType = "int")
})
public PageResult<DeviceVo> getDeviceList(@RequestParam(value = "pageNo", defaultValue = "0") int pageNo,
@RequestParam(value = "pageSize", defaultValue = "0") int pageSize,
@RequestParam(value = "appName", required = false) String appName,
@RequestParam(value = "userName", required = false) String userName,
@RequestParam(value = "sn", required = false) String sn,
@RequestParam(value = "status", required = false) Integer status) {
PageInfoModel<DeviceVo> records = deviceService.getDeviceList(pageNo, pageSize, appName, userName, status);
PageInfoModel<DeviceVo> records = deviceService.getDeviceList(pageNo, pageSize, appName, userName, sn, status);
int total = records.getTotal();
int pages = total / pageSize;//pages为总页数
int mod = total % pageSize;
......
......@@ -13,7 +13,7 @@ import java.util.List;
* @since 2022-06-08
*/
public interface DeviceMapper extends BaseMapper<Device> {
List<DeviceVo> getDeviceList(String appName, String userName, Integer status);
List<DeviceVo> getDeviceList(String appName, String userName, String sn, Integer status);
boolean addDevice(String sn, String appId);
}
......@@ -13,7 +13,7 @@ import iot.sixiang.license.model.vo.DeviceVo;
* @since 2022-06-08
*/
public interface DeviceService extends IService<Device> {
PageInfoModel<DeviceVo> getDeviceList(int pageNo, int pageSize, String appName, String userName, Integer status);
PageInfoModel<DeviceVo> getDeviceList(int pageNo, int pageSize, String appName, String userName, String sn, Integer status);
boolean addDevice(String appId, int count);
......
......@@ -35,11 +35,11 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
private DeviceMapper deviceMapper;
@Override
public PageInfoModel<DeviceVo> getDeviceList(int pageNo, int pageSize, String appName, String userName, Integer status) {
public PageInfoModel<DeviceVo> getDeviceList(int pageNo, int pageSize, String appName, String userName, String sn, Integer status) {
if (pageNo == 0 || pageSize == 0) {
throw new IotLicenseException(ResultCode.VALIDATE_FAILED.getCode(), ResultCode.VALIDATE_FAILED.getMsg());
}
List<DeviceVo> deviceTypes = deviceMapper.getDeviceList(appName, userName, status);
List<DeviceVo> deviceTypes = deviceMapper.getDeviceList(appName, userName, sn, status);
deviceTypes = deviceTypes.stream().sorted(Comparator.comparing(DeviceVo::getCreateTime, Comparator.reverseOrder())).collect(Collectors.toList());
List<DeviceVo> result = new ArrayList<>();
int begin = (pageNo - 1) * pageSize;
......
......@@ -14,6 +14,9 @@
<if test="null != userName and '' != userName">
and user_name like concat('%',#{userName},'%')
</if>
<if test="null != sn and '' != sn">
and sn like concat('%',#{sn},'%')
</if>
<if test="null != status">
and status = #{status}
</if>
......
......@@ -5,7 +5,7 @@
SELECT * FROM pms_use_log
where 1=1
<if test="null != sn and '' != sn">
and sn = #{sn}
and sn like concat('%',#{sn},'%')
</if>
<if test="null != status">
and status = #{status}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment