Commit 32d8256b by 杨林龙

1.23.0 POI列表 优化POI名称校验

1 parent 5d9de07d
......@@ -79,12 +79,12 @@ public class PoiFenceController extends AbstractController {
@ApiOperation(value = "校验POI名称")
@GetMapping("/checkPoiName")
public R checkPoiName(@RequestParam String poiName) {
PoiFence poiFence = poiFenceService.checkPoiName(poiName);
if (Objects.nonNull(poiFence)) {
public R checkPoiName(@RequestParam String poiName, Long id) {
Boolean flag = poiFenceService.checkPoiName(poiName, id);
if (!flag) {
throw new AdminException("该POI名称已存在,请重新输入!");
}
return R.ok();
return R.ok().data(Boolean.TRUE);
}
@ApiOperation(value = "增加POI地址类型")
......
......@@ -24,6 +24,7 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
/**
* poi列表 service
......@@ -96,11 +97,24 @@ public class PoiFenceService extends AbstractCommonService {
/**
* 校验POI名称
*
* @param poiName
* @param poiName poi名称
* @param id id
*/
public PoiFence checkPoiName(String poiName) {
public Boolean checkPoiName(String poiName, Long id) {
// 通过POI名称查询是否存在POI数据
PoiFence poiFence = poiFenceMapper.checkPoiName(poiName);
return poiFence;
// 通过id查询是否存在
if (Objects.nonNull(id)) {
PoiFence poiFenceById = poiFenceMapper.selectByPrimaryKey(id);
if (Objects.isNull(poiFence) || (Objects.nonNull(poiFenceById) && poiFenceById.getPoiName().equals(poiName))) {
return Boolean.TRUE;
}
} else {
if (Objects.isNull(poiFence)) {
return Boolean.TRUE;
}
}
return Boolean.FALSE;
}
/**
......
......@@ -101,8 +101,8 @@ public class PoiFenceServiceTest {
@Test
public void checkPoiName() {
PoiFence poiFence = poiFenceService.checkPoiName("POI名称");
System.out.println("poiFence = " + JSONUtil.toJsonStr(poiFence));
Boolean flag = poiFenceService.checkPoiName("POI名称", null);
System.out.println("flag = " + flag);
}
@Test
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!