stjdydayou 4 年之前
父节点
当前提交
61bbc69a73

+ 11 - 0
src/main/java/com/zhiqiyun/open/core/models/place/PlaceBaseInfo.java

@@ -3,6 +3,7 @@ package com.zhiqiyun.open.core.models.place;
 import com.baomidou.mybatisplus.annotation.*;
 import com.zhiqiyun.open.core.typeHandler.FastjsonTypeHandler;
 import lombok.Data;
+import org.apache.commons.lang3.StringUtils;
 
 import java.math.BigDecimal;
 import java.util.Date;
@@ -34,4 +35,14 @@ public class PlaceBaseInfo {
 
     @TableField(exist = false)
     private PlaceCategory category;
+
+    @TableField(exist = false)
+    private String litpic;
+
+    public String getLitpic() {
+        if (StringUtils.isBlank(this.litpic) && this.litpics != null && this.litpics.size() > 0) {
+            this.litpic = this.litpics.get(0);
+        }
+        return this.litpic;
+    }
 }

+ 10 - 9
src/main/java/com/zhiqiyun/open/core/models/place/PlaceCategory.java

@@ -10,15 +10,16 @@ import java.util.Date;
 @TableName("place_category")
 public class PlaceCategory implements Serializable {
 
-    private static final long serialVersionUID = -3306018969325222999L;
+	private static final long serialVersionUID = -3306018969325222999L;
 
-    private Long id;
-    private String name;
-    private Integer sortNumber;
-    private String remark;
+	private Long id;
+	private String name;
+	private Integer sortNumber;
+	private String remark;
+	private String iconImage;
 
-    private Date createdTime;
-    private Long createdBy;
-    private Date updatedTime;
-    private Long updatedBy;
+	private Date createdTime;
+	private Long createdBy;
+	private Date updatedTime;
+	private Long updatedBy;
 }

+ 202 - 198
src/main/java/com/zhiqiyun/open/mvc/controller/PlaceBaseInfoController.java

@@ -35,205 +35,209 @@ import java.util.Map;
 @RequestMapping("/bz/data/info")
 public class PlaceBaseInfoController {
 
-    @Autowired
-    private PlaceCategoryService placeCategoryService;
+	@Autowired
+	private PlaceCategoryService placeCategoryService;
 
-    @Autowired
-    private PlaceCategoryExtendColumnService placeCategoryExtendColumnService;
+	@Autowired
+	private PlaceCategoryExtendColumnService placeCategoryExtendColumnService;
 
-    @Autowired
-    private PlaceBaseInfoService placeBaseInfoService;
+	@Autowired
+	private PlaceBaseInfoService placeBaseInfoService;
 
-    @Autowired
-    private PlaceBaseInfoExtendService placeBaseInfoExtendService;
-
-    @Autowired
-    private SequenceService sequenceService;
-
-    @Autowired
-    private OauthService oauthService;
-
-    @Permission(value = "place.base.info.find", tags = "查询文旅场所")
-    @PostMapping("/findPage")
-    public Result findPage(@RequestBody QueryPlaceBaseInfoParam param) {
-
-        QueryWrapper<PlaceBaseInfo> wrapper = new QueryWrapper<>();
-
-        if (StringUtils.isNotBlank(param.getName())) {
-            wrapper.like("name", param.getName());
-        }
-        Page<PlaceBaseInfo> page = param.getPage();
-        page.addOrder(OrderItem.desc("id"));
-
-        Page<PlaceBaseInfo> resultData = this.placeBaseInfoService.page(page, wrapper);
-
-        for (PlaceBaseInfo baseInfo : resultData.getRecords()) {
-            PlaceCategory category = this.placeCategoryService.getById(baseInfo.getCategoryId());
-            baseInfo.setCategory(category);
-        }
-
-        return Result.instance(Result.Code.SUCCESS).setData(resultData);
-    }
-
-    @Permission(value = "place.base.info.add", tags = "新建文旅场所")
-    @PostMapping("/save")
-    public Result save(@Valid @RequestBody SavePlaceBaseInfoParam param) throws Exception {
-
-        PlaceBaseInfo entity = new PlaceBaseInfo();
-        BeanUtils.copyProperties(param, entity);
-
-        OauthInfo oauthInfo = this.oauthService.getAuth(ServletContext.getAccessToken());
-
-        entity.setCreatedTime(DateUtil.current());
-        entity.setCreatedBy(oauthInfo.getId());
-
-        entity.setUpdatedTime(DateUtil.current());
-        entity.setUpdatedBy(oauthInfo.getId());
-        entity.setId(this.sequenceService.nextId());
-
-        List<PlaceBaseInfoExtend> listExtends = new ArrayList<>();
-        if (param.getListExtends() != null) {
-            for (SavePlaceBaseInfoExtendParam extendParam : param.getListExtends()) {
-                PlaceBaseInfoExtend extend = new PlaceBaseInfoExtend();
-                BeanUtils.copyProperties(extendParam, extend);
-                listExtends.add(extend);
-            }
-        }
-
-        this.placeBaseInfoService.save(entity, listExtends);
-
-        return Result.instance(Result.Code.MESSAGE_SUCCESS);
-    }
-
-    @Permission(value = "place.base.info.edit", tags = "更新文旅场所")
-    @PostMapping("/updateById")
-    public Result updateById(Long id, @Valid @RequestBody SavePlaceBaseInfoParam param) {
-        PlaceBaseInfo entity = new PlaceBaseInfo();
-        BeanUtils.copyProperties(param, entity);
-
-        OauthInfo oauthInfo = this.oauthService.getAuth(ServletContext.getAccessToken());
-
-        entity.setUpdatedBy(oauthInfo.getId());
-        entity.setUpdatedTime(DateUtil.current());
-        entity.setId(id);
-
-        List<PlaceBaseInfoExtend> listExtends = new ArrayList<>();
-        if (param.getListExtends() != null) {
-            for (SavePlaceBaseInfoExtendParam extendParam : param.getListExtends()) {
-                PlaceBaseInfoExtend extend = new PlaceBaseInfoExtend();
-                BeanUtils.copyProperties(extendParam, extend);
-                listExtends.add(extend);
-            }
-        }
-
-        log.info(JSON.toJSONString(listExtends));
-        this.placeBaseInfoService.updateById(entity, listExtends);
-
-        return Result.instance(Result.Code.MESSAGE_SUCCESS);
-    }
-
-    @Permission(value = "place.base.info.delete", tags = "删除文旅场所")
-    @PostMapping("/deleteByIds")
-    public Result deleteByIds(@RequestBody List<Long> ids) {
-        this.placeBaseInfoService.removeByIds(ids);
-        return Result.instance(Result.Code.MESSAGE_SUCCESS);
-    }
-
-    @Permission(value = "place.base.info.gis.map", tags = "分类组查询数量", writeLog = false)
-    @PostMapping("/findByGroupByDataType")
-    public Result findByGroupByDataType() {
-        QueryWrapper<PlaceBaseInfo> queryWrapper = new QueryWrapper<>();
-        queryWrapper.select("category_id, count(1) num");
-        queryWrapper.groupBy("category_id");
-        List<Map<String, Object>> listData = this.placeBaseInfoService.listMaps(queryWrapper);
-        for (Map<String, Object> dataMap : listData) {
-            Long categoryId = Long.valueOf(dataMap.get("category_id").toString());
-            PlaceCategory category = this.placeCategoryService.getById(categoryId);
-            dataMap.put("category", category);
-        }
-        return Result.instance(Result.Code.SUCCESS).setData(listData);
-    }
-
-    @ResponseBody
-    @PostMapping("/findByMapBounds")
-    public Result findByMapBounds(BigDecimal maxlng, BigDecimal maxlat, BigDecimal minlng, BigDecimal minlat, Long categoryId) {
-        QueryWrapper<PlaceBaseInfo> queryWrapper = new QueryWrapper<>();
-        if (maxlng != null) {
-            queryWrapper.le("lng", maxlng);
-        }
-        if (maxlat != null) {
-            queryWrapper.le("lat", maxlat);
-        }
-        if (minlng != null) {
-            queryWrapper.ge("lng", minlng);
-        }
-        if (minlat != null) {
-            queryWrapper.ge("lat", minlat);
-        }
-        if (categoryId != null) {
-            queryWrapper.eq("category_id", categoryId);
-        }
-
-        List<PlaceBaseInfo> listData = this.placeBaseInfoService.list(queryWrapper);
-        return Result.instance(Result.Code.SUCCESS).setData(listData);
-    }
-
-    @PostMapping("/findAllDataType")
-    @Permission(value = {"place.base.info.edit", "place.base.info.add"}, tags = "获取文旅场所", writeLog = false)
-    public Result findAllDataType() {
-        List<PlaceCategory> listData = this.placeCategoryService.list();
-        return Result.instance(Result.Code.SUCCESS).setData(listData);
-
-    }
-
-    @PostMapping("/findDataBaseInfoExtends")
-    @Permission(value = {"place.base.info.edit", "place.base.info.add"}, tags = "获取文旅场所扩展字段", writeLog = false)
-    public Result findDataBaseInfoExtends(Long baseInfoId, Long categoryId) {
-
-        QueryWrapper<PlaceCategoryExtendColumn> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("category_id", categoryId);
-        List<PlaceCategoryExtendColumn> listData = this.placeCategoryExtendColumnService.list(queryWrapper);
-        if (baseInfoId != null) {
-            for (PlaceCategoryExtendColumn extendColumn : listData) {
-                String id = DigestUtils.md5Hex(String.format("%s@%s", baseInfoId, extendColumn.getId()));
-                PlaceBaseInfoExtend extend = this.placeBaseInfoExtendService.getById(id);
-                if (extend != null) {
-                    extendColumn.setFieldValue(extend.getFieldValue());
-                }
-            }
-        }
-
-        return Result.instance(Result.Code.SUCCESS).setData(listData);
-    }
-
-    @ResponseBody
-    @PostMapping("/findSelectByKeyword")
-    public Result findSelectBaseInfoByKeyword(String keyword) throws Exception {
-        QueryWrapper<PlaceBaseInfo> queryWrapper = new QueryWrapper<>();
-
-        if (StringUtils.isNotBlank(keyword)) {
-            queryWrapper.like("id", keyword);
-            queryWrapper.or();
-            queryWrapper.like("name", keyword);
-            queryWrapper.or();
-            queryWrapper.like("brief", keyword);
-            queryWrapper.or();
-            queryWrapper.like("address", keyword);
-            queryWrapper.or();
-            queryWrapper.like("contacts", keyword);
-            queryWrapper.or();
-            queryWrapper.like("contact_number", keyword);
-            queryWrapper.or();
-            queryWrapper.inSql("category_id", "select id from place_category where name like '%" + keyword + "%'");
-        }
-        queryWrapper.last("limit 10");
-        queryWrapper.orderByDesc("id");
-
-        List<PlaceBaseInfo> listData = this.placeBaseInfoService.list(queryWrapper);
-        for (PlaceBaseInfo baseInfo : listData) {
-            PlaceCategory category = this.placeCategoryService.getById(baseInfo.getCategoryId());
-            baseInfo.setCategory(category);
-        }
-        return Result.instance(Result.Code.SUCCESS).setData(listData);
-    }
+	@Autowired
+	private PlaceBaseInfoExtendService placeBaseInfoExtendService;
+
+	@Autowired
+	private SequenceService sequenceService;
+
+	@Autowired
+	private OauthService oauthService;
+
+	@Permission(value = "place.base.info.find", tags = "查询文旅场所")
+	@PostMapping("/findPage")
+	public Result findPage(@RequestBody QueryPlaceBaseInfoParam param) {
+
+		QueryWrapper<PlaceBaseInfo> wrapper = new QueryWrapper<>();
+
+		if (StringUtils.isNotBlank(param.getName())) {
+			wrapper.like("name", param.getName());
+		}
+		Page<PlaceBaseInfo> page = param.getPage();
+		page.addOrder(OrderItem.desc("id"));
+
+		Page<PlaceBaseInfo> resultData = this.placeBaseInfoService.page(page, wrapper);
+
+		for (PlaceBaseInfo baseInfo : resultData.getRecords()) {
+			PlaceCategory category = this.placeCategoryService.getById(baseInfo.getCategoryId());
+			baseInfo.setCategory(category);
+		}
+
+		return Result.instance(Result.Code.SUCCESS).setData(resultData);
+	}
+
+	@Permission(value = "place.base.info.add", tags = "新建文旅场所")
+	@PostMapping("/save")
+	public Result save(@Valid @RequestBody SavePlaceBaseInfoParam param) throws Exception {
+
+		PlaceBaseInfo entity = new PlaceBaseInfo();
+		BeanUtils.copyProperties(param, entity);
+
+		OauthInfo oauthInfo = this.oauthService.getAuth(ServletContext.getAccessToken());
+
+		entity.setCreatedTime(DateUtil.current());
+		entity.setCreatedBy(oauthInfo.getId());
+
+		entity.setUpdatedTime(DateUtil.current());
+		entity.setUpdatedBy(oauthInfo.getId());
+		entity.setId(this.sequenceService.nextId());
+
+		List<PlaceBaseInfoExtend> listExtends = new ArrayList<>();
+		if (param.getListExtends() != null) {
+			for (SavePlaceBaseInfoExtendParam extendParam : param.getListExtends()) {
+				PlaceBaseInfoExtend extend = new PlaceBaseInfoExtend();
+				BeanUtils.copyProperties(extendParam, extend);
+				listExtends.add(extend);
+			}
+		}
+
+		this.placeBaseInfoService.save(entity, listExtends);
+
+		return Result.instance(Result.Code.MESSAGE_SUCCESS);
+	}
+
+	@Permission(value = "place.base.info.edit", tags = "更新文旅场所")
+	@PostMapping("/updateById")
+	public Result updateById(Long id, @Valid @RequestBody SavePlaceBaseInfoParam param) {
+		PlaceBaseInfo entity = new PlaceBaseInfo();
+		BeanUtils.copyProperties(param, entity);
+
+		OauthInfo oauthInfo = this.oauthService.getAuth(ServletContext.getAccessToken());
+
+		entity.setUpdatedBy(oauthInfo.getId());
+		entity.setUpdatedTime(DateUtil.current());
+		entity.setId(id);
+
+		List<PlaceBaseInfoExtend> listExtends = new ArrayList<>();
+		if (param.getListExtends() != null) {
+			for (SavePlaceBaseInfoExtendParam extendParam : param.getListExtends()) {
+				PlaceBaseInfoExtend extend = new PlaceBaseInfoExtend();
+				BeanUtils.copyProperties(extendParam, extend);
+				listExtends.add(extend);
+			}
+		}
+
+		log.info(JSON.toJSONString(listExtends));
+		this.placeBaseInfoService.updateById(entity, listExtends);
+
+		return Result.instance(Result.Code.MESSAGE_SUCCESS);
+	}
+
+	@Permission(value = "place.base.info.delete", tags = "删除文旅场所")
+	@PostMapping("/deleteByIds")
+	public Result deleteByIds(@RequestBody List<Long> ids) {
+		this.placeBaseInfoService.removeByIds(ids);
+		return Result.instance(Result.Code.MESSAGE_SUCCESS);
+	}
+
+	@Permission(value = "place.base.info.gis.map", tags = "分类组查询数量", writeLog = false)
+	@PostMapping("/findByGroupByDataType")
+	public Result findByGroupByDataType() {
+		QueryWrapper<PlaceBaseInfo> queryWrapper = new QueryWrapper<>();
+		queryWrapper.select("category_id, count(1) num");
+		queryWrapper.groupBy("category_id");
+		List<Map<String, Object>> listData = this.placeBaseInfoService.listMaps(queryWrapper);
+		for (Map<String, Object> dataMap : listData) {
+			Long categoryId = Long.valueOf(dataMap.get("category_id").toString());
+			PlaceCategory category = this.placeCategoryService.getById(categoryId);
+			dataMap.put("category", category);
+		}
+		return Result.instance(Result.Code.SUCCESS).setData(listData);
+	}
+
+	@ResponseBody
+	@PostMapping("/findByMapBounds")
+	public Result findByMapBounds(BigDecimal maxlng, BigDecimal maxlat, BigDecimal minlng, BigDecimal minlat, Long categoryId) {
+		QueryWrapper<PlaceBaseInfo> queryWrapper = new QueryWrapper<>();
+		if (maxlng != null) {
+			queryWrapper.le("lng", maxlng);
+		}
+		if (maxlat != null) {
+			queryWrapper.le("lat", maxlat);
+		}
+		if (minlng != null) {
+			queryWrapper.ge("lng", minlng);
+		}
+		if (minlat != null) {
+			queryWrapper.ge("lat", minlat);
+		}
+		if (categoryId != null) {
+			queryWrapper.eq("category_id", categoryId);
+		}
+
+		List<PlaceBaseInfo> listData = this.placeBaseInfoService.list(queryWrapper);
+		for (PlaceBaseInfo baseInfo : listData) {
+			PlaceCategory category = this.placeCategoryService.getById(baseInfo.getCategoryId());
+			baseInfo.setCategory(category);
+		}
+		return Result.instance(Result.Code.SUCCESS).setData(listData);
+	}
+
+	@PostMapping("/findAllDataType")
+	@Permission(value = {"place.base.info.edit", "place.base.info.add"}, tags = "获取文旅场所", writeLog = false)
+	public Result findAllDataType() {
+		List<PlaceCategory> listData = this.placeCategoryService.list();
+		return Result.instance(Result.Code.SUCCESS).setData(listData);
+
+	}
+
+	@PostMapping("/findDataBaseInfoExtends")
+	@Permission(value = {"place.base.info.edit", "place.base.info.add"}, tags = "获取文旅场所扩展字段", writeLog = false)
+	public Result findDataBaseInfoExtends(Long baseInfoId, Long categoryId) {
+
+		QueryWrapper<PlaceCategoryExtendColumn> queryWrapper = new QueryWrapper<>();
+		queryWrapper.eq("category_id", categoryId);
+		List<PlaceCategoryExtendColumn> listData = this.placeCategoryExtendColumnService.list(queryWrapper);
+		if (baseInfoId != null) {
+			for (PlaceCategoryExtendColumn extendColumn : listData) {
+				String id = DigestUtils.md5Hex(String.format("%s@%s", baseInfoId, extendColumn.getId()));
+				PlaceBaseInfoExtend extend = this.placeBaseInfoExtendService.getById(id);
+				if (extend != null) {
+					extendColumn.setFieldValue(extend.getFieldValue());
+				}
+			}
+		}
+
+		return Result.instance(Result.Code.SUCCESS).setData(listData);
+	}
+
+	@ResponseBody
+	@PostMapping("/findSelectByKeyword")
+	public Result findSelectBaseInfoByKeyword(String keyword) throws Exception {
+		QueryWrapper<PlaceBaseInfo> queryWrapper = new QueryWrapper<>();
+
+		if (StringUtils.isNotBlank(keyword)) {
+			queryWrapper.like("id", keyword);
+			queryWrapper.or();
+			queryWrapper.like("name", keyword);
+			queryWrapper.or();
+			queryWrapper.like("brief", keyword);
+			queryWrapper.or();
+			queryWrapper.like("address", keyword);
+			queryWrapper.or();
+			queryWrapper.like("contacts", keyword);
+			queryWrapper.or();
+			queryWrapper.like("contact_number", keyword);
+			queryWrapper.or();
+			queryWrapper.inSql("category_id", "select id from place_category where name like '%" + keyword + "%'");
+		}
+		queryWrapper.last("limit 10");
+		queryWrapper.orderByDesc("id");
+
+		List<PlaceBaseInfo> listData = this.placeBaseInfoService.list(queryWrapper);
+		for (PlaceBaseInfo baseInfo : listData) {
+			PlaceCategory category = this.placeCategoryService.getById(baseInfo.getCategoryId());
+			baseInfo.setCategory(category);
+		}
+		return Result.instance(Result.Code.SUCCESS).setData(listData);
+	}
 }

+ 1 - 0
src/main/java/com/zhiqiyun/open/mvc/params/place/SavePlaceCategoryParam.java

@@ -7,4 +7,5 @@ public class SavePlaceCategoryParam {
     private String name;
     private String remark;
     private Integer sortNumber;
+    private String iconImage;
 }

+ 2 - 0
src/main/resources/db/migration/V1.1.1__update_place_category.sql

@@ -0,0 +1,2 @@
+ALTER TABLE `liucheng_open`.`place_category`
+    ADD COLUMN `icon_image` VARCHAR(200) NULL AFTER `sort_number`;