123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- 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.BaseNotice;
- import com.ozs.base.domain.BaseNoticeType;
- import com.ozs.base.service.BaseNoticeService;
- import com.ozs.base.service.BaseNoticeTypeService;
- import com.ozs.base.vo.BaseNoticePageReqVo;
- import com.ozs.base.vo.BaseNoticeVo;
- import com.ozs.common.annotation.Log;
- import com.ozs.common.constant.Constants;
- import com.ozs.common.constant.ModularConstans;
- import com.ozs.common.core.controller.BaseController;
- import com.ozs.common.core.domain.AjaxResult;
- import com.ozs.common.core.domain.entity.SysDept;
- import com.ozs.common.core.domain.entity.SysRole;
- import com.ozs.common.enums.BusinessType;
- import com.ozs.plan.doman.MonthlyReconciliation;
- import com.ozs.system.service.ISysDeptService;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.beans.BeanUtils;
- 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;
- import java.util.List;
- import java.util.stream.Collectors;
- @Api(tags = ModularConstans.notice)
- @RestController
- @RequestMapping("/base/notice")
- public class BaseNoticeController extends BaseController {
- @Autowired
- private BaseNoticeService baseNoticeService;
- @Autowired
- private BaseNoticeTypeService baseNoticeTypeService;
- @Autowired
- private ISysDeptService iSysDeptService;
- @ApiOperation(value = "分页查询公告信息")
- @PostMapping("/page")
- @PreAuthorize("@ss.hasPermi('base:notice:list')")
- @Log(title = ModularConstans.notice, businessType = BusinessType.QUERY)
- public AjaxResult page(@NotEmpty(message = "数据为空")
- @RequestBody BaseNoticePageReqVo vo) {
- LambdaQueryWrapper<BaseNotice> lw = new LambdaQueryWrapper<>();
- if (!StringUtils.isBlank(vo.getTitle())) {
- lw.like(BaseNotice::getTitle, vo.getTitle());
- }
- if (!ObjectUtils.isEmpty(vo.getStartTime())) {
- lw.ge(BaseNotice::getReleaseTime, vo.getStartTime());
- }
- if (!ObjectUtils.isEmpty(vo.getStartTime())) {
- lw.le(BaseNotice::getReleaseTime, vo.getEntTime());
- }
- if (!ObjectUtils.isEmpty(vo.getType())) {
- lw.eq(BaseNotice::getType, vo.getType());
- }
- lw.orderByDesc(BaseNotice::getReleaseTime);
- IPage<BaseNotice> page = baseNoticeService.page(new Page<>(vo.getPageNum(), vo.getPageSize()), lw);
- IPage<BaseNoticeVo> pagev = new Page<>();
- pagev.setTotal(page.getTotal());
- pagev.setCurrent(page.getCurrent());
- pagev.setPages(page.getPages());
- if (!ObjectUtils.isEmpty(page) && page.getRecords().size() > 0) {
- List<BaseNoticeType> list = baseNoticeTypeService.list();
- List<Long> ids = list.stream().map(BaseNoticeType::getId).collect(Collectors.toList());
- List<BaseNoticeVo> collect = page.getRecords().stream().map(o -> {
- BaseNoticeVo baseNoticeVo = new BaseNoticeVo();
- BeanUtils.copyProperties(o, baseNoticeVo);
- if (ids.contains(o.getType())) {
- List<BaseNoticeType> collect1 = list.stream().filter(tdto -> tdto.getId().equals(o.getType())).collect(Collectors.toList());
- if(!ObjectUtils.isEmpty(collect1)){
- baseNoticeVo.setTypeName(collect1.get(0).getName());
- }
- }
- return baseNoticeVo;
- }).collect(Collectors.toList());
- pagev.setRecords(collect);
- }else {
- pagev.setRecords(null);
- }
- return success(pagev);
- }
- @ApiOperation(value = "新增公告信息")
- @PostMapping("/insert")
- @PreAuthorize("@ss.hasPermi('base:notice:add')")
- @Log(title = ModularConstans.notice, businessType = BusinessType.INSERT)
- public AjaxResult insert(@NotEmpty(message = "数据为空")
- @RequestBody BaseNotice vo) {
- vo.setCreated(getUserId().toString());
- vo.setCreateTime(new Date());
- vo.setUpdated(vo.getCreated());
- vo.setUpdateTime(vo.getCreateTime());
- return toAjax(baseNoticeService.save(vo));
- }
- @ApiOperation(value = "删除公告信息")
- @PostMapping("/remove")
- @PreAuthorize("@ss.hasPermi('base:notice:remove')")
- @Log(title = ModularConstans.notice, businessType = BusinessType.DELETE)
- public AjaxResult remove(@NotEmpty(message = "主键id不能为空")
- @RequestBody List<Long> ids) {
- return toAjax(baseNoticeService.removeBatchByIds(ids));
- }
- @ApiOperation(value = "查看公告信息")
- @PostMapping("/getInfo")
- @PreAuthorize("@ss.hasPermi('base:notice:query')")
- @Log(title = ModularConstans.notice, businessType = BusinessType.QUERY)
- public AjaxResult getInfo(@NotEmpty(message = "主键id不能为空")
- @RequestParam(value = "id", required = true)
- Long id) {
- BaseNotice vo = baseNoticeService.getById(id);
- BaseNoticeVo baseNoticeVo = new BaseNoticeVo();
- if(!ObjectUtils.isEmpty(vo)){
- BeanUtils.copyProperties(vo, baseNoticeVo);
- List<BaseNoticeType> list = baseNoticeTypeService.list();
- List<BaseNoticeType> collect1 = list.stream().filter(tdto -> tdto.getId().equals(vo.getType())).collect(Collectors.toList());
- if(!ObjectUtils.isEmpty(collect1)){
- baseNoticeVo.setTypeName(collect1.get(0).getName());
- }
- }
- return success(baseNoticeVo);
- }
- @ApiOperation(value = "首页分页查询公告信息")
- @PostMapping("/homePage")
- @Log(title = ModularConstans.notice, businessType = BusinessType.QUERY)
- public AjaxResult homePage(@NotEmpty(message = "数据为空")
- @RequestBody BaseNoticePageReqVo vo) {
- // LambdaQueryWrapper<BaseNotice> lw = new LambdaQueryWrapper<>();
- // if(!StringUtils.isBlank(vo.getTitle())){
- // lw.like(BaseNotice::getTitle,vo.getTitle());
- // }
- // if(!ObjectUtils.isEmpty(vo.getStartTime())){
- // lw.ge(BaseNotice::getReleaseTime,vo.getStartTime());
- // }
- // if(!ObjectUtils.isEmpty(vo.getStartTime())){
- // lw.le(BaseNotice::getReleaseTime,vo.getEntTime());
- // }
- // if (!ObjectUtils.isEmpty(vo.getType())) {
- // lw.eq(BaseNotice::getType, vo.getType());
- // }
- // lw.orderByDesc(BaseNotice::getReleaseTime);
- vo.setUserId(getUserId());
- vo.setDeptId(getDeptId());
- IPage<BaseNotice> page = baseNoticeService.queryPage(vo);
- IPage<BaseNoticeVo> pagev = new Page<>();
- pagev.setTotal(page.getTotal());
- pagev.setCurrent(page.getCurrent());
- pagev.setPages(page.getPages());
- if (!ObjectUtils.isEmpty(page) && page.getRecords().size() > 0) {
- List<BaseNoticeType> list = baseNoticeTypeService.list();
- List<Long> ids = list.stream().map(BaseNoticeType::getId).collect(Collectors.toList());
- List<BaseNoticeVo> collect = page.getRecords().stream().map(o -> {
- BaseNoticeVo baseNoticeVo = new BaseNoticeVo();
- BeanUtils.copyProperties(o, baseNoticeVo);
- if (ids.contains(o.getType())) {
- List<BaseNoticeType> collect1 = list.stream().filter(tdto -> tdto.getId().equals(o.getType())).collect(Collectors.toList());
- if(!ObjectUtils.isEmpty(collect1)){
- baseNoticeVo.setTypeName(collect1.get(0).getName());
- }
- }
- return baseNoticeVo;
- }).collect(Collectors.toList());
- pagev.setRecords(collect);
- }else {
- pagev.setRecords(null);
- }
- return success(pagev);
- }
- }
|