¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.moon.server.controller.sys; |
| | | |
| | | import com.moon.server.annotation.SysLog; |
| | | import com.moon.server.controller.all.BaseController; |
| | | import com.moon.server.entity.all.ResponseMsg; |
| | | import com.moon.server.entity.sys.ResOpEntity; |
| | | import com.moon.server.entity.sys.UserEntity; |
| | | import com.moon.server.service.sys.ResOpService; |
| | | import com.moon.server.service.sys.TokenService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.sql.Timestamp; |
| | | import java.util.List; |
| | | |
| | | @SuppressWarnings("ALL") |
| | | @Api(tags = "è¿ç»´ç®¡ç\\èµæºæä½") |
| | | @RestController |
| | | @RequestMapping("/resOp") |
| | | public class ResOpController extends BaseController { |
| | | @Resource |
| | | ResOpService resOpService; |
| | | |
| | | @Resource |
| | | TokenService tokenService; |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "æ¥è¯¢è®°å½æ°") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "name", value = "èµæºåç§°", dataType = "String", paramType = "query", example = "天å°å¾"), |
| | | @ApiImplicitParam(name = "type", value = "æä½ç±»å", dataType = "Integer", paramType = "query", example = "1"), |
| | | @ApiImplicitParam(name = "start", value = "å¼å§æ¶é´", dataType = "Timestamp", paramType = "query", example = "2022-10-09 09:00:00"), |
| | | @ApiImplicitParam(name = "end", value = "ç»ææ¶é´", dataType = "Timestamp", paramType = "query", example = "2022-10-10 18:00:00"), |
| | | }) |
| | | @GetMapping({"/selectCount"}) |
| | | public ResponseMsg<Integer> selectCount(String name, Integer type, Timestamp start, Timestamp end) { |
| | | try { |
| | | int count = resOpService.selectCount(name, type, start, end); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | | return fail(ex, -1); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "å页æ¥è¯¢") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "name", value = "èµæºåç§°", dataType = "String", paramType = "query", example = "天å°å¾"), |
| | | @ApiImplicitParam(name = "type", value = "æä½ç±»å", dataType = "Integer", paramType = "query", example = "1"), |
| | | @ApiImplicitParam(name = "start", value = "å¼å§æ¶é´", dataType = "Timestamp", paramType = "query", example = "2022-10-09 09:00:00"), |
| | | @ApiImplicitParam(name = "end", value = "ç»ææ¶é´", dataType = "Timestamp", paramType = "query", example = "2022-10-10 18:00:00"), |
| | | @ApiImplicitParam(name = "pageSize", value = "æ¯é¡µæ¡æ°", dataType = "Integer", paramType = "query", example = "10"), |
| | | @ApiImplicitParam(name = "pageIndex", value = "å页æ°ï¼ä»1å¼å§ï¼", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/selectByPage") |
| | | public ResponseMsg<List<ResOpEntity>> selectByPage(String name, Integer type, Timestamp start, Timestamp end, Integer pageSize, Integer pageIndex) { |
| | | try { |
| | | if (pageSize < 1 || pageIndex < 1) { |
| | | return fail("æ¯é¡µé¡µæ°æå页æ°å°äº1", null); |
| | | } |
| | | List<ResOpEntity> rs = resOpService.selectByPage(name, type, start, end, pageSize, pageSize * (pageIndex - 1)); |
| | | return success(rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "å页æ¥è¯¢å¹¶è¿åè®°å½æ°") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "name", value = "èµæºåç§°", dataType = "String", paramType = "query", example = "天å°å¾"), |
| | | @ApiImplicitParam(name = "type", value = "æä½ç±»å", dataType = "Integer", paramType = "query", example = "1"), |
| | | @ApiImplicitParam(name = "start", value = "å¼å§æ¶é´", dataType = "Timestamp", paramType = "query", example = "2022-10-09 09:00:00"), |
| | | @ApiImplicitParam(name = "end", value = "ç»ææ¶é´", dataType = "Timestamp", paramType = "query", example = "2022-10-10 18:00:00"), |
| | | @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<ResOpEntity>> selectByPageAndCount(String name, Integer type, Timestamp start, Timestamp end, Integer pageSize, Integer pageIndex) { |
| | | try { |
| | | if (pageSize < 1 || pageIndex < 1) { |
| | | return fail("æ¯é¡µé¡µæ°æå页æ°å°äº1", null); |
| | | } |
| | | |
| | | int count = resOpService.selectCount(name, type, start, end); |
| | | if (count == 0) { |
| | | return success(0, null); |
| | | } |
| | | |
| | | List<ResOpEntity> rs = resOpService.selectByPage(name, type, start, end, pageSize, pageSize * (pageIndex - 1)); |
| | | |
| | | return success(count, rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "æå
¥ä¸æ¡") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "entity", value = "å®ä½ç±»", dataType = "com.lf.server.entity.sys.ResOpEntity", paramType = "body", example = "") |
| | | }) |
| | | @PostMapping(value = "/insertResOp", produces = "application/json; charset=UTF-8") |
| | | public ResponseMsg<Integer> insertResOp(@RequestBody ResOpEntity entity, HttpServletRequest req) { |
| | | try { |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue != null) { |
| | | entity.setUserid(ue.getId()); |
| | | } |
| | | |
| | | int count = resOpService.insertResOp(entity); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | | return fail(ex, -1); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "æå
¥å¤æ¡") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "list", value = "å®ä½ç±»éå", dataType = "List<ResOpEntity>", paramType = "body", example = "") |
| | | }) |
| | | @PostMapping(value = "/insertResOps", produces = "application/json; charset=UTF-8") |
| | | public ResponseMsg<Integer> insertResOps(@RequestBody List<ResOpEntity> list, HttpServletRequest req) { |
| | | try { |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue != null) { |
| | | for (ResOpEntity entity : list) { |
| | | entity.setUserid(ue.getId()); |
| | | } |
| | | } |
| | | |
| | | int count = resOpService.insertResOps(list); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | | return fail(ex, -1); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "å é¤ä¸æ¡") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "ID", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/deleteLogin") |
| | | public ResponseMsg<Integer> deleteResOp(int id) { |
| | | try { |
| | | int count = resOpService.deleteResOp(id); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | | return fail(ex, -1); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "å é¤å¤æ¡") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "ids", value = "IDæ°ç»", dataType = "List<Integer>", paramType = "query", example = "1,2") |
| | | }) |
| | | @GetMapping(value = "/deleteResOps") |
| | | public ResponseMsg<Integer> deleteResOps(@RequestParam List<Integer> ids) { |
| | | try { |
| | | if (ids == null || ids.isEmpty()) { |
| | | return fail("idæ°ç»ä¸è½ä¸ºç©º", -1); |
| | | } |
| | | int count = resOpService.deleteResOps(ids); |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | | return fail(ex, -1); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "æ´æ°ä¸æ¡") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "entity", value = "IDæ°ç»", dataType = "LoginEntity", paramType = "body", example = "") |
| | | }) |
| | | @ResponseBody |
| | | @PostMapping(value = "/updateResOp", produces = "application/json; charset=UTF-8") |
| | | public ResponseMsg<Integer> updateResOp(@RequestBody ResOpEntity entity, HttpServletRequest req) { |
| | | try { |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue != null) { |
| | | entity.setUserid(ue.getId()); |
| | | } |
| | | |
| | | int count = resOpService.updateResOp(entity); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | | return fail(ex, -1); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "æ ¹æ®IDæ¥è¯¢") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "ID", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/selectResOp") |
| | | public ResponseMsg<ResOpEntity> selectResOp(int id) { |
| | | try { |
| | | ResOpEntity resOpEntity = resOpService.selectResOp(id); |
| | | |
| | | return success(resOpEntity); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "æ¥è¯¢ææ") |
| | | @GetMapping(value = "/selectResOpAll") |
| | | public ResponseMsg<List<ResOpEntity>> selectResOpAll() { |
| | | try { |
| | | List<ResOpEntity> list = resOpService.selectResOpAll(); |
| | | |
| | | return success(list); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | } |