BaseExpertController.java 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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.service.BaseExpertService;
  8. import com.ozs.common.annotation.Log;
  9. import com.ozs.common.constant.ModularConstans;
  10. import com.ozs.common.core.controller.BaseController;
  11. import com.ozs.common.core.domain.AjaxResult;
  12. import com.ozs.common.enums.BusinessType;
  13. import com.ozs.common.utils.StringUtils;
  14. import io.swagger.annotations.Api;
  15. import io.swagger.annotations.ApiOperation;
  16. import org.joda.time.DateTime;
  17. import org.springframework.beans.factory.annotation.Autowired;
  18. import org.springframework.security.access.prepost.PreAuthorize;
  19. import org.springframework.util.ObjectUtils;
  20. import org.springframework.web.bind.annotation.PostMapping;
  21. import org.springframework.web.bind.annotation.RequestBody;
  22. import org.springframework.web.bind.annotation.RequestMapping;
  23. import org.springframework.web.bind.annotation.RestController;
  24. import javax.validation.constraints.NotEmpty;
  25. /**
  26. * 专家库管理
  27. *
  28. * @author sunhh
  29. */
  30. @Api(tags = "专家库管理")
  31. @RestController
  32. @RequestMapping("/base/expert")
  33. public class BaseExpertController extends BaseController {
  34. @Autowired
  35. private BaseExpertService baseExpertService;
  36. @ApiOperation(value = "新增专家库", notes = "必传 专家库名称")
  37. @PostMapping("/insertExpert")
  38. @PreAuthorize("@ss.hasPermi('base:expert:insertExpert')")
  39. @Log(title = ModularConstans.policy, businessType = BusinessType.INSERT)
  40. public AjaxResult insertExpert(@RequestBody BaseExpert baseExpert) {
  41. if (StringUtils.isNull(baseExpert) || StringUtils.isNull(baseExpert.getExpertName())) {
  42. return error("专家库名称不能为空");
  43. }
  44. return toAjax(baseExpertService.insertExpert(baseExpert));
  45. }
  46. @ApiOperation(value = "删除专家库", notes = "必传 id")
  47. @PostMapping("/deleteExpert")
  48. public AjaxResult deleteExpert(@RequestBody BaseExpert baseExpert) {
  49. if (StringUtils.isNull(baseExpert) || StringUtils.isNull(baseExpert.getId())) {
  50. return error("专家库id不能为空");
  51. }
  52. return toAjax(baseExpertService.removeById(baseExpert.getId()));
  53. }
  54. @ApiOperation(value = "修改专家库", notes = "必传 id 及修改数据")
  55. @PostMapping("/updateExpert")
  56. public AjaxResult updateProfessional(@RequestBody BaseExpert baseExpert) {
  57. if (StringUtils.isNull(baseExpert) || StringUtils.isNull(baseExpert.getId())) {
  58. return error("专家库id和修改数据不能为空");
  59. }
  60. return toAjax(baseExpertService.updateById(baseExpert));
  61. }
  62. @ApiOperation(value = "查询专家库", notes = "非必传 查询条件:品目名称")
  63. @PostMapping("/selectExpert")
  64. public AjaxResult selectExpert(@RequestBody BaseExpertVo baseExpertVo) {
  65. LambdaQueryWrapper<BaseExpert> lw = new LambdaQueryWrapper<BaseExpert>();
  66. if (!StringUtils.isBlank(baseExpertVo.getExpertNameVo())) {
  67. lw.like(BaseExpert::getExpertName, baseExpertVo.getExpertNameVo());
  68. }
  69. if (!StringUtils.isBlank(baseExpertVo.getMajorTypeVo())) {
  70. lw.eq(BaseExpert::getMajorType, baseExpertVo.getMajorTypeVo());
  71. }
  72. if (!ObjectUtils.isEmpty(baseExpertVo.getMajorGradeVo())) {
  73. lw.eq(BaseExpert::getMajorGrade, baseExpertVo.getMajorGradeVo());
  74. }
  75. IPage<BaseExpert> page = baseExpertService.page(new Page<BaseExpert>(baseExpertVo.getPageNum(), baseExpertVo.getPageSize()), lw);
  76. return success(page);
  77. }
  78. @ApiOperation(value = "黑白名单开关", notes = "必传id,status 其他字段不传; 黑名单传0,白名单传1")
  79. @PostMapping("/updateSupplierType")
  80. public AjaxResult updateSupplierType(@RequestBody BaseExpert baseExpert) {
  81. if (StringUtils.isNull(baseExpert) || StringUtils.isNull(baseExpert.getId())
  82. || StringUtils.isNull(baseExpert.getStatus())) {
  83. return error("状态及ID不能为空");
  84. }
  85. // LambdaQueryWrapper<BaseExpert> lw = new LambdaQueryWrapper<BaseExpert>();
  86. // if (!StringUtils.isNull(baseExpert.getId())) {
  87. // lw.eq(BaseExpert::getId, baseExpert.getId());
  88. // }
  89. // if (!StringUtils.isBlank(baseExpert.getStatus())) {
  90. // lw.eq(BaseExpert::getStatus, baseExpert.getStatus());
  91. // }
  92. return toAjax(baseExpertService.updateSupplierType(baseExpert));
  93. }
  94. }