| | |
| | | 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.DepEntity; |
| | | import com.lf.server.entity.data.DictEntity; |
| | | import com.lf.server.service.data.DepService; |
| | | 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.*; |
| | | |
| | |
| | | * @date 2022-09-23 |
| | | */ |
| | | |
| | | @Api(tags = "组织机构") |
| | | @RestController |
| | | @RequestMapping("/dep") |
| | | public class DepController { |
| | | public class DepController extends BaseController { |
| | | @Autowired |
| | | DepService depService; |
| | | |
| | | @RequestMapping(value ="/insertDep", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") |
| | | public Integer insertDep(DepEntity depEntity){ |
| | | @ApiOperation(value = "插入数据") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "DepEntity", value = "字典实体类", dataType = "com.lf.server.entity.data.DepEntity", paramType = "body", example = "") |
| | | }) |
| | | @RequestMapping(value = "/insertDep", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") |
| | | public ResponseMsg<Integer> insertDep(DepEntity depEntity) { |
| | | try { |
| | | int count = depService.insertDep(depEntity); |
| | | |
| | | return depService.insertDep(depEntity); |
| | | } |
| | | |
| | | @RequestMapping(value ="/insertDes", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") |
| | | public Integer insertDes(@RequestBody List<DepEntity> depEntity){ |
| | | |
| | | return depService.insertDeps(depEntity); |
| | | } |
| | | @ResponseBody |
| | | @RequestMapping(value ="/deleteDep", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") |
| | | public Integer deleteDep(int id){ |
| | | return depService.deleteDep(id); |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value ="/deleteDeps", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") |
| | | public Integer deleteDeps(@RequestBody List<Integer> ids){ |
| | | if(!ids.isEmpty()){ |
| | | return depService.deleteDeps(ids); |
| | | }else { |
| | | return -1; |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), -1); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "插入多条数据") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "DepEntity", value = "字典实体类", dataType = "com.lf.server.entity.data.DepEntity", paramType = "body", example = "") |
| | | }) |
| | | @RequestMapping(value = "/insertDes", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") |
| | | public ResponseMsg<Integer> insertDes(@RequestBody List<DepEntity> depEntity) { |
| | | try { |
| | | int count = depService.insertDeps(depEntity); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), -1); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "删除一条数据") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "主键ID", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/deleteDep") |
| | | public ResponseMsg<Integer> deleteDep(int id) { |
| | | try { |
| | | int count = depService.deleteDep(id); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), -1); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "删除多条数据") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "ids", value = "主键ID", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/deleteDeps") |
| | | public ResponseMsg<Integer> deleteDeps(List<Integer> ids) { |
| | | try { |
| | | if (ids == null || ids.isEmpty()) { |
| | | return fail("id数组不能为空", -1); |
| | | } |
| | | |
| | | int count = depService.deleteDeps(ids); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), -1); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "更新一条数据") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "depEntity", value = "主键ID集合", dataType = "DepEntity", paramType = "body", example = "") |
| | | }) |
| | | @ResponseBody |
| | | @RequestMapping(value ="/updateDep", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") |
| | | public Integer updateDep(DepEntity depEntity){ |
| | | return depService.updateDep(depEntity); |
| | | @RequestMapping(value = "/updateDep", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") |
| | | public ResponseMsg<Integer> updateDep(DepEntity depEntity) { |
| | | try { |
| | | int count = depService.updateDep(depEntity); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), -1); |
| | | } |
| | | } |
| | | |
| | | @GetMapping(value ="/selectDep") |
| | | public DepEntity selectDep(int id){ |
| | | return depService.selectDep(id); |
| | | @ApiOperation(value = "根据ID查询") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "主键ID", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/selectDep") |
| | | public ResponseMsg<DepEntity> selectDep(int id) { |
| | | try { |
| | | DepEntity de = depService.selectDep(id); |
| | | return success(de); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | } |
| | | } |
| | | |
| | | @GetMapping(value ="/selectDepAll") |
| | | public List<DepEntity> selectDepAll( ){ |
| | | return depService.selectDepAll( ); |
| | | @ApiOperation(value = "查询所有数据") |
| | | @GetMapping(value = "/selectDepAll") |
| | | public ResponseMsg<List<DepEntity>> selectDepAll() { |
| | | try { |
| | | List<DepEntity> list = depService.selectDepAll(); |
| | | return success(list); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | } |
| | | } |
| | | |
| | | } |