123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- package com.ozs.web.controller.base;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.ozs.base.domain.BaseExpert;
- import com.ozs.base.domain.vo.BaseExpertVo;
- import com.ozs.base.domain.vo.BaseProfessionalVo;
- import com.ozs.base.service.BaseExpertService;
- import com.ozs.common.annotation.Log;
- import com.ozs.common.constant.ModularConstans;
- import com.ozs.common.core.controller.BaseController;
- import com.ozs.common.core.domain.AjaxResult;
- import com.ozs.common.enums.BusinessType;
- import com.ozs.common.utils.PageUtils;
- import com.ozs.common.utils.StringUtils;
- import com.ozs.common.utils.bean.BeanUtils;
- import com.ozs.system.service.SysRegionService;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import org.joda.time.DateTime;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.security.access.prepost.PreAuthorize;
- import org.springframework.util.ObjectUtils;
- import org.springframework.web.bind.annotation.PostMapping;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RestController;
- import javax.validation.constraints.NotEmpty;
- import java.util.Date;
- import java.util.List;
- /**
- * 专家库管理
- *
- * @author sunhh
- */
- @Api(tags = "专家库管理")
- @RestController
- @RequestMapping("/base/expert")
- public class BaseExpertController extends BaseController {
- @Autowired
- private BaseExpertService baseExpertService;
- @Autowired
- private SysRegionService sysRegionService;
- @ApiOperation(value = "新增专家库", notes = "必传 专家库名称")
- @PostMapping("/insertExpert")
- @PreAuthorize("@ss.hasPermi('base:expert:insertExpert')")
- @Log(title = ModularConstans.expert, businessType = BusinessType.INSERT)
- public AjaxResult insertExpert(@RequestBody BaseExpertVo baseExpertVo) {
- if (StringUtils.isNull(baseExpertVo) || StringUtils.isNull(baseExpertVo.getExpertName())) {
- return error("专家库名称不能为空");
- }
- baseExpertVo.setCreated(getUserId().toString());
- baseExpertVo.setCreateTime(new Date());
- baseExpertVo.setUpdated(baseExpertVo.getCreated());
- baseExpertVo.setUpdateTime(baseExpertVo.getCreateTime());
- return toAjax(baseExpertService.insertExpert(baseExpertVo));
- }
- @ApiOperation(value = "删除专家库", notes = "必传 id")
- @PostMapping("/deleteExpert")
- @PreAuthorize("@ss.hasPermi('base:expert:deleteExpert')")
- @Log(title = ModularConstans.expert, businessType = BusinessType.DELETE)
- public AjaxResult deleteExpert(@RequestBody BaseExpert baseExpert) {
- if (StringUtils.isNull(baseExpert) || StringUtils.isNull(baseExpert.getId())) {
- return error("专家库id不能为空");
- }
- return toAjax(baseExpertService.removeById(baseExpert.getId()));
- }
- @ApiOperation(value = "修改专家库", notes = "必传 id 及修改数据")
- @PostMapping("/updateExpert")
- @PreAuthorize("@ss.hasPermi('base:expert:updateExpert')")
- @Log(title = ModularConstans.expert, businessType = BusinessType.UPDATE)
- public AjaxResult updateProfessional(@RequestBody BaseExpert baseExpert) {
- if (StringUtils.isNull(baseExpert) || StringUtils.isNull(baseExpert.getId())) {
- return error("专家库id和修改数据不能为空");
- }
- baseExpert.setUpdated(getUserId().toString());
- baseExpert.setUpdateTime(new Date());
- return toAjax(baseExpertService.updateById(baseExpert));
- }
- @ApiOperation(value = "查询专家库", notes = "非必传 查询条件:品目名称")
- @PostMapping("/selectExpert")
- @PreAuthorize("@ss.hasPermi('base:expert:selectExpert')")
- @Log(title = ModularConstans.expert, businessType = BusinessType.QUERY)
- public AjaxResult selectExpert(@RequestBody BaseExpertVo baseExpertVo) {
- LambdaQueryWrapper<BaseExpert> lw = new LambdaQueryWrapper<BaseExpert>();
- if (!StringUtils.isBlank(baseExpertVo.getExpertName())) {
- lw.like(BaseExpert::getExpertName, baseExpertVo.getExpertName());
- }
- if (!StringUtils.isBlank(baseExpertVo.getMajorType())) {
- lw.eq(BaseExpert::getMajorType, baseExpertVo.getMajorType());
- }
- if (!ObjectUtils.isEmpty(baseExpertVo.getMajorGrade())) {
- lw.eq(BaseExpert::getMajorGrade, baseExpertVo.getMajorGrade());
- }
- lw.orderBy(true, false, BaseExpert::getCreateTime);
- List<BaseExpert> list = baseExpertService.list(lw);
- // IPage<BaseExpert> page = baseExpertService.page(new Page<BaseExpert>(baseExpertVo.getPageNum(), baseExpertVo.getPageSize()), lw);
- // List<BaseExpert> records = page.getRecords();
- // 把 localArea 翻译为 省/市/县,存localAreaName中,(使用SysRegionService的getParentAdministrativeDivisionNames方法)
- List<BaseExpertVo> listVo = BeanUtils.entityListToVOList(list, BaseExpertVo.class);
- for (BaseExpertVo vo : listVo) {
- if (StringUtils.isNotNull(vo.getLocalArea())) {
- String parentAdministrativeDivisionNames = sysRegionService.getParentAdministrativeDivisionNames(vo.getLocalArea());
- vo.setLocalAreaName(parentAdministrativeDivisionNames);
- }
- }
- Page pages = PageUtils.getPages(baseExpertVo.getPageNum().intValue(), baseExpertVo.getPageSize().intValue(), listVo);
- return success(pages);
- }
- @ApiOperation(value = "黑白名单开关", notes = "必传id,status 其他字段不传; 黑名单传0,白名单传1")
- @PostMapping("/updateSupplierType")
- @PreAuthorize("@ss.hasPermi('base:expert:updateSupplierType')")
- @Log(title = ModularConstans.expert, businessType = BusinessType.UPDATE)
- public AjaxResult updateSupplierType(@RequestBody BaseExpert baseExpert) {
- if (StringUtils.isNull(baseExpert) || StringUtils.isNull(baseExpert.getId())
- || StringUtils.isNull(baseExpert.getStatus())) {
- return error("状态及ID不能为空");
- }
- // LambdaQueryWrapper<BaseExpert> lw = new LambdaQueryWrapper<BaseExpert>();
- // if (!StringUtils.isNull(baseExpert.getId())) {
- // lw.eq(BaseExpert::getId, baseExpert.getId());
- // }
- // if (!StringUtils.isBlank(baseExpert.getStatus())) {
- // lw.eq(BaseExpert::getStatus, baseExpert.getStatus());
- // }
- return toAjax(baseExpertService.updateSupplierType(baseExpert));
- }
- @ApiOperation(value = "评审项目", notes = "必传:分页,专家ID")
- @PostMapping("/selectReviewProject")
- @PreAuthorize("@ss.hasPermi('base:expert:selectReviewProject')")
- @Log(title = ModularConstans.expert, businessType = BusinessType.OTHER)
- public AjaxResult selectReviewProject(@RequestBody BaseExpertVo baseExpertVo) {
- if (StringUtils.isNull(baseExpertVo)
- || StringUtils.isNull(baseExpertVo.getPageNum())
- || StringUtils.isNull(baseExpertVo.getPageSize())
- || StringUtils.isNull(baseExpertVo.getId())) {
- return error("专家ID、分页 不能为空");
- }
- return baseExpertService.selectReviewProject(baseExpertVo);
- }
- @ApiOperation(value = "抽取专家", notes = "必传:分页;非必传:专家名称,开始结束时间")
- @PostMapping("/selectExtractionExpert")
- @PreAuthorize("@ss.hasPermi('base:expert:selectExtractionExpert')")
- @Log(title = ModularConstans.expert, businessType = BusinessType.OTHER)
- public AjaxResult selectExtractionExpert(@RequestBody BaseExpertVo baseExpertVo) {
- if (StringUtils.isNull(baseExpertVo)
- || StringUtils.isNull(baseExpertVo.getPageNum())
- || StringUtils.isNull(baseExpertVo.getPageSize())) {
- return error("分页 不能为空");
- }
- return baseExpertService.selectExtractionExpert(baseExpertVo);
- }
- }
|