月球大数据地理空间分析展示平台-【后端】-月球后台服务
1
13693261870
2024-11-11 fee67ca8a0760315047a52fc4101a8f4f80b7a7f
src/main/java/com/moon/server/controller/show/MarkController.java
@@ -14,43 +14,41 @@
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
 * 标绘
 * @author WWW
 */
@Api(tags = "综合展示\\标绘")
@RestController
@SuppressWarnings("ALL")
@RequestMapping("/mark")
public class MarkController extends BaseController {
    @Autowired
    @Resource
    MarkService markService;
    @Autowired
    @Resource
    TokenService tokenService;
    @Autowired
    @Resource
    BaseUploadService baseUploadService;
    @Autowired
    @Resource
    DownlogService downlogService;
    @Autowired
    @Resource
    DownloadService downloadService;
    @SysLog()
    @ApiOperation(value = "分页查询并返回记录数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "名称", dataType = "String", paramType = "query", example = ""),
            @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "Integer", paramType = "query", example = "10"),
            @ApiImplicitParam(name = "pageIndex", value = "分页数(从1开始)", dataType = "Integer", paramType = "query", example = "1")
    })
    @GetMapping(value = "/selectByPageAndCount")
    public ResponseMsg<List<MarkEntity>> selectByPageAndCount(Integer pageSize, Integer pageIndex, HttpServletRequest req) {
    public ResponseMsg<List<MarkEntity>> selectByPageAndCount(String name, Integer pageSize, Integer pageIndex, HttpServletRequest req) {
        try {
            if (pageSize < 1 || pageIndex < 1) {
                return fail("每页页数或分页数小于1", null);
@@ -60,12 +58,12 @@
                return fail("用户未登录", null);
            }
            int count = markService.selectCount(ue.getId());
            int count = markService.selectCount(name, ue.getId());
            if (count == 0) {
                return success(0, null);
            }
            List<MarkEntity> rs = markService.selectByPage(ue.getId(), pageSize, pageSize * (pageIndex - 1));
            List<MarkEntity> rs = markService.selectByPage(name, ue.getId(), pageSize, pageSize * (pageIndex - 1));
            return success(count, rs);
        } catch (Exception ex) {
@@ -79,9 +77,13 @@
            @ApiImplicitParam(name = "id", value = "ID", dataType = "int", paramType = "query", example = "1")
    })
    @GetMapping(value = "/selectById")
    public ResponseMsg<MarkEntity> selectById(int id) {
    public ResponseMsg<MarkEntity> selectById(int id, HttpServletRequest req) {
        try {
            MarkEntity entity = markService.selectById(id);
            UserEntity ue = tokenService.getCurrentUser(req);
            if (ue == null) {
                return fail("用户未登录", null);
            }
            MarkEntity entity = markService.selectById(id, ue.getId());
            return success(entity);
        } catch (Exception ex) {
@@ -94,6 +96,7 @@
    @ApiImplicitParams({
            @ApiImplicitParam(name = "entity", value = "实体类", dataType = "MarkEntity", paramType = "body")
    })
    @ResponseBody
    @PostMapping(value = "/insert", produces = "application/json; charset=UTF-8")
    public ResponseMsg<Integer> insert(@RequestBody MarkEntity entity, HttpServletRequest req) {
        try {
@@ -104,7 +107,7 @@
            int count = markService.insert(entity);
            return success(count);
            return success(count, entity.getId());
        } catch (Exception ex) {
            return fail(ex, -1);
        }
@@ -115,6 +118,7 @@
    @ApiImplicitParams({
            @ApiImplicitParam(name = "list", value = "实体类集合", dataType = "MarkEntity", paramType = "body")
    })
    @ResponseBody
    @PostMapping(value = "/inserts", produces = "application/json; charset=UTF-8")
    public ResponseMsg<Integer> inserts(@RequestBody List<MarkEntity> list, HttpServletRequest req) {
        try {
@@ -139,9 +143,13 @@
            @ApiImplicitParam(name = "id", value = "ID", dataType = "Integer", paramType = "query", example = "1")
    })
    @GetMapping(value = "/delete")
    public ResponseMsg<Integer> delete(int id) {
    public ResponseMsg<Integer> delete(int id, HttpServletRequest req) {
        try {
            int count = markService.delete(id);
            UserEntity ue = tokenService.getCurrentUser(req);
            if (ue == null) {
                return fail("用户未登录", null);
            }
            int count = markService.delete(id, ue.getId());
            return success(count);
        } catch (Exception ex) {
@@ -155,13 +163,17 @@
            @ApiImplicitParam(name = "ids", value = "ID数组", dataType = "Integer", paramType = "query", example = "1,2")
    })
    @GetMapping(value = "/deletes")
    public ResponseMsg<Integer> deletes(@RequestParam List<Integer> ids) {
    public ResponseMsg<Integer> deletes(@RequestParam List<Integer> ids, HttpServletRequest req) {
        try {
            if (ids == null || ids.isEmpty()) {
                return fail("id数组不能为空", -1);
            }
            UserEntity ue = tokenService.getCurrentUser(req);
            if (ue == null) {
                return fail("用户未登录", null);
            }
            int count = markService.deletes(ids);
            int count = markService.deletes(ids, ue.getId());
            return success(count);
        } catch (Exception ex) {
@@ -180,6 +192,7 @@
        try {
            UserEntity ue = tokenService.getCurrentUser(req);
            if (ue != null) {
                entity.setCreateUser(ue.getId());
                entity.setUpdateUser(ue.getId());
            }
@@ -203,6 +216,7 @@
            UserEntity ue = tokenService.getCurrentUser(req);
            if (ue != null) {
                for (MarkEntity entity : list) {
                    entity.setCreateUser(ue.getId());
                    entity.setUpdateUser(ue.getId());
                }
            }