IpAccountController.java 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. package com.hr.controller;
  2. import com.hr.param.IpAccountParam;
  3. import com.hr.param.SwitchStatusParam;
  4. import com.hr.service.IpAccountService;
  5. import com.hr.vo.IpAccountVO;
  6. import com.yy.basedevelop.common.data.BasePageResult;
  7. import com.yy.basedevelop.common.data.BaseReturnDto;
  8. import com.yy.basedevelop.common.http.config.TokenUtil;
  9. import com.yy.basedevelop.dto.LoginUser;
  10. import io.swagger.v3.oas.annotations.Operation;
  11. import io.swagger.v3.oas.annotations.tags.Tag;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.data.domain.Page;
  14. import org.springframework.web.bind.annotation.*;
  15. /**
  16. * 账户管理
  17. * @author : longhoo
  18. * @date : 2025-10-10
  19. */
  20. @RestController
  21. @RequestMapping("/ipAccount")
  22. @Tag(name = "账户管理")
  23. public class IpAccountController{
  24. @Autowired
  25. private IpAccountService ipAccountService;
  26. /**
  27. * 分页查询
  28. *
  29. * @param ipAccountParam 筛选条件
  30. * @return 查询结果
  31. */
  32. @Operation(summary = "分页查询")
  33. @GetMapping
  34. public BasePageResult<IpAccountVO> paginQuery(@RequestBody IpAccountParam ipAccountParam){
  35. Page<IpAccountVO> ipAccountPOS = ipAccountService.paginQuery(ipAccountParam, ipAccountParam.getPageNum(), ipAccountParam.getPageSize());
  36. return BasePageResult.success(ipAccountPOS.getContent(), ipAccountPOS.getTotalElements(), ipAccountParam.getPageNum(), ipAccountParam.getPageSize());
  37. }
  38. /**
  39. * 新增数据
  40. *
  41. * @param accountParam 实例对象
  42. * @return 实例对象
  43. */
  44. @Operation(summary = "新增/更新数据")
  45. @PostMapping
  46. public BaseReturnDto<IpAccountVO> saveOrUpdate(@RequestBody IpAccountParam accountParam){
  47. LoginUser user= TokenUtil.getUser();
  48. ipAccountService.saveOrUpdate(accountParam,user.getUsername(),user.getUserid());
  49. return BaseReturnDto.success();
  50. }
  51. /**
  52. * 通过主键删除数据
  53. *
  54. * @param id 主键
  55. * @return 是否成功
  56. */
  57. @Operation(summary = "通过主键删除数据")
  58. @DeleteMapping
  59. public BaseReturnDto<Boolean> deleteById(Long id){
  60. return BaseReturnDto.success(ipAccountService.deleteById(id));
  61. }
  62. /**
  63. * 修改状态
  64. *
  65. * @param switchStatusParam 主键
  66. * @return 是否成功
  67. */
  68. @Operation(summary = "修改状态")
  69. @PostMapping("/switchStatus")
  70. public BaseReturnDto<Boolean> switchStatus(@RequestBody SwitchStatusParam switchStatusParam){
  71. return BaseReturnDto.success(ipAccountService.switchStatus(switchStatusParam));
  72. }
  73. }