qa-prevention-gwj/src/main/java/com/zcloud/service/mkmj/impl/MkmjAreaServiceImpl.java

133 lines
3.5 KiB
Java
Raw Normal View History

2024-01-17 14:46:28 +08:00
package com.zcloud.service.mkmj.impl;
import com.zcloud.entity.Page;
import com.zcloud.entity.PageData;
import com.zcloud.mapper.datasource.mkmj.MkmjAreaGateMapper;
import com.zcloud.mapper.datasource.mkmj.MkmjAreaMapper;
import com.zcloud.service.map.util.ReturnMap;
import com.zcloud.service.mkmj.MkmjAreaService;
import com.zcloud.util.UuidUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
2024-01-24 16:32:13 +08:00
import java.util.HashMap;
2024-01-17 14:46:28 +08:00
import java.util.List;
2024-01-24 16:32:13 +08:00
import java.util.Map;
2024-01-17 14:46:28 +08:00
/**
*
* zhaoyu
* 2024-01-16
* www.zcloudchina.com
*/
@Service
@Transactional //开启事物
public class MkmjAreaServiceImpl implements MkmjAreaService {
@Autowired
private MkmjAreaMapper mkmjAreaMapper;
@Autowired
private MkmjAreaGateMapper mkmjAreaGateMapper;
/**
* @param pd
* @throws Exception
*/
2024-01-24 16:32:13 +08:00
public Object save(PageData pd)throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
2024-01-17 14:46:28 +08:00
//保存校验名称不重复
PageData pageData = mkmjAreaMapper.findByOnly(pd);
//查询不到重复数据 开始走业务
if(ObjectUtils.isEmpty(pageData)){
pd.put("AREA_ID", UuidUtil.get32UUID());
}else {
2024-01-24 16:32:13 +08:00
map.put("result", "fail");
map.put("msg", "名称已存在,请修改后重新提交");
return map;
2024-01-17 14:46:28 +08:00
}
mkmjAreaMapper.save(pd);
2024-01-24 16:32:13 +08:00
map.put("result", errInfo);
map.put("msg", "保存成功");
return map;
2024-01-17 14:46:28 +08:00
}
/**
* @param pd
* @throws Exception
*/
2024-01-24 16:32:13 +08:00
public Object delete(PageData pd)throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
2024-01-17 14:46:28 +08:00
//校验区域下是否还存在区域 存在则不让删除
List<PageData> childList = mkmjAreaMapper.findByChild(pd);
if(childList.size()>0){
2024-01-24 16:32:13 +08:00
map.put("result", "fail");
map.put("msg", "当前区域还存在下级区域,请删除当前区域的所有下级区域后进行删除");
return map;
2024-01-17 14:46:28 +08:00
}
//校验区域下是否存在闸机,存在则不让删除
List<PageData> gateList = mkmjAreaGateMapper.listAll(pd);
if(gateList.size()>0){
2024-01-24 16:32:13 +08:00
map.put("result", "fail");
map.put("msg", "当前区域还存在闸机,请删除当前区域的所有闸机后进行删除");
return map;
2024-01-17 14:46:28 +08:00
}
//两个校验都不存在 则可以删除
mkmjAreaMapper.delete(pd);
2024-01-24 16:32:13 +08:00
map.put("result", errInfo);
map.put("msg", "删除成功");
return map;
2024-01-17 14:46:28 +08:00
}
/**
* @param pd
* @throws Exception
*/
2024-01-24 16:32:13 +08:00
public Object edit(PageData pd)throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
2024-01-17 14:46:28 +08:00
PageData pageData = mkmjAreaMapper.findByOnly(pd);
//查询不到重复数据 开始走业务
if(!ObjectUtils.isEmpty(pageData)){
2024-01-24 16:32:13 +08:00
map.put("result", "fail");
map.put("msg", "名称已存在,请修改后重新提交");
return map;
2024-01-17 14:46:28 +08:00
}
mkmjAreaMapper.edit(pd);
2024-01-24 16:32:13 +08:00
map.put("result", errInfo);
map.put("msg", "编辑成功");
return map;
2024-01-17 14:46:28 +08:00
}
/**
* @param page
* @throws Exception
*/
public List<PageData> list(Page page)throws Exception{
return mkmjAreaMapper.datalistPage(page);
}
/**()
* @param pd
* @throws Exception
*/
public List<PageData> listAll(PageData pd)throws Exception{
return mkmjAreaMapper.listAll(pd);
}
/**id
* @param pd
* @throws Exception
*/
public PageData findById(PageData pd)throws Exception{
return mkmjAreaMapper.findById(pd);
}
}