月球大数据地理空间分析展示平台-【后端】-月球后台服务
13693261870
2023-09-03 d950bfac44ca8dcdfe91de52fde0fe86e0829753
src/main/java/com/moon/server/controller/data/PublishController.java
@@ -8,9 +8,9 @@
import com.moon.server.entity.data.PublishEntity;
import com.moon.server.entity.sys.UserEntity;
import com.moon.server.helper.StringHelper;
import com.moon.server.helper.WebHelper;
import com.moon.server.service.all.PermsService;
import com.moon.server.service.data.PublishService;
import com.moon.server.service.data.ShuJianService;
import com.moon.server.service.sys.TokenService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
@@ -20,7 +20,7 @@
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
@@ -39,6 +39,9 @@
    @Resource
    PermsService permsService;
    @Resource
    ShuJianService shuJianService;
    @SysLog()
    @ApiOperation(value = "分页查询元数据")
@@ -162,79 +165,95 @@
    }
    @SysLog()
    @ApiOperation(value = "插入发布数据")
    @ApiOperation(value = "分页查询数简的颜色表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", example = "10"),
            @ApiImplicitParam(name = "pageIndex", value = "分页数(从1开始)", dataType = "int", paramType = "query", example = "1")
    })
    @GetMapping(value = "/selectSjColorTables")
    public void selectSjColorTables(int pageSize, int pageIndex, HttpServletRequest req, HttpServletResponse res) {
        pageIndex = Math.max(pageIndex, 1);
        pageSize = Math.max(pageSize, 5);
        shuJianService.selectSjColorTables(pageSize, pageIndex, req, res);
    }
    @SysLog()
    @ApiOperation(value = "插入数简服务")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "entity", value = "实体类", dataType = "PubEntity", paramType = "body")
    })
    @PostMapping(value = "/insertForPub", produces = "application/json; charset=UTF-8")
    public ResponseMsg<Object> insertForPub(@RequestBody PubEntity entity, HttpServletRequest req) {
    @ResponseBody
    @PostMapping(value = "/insertSjService", produces = "application/json; charset=UTF-8")
    public ResponseMsg<Object> insertSjService(@RequestBody PubEntity entity, HttpServletRequest req, HttpServletResponse res) {
        try {
            if (null == entity || null == entity.getIds() || entity.getIds().isEmpty()) {
                return fail("实体类为空或找不到元数据ID", 0);
            }
            if (StringHelper.isEmpty(entity.getType())) {
                return fail("数据类别为空", null);
                return fail("发布类别为空", null);
            }
            UserEntity ue = tokenService.getCurrentUser(req);
            if (ue != null) {
            if (null != ue) {
                entity.setUserId(ue.getId());
                entity.setToken(WebHelper.getToken(req));
                entity.setDepcode(ue.getDepcode());
            }
            permsService.clearPermsCache();
            // String method = getConvertMethod(entity.getType())
            long count = publishService.postForPub(entity, "", req);
            Integer rows = shuJianService.insertSjService(entity);
            return success(count);
            return success(rows);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
        }
    }
    @SysLog()
    @ApiOperation(value = "删除多条")
    @ApiOperation(value = "更新数简服务")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "entity", value = "实体类", dataType = "PubEntity", paramType = "body")
    })
    @ResponseBody
    @PostMapping(value = "/updateSjService", produces = "application/json; charset=UTF-8")
    public ResponseMsg<Object> updateSjService(@RequestBody PubEntity entity, HttpServletRequest req, HttpServletResponse res) {
        try {
            if (null == entity || null == entity.getPubid()) {
                return fail("实体类为空或发布ID为空", 0);
            }
            if (StringHelper.isEmpty(entity.getType())) {
                return fail("发布类别为空", null);
            }
            UserEntity ue = tokenService.getCurrentUser(req);
            if (null != ue) {
                entity.setUserId(ue.getId());
                entity.setDepcode(ue.getDepcode());
            }
            permsService.clearPermsCache();
            Integer rows = shuJianService.updateSjService(entity, req, res);
            return success(rows);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
        }
    }
    @SysLog()
    @ApiOperation(value = "删除数简服务")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ids", value = "ID数组", dataType = "Integer", paramType = "query", allowMultiple = true, example = "1")
    })
    @GetMapping(value = "/deletes")
    public ResponseMsg<Integer> deletes(@RequestParam List<Integer> ids, HttpServletRequest req) {
    public ResponseMsg<Integer> deletesSjServices(@RequestParam List<Integer> ids) {
        try {
            if (ids == null || ids.isEmpty()) {
            if (null == ids || ids.isEmpty()) {
                return fail("id数组不能为空", -1);
            }
            String strs = StringHelper.join(ids, ",");
            List<PublishEntity> list = publishService.selectByIds(strs);
            if (null == list || list.isEmpty()) {
                return fail("没有找到要删除的数据", -1);
            }
            permsService.clearPermsCache();
            int count = publishService.deletes(ids, req);
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
        }
    }
    @SysLog()
    @ApiOperation(value = "更新一条")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "entity", value = "实体类", dataType = "PublishEntity", paramType = "body")
    })
    @ResponseBody
    @PostMapping(value = "/update", produces = "application/json; charset=UTF-8")
    public ResponseMsg<Integer> update(@RequestBody PublishEntity entity, HttpServletRequest req) {
        try {
            UserEntity ue = tokenService.getCurrentUser(req);
            if (ue != null) {
                entity.setUpdateUser(ue.getId());
            }
            permsService.clearPermsCache();
            int count = publishService.update(entity);
            int count = shuJianService.deletesSjServices(ids);
            return success(count);
        } catch (Exception ex) {