2
13693261870
2022-09-16 653761a31dfeb50dd3d007e892d69c90bf0cdafc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
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;
    }
}