package com.landtool.lanbase.modules.api.controller.MapPortal;
|
|
import java.sql.Timestamp;
|
import java.util.Date;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import com.alibaba.fastjson.JSONObject;
|
import com.landtool.lanbase.modules.res.entity.Res_DiyLayerInfo;
|
import com.landtool.lanbase.modules.res.entity.Res_MainInfo;
|
import com.landtool.lanbase.modules.res.service.ResDiyLayerInfoService;
|
import com.landtool.lanbase.modules.res.service.ResMainInfoService;
|
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiParam;
|
|
@Controller
|
@RequestMapping("/api/layerdiy")
|
@Api(value = "", tags = {"自定义图层操作信息"})
|
public class LayerDiyInfo {
|
@Autowired
|
private ResDiyLayerInfoService resDiyLayerInfoService;
|
|
@Autowired
|
private ResMainInfoService resMainInfoService;
|
|
/**
|
* 新增/修改自定义图层信息
|
*/
|
@PostMapping(path = "/add")
|
@ApiOperation(value = "自定义图层信息 新增/修改", notes = "")
|
@ResponseBody
|
public String addDiyLayerInfo(
|
@ApiParam(name = "userid", value = "用户Id", required = true) @RequestParam(name = "userid") int userid,
|
@ApiParam(name = "resourceid", value = "信息资源Id", required = true) @RequestParam(name = "resourceid") int resourceid,
|
@ApiParam(name = "title", value = "标题", required = true) @RequestParam(name = "title") String title,
|
@ApiParam(name = "typename", value = "信息类型", required = true) @RequestParam(name = "typename") String typename,
|
@ApiParam(name = "content", value = "内容", required = true) @RequestParam(name = "content") String content,
|
@ApiParam(name = "isshare", value = "共享", required = true) @RequestParam(name = "isshare") Integer isshare) {
|
// 是否存在记录,存在则修改
|
Res_DiyLayerInfo info = resDiyLayerInfoService.queryObjectByUseridAndResid(userid, resourceid, title);
|
if (info == null) {// 新增
|
info = new Res_DiyLayerInfo();
|
info.setResourceid(resourceid);
|
info.setContent(content);
|
info.setTitle(title);
|
info.setTypename(typename);
|
info.setDiyuserid(userid);
|
Timestamp audittime = new Timestamp(new Date().getTime());
|
info.setDiytime(audittime);
|
info.setIsshare(isshare);
|
resDiyLayerInfoService.insert(info);
|
return "添加成功";
|
} else {// 修改
|
info.setTitle(title);
|
info.setTypename(typename);
|
info.setContent(content);
|
Timestamp audittime = new Timestamp(new Date().getTime());
|
info.setDiytime(audittime);
|
info.setIsshare(isshare);
|
resDiyLayerInfoService.updateByPrimaryKeySelective(info);
|
return "修改成功";
|
}
|
}
|
|
/**
|
* 编辑自定义图层信息风格内容
|
*/
|
@PostMapping(path = "/update")
|
@ApiOperation(value = "编辑自定义图层信息风格内容", notes = "")
|
@ResponseBody
|
public String updateDiyLayerInfo(
|
@ApiParam(name = "diyid", value = "Id", required = true) @RequestParam(name = "diyid") int diyid,
|
@ApiParam(name = "title", value = "标题") String title,
|
@ApiParam(name = "typename", value = "信息类型") String typename,
|
@ApiParam(name = "content", value = "内容", required = true) @RequestParam(name = "content") String content) {
|
Res_DiyLayerInfo info = new Res_DiyLayerInfo();
|
if (content.length() != 0) {
|
info.setContent(content);
|
}
|
if (title != null && title.length() != 0) {
|
info.setTitle(title);
|
}
|
if (typename != null && typename.length() != 0) {
|
info.setTypename(typename);
|
}
|
info.setDiyid(diyid);
|
//info.setDiyuserid(1); // 先写死id,后续改成读取当前登录人id
|
resDiyLayerInfoService.updateContentApi(info);
|
return "编辑成功";
|
}
|
|
/**
|
* 查询自定义图层信息列表
|
*/
|
// @ResponseBody
|
// @GetMapping(path = "/info")
|
// @ApiOperation(value = "自定义图层信息列表", notes = "")
|
// public List<Res_DiyLayerInfo> queryListByUserId(@ApiParam(name = "resourceid", value = "信息资源Id") Integer resourceid,
|
// @ApiParam(name = "title", value = "标题") String title,
|
// @ApiParam(name = "typename", value = "信息类型") String typename,
|
// @ApiParam(name = "diyid", value = "diyid") Integer diyid) {
|
// Res_DiyLayerInfo record = new Res_DiyLayerInfo();
|
// record.setResourceid(resourceid);
|
// record.setTitle(title);
|
// record.setTypename(typename);
|
// record.setDiyid(diyid);
|
// return resDiyLayerInfoService.queryApiList(record);
|
// }
|
|
/**
|
* 删除自定义图层信息
|
*/
|
@PostMapping(path = "/del")
|
@ApiOperation(value = "删除自定义图层信息", notes = "")
|
@ResponseBody
|
public String deleteDiyLayerInfo(
|
@ApiParam(name = "diyid", value = "diyid", required = true) @RequestParam(name = "diyid") Integer diyid) {
|
resDiyLayerInfoService.deleteDiyLayerInfo(diyid);
|
return "删除成功";
|
}
|
|
/**
|
* 检查用户是否为资源发布人(地图自定义信息保存--共享选项是否显示判断)
|
* @param userid
|
* @param resourceid
|
* @return
|
*/
|
@ResponseBody
|
@GetMapping(path = "/checkUserShare")
|
@ApiOperation(value = "检查用户是否为资源发布人", notes = "")
|
public String checkUserShare(
|
@ApiParam(name = "userid", value = "用户ID", required = true) @RequestParam(name = "userid") Long userid,
|
@ApiParam(name = "resourceid", value = "资源ID", required = true) @RequestParam(name = "resourceid") Long resourceid) {
|
Res_MainInfo resMainInfo = resMainInfoService.selectByPrimaryKey(resourceid.intValue());//获取资源信息
|
if(resMainInfo.getCreateuserid() == resourceid) {
|
return "true";
|
} else {
|
return "false";
|
}
|
}
|
/**
|
* 根据ID获取自定义风格内容
|
* @param diyid
|
* @return
|
*/
|
@ResponseBody
|
@GetMapping(path = "layerdiycontent/{diyid}")
|
@ApiOperation(value = "根据ID获取自定义风格内容", notes = "")
|
public String GetLayerDiyContent(@ApiParam(name = "diyid", value = "diyid", required = true) @PathVariable(name = "diyid") Integer diyid,
|
HttpServletRequest request) {
|
String Json = "";
|
Res_DiyLayerInfo resDiyLayerInfo = resDiyLayerInfoService.getById(diyid);// 获取自定义风格信息
|
if (resDiyLayerInfo != null && resDiyLayerInfo.getContent() != null) {
|
JSONObject jsStr = JSONObject.parseObject(resDiyLayerInfo.getContent());
|
Json = jsStr.get("text").toString();
|
}
|
return Json;
|
}
|
}
|