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.BaseAgency; import com.ozs.base.service.BaseAgencyService; import com.ozs.base.vo.BaseAgentPageReqVo; import com.ozs.common.annotation.Log; import com.ozs.common.core.controller.BaseController; import com.ozs.common.core.domain.AjaxResult; import com.ozs.common.enums.BusinessType; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; 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.*; import javax.validation.constraints.NotEmpty; import java.util.Date; @Api(tags = "招标代理机构管理") @RestController @RequestMapping("/base/agency") public class BaseAgencyController extends BaseController { @Autowired private BaseAgencyService baseAgencyService; @ApiOperation(value = "新增招标代理机构") @PostMapping("/insertBaseAgency") @PreAuthorize("@ss.hasPermi('base:agency:add')") @Log(title = "招标代理机构管理", businessType = BusinessType.INSERT) public AjaxResult insertBaseAgency(@NotEmpty(message = "数据为空") @RequestBody BaseAgency baseAgency) { // if (ObjectUtils.isEmpty(baseAgency)) { // return error("数据为空"); // } baseAgency.setStatus(0); baseAgency.setCreated(getUserId().toString()); baseAgency.setCreateTime(new Date()); baseAgency.setUpdated(baseAgency.getCreated()); baseAgency.setUpdateTime(baseAgency.getCreateTime()); return toAjax(baseAgencyService.insert(baseAgency)); } @ApiOperation(value = "查看招标代理机构") @PostMapping("/getInfo") @PreAuthorize("@ss.hasPermi('base:agency:query')") @Log(title = "招标代理机构管理", businessType = BusinessType.QUERY) public AjaxResult getInfo(@NotEmpty(message = "主键id不能为空") @RequestParam(value = "id", required = true) Long id) { return success(baseAgencyService.getInfo(id)); } @ApiOperation(value = "修改招标代理机构信息") @PostMapping("/updateInfo") @PreAuthorize("@ss.hasPermi('base:agency:edit')") @Log(title = "招标代理机构管理", businessType = BusinessType.UPDATE) public AjaxResult updateInfo(@NotEmpty(message = "数据为空") @RequestBody BaseAgency baseAgency) { baseAgency.setUpdateTime(new Date()); baseAgency.setUpdated(getUserId().toString()); return toAjax(baseAgencyService.updateInfo(baseAgency)); } @ApiOperation(value = "操作招标代理机构黑白名单") @PostMapping("/operationBlacklist") @PreAuthorize("@ss.hasPermi('base:agency:edit')") @Log(title = "招标代理机构管理", businessType = BusinessType.UPDATE) public AjaxResult operationBlacklist(@NotEmpty(message = "主键id不能为空") @RequestParam(value = "id", required = true) Long id, @NotEmpty(message = "状态不能为空") @RequestParam(value = "status", required = true) Integer status) { BaseAgency build = BaseAgency.builder().id(id).status(status).build(); build.setUpdated(getUserId().toString()); build.setUpdateTime(new Date()); return toAjax(baseAgencyService.operationBlacklist(build)); } @ApiOperation(value = "删除招标代理机构信息") @PostMapping("/remove") @PreAuthorize("@ss.hasPermi('base:agency:remove')") @Log(title = "招标代理机构管理", businessType = BusinessType.DELETE) public AjaxResult remove(@NotEmpty(message = "主键id不能为空") @RequestParam(value = "id", required = true) Long id) { return toAjax(baseAgencyService.remove(id)); } @ApiOperation(value = "分页查询招标代理机构信息") @PostMapping("/page") @PreAuthorize("@ss.hasPermi('base:agency:list')") @Log(title = "招标代理机构管理", businessType = BusinessType.QUERY) public AjaxResult page(@NotEmpty(message = "数据为空") @RequestBody BaseAgentPageReqVo vo) { LambdaQueryWrapper lw = new LambdaQueryWrapper(); if(!StringUtils.isBlank(vo.getCompanyName())){ lw.like(BaseAgency::getCompanyName,vo.getCompanyName()); } if(!StringUtils.isBlank(vo.getCompanyNature())){ lw.eq(BaseAgency::getCompanyNature,vo.getCompanyNature()); } if(!ObjectUtils.isEmpty(vo.getStatus())){ lw.eq(BaseAgency::getStatus,vo.getStatus()); } IPage page = baseAgencyService.page(new Page(vo.getPageNum(), vo.getPageSize()), lw); return success(page); } }