| | |
| | | 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); |
| | |
| | | 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) { |
| | |
| | | @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) { |
| | |
| | | @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 { |
| | |
| | | |
| | | int count = markService.insert(entity); |
| | | |
| | | return success(count); |
| | | return success(count, entity.getId()); |
| | | } catch (Exception ex) { |
| | | return fail(ex, -1); |
| | | } |
| | |
| | | @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 { |
| | |
| | | @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) { |
| | |
| | | @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) { |
| | |
| | | try { |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue != null) { |
| | | entity.setCreateUser(ue.getId()); |
| | | entity.setUpdateUser(ue.getId()); |
| | | } |
| | | |
| | |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue != null) { |
| | | for (MarkEntity entity : list) { |
| | | entity.setCreateUser(ue.getId()); |
| | | entity.setUpdateUser(ue.getId()); |
| | | } |
| | | } |