forked from dyf/fys-Multi-tenant
Compare commits
8 Commits
3250dd3f83
...
a109f187b9
Author | SHA1 | Date | |
---|---|---|---|
a109f187b9 | |||
b5ebc8855d | |||
99aef4b353 | |||
a423ac0f8b | |||
82b1494bc7 | |||
c3b7849190 | |||
33b718c048 | |||
a708889117 |
@ -6,6 +6,7 @@ import com.fuyuanshen.app.domain.vo.AppFileVo;
|
|||||||
import com.fuyuanshen.app.service.AppFileService;
|
import com.fuyuanshen.app.service.AppFileService;
|
||||||
import com.fuyuanshen.common.core.domain.R;
|
import com.fuyuanshen.common.core.domain.R;
|
||||||
import com.fuyuanshen.common.web.core.BaseController;
|
import com.fuyuanshen.common.web.core.BaseController;
|
||||||
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@ -44,8 +45,8 @@ public class AppFileController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 文件删除
|
* 文件删除
|
||||||
*/
|
*/
|
||||||
@DeleteMapping("/delete")
|
@DeleteMapping("/delete/{ids}")
|
||||||
public R<Void> delete(Long[] ids) {
|
public R<Void> delete(@NotEmpty(message = "主键不能为空") @PathVariable Long[] ids) {
|
||||||
if(ids == null || ids.length == 0){
|
if(ids == null || ids.length == 0){
|
||||||
return R.fail("请选择要删除的文件");
|
return R.fail("请选择要删除的文件");
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,6 @@ public class AppFileDto {
|
|||||||
/**
|
/**
|
||||||
* 文件
|
* 文件
|
||||||
*/
|
*/
|
||||||
private MultipartFile file;
|
private MultipartFile[] files;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import com.fuyuanshen.app.domain.bo.AppBusinessFileBo;
|
|||||||
import com.fuyuanshen.app.domain.dto.AppFileDto;
|
import com.fuyuanshen.app.domain.dto.AppFileDto;
|
||||||
import com.fuyuanshen.app.domain.vo.AppBusinessFileVo;
|
import com.fuyuanshen.app.domain.vo.AppBusinessFileVo;
|
||||||
import com.fuyuanshen.app.domain.vo.AppFileVo;
|
import com.fuyuanshen.app.domain.vo.AppFileVo;
|
||||||
|
import com.fuyuanshen.common.core.exception.ServiceException;
|
||||||
import com.fuyuanshen.common.oss.core.OssClient;
|
import com.fuyuanshen.common.oss.core.OssClient;
|
||||||
import com.fuyuanshen.common.oss.factory.OssFactory;
|
import com.fuyuanshen.common.oss.factory.OssFactory;
|
||||||
import com.fuyuanshen.common.satoken.utils.AppLoginHelper;
|
import com.fuyuanshen.common.satoken.utils.AppLoginHelper;
|
||||||
@ -12,6 +13,7 @@ import com.fuyuanshen.system.service.ISysOssService;
|
|||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -36,20 +38,32 @@ public class AppFileService {
|
|||||||
|
|
||||||
public Boolean add(AppFileDto bo) {
|
public Boolean add(AppFileDto bo) {
|
||||||
|
|
||||||
// 上传文件
|
MultipartFile[] files = bo.getFiles();
|
||||||
SysOssVo upload = sysOssService.upload(bo.getFile());
|
if(files == null || files.length == 0){
|
||||||
|
throw new ServiceException("请选择要上传的文件");
|
||||||
|
}
|
||||||
|
if(files.length > 5){
|
||||||
|
throw new ServiceException("最多只能上传5个文件");
|
||||||
|
}
|
||||||
|
for (int i = 0; i < files.length; i++) {
|
||||||
|
MultipartFile file = files[i];
|
||||||
|
// 上传文件
|
||||||
|
SysOssVo upload = sysOssService.upload(file);
|
||||||
|
|
||||||
if (upload == null) {
|
if (upload == null) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
AppBusinessFileBo appBusinessFileBo = new AppBusinessFileBo();
|
||||||
|
appBusinessFileBo.setFileId(upload.getOssId());
|
||||||
|
appBusinessFileBo.setBusinessId(bo.getDeviceId());
|
||||||
|
appBusinessFileBo.setFileType(bo.getFileType());
|
||||||
|
appBusinessFileBo.setCreateBy(AppLoginHelper.getUserId());
|
||||||
|
appBusinessFileService.insertByBo(appBusinessFileBo);
|
||||||
}
|
}
|
||||||
|
|
||||||
AppBusinessFileBo appBusinessFileBo = new AppBusinessFileBo();
|
|
||||||
appBusinessFileBo.setFileId(upload.getOssId());
|
|
||||||
appBusinessFileBo.setBusinessId(bo.getDeviceId());
|
|
||||||
appBusinessFileBo.setFileType(bo.getFileType());
|
|
||||||
appBusinessFileBo.setCreateBy(AppLoginHelper.getUserId());
|
|
||||||
|
|
||||||
return appBusinessFileService.insertByBo(appBusinessFileBo);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean delete(Long[] ids) {
|
public Boolean delete(Long[] ids) {
|
||||||
|
@ -78,11 +78,23 @@ public class APPDeviceController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@PostMapping(value = "/unbind")
|
// @PostMapping(value = "/unbind")
|
||||||
|
// @Operation(summary = "设备解绑")
|
||||||
|
// public ResponseVO<String> unbindAPPDevice(@Validated @ModelAttribute APPUnbindDTO deviceForm) {
|
||||||
|
// appDeviceService.unbindAPPDevice(deviceForm);
|
||||||
|
// return ResponseVO.success("解绑成功!!!");
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* app设备解绑
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Operation(summary = "设备解绑")
|
@Operation(summary = "设备解绑")
|
||||||
public ResponseVO<String> unbindAPPDevice(@Validated @ModelAttribute APPUnbindDTO deviceForm) {
|
@DeleteMapping("/unBind")
|
||||||
appDeviceService.unbindAPPDevice(deviceForm);
|
public R<Void> unBind(Long id) {
|
||||||
return ResponseVO.success("解绑成功!!!");
|
return toAjax(deviceService.unBindDevice(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,6 +6,11 @@ import lombok.Data;
|
|||||||
public class AppFileVo {
|
public class AppFileVo {
|
||||||
|
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 业务id
|
||||||
|
*/
|
||||||
|
private String businessId;
|
||||||
/**
|
/**
|
||||||
* 文件id
|
* 文件id
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<mapper namespace="com.fuyuanshen.app.mapper.AppBusinessFileMapper">
|
<mapper namespace="com.fuyuanshen.app.mapper.AppBusinessFileMapper">
|
||||||
|
|
||||||
<select id="queryAppFileList" resultType="com.fuyuanshen.app.domain.vo.AppFileVo">
|
<select id="queryAppFileList" resultType="com.fuyuanshen.app.domain.vo.AppFileVo">
|
||||||
select a.business_id id,a.file_id,b.file_name,b.url fileUrl from app_business_file a left join sys_oss b on a.file_id = b.oss_id
|
select a.id,a.business_id,a.file_id,b.file_name,b.url fileUrl from app_business_file a left join sys_oss b on a.file_id = b.oss_id
|
||||||
where
|
where
|
||||||
<if test="businessId != null">
|
<if test="businessId != null">
|
||||||
and a.business_id = #{businessId}
|
and a.business_id = #{businessId}
|
||||||
|
@ -97,6 +97,9 @@ public class Device extends TenantEntity {
|
|||||||
@Schema(name = "设备状态")
|
@Schema(name = "设备状态")
|
||||||
private Integer deviceStatus;
|
private Integer deviceStatus;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 绑定状态
|
* 绑定状态
|
||||||
* 0 未绑定
|
* 0 未绑定
|
||||||
|
@ -42,4 +42,11 @@ public class AppDeviceVo {
|
|||||||
* 蓝牙名称
|
* 蓝牙名称
|
||||||
*/
|
*/
|
||||||
private String bluetoothName;
|
private String bluetoothName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备状态
|
||||||
|
* 0 失效
|
||||||
|
* 1 正常
|
||||||
|
*/
|
||||||
|
private Integer deviceStatus;
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,15 @@ public interface DeviceMapper extends BaseMapper<Device> {
|
|||||||
*/
|
*/
|
||||||
List<Device> findDevices(@Param("criteria") DeviceQueryCriteria criteria);
|
List<Device> findDevices(@Param("criteria") DeviceQueryCriteria criteria);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询APP绑定设备列表
|
||||||
|
*
|
||||||
|
* @param criteria
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Page<AppDeviceVo> queryAppBindDeviceList(Page<AppDeviceVo> page, @Param("criteria") DeviceQueryCriteria criteria);
|
||||||
|
|
||||||
|
|
||||||
Page<AppDeviceVo> queryAppDeviceList(Page<AppDeviceVo> page, @Param("criteria") DeviceQueryCriteria criteria);
|
Page<AppDeviceVo> queryAppDeviceList(Page<AppDeviceVo> page, @Param("criteria") DeviceQueryCriteria criteria);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -503,7 +503,7 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
|||||||
Long userId = AppLoginHelper.getUserId();
|
Long userId = AppLoginHelper.getUserId();
|
||||||
bo.setBindingUserId(userId);
|
bo.setBindingUserId(userId);
|
||||||
}
|
}
|
||||||
Page<AppDeviceVo> result = baseMapper.queryAppDeviceList(pageQuery.build(), bo);
|
Page<AppDeviceVo> result = baseMapper.queryAppBindDeviceList(pageQuery.build(), bo);
|
||||||
return TableDataInfo.build(result);
|
return TableDataInfo.build(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,6 +164,34 @@
|
|||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<!-- 查询APP绑定设备列表 -->
|
||||||
|
<select id="queryAppBindDeviceList" resultType="com.fuyuanshen.equipment.domain.vo.AppDeviceVo">
|
||||||
|
select d.id, d.device_name, d.device_name,
|
||||||
|
d.device_name,
|
||||||
|
d.device_mac,
|
||||||
|
d.device_sn,
|
||||||
|
d.device_imei,
|
||||||
|
d.device_pic,
|
||||||
|
dt.type_name,
|
||||||
|
dt.communication_mode,
|
||||||
|
d.bluetooth_name
|
||||||
|
from device d
|
||||||
|
inner join device_type dt on d.device_type = dt.id
|
||||||
|
where d.binding_user_id = #{criteria.bindingUserId}
|
||||||
|
<if test="criteria.deviceType != null">
|
||||||
|
and d.device_type = #{criteria.deviceType}
|
||||||
|
</if>
|
||||||
|
<if test="criteria.deviceName != null">
|
||||||
|
and d.device_name = #{criteria.deviceName}
|
||||||
|
</if>
|
||||||
|
<if test="criteria.deviceMac != null">
|
||||||
|
and d.device_mac = #{criteria.deviceMac}
|
||||||
|
</if>
|
||||||
|
<if test="criteria.deviceImei != null">
|
||||||
|
and d.device_imei = #{criteria.deviceImei}
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
<select id="queryAppDeviceList" resultType="com.fuyuanshen.equipment.domain.vo.AppDeviceVo">
|
<select id="queryAppDeviceList" resultType="com.fuyuanshen.equipment.domain.vo.AppDeviceVo">
|
||||||
select d.id,
|
select d.id,
|
||||||
|
Reference in New Issue
Block a user