111 lines
3.0 KiB
Java
111 lines
3.0 KiB
Java
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;
|
||
|
||
import java.util.List;
|
||
|
||
/**
|
||
* 说明:门口门禁区域闸机
|
||
* 作者: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
|
||
*/
|
||
public ReturnMap save(PageData pd)throws Exception{
|
||
//保存校验名称不重复
|
||
PageData pageData = mkmjAreaMapper.findByOnly(pd);
|
||
//查询不到重复数据 开始走业务
|
||
if(ObjectUtils.isEmpty(pageData)){
|
||
pd.put("AREA_ID", UuidUtil.get32UUID());
|
||
}else {
|
||
return ReturnMap.error("名称已存在,请修改后重新提交");
|
||
}
|
||
mkmjAreaMapper.save(pd);
|
||
return ReturnMap.ok("保存成功");
|
||
}
|
||
|
||
/**删除
|
||
* @param pd
|
||
* @throws Exception
|
||
*/
|
||
public ReturnMap delete(PageData pd)throws Exception{
|
||
//校验区域下是否还存在区域 存在则不让删除
|
||
List<PageData> childList = mkmjAreaMapper.findByChild(pd);
|
||
if(childList.size()>0){
|
||
return ReturnMap.error("当前区域还存在下级区域,请删除当前区域的所有下级区域后进行删除");
|
||
}
|
||
//校验区域下是否存在闸机,存在则不让删除
|
||
List<PageData> gateList = mkmjAreaGateMapper.listAll(pd);
|
||
if(gateList.size()>0){
|
||
return ReturnMap.error("当前区域还存在闸机,请删除当前区域的所有闸机后进行删除");
|
||
}
|
||
//两个校验都不存在 则可以删除
|
||
mkmjAreaMapper.delete(pd);
|
||
return ReturnMap.ok("删除成功");
|
||
}
|
||
|
||
/**修改
|
||
* @param pd
|
||
* @throws Exception
|
||
*/
|
||
public ReturnMap edit(PageData pd)throws Exception{
|
||
PageData pageData = mkmjAreaMapper.findByOnly(pd);
|
||
//查询不到重复数据 开始走业务
|
||
if(!ObjectUtils.isEmpty(pageData)){
|
||
return ReturnMap.error("名称已存在,请修改后重新提交");
|
||
}
|
||
mkmjAreaMapper.edit(pd);
|
||
return ReturnMap.ok("编辑成功");
|
||
}
|
||
|
||
/**列表
|
||
* @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);
|
||
}
|
||
|
||
|
||
}
|
||
|