2023-05-16 14:08:35 完成策略管理的增、删、改、查接口!

master
魔神煜修罗皇 2 years ago
parent 740d098d26
commit 4cdd1fd2c2
  1. 16
      psdc-business/src/main/java/com/psdc/mapper/PsdcSceneMapper.java
  2. 10
      psdc-business/src/main/java/com/psdc/service/IPsdcSceneService.java
  3. 18
      psdc-business/src/main/java/com/psdc/service/impl/PsdcSceneServiceImpl.java
  4. 13
      psdc-business/src/main/resources/mapper/business/PsdcSceneMapper.xml
  5. 12
      psdc-web/src/main/java/com/psdc/controller/manager/PsdcSceneController.java

@ -34,11 +34,25 @@ public interface PsdcSceneMapper{
*/ */
int insert(PsdcScene psdcScene); int insert(PsdcScene psdcScene);
/**
* 新增场景策略
* @param sceneList
*/
void InsertSceneData(@Param(value = "sceneRecord") List<SceneVo> sceneList); void InsertSceneData(@Param(value = "sceneRecord") List<SceneVo> sceneList);
/**
* 修改场景策略
* @param sceneList
*/
void UpdateSceneData(@Param(value = "sceneRecord") List<SceneVo> sceneList); void UpdateSceneData(@Param(value = "sceneRecord") List<SceneVo> sceneList);
/**
* 通过策略名称删除场景策略
* @param sceneName
* @return
*/
Integer deleteBySceneName(@Param(value = "sceneName") String sceneName);
/** /**
* 更新数据 * 更新数据
* *

@ -21,7 +21,6 @@ public interface IPsdcSceneService {
/** /**
* 新增数据 * 新增数据
*
* @param scenes 实例对象集合 * @param scenes 实例对象集合
* @return * @return
*/ */
@ -31,18 +30,17 @@ public interface IPsdcSceneService {
/** /**
* 更新数据 * 更新数据
*
* @param scenes 实例对象 * @param scenes 实例对象
* @return 实例对象 * @return 实例对象
*/ */
Boolean update(List<SceneVo> scenes); Boolean update(List<SceneVo> scenes);
/** /**
* 通过主键删除数据 * 通过策略名称删除数据
* * @param sceneName
* @param sceneId 主键
* @return 是否成功 * @return 是否成功
*/ */
boolean deleteById(Integer sceneId); Boolean deleteBySceneName(String sceneName);
List<Map<String, Object>> getStrategyList(); List<Map<String, Object>> getStrategyList();

@ -91,17 +91,21 @@ public class PsdcSceneServiceImpl implements IPsdcSceneService {
} }
} }
/** /**
* 通过主键删除数据 * 通过策略名称删除数据
* * @param sceneName
* @param sceneId 主键
* @return 是否成功 * @return 是否成功
*/ */
public boolean deleteById(Integer sceneId){ @Override
int total = psdcSceneMapper.deleteById(sceneId); public Boolean deleteBySceneName(String sceneName) {
return total > 0; int count = psdcSceneMapper.deleteBySceneName(sceneName);
if (count > 0){
return true;
} else {
return false;
} }
}
@Override @Override
public List<Map<String, Object>> getStrategyList() { public List<Map<String, Object>> getStrategyList() {

@ -115,12 +115,17 @@
delete from psdc_scene where scene_id = #{sceneId} delete from psdc_scene where scene_id = #{sceneId}
</delete> </delete>
<delete id="deleteBySceneName">
Delete From psdc_scene Where scene_name = #{sceneName}
</delete>
<!-- 根据用户ID查询策略信息--> <!-- 根据用户ID查询策略信息-->
<select id="queryByUserId" resultMap="SceneVoMap"> <select id="queryByUserId" resultMap="SceneVoMap">
select ps.scene_id,ps.scene_name,ps.scene_code,ps.user_id,pd.device_name,ps.device_id,pd.device_sn,ps.scene_context,ps.scene_key,ps.scene_value Select ps.scene_id,ps.scene_name,ps.scene_code,ps.user_id,pd.device_name,ps.device_id,pd.device_sn,ps.scene_context,ps.scene_key,ps.scene_value
from psdc_scene ps left join sys_user su on ps.user_id = su.user_id From psdc_scene ps
left join psdc_device pd on ps.device_id = pd.device_id Left join sys_user su on ps.user_id = su.user_id
where su.user_id = #{userId} Left join psdc_device pd on ps.device_id = pd.device_id
Where su.user_id = #{userId}
</select> </select>
<!-- 根据用户ID查询策略信息--> <!-- 根据用户ID查询策略信息-->

@ -3,14 +3,11 @@ package com.psdc.controller.manager;
import com.psdc.annotation.Log; import com.psdc.annotation.Log;
import com.psdc.core.controller.BaseController; import com.psdc.core.controller.BaseController;
import com.psdc.core.domain.AjaxResult; import com.psdc.core.domain.AjaxResult;
import com.psdc.core.domain.entity.SysUser;
import com.psdc.core.page.TableDataInfo; import com.psdc.core.page.TableDataInfo;
import com.psdc.entity.PsdcScene; import com.psdc.entity.PsdcScene;
import com.psdc.entity.vo.SceneVo; import com.psdc.entity.vo.SceneVo;
import com.psdc.enums.BusinessType; import com.psdc.enums.BusinessType;
import com.psdc.service.IPsdcSceneService; import com.psdc.service.IPsdcSceneService;
import com.psdc.utils.SecurityUtils;
import com.psdc.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -78,5 +75,14 @@ public class PsdcSceneController extends BaseController {
return toAjax(psdcSceneService.update(scenes)); return toAjax(psdcSceneService.update(scenes));
} }
/**
* 删除场景策略
*/
@PreAuthorize("@ss.hasPermi('system:cl:list')")
@Log(title = "策略管理", businessType = BusinessType.DELETE)
@DeleteMapping()
public AjaxResult remove(@RequestParam String sceneName) {
return toAjax(psdcSceneService.deleteBySceneName(sceneName));
}
} }

Loading…
Cancel
Save