| | |
| | | package com.lf.server.controller.data; |
| | | |
| | | import com.lf.server.controller.BaseController; |
| | | import com.lf.server.entity.all.ResponseMsg; |
| | | import com.lf.server.entity.data.DirEntity; |
| | | import com.lf.server.service.data.DirService; |
| | | import io.swagger.annotations.Api; |
| | | 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.*; |
| | | |
| | |
| | | * @author sws |
| | | * @date 2022-09-22 |
| | | */ |
| | | |
| | | @Api(tags = "目录管理") |
| | | @RestController |
| | | @RequestMapping("/dir") |
| | | public class DirController { |
| | | public class DirController extends BaseController { |
| | | @Autowired |
| | | DirService dirService; |
| | | |
| | | @ApiOperation(value = "插入数据") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "DirEntity", value = "目录实体类", dataType = "com.lf.server.entity.data.DirEntity", paramType = "body", example = "") |
| | | }) |
| | | @RequestMapping(value = "/insertDir", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") |
| | | public Integer insertDir(DirEntity dirEntity) { |
| | | public ResponseMsg<Integer> insertDir(DirEntity dirEntity) { |
| | | try { |
| | | int count = dirService.insertDir(dirEntity); |
| | | |
| | | return dirService.insertDir(dirEntity); |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), -1); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "插入多条数据") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "DirEntity", value = "目录实体类", dataType = "com.lf.server.entity.data.DirEntity", paramType = "body", example = "") |
| | | }) |
| | | @RequestMapping(value = "/insertDirs", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") |
| | | public Integer insertDirs(@RequestBody List<DirEntity> dirEntity) { |
| | | public ResponseMsg<Integer> insertDirs(@RequestBody List<DirEntity> dirEntity) { |
| | | try { |
| | | int count = dirService.insertDirs(dirEntity); |
| | | |
| | | return dirService.insertDirs(dirEntity); |
| | | } |
| | | |
| | | @ResponseBody |
| | | @RequestMapping(value = "/deleteDir", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") |
| | | public Integer deleteDir(int id) { |
| | | |
| | | return dirService.deleteDir(id); |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value = "/deleteDirs", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") |
| | | public Integer deleteDirs(@RequestBody List<Integer> ids) { |
| | | |
| | | if (!ids.isEmpty()) { |
| | | |
| | | return dirService.deleteDirs(ids); |
| | | |
| | | } else { |
| | | |
| | | return -1; |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), -1); |
| | | } |
| | | } |
| | | |
| | | @ResponseBody |
| | | @RequestMapping(value = "/updateDir", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") |
| | | public Integer updateDir(DirEntity dirEntity) { |
| | | @ApiOperation(value = "删除一条数据") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "主键ID", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/deleteDir") |
| | | public ResponseMsg<Integer> deleteDir(int id) { |
| | | try { |
| | | int count = dirService.deleteDir(id); |
| | | |
| | | return dirService.updateDir(dirEntity); |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), -1); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "删除多条数据") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "ids", value = "主键ID集合", dataType = "List<Integer>", paramType = "query", example = "1,2") |
| | | }) |
| | | @GetMapping(value = "/deleteDirs") |
| | | public ResponseMsg<Integer> deleteDirs( List<Integer> ids) { |
| | | try { |
| | | if (ids == null || ids.isEmpty()) { |
| | | return fail("id数组不能为空", -1); |
| | | } |
| | | |
| | | int count = dirService.deleteDirs(ids); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), -1); |
| | | } |
| | | } |
| | | @ApiOperation(value = "更新一条数据") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "dirEntity", value = "主键ID集合", dataType = "DictEntity", paramType = "body", example = "") |
| | | }) |
| | | @ResponseBody |
| | | @RequestMapping(value = "/updateDir", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") |
| | | public ResponseMsg<Integer> updateDir(DirEntity dirEntity) { |
| | | try { |
| | | int count = dirService.updateDir(dirEntity); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), -1); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "根据ID查询数据") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "主键ID", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @ResponseBody |
| | | @RequestMapping(value = "/selectDir", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") |
| | | public DirEntity selectDir(int id) { |
| | | return dirService.selectDir(id); |
| | | } |
| | | |
| | | @ApiOperation(value = "查询所有数据") |
| | | @GetMapping(value = "/selectDirAll") |
| | | public List<DirEntity> selectDirAll() { |
| | | |