BaseExpertController.java 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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.BaseExpert;
  6. import com.ozs.base.domain.vo.BaseExpertVo;
  7. import com.ozs.base.domain.vo.BaseProfessionalVo;
  8. import com.ozs.base.service.BaseExpertService;
  9. import com.ozs.common.annotation.Log;
  10. import com.ozs.common.constant.ModularConstans;
  11. import com.ozs.common.core.controller.BaseController;
  12. import com.ozs.common.core.domain.AjaxResult;
  13. import com.ozs.common.enums.BusinessType;
  14. import com.ozs.common.utils.PageUtils;
  15. import com.ozs.common.utils.StringUtils;
  16. import com.ozs.common.utils.bean.BeanUtils;
  17. import com.ozs.system.service.SysRegionService;
  18. import io.swagger.annotations.Api;
  19. import io.swagger.annotations.ApiOperation;
  20. import org.joda.time.DateTime;
  21. import org.springframework.beans.factory.annotation.Autowired;
  22. import org.springframework.security.access.prepost.PreAuthorize;
  23. import org.springframework.util.ObjectUtils;
  24. import org.springframework.web.bind.annotation.PostMapping;
  25. import org.springframework.web.bind.annotation.RequestBody;
  26. import org.springframework.web.bind.annotation.RequestMapping;
  27. import org.springframework.web.bind.annotation.RestController;
  28. import javax.validation.constraints.NotEmpty;
  29. import java.util.Date;
  30. import java.util.List;
  31. /**
  32. * 专家库管理
  33. *
  34. * @author sunhh
  35. */
  36. @Api(tags = "专家库管理")
  37. @RestController
  38. @RequestMapping("/base/expert")
  39. public class BaseExpertController extends BaseController {
  40. @Autowired
  41. private BaseExpertService baseExpertService;
  42. @Autowired
  43. private SysRegionService sysRegionService;
  44. @ApiOperation(value = "新增专家库", notes = "必传 专家库名称")
  45. @PostMapping("/insertExpert")
  46. @PreAuthorize("@ss.hasPermi('base:expert:insertExpert')")
  47. @Log(title = ModularConstans.expert, businessType = BusinessType.INSERT)
  48. public AjaxResult insertExpert(@RequestBody BaseExpertVo baseExpertVo) {
  49. if (StringUtils.isNull(baseExpertVo) || StringUtils.isNull(baseExpertVo.getExpertName())) {
  50. return error("专家库名称不能为空");
  51. }
  52. baseExpertVo.setCreated(getUserId().toString());
  53. baseExpertVo.setCreateTime(new Date());
  54. baseExpertVo.setUpdated(baseExpertVo.getCreated());
  55. baseExpertVo.setUpdateTime(baseExpertVo.getCreateTime());
  56. return toAjax(baseExpertService.insertExpert(baseExpertVo));
  57. }
  58. @ApiOperation(value = "删除专家库", notes = "必传 id")
  59. @PostMapping("/deleteExpert")
  60. @PreAuthorize("@ss.hasPermi('base:expert:deleteExpert')")
  61. @Log(title = ModularConstans.expert, businessType = BusinessType.DELETE)
  62. public AjaxResult deleteExpert(@RequestBody BaseExpert baseExpert) {
  63. if (StringUtils.isNull(baseExpert) || StringUtils.isNull(baseExpert.getId())) {
  64. return error("专家库id不能为空");
  65. }
  66. return toAjax(baseExpertService.removeById(baseExpert.getId()));
  67. }
  68. @ApiOperation(value = "修改专家库", notes = "必传 id 及修改数据")
  69. @PostMapping("/updateExpert")
  70. @PreAuthorize("@ss.hasPermi('base:expert:updateExpert')")
  71. @Log(title = ModularConstans.expert, businessType = BusinessType.UPDATE)
  72. public AjaxResult updateProfessional(@RequestBody BaseExpert baseExpert) {
  73. if (StringUtils.isNull(baseExpert) || StringUtils.isNull(baseExpert.getId())) {
  74. return error("专家库id和修改数据不能为空");
  75. }
  76. baseExpert.setUpdated(getUserId().toString());
  77. baseExpert.setUpdateTime(new Date());
  78. return toAjax(baseExpertService.updateById(baseExpert));
  79. }
  80. @ApiOperation(value = "查询专家库", notes = "非必传 查询条件:品目名称")
  81. @PostMapping("/selectExpert")
  82. @PreAuthorize("@ss.hasPermi('base:expert:selectExpert')")
  83. @Log(title = ModularConstans.expert, businessType = BusinessType.QUERY)
  84. public AjaxResult selectExpert(@RequestBody BaseExpertVo baseExpertVo) {
  85. LambdaQueryWrapper<BaseExpert> lw = new LambdaQueryWrapper<BaseExpert>();
  86. if (!StringUtils.isBlank(baseExpertVo.getExpertName())) {
  87. lw.like(BaseExpert::getExpertName, baseExpertVo.getExpertName());
  88. }
  89. if (!StringUtils.isBlank(baseExpertVo.getMajorType())) {
  90. lw.eq(BaseExpert::getMajorType, baseExpertVo.getMajorType());
  91. }
  92. if (!ObjectUtils.isEmpty(baseExpertVo.getMajorGrade())) {
  93. lw.eq(BaseExpert::getMajorGrade, baseExpertVo.getMajorGrade());
  94. }
  95. lw.orderBy(true, false, BaseExpert::getCreateTime);
  96. List<BaseExpert> list = baseExpertService.list(lw);
  97. // IPage<BaseExpert> page = baseExpertService.page(new Page<BaseExpert>(baseExpertVo.getPageNum(), baseExpertVo.getPageSize()), lw);
  98. // List<BaseExpert> records = page.getRecords();
  99. // 把 localArea 翻译为 省/市/县,存localAreaName中,(使用SysRegionService的getParentAdministrativeDivisionNames方法)
  100. List<BaseExpertVo> listVo = BeanUtils.entityListToVOList(list, BaseExpertVo.class);
  101. for (BaseExpertVo vo : listVo) {
  102. if (StringUtils.isNotNull(vo.getLocalArea())) {
  103. String parentAdministrativeDivisionNames = sysRegionService.getParentAdministrativeDivisionNames(vo.getLocalArea());
  104. vo.setLocalAreaName(parentAdministrativeDivisionNames);
  105. }
  106. }
  107. Page pages = PageUtils.getPages(baseExpertVo.getPageNum().intValue(), baseExpertVo.getPageSize().intValue(), listVo);
  108. return success(pages);
  109. }
  110. @ApiOperation(value = "黑白名单开关", notes = "必传id,status 其他字段不传; 黑名单传0,白名单传1")
  111. @PostMapping("/updateSupplierType")
  112. @PreAuthorize("@ss.hasPermi('base:expert:updateSupplierType')")
  113. @Log(title = ModularConstans.expert, businessType = BusinessType.UPDATE)
  114. public AjaxResult updateSupplierType(@RequestBody BaseExpert baseExpert) {
  115. if (StringUtils.isNull(baseExpert) || StringUtils.isNull(baseExpert.getId())
  116. || StringUtils.isNull(baseExpert.getStatus())) {
  117. return error("状态及ID不能为空");
  118. }
  119. // LambdaQueryWrapper<BaseExpert> lw = new LambdaQueryWrapper<BaseExpert>();
  120. // if (!StringUtils.isNull(baseExpert.getId())) {
  121. // lw.eq(BaseExpert::getId, baseExpert.getId());
  122. // }
  123. // if (!StringUtils.isBlank(baseExpert.getStatus())) {
  124. // lw.eq(BaseExpert::getStatus, baseExpert.getStatus());
  125. // }
  126. return toAjax(baseExpertService.updateSupplierType(baseExpert));
  127. }
  128. @ApiOperation(value = "评审项目", notes = "必传:分页,专家ID")
  129. @PostMapping("/selectReviewProject")
  130. @PreAuthorize("@ss.hasPermi('base:expert:selectReviewProject')")
  131. @Log(title = ModularConstans.expert, businessType = BusinessType.OTHER)
  132. public AjaxResult selectReviewProject(@RequestBody BaseExpertVo baseExpertVo) {
  133. if (StringUtils.isNull(baseExpertVo)
  134. || StringUtils.isNull(baseExpertVo.getPageNum())
  135. || StringUtils.isNull(baseExpertVo.getPageSize())
  136. || StringUtils.isNull(baseExpertVo.getId())) {
  137. return error("专家ID、分页 不能为空");
  138. }
  139. return baseExpertService.selectReviewProject(baseExpertVo);
  140. }
  141. @ApiOperation(value = "抽取专家", notes = "必传:分页;非必传:专家名称,开始结束时间")
  142. @PostMapping("/selectExtractionExpert")
  143. @PreAuthorize("@ss.hasPermi('base:expert:selectExtractionExpert')")
  144. @Log(title = ModularConstans.expert, businessType = BusinessType.OTHER)
  145. public AjaxResult selectExtractionExpert(@RequestBody BaseExpertVo baseExpertVo) {
  146. if (StringUtils.isNull(baseExpertVo)
  147. || StringUtils.isNull(baseExpertVo.getPageNum())
  148. || StringUtils.isNull(baseExpertVo.getPageSize())) {
  149. return error("分页 不能为空");
  150. }
  151. return baseExpertService.selectExtractionExpert(baseExpertVo);
  152. }
  153. }