123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- package com.ozs.web.controller.home;
- 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.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.StringUtils;
- import com.ozs.home.domain.HomeNotice;
- import com.ozs.home.domain.vo.HomeNoticeVo;
- import com.ozs.home.service.HomeNoticeService;
- import com.ozs.plan.doman.PlanYears;
- import com.ozs.plan.doman.vo.requestVo.PlanYearsStandardVo;
- import com.ozs.plan.service.PlanYearsService;
- import io.swagger.annotations.ApiOperation;
- 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.annotation.Resource;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- import java.util.List;
- import java.util.Map;
- /**
- * 首页公告控制层
- *
- * @author buzhanyi
- */
- @RestController
- @RequestMapping("/home/homeNotice")
- public class HomeNoticeController extends BaseController {
- @Resource
- private HomeNoticeService homeNoticeService;
- @Autowired
- private PlanYearsService planYearsService;
- @ApiOperation(value = "查询首页公告")
- @PostMapping("/selectHomeNotice")
- // @PreAuthorize("@ss.hasPermi('home:homeNotice:selecthomeNotice')")
- @Log(title = ModularConstans.notice, businessType = BusinessType.QUERY)
- public AjaxResult selectHomeNotice(@RequestBody HomeNoticeVo homeNoticeVo) {
- LambdaQueryWrapper<HomeNotice> lw = new LambdaQueryWrapper<HomeNotice>();
- if (!StringUtils.isBlank(homeNoticeVo.getNoticeName())) {
- lw.like(HomeNotice::getNoticeName, "%" + homeNoticeVo.getNoticeName() + "%");
- }
- if (!StringUtils.isBlank(homeNoticeVo.getAnnouncementClassification())) {
- lw.eq(HomeNotice::getAnnouncementClassification, homeNoticeVo.getAnnouncementClassification());
- }
- if (!StringUtils.isBlank(homeNoticeVo.getHomepageClassification())) {
- lw.eq(HomeNotice::getHomepageClassification, homeNoticeVo.getHomepageClassification());
- }
- if (!ObjectUtils.isEmpty(homeNoticeVo.getNoticeTime())) {
- lw.ge(HomeNotice::getNoticeTime, homeNoticeVo.getNoticeTime());
- }
- if (!ObjectUtils.isEmpty(homeNoticeVo.getNoticeTime())) {
- lw.le(HomeNotice::getNoticeTime, homeNoticeVo.getNoticeTime());
- }
- IPage<HomeNotice> page = homeNoticeService.page(new Page<HomeNotice>(homeNoticeVo.getPageNum(), homeNoticeVo.getPageSize()), lw);
- return success(page);
- }
- @ApiOperation(value = "搜索项目列表")
- @PostMapping("/listPlanYears")
- public AjaxResult listPlanYears(@RequestBody PlanYearsStandardVo yearsStandardVo) {
- if (StringUtils.isNull(yearsStandardVo.getProjectName())) {
- return error("查询项目名称不能为空!");
- }
- LambdaQueryWrapper<PlanYears> lw = new LambdaQueryWrapper<PlanYears>();
- if (!StringUtils.isBlank(yearsStandardVo.getProjectName())) {
- lw.like(PlanYears::getProjectName, "%" + yearsStandardVo.getProjectName() + "%");
- }
- List<PlanYears> list = planYearsService.list(lw);
- return AjaxResult.success(list);
- }
- @ApiOperation(value = "搜索项目--选择项目查看详情")
- @PostMapping("/projectDetails")
- public AjaxResult projectDetails(@RequestBody PlanYearsStandardVo yearsStandardVo) {
- if (StringUtils.isNull(yearsStandardVo.getPlanYearId())) {
- return error("查询年度ID不能为空!");
- }
- return planYearsService.projectDetails(yearsStandardVo);
- }
- /**
- * 查询不同类型的公告
- */
- @PreAuthorize("@ss.hasPermi('home:homeNotice:getNoticesByType')")
- @Log(title = "查询公告", businessType = BusinessType.QUERY)
- @PostMapping("getNoticesByType")
- @ApiOperation("查询不同类型的公告")
- public AjaxResult getNoticesByType(@RequestBody HomeNoticeVo homeNoticeVo) {
- LambdaQueryWrapper<HomeNotice> lw = new LambdaQueryWrapper<>();
- if (!ObjectUtils.isEmpty(homeNoticeVo.getNoticeName())) {
- lw.like(HomeNotice::getNoticeName, homeNoticeVo.getNoticeName());
- }
- if (!ObjectUtils.isEmpty(homeNoticeVo.getAnnouncementClassification())) {
- lw.eq(HomeNotice::getAnnouncementClassification, homeNoticeVo.getAnnouncementClassification());
- }
- if (!ObjectUtils.isEmpty(homeNoticeVo.getBeginTime())) {
- lw.ge(HomeNotice::getNoticeTime, homeNoticeVo.getBeginTime());
- }
- if (!ObjectUtils.isEmpty(homeNoticeVo.getEndTime())) {
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
- SimpleDateFormat dateFormatT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
- Date parse = null;
- try {
- parse = dateFormatT.parse((dateFormat.format(homeNoticeVo.getEndTime()) + " 23:59:59:999"));
- } catch (ParseException e) {
- e.printStackTrace();
- }
- lw.le(HomeNotice::getNoticeTime, parse);
- }
- List<HomeNotice> noticeList = homeNoticeService.list(lw);
- return AjaxResult.success(noticeList);
- }
- }
|