| | |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.example.jz.dao.UserDao; |
| | | import com.example.jz.modle.PageParam; |
| | | import com.example.jz.modle.entity.Publicity; |
| | | import com.example.jz.modle.R; |
| | | import com.example.jz.modle.entity.Publicity; |
| | | import com.example.jz.modle.entity.User; |
| | | import com.example.jz.modle.vo.PublicityVo; |
| | | import com.example.jz.service.PublicityService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiResponse; |
| | | import lombok.SneakyThrows; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.security.core.context.SecurityContextHolder; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.Serializable; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Resource |
| | | private PublicityService publicityService; |
| | | @Resource |
| | | UserDao userDao; |
| | | |
| | | /** |
| | | * 分页查询所有数据 |
| | |
| | | */ |
| | | @GetMapping |
| | | @ApiOperation("分页查询所有数据") |
| | | public R<IPage<Publicity>> selectAll(PageParam<Publicity> page, Publicity publicity) { |
| | | return R.ok(publicityService.page(page, new QueryWrapper<>(publicity))); |
| | | public R<IPage<PublicityVo>> selectAll(PageParam<Publicity> page, Publicity publicity) { |
| | | ArrayList<PublicityVo> publicityVos = new ArrayList<>(); |
| | | PageParam<Publicity> publicityPageParam ; |
| | | if (publicity.getStatus()!=null ){ |
| | | publicityPageParam = publicityService.page(page, new QueryWrapper<Publicity>().like(StringUtils.isNotBlank(publicity.getPublicityTitle()),"publicity_title",publicity.getPublicityTitle()).eq("status",publicity.getStatus()).orderByDesc("ctime")); |
| | | }else { |
| | | publicityPageParam = publicityService.page(page, new QueryWrapper<Publicity>().like(StringUtils.isNotBlank(publicity.getPublicityTitle()),"publicity_title",publicity.getPublicityTitle()).orderByDesc("ctime")); |
| | | } |
| | | publicityPageParam.getRecords().forEach(item->{ |
| | | PublicityVo publicityVo = new PublicityVo(); |
| | | BeanUtils.copyProperties(item,publicityVo); |
| | | publicityVo.setUserName(userDao.selectOne(new QueryWrapper<User>().eq("id",item.getCreator())).getRealName()); |
| | | publicityVos.add(publicityVo); |
| | | }); |
| | | PageParam<PublicityVo> publicityVoPageParam = new PageParam<>(); |
| | | BeanUtils.copyProperties(publicityPageParam,publicityVoPageParam); |
| | | publicityVoPageParam.setRecords(publicityVos); |
| | | return R.ok(publicityVoPageParam); |
| | | } |
| | | |
| | | /** |
| | |
| | | @PostMapping |
| | | @ApiOperation("添加公共宣传") |
| | | public R<Boolean> insert(@RequestBody Publicity publicity) { |
| | | publicity.setStatus(0); |
| | | publicity.setCtime(new Date()); |
| | | publicity.setCreator(userDao.selectOne(new QueryWrapper<User>().eq("login_username", SecurityContextHolder.getContext().getAuthentication().getPrincipal())).getId()); |
| | | return R.ok(publicityService.save(publicity)); |
| | | } |
| | | |
| | |
| | | public R<Boolean> delete(@PathVariable Serializable id) { |
| | | return R.ok(publicityService.removeById(id)); |
| | | } |
| | | |
| | | @ApiOperation(httpMethod = "POST", value = "案件台-案件录入-案件导入") |
| | | @PostMapping("/upload") |
| | | @ApiResponse(message = "执行成功", code = 200) |
| | | @SneakyThrows |
| | | public R upload(@RequestParam(value = "multipartFile") MultipartFile multipartFile) { |
| | | publicityService.loadFile(multipartFile); |
| | | return R.ok(); |
| | | } |
| | | } |