BaseAgencyController.java 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. package com.ozs.web.controller.base;
  2. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  3. import com.baomidou.mybatisplus.core.metadata.IPage;
  4. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  5. import com.ozs.base.domain.BaseAgency;
  6. import com.ozs.base.service.BaseAgencyService;
  7. import com.ozs.base.vo.BaseAgentPageReqVo;
  8. import com.ozs.common.annotation.Log;
  9. import com.ozs.common.core.controller.BaseController;
  10. import com.ozs.common.core.domain.AjaxResult;
  11. import com.ozs.common.enums.BusinessType;
  12. import io.swagger.annotations.Api;
  13. import io.swagger.annotations.ApiOperation;
  14. import org.apache.commons.lang3.StringUtils;
  15. import org.springframework.beans.factory.annotation.Autowired;
  16. import org.springframework.security.access.prepost.PreAuthorize;
  17. import org.springframework.util.ObjectUtils;
  18. import org.springframework.web.bind.annotation.*;
  19. import javax.validation.constraints.NotEmpty;
  20. import java.util.Date;
  21. @Api(tags = "招标代理机构管理")
  22. @RestController
  23. @RequestMapping("/base/agency")
  24. public class BaseAgencyController extends BaseController {
  25. @Autowired
  26. private BaseAgencyService baseAgencyService;
  27. @ApiOperation(value = "新增招标代理机构")
  28. @PostMapping("/insertBaseAgency")
  29. @PreAuthorize("@ss.hasPermi('base:agency:add')")
  30. @Log(title = "招标代理机构管理", businessType = BusinessType.INSERT)
  31. public AjaxResult insertBaseAgency(@NotEmpty(message = "数据为空") @RequestBody BaseAgency baseAgency) {
  32. // if (ObjectUtils.isEmpty(baseAgency)) {
  33. // return error("数据为空");
  34. // }
  35. baseAgency.setStatus(0);
  36. baseAgency.setCreated(getUserId().toString());
  37. baseAgency.setCreateTime(new Date());
  38. baseAgency.setUpdated(baseAgency.getCreated());
  39. baseAgency.setUpdateTime(baseAgency.getCreateTime());
  40. return toAjax(baseAgencyService.insert(baseAgency));
  41. }
  42. @ApiOperation(value = "查看招标代理机构")
  43. @PostMapping("/getInfo")
  44. @PreAuthorize("@ss.hasPermi('base:agency:query')")
  45. @Log(title = "招标代理机构管理", businessType = BusinessType.QUERY)
  46. public AjaxResult getInfo(@NotEmpty(message = "主键id不能为空")
  47. @RequestParam(value = "id", required = true)
  48. Long id) {
  49. return success(baseAgencyService.getInfo(id));
  50. }
  51. @ApiOperation(value = "修改招标代理机构信息")
  52. @PostMapping("/updateInfo")
  53. @PreAuthorize("@ss.hasPermi('base:agency:edit')")
  54. @Log(title = "招标代理机构管理", businessType = BusinessType.UPDATE)
  55. public AjaxResult updateInfo(@NotEmpty(message = "数据为空")
  56. @RequestBody BaseAgency baseAgency) {
  57. baseAgency.setUpdateTime(new Date());
  58. baseAgency.setUpdated(getUserId().toString());
  59. return toAjax(baseAgencyService.updateInfo(baseAgency));
  60. }
  61. @ApiOperation(value = "操作招标代理机构黑白名单")
  62. @PostMapping("/operationBlacklist")
  63. @PreAuthorize("@ss.hasPermi('base:agency:edit')")
  64. @Log(title = "招标代理机构管理", businessType = BusinessType.UPDATE)
  65. public AjaxResult operationBlacklist(@NotEmpty(message = "主键id不能为空")
  66. @RequestParam(value = "id", required = true)
  67. Long id,
  68. @NotEmpty(message = "状态不能为空")
  69. @RequestParam(value = "status", required = true)
  70. Integer status) {
  71. BaseAgency build = BaseAgency.builder().id(id).status(status).build();
  72. build.setUpdated(getUserId().toString());
  73. build.setUpdateTime(new Date());
  74. return toAjax(baseAgencyService.operationBlacklist(build));
  75. }
  76. @ApiOperation(value = "删除招标代理机构信息")
  77. @PostMapping("/remove")
  78. @PreAuthorize("@ss.hasPermi('base:agency:remove')")
  79. @Log(title = "招标代理机构管理", businessType = BusinessType.DELETE)
  80. public AjaxResult remove(@NotEmpty(message = "主键id不能为空")
  81. @RequestParam(value = "id", required = true)
  82. Long id) {
  83. return toAjax(baseAgencyService.remove(id));
  84. }
  85. @ApiOperation(value = "分页查询招标代理机构信息")
  86. @PostMapping("/page")
  87. @PreAuthorize("@ss.hasPermi('base:agency:list')")
  88. @Log(title = "招标代理机构管理", businessType = BusinessType.QUERY)
  89. public AjaxResult page(@NotEmpty(message = "数据为空") @RequestBody BaseAgentPageReqVo vo) {
  90. LambdaQueryWrapper<BaseAgency> lw = new LambdaQueryWrapper<BaseAgency>();
  91. if(!StringUtils.isBlank(vo.getCompanyName())){
  92. lw.like(BaseAgency::getCompanyName,vo.getCompanyName());
  93. }
  94. if(!StringUtils.isBlank(vo.getCompanyNature())){
  95. lw.eq(BaseAgency::getCompanyNature,vo.getCompanyNature());
  96. }
  97. if(!ObjectUtils.isEmpty(vo.getStatus())){
  98. lw.eq(BaseAgency::getStatus,vo.getStatus());
  99. }
  100. IPage<BaseAgency> page = baseAgencyService.page(new Page<BaseAgency>(vo.getPageNum(), vo.getPageSize()), lw);
  101. return success(page);
  102. }
  103. }