月球大数据地理空间分析展示平台-【后端】-月球后台服务
13693261870
2023-09-25 18b0beec7bf9b755e5d2cc0116bccb0ee2403996
src/main/java/com/moon/server/controller/show/MarkController.java
@@ -14,9 +14,9 @@
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;
@@ -28,29 +28,30 @@
@RestController
@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 +61,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 +80,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) {
@@ -139,9 +144,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 +164,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) {