| | |
| | | return R.ok(announcementService.getAnnouncements(size, current, content, status, groupId)); |
| | | } |
| | | |
| | | @ApiOperation(httpMethod = "GET", value = "群公告通过id查询") |
| | | @GetMapping("/getAnnouncementsById") |
| | | @ApiResponse(message = "执行成功", code = 200) |
| | | public R getAnnouncements(@RequestParam(value = "id") Integer id) { |
| | | return R.ok(announcementService.getAnnouncementsById(id)); |
| | | } |
| | | |
| | | @ApiOperation(httpMethod = "POST", value = "群公告添加") |
| | | @PostMapping("/add") |
| | | @ApiResponse(message = "执行成功", code = 200) |
| | |
| | | return R.ok(announcementService.add(groupId, announcement)); |
| | | } |
| | | |
| | | @ApiOperation(httpMethod = "PUT", value = "群公告发布") |
| | | @PutMapping("/updateStatusPublic") |
| | | @ApiOperation(httpMethod = "PUT", value = "群公告发布/下架") |
| | | @PutMapping("/publicOrUnshelve") |
| | | @ApiResponse(message = "执行成功", code = 200) |
| | | public R updateStatusPublic(@RequestParam(value = "id") Integer id) { |
| | | announcementService.updateStatus(id); |
| | | public R updateStatusPublic(@RequestParam(value = "id") Integer id, |
| | | @RequestParam(value = "status")Integer status) { |
| | | announcementService.updateStatus(id,status); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @ApiOperation(httpMethod = "PUT", value = "群公告下架") |
| | | @PutMapping("/updateStatusUnshelve") |
| | | @ApiResponse(message = "执行成功", code = 200) |
| | | public R updateStatusUnshelve(@RequestParam(value = "id") Integer id) { |
| | | announcementService.updateStatusUnshelve(id); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(httpMethod = "DELETE", value = "群公告删除") |
| | | @DeleteMapping("/delete") |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.baomidou.mybatisplus.extension.api.ApiController; |
| | | import com.baomidou.mybatisplus.extension.api.R; |
| | | |
| | | import com.example.jz.dao.UserDao; |
| | | import com.example.jz.modle.PageParam; |
| | | import com.example.jz.modle.R; |
| | | import com.example.jz.modle.entity.CommonQuestion; |
| | | import com.example.jz.modle.entity.User; |
| | | import com.example.jz.modle.vo.QuestionVo; |
| | | import com.example.jz.service.CommonQuestionService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.security.core.context.SecurityContextHolder; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.Serializable; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Resource |
| | | private CommonQuestionService commonQuestionService; |
| | | @Resource |
| | | UserDao userDao; |
| | | |
| | | /** |
| | | * 分页查询所有数据 |
| | |
| | | */ |
| | | @GetMapping |
| | | @ApiOperation("分页查询所有数据") |
| | | public R<IPage<CommonQuestion>> selectAll(PageParam<CommonQuestion> page, CommonQuestion commonQuestion) { |
| | | return R.ok(commonQuestionService.page(page, new QueryWrapper<>(commonQuestion))); |
| | | public R<IPage<QuestionVo>> selectAll(PageParam<CommonQuestion> page, CommonQuestion commonQuestion) { |
| | | ArrayList<QuestionVo> QuestionVos = new ArrayList<>(); |
| | | PageParam<CommonQuestion> CommonQuestionPageParam ; |
| | | if (commonQuestion.getStatus()!=null ){ |
| | | CommonQuestionPageParam = commonQuestionService.page(page, new QueryWrapper<CommonQuestion>().like(StringUtils.isNotBlank(commonQuestion.getQuestionTitle()),"question_title",commonQuestion.getQuestionTitle()).eq("status",commonQuestion.getStatus()).orderByDesc("ctime")); |
| | | }else { |
| | | CommonQuestionPageParam = commonQuestionService.page(page, new QueryWrapper<CommonQuestion>().like(StringUtils.isNotBlank(commonQuestion.getQuestionTitle()),"question_title",commonQuestion.getQuestionTitle()).orderByDesc("ctime")); |
| | | } |
| | | CommonQuestionPageParam.getRecords().forEach(item->{ |
| | | QuestionVo QuestionVo = new QuestionVo(); |
| | | BeanUtils.copyProperties(item,QuestionVo); |
| | | QuestionVo.setUserName(userDao.selectOne(new QueryWrapper<User>().eq("id",item.getCreator())).getRealName()); |
| | | QuestionVos.add(QuestionVo); |
| | | }); |
| | | PageParam<QuestionVo> QuestionVoPageParam = new PageParam<>(); |
| | | BeanUtils.copyProperties(CommonQuestionPageParam,QuestionVoPageParam); |
| | | QuestionVoPageParam.setRecords(QuestionVos); |
| | | return R.ok(QuestionVoPageParam); |
| | | } |
| | | |
| | | /** |
| | |
| | | public R<Boolean> insert(@RequestBody CommonQuestion commonQuestion) { |
| | | commonQuestion.setStatus(0); |
| | | commonQuestion.setCtime(new Date()); |
| | | commonQuestion.setCreator(userDao.selectOne(new QueryWrapper<User>().eq("login_username", SecurityContextHolder.getContext().getAuthentication().getPrincipal())).getId()); |
| | | return R.ok(commonQuestionService.save(commonQuestion)); |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | 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(); |
| | | } |
| | | } |
| | |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.baomidou.mybatisplus.extension.api.ApiController; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.example.jz.dao.UserDao; |
| | | import com.example.jz.modle.PageParam; |
| | | import com.example.jz.modle.R; |
| | | import com.example.jz.modle.entity.Sensitive; |
| | | import com.example.jz.modle.dto.SensitiveDto; |
| | | import com.example.jz.modle.entity.User; |
| | | import com.example.jz.modle.vo.SensitiveVO; |
| | | import com.example.jz.service.SensitiveService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.security.core.context.SecurityContextHolder; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | @Resource |
| | | private SensitiveService sensitiveService; |
| | | |
| | | @Resource |
| | | UserDao userDao; |
| | | |
| | | /** |
| | | * 分页查询所有数据 |
| | | * |
| | |
| | | @GetMapping |
| | | @ApiOperation("分页查询所有数据") |
| | | public R<Page<SensitiveVO>> selectAll(PageParam<Sensitive> page, Sensitive sensitive) { |
| | | Page<Sensitive> sensitivePage = sensitiveService.page(page, new QueryWrapper<>(sensitive)); |
| | | Page<Sensitive> sensitivePage = sensitiveService.page(page, new QueryWrapper<Sensitive>() |
| | | .like(StringUtils.isNotBlank(sensitive.getWords()),"words",sensitive.getWords()).orderByDesc("ctime")); |
| | | // 将sensitive转换成sensitiveVO |
| | | List<SensitiveVO> sensitiveVOList = new ArrayList<>(); |
| | | for (Sensitive s : sensitivePage.getRecords()) { |
| | | SensitiveVO sensitiveVO = new SensitiveVO(); |
| | | BeanUtil.copyProperties(s, sensitiveVO); |
| | | sensitiveVO.setWords(Arrays.asList(s.getWord().split(","))); |
| | | sensitiveVO.setCreator(userDao.selectOne(new QueryWrapper<User>().eq("id",s.getCreator())).getRealName()); |
| | | sensitiveVOList.add(sensitiveVO); |
| | | } |
| | | // 封装分页数据 |
| | |
| | | Sensitive sensitive = sensitiveService.getById(id); |
| | | SensitiveVO sensitiveVO = new SensitiveVO(); |
| | | BeanUtil.copyProperties(sensitive, sensitiveVO); |
| | | sensitiveVO.setWords(Arrays.asList(sensitive.getWord().split(","))); |
| | | sensitiveVO.setCreator(userDao.selectOne(new QueryWrapper<User>().eq("id",sensitive.getCreator())).getRealName()); |
| | | return R.ok(sensitiveVO); |
| | | } |
| | | |
| | |
| | | @PostMapping |
| | | @ApiOperation("新增数据") |
| | | public R<Boolean> insert(@RequestBody SensitiveDto sensitiveDto) { |
| | | Sensitive sensitive = new Sensitive().setCreator(sensitiveDto.getCreator()).setCtime(new Date()).setWord(String.join(",", sensitiveDto.getWords())); |
| | | Sensitive sensitive = new Sensitive().setCreator(userDao.selectOne(new QueryWrapper<User>() |
| | | .eq("login_username", SecurityContextHolder.getContext().getAuthentication().getPrincipal())).getId()) |
| | | .setCtime(new Date()).setWords(sensitiveDto.getWords()); |
| | | return R.ok(sensitiveService.save(sensitive)); |
| | | } |
| | | |
| | |
| | | * @param sensitiveDto 实体对象 |
| | | * @return 修改结果 |
| | | */ |
| | | @PutMapping |
| | | @ApiOperation("修改数据") |
| | | public R<Boolean> update(@RequestBody SensitiveDto sensitiveDto) { |
| | | Sensitive sensitive = new Sensitive().setId(sensitiveDto.getId()).setCreator(sensitiveDto.getCreator()).setWord(String.join(",", sensitiveDto.getWords())); |
| | | return R.ok(sensitiveService.updateById(sensitive)); |
| | | } |
| | | // @PutMapping |
| | | // @ApiOperation("修改数据") |
| | | // public R<Boolean> update(@RequestBody SensitiveDto sensitiveDto) { |
| | | // Sensitive sensitive = new Sensitive().setId(sensitiveDto.getId()).setCreator(sensitiveDto.getCreator()).setWord(String.join(",", sensitiveDto.getWords())); |
| | | // return R.ok(sensitiveService.updateById(sensitive)); |
| | | // } |
| | | |
| | | /** |
| | | * 删除数据 |
| | |
| | | package com.example.jz.controller; |
| | | |
| | | import com.example.jz.auth.TokenJwtManager; |
| | | import com.example.jz.exception.BusinessException; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.core.context.SecurityContextHolder; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | |
| | | @RestController("test") |
| | | @Api(value = "测试接口", tags = "测试接口") |
| | | public class TestController { |
| | | @Autowired |
| | | TokenJwtManager tokenJwtManager; |
| | | |
| | | @GetMapping("/business") |
| | | @ApiOperation("业务异常测试") |
| | | public String test() { |
| | | throw new BusinessException("业务异常"); |
| | | return null; |
| | | } |
| | | |
| | | @GetMapping("/custom") |
| | |
| | | package com.example.jz.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.baomidou.mybatisplus.extension.api.ApiController; |
| | | import com.baomidou.mybatisplus.extension.api.R; |
| | | import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.example.jz.modle.R; |
| | | import com.example.jz.modle.entity.User; |
| | | import com.example.jz.service.UserService; |
| | | import com.example.jz.utils.Md5Utils; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | @GetMapping |
| | | @ApiOperation("分页查询所有数据") |
| | | public R selectAll(Page<User> page, User user) { |
| | | return success(this.userService.page(page, new QueryWrapper<>(user))); |
| | | return R.ok(this.userService.page(page, new QueryWrapper<User>() |
| | | .like(StringUtils.isNotBlank(user.getNickName()),"nick_name",user.getNickName()) |
| | | .or() |
| | | .like(StringUtils.isNotBlank(user.getRealName()),"real_name",user.getRealName()) |
| | | .orderByDesc("ctime"))); |
| | | } |
| | | |
| | | /** |
| | |
| | | @GetMapping("{id}") |
| | | @ApiOperation("通过主键查询单条数据") |
| | | public R selectOne(@PathVariable Serializable id) { |
| | | return success(this.userService.getById(id)); |
| | | return R.ok(this.userService.getById(id)); |
| | | } |
| | | |
| | | /** |
| | |
| | | @PutMapping |
| | | @ApiOperation("修改用户数据") |
| | | public R update(@RequestBody User user) { |
| | | return success(userService.updateById(user)); |
| | | return R.ok(userService.updateById(user)); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @DeleteMapping |
| | | @ApiOperation("删除用户数据") |
| | | public R delete(@RequestParam("idList") List<Long> idList) { |
| | | return success(this.userService.removeByIds(idList)); |
| | | public R delete(@RequestParam("id") Integer id) { |
| | | return R.ok(this.userService.removeById(id)); |
| | | } |
| | | |
| | | /** |
| | |
| | | }) |
| | | public R addAdmin(@PathVariable Serializable id, String username, String password) { |
| | | User user = userService.getById(id).setLoginUsername(username).setLoginPassword(Md5Utils.md5(password)).setRole(1); |
| | | return success(userService.updateById(user)); |
| | | return R.ok(userService.updateById(user)); |
| | | } |
| | | |
| | | @PostMapping("/add") |
| | | @ApiOperation("添加") |
| | | public R add(@RequestBody User user) { |
| | | user.setCtime(new Date()); |
| | | return R.ok(userService.save(user)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 重置管理员密码 |
| | |
| | | User user = userService.getById(id); |
| | | // 重置初始密码为身份证后六位 |
| | | user.setLoginPassword(Md5Utils.md5(user.getUserIdcard().substring(user.getUserIdcard().length() - 6))); |
| | | return success(userService.updateById(user)); |
| | | return R.ok(userService.updateById(user)); |
| | | } |
| | | } |
New file |
| | |
| | | package com.example.jz.modle.dto; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | @Data |
| | | @ApiModel(description = "群公告录入导入", value = "PublicityLoadDto") |
| | | public class PublicityLoadDto { |
| | | //案件编号 |
| | | @ApiModelProperty(dataType = "String", value = "标题") |
| | | @ExcelProperty(value = "标题", index = 0) |
| | | private String publicityTitle; |
| | | |
| | | @ApiModelProperty(dataType = "String", value = "内容") |
| | | @ExcelProperty(value = "内容", index = 1) |
| | | private String text; |
| | | |
| | | |
| | | //负责人 |
| | | @ApiModelProperty(dataType = "String", value = "创建人") |
| | | @ExcelProperty(value = "创建人", index = 2) |
| | | private String userName; |
| | | } |
| | |
| | | private Integer id; |
| | | //敏感词,用,分隔 |
| | | @ApiModelProperty(value = "敏感词") |
| | | private List<String> words; |
| | | private String words; |
| | | //创建者 |
| | | @ApiModelProperty(value = "创建者") |
| | | private String creator; |
| | |
| | | |
| | | //状态 |
| | | private Integer status; |
| | | |
| | | //发布时间 |
| | | private Date publishTime; |
| | | } |
| | | |
| | |
| | | @TableId |
| | | private Integer id; |
| | | //敏感词,用,分隔 |
| | | private String word; |
| | | private String words; |
| | | //创建者 |
| | | private String creator; |
| | | private Integer creator; |
| | | //创建时间 |
| | | private Date ctime; |
| | | |
| | |
| | | private Integer id; |
| | | |
| | | private Integer role; |
| | | |
| | | private Date ctime; |
| | | } |
| | | |
| | |
| | | |
| | | //状态 |
| | | private Integer status; |
| | | |
| | | //发布时间 |
| | | private Date publishTime; |
| | | } |
New file |
| | |
| | | package com.example.jz.modle.vo; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | @Data |
| | | public class PublicityVo { |
| | | |
| | | @ApiModelProperty(dataType = "Integer", value = "id") |
| | | private Integer id; |
| | | |
| | | @ApiModelProperty(dataType = "String", value = "标题") |
| | | private String publicityTitle; |
| | | |
| | | //案件状态 |
| | | @ApiModelProperty(dataType = "Integer", value = "状态") |
| | | private Integer status; |
| | | |
| | | //负责人 |
| | | @ApiModelProperty(dataType = "String", value = "创建人") |
| | | private String userName; |
| | | |
| | | //最早次案发时间 |
| | | @ApiModelProperty(dataType = "Date", value = "发布时间") |
| | | private Date releaseTime; |
| | | } |
New file |
| | |
| | | package com.example.jz.modle.vo; |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | @Data |
| | | public class QuestionVo { |
| | | |
| | | @ApiModelProperty(dataType = "Integer", value = "id") |
| | | private Integer id; |
| | | |
| | | @ApiModelProperty(dataType = "String", value = "关键字") |
| | | private String questionTitle; |
| | | |
| | | //案件状态 |
| | | @ApiModelProperty(dataType = "Integer", value = "状态") |
| | | private Integer status; |
| | | |
| | | //负责人 |
| | | @ApiModelProperty(dataType = "String", value = "创建人") |
| | | private String userName; |
| | | |
| | | //最早次案发时间 |
| | | @ApiModelProperty(dataType = "Date", value = "发布时间") |
| | | private Date releaseTime; |
| | | } |
| | |
| | | private Integer id; |
| | | //敏感词,用,分隔 |
| | | @ApiModelProperty(value = "敏感词") |
| | | private List<String> words; |
| | | private String words; |
| | | //创建者 |
| | | @ApiModelProperty(value = "创建者") |
| | | private String creator; |
| | |
| | | PageParam<AnnouncementVo> getAnnouncements(Integer size, Integer current, String content, Integer status,Integer groupId); |
| | | |
| | | /** |
| | | * @Description 发布 |
| | | * @Description 发布/下架 |
| | | * @Param [id] |
| | | * @return java.lang.Integer |
| | | **/ |
| | | Integer updateStatus(Integer id); |
| | | void updateStatus(Integer id,Integer status); |
| | | |
| | | /** |
| | | * @Description 下架 |
| | | * @Param [id] |
| | | * @Description 添加 |
| | | * @Param [groupId, announcement] |
| | | * @return java.lang.Integer |
| | | **/ |
| | | Integer updateStatusUnshelve(Integer id); |
| | | |
| | | Integer add(Integer groupId, Announcement announcement); |
| | | |
| | | AnnouncementVo getAnnouncementsById(Integer id); |
| | | } |
| | | |
| | |
| | | import com.example.jz.modle.PageParam; |
| | | import com.example.jz.modle.dto.PublicityDto; |
| | | import com.example.jz.modle.entity.Publicity; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | |
| | | Boolean grounding(Serializable id); |
| | | |
| | | IPage<PublicityDto> findByPage(PageParam<PublicityDto> page, QueryWrapper<PublicityDto> publicityDtoQueryWrapper); |
| | | |
| | | void loadFile(MultipartFile multipartFile); |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.example.jz.auth.TokenJwtManager; |
| | | import com.example.jz.dao.AnnouncementDao; |
| | | import com.example.jz.dao.UserDao; |
| | | import com.example.jz.modle.PageParam; |
| | |
| | | import com.example.jz.modle.vo.AnnouncementVo; |
| | | import com.example.jz.service.AnnouncementService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.core.context.SecurityContextHolder; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | AnnouncementDao announcementDao; |
| | | @Resource |
| | | UserDao userDao; |
| | | |
| | | @Autowired |
| | | TokenJwtManager tokenJwtManager; |
| | | |
| | | @Override |
| | | public PageParam<AnnouncementVo> getAnnouncements(Integer size, Integer current, String content, Integer status, Integer groupId) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Integer updateStatus(Integer id) { |
| | | return announcementDao.update(new Announcement().setStatus(1), new UpdateWrapper<Announcement>().eq("id", id)); |
| | | public void updateStatus(Integer id,Integer status) { |
| | | if (status==1){ |
| | | announcementDao.update(new Announcement().setStatus(2), new UpdateWrapper<Announcement>().eq("id", id)); |
| | | }else { |
| | | Announcement announcement = new Announcement(); |
| | | announcement.setStatus(1); |
| | | announcement.setPublishTime(new Date()); |
| | | announcementDao.update(announcement, new UpdateWrapper<Announcement>().eq("id", id)); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public Integer updateStatusUnshelve(Integer id) { |
| | | return announcementDao.update(new Announcement().setStatus(2), new UpdateWrapper<Announcement>().eq("id", id)); |
| | | } |
| | | |
| | | @Override |
| | | public Integer add(Integer groupId, Announcement announcement) { |
| | | announcement.setStatus(0); |
| | | announcement.setCreator(userDao.selectOne(new QueryWrapper<User>().eq("login_username", SecurityContextHolder.getContext().getAuthentication().getPrincipal())).getId()); |
| | | if(announcement.getStatus()==1){ |
| | | announcement.setPublishTime(new Date()); |
| | | } |
| | | announcement.setCtime(new Date()); |
| | | announcement.setGroupId(groupId); |
| | | return announcementDao.insert(announcement); |
| | | } |
| | | |
| | | @Override |
| | | public AnnouncementVo getAnnouncementsById(Integer id) { |
| | | AnnouncementVo announcementVo = new AnnouncementVo(); |
| | | Announcement announcement = announcementDao.selectById(id); |
| | | User user = userDao.selectOne(new QueryWrapper<User>().eq("id", announcement.getCreator())); |
| | | BeanUtils.copyProperties(announcement,announcementVo); |
| | | announcementVo.setCreateName(user.getRealName()); |
| | | return announcementVo; |
| | | } |
| | | } |
| | |
| | | package com.example.jz.service.impl; |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.context.AnalysisContext; |
| | | import com.alibaba.excel.event.AnalysisEventListener; |
| | | import com.alibaba.excel.metadata.data.ReadCellData; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.example.jz.dao.PublicityDao; |
| | | import com.example.jz.dao.UserDao; |
| | | import com.example.jz.modle.PageParam; |
| | | import com.example.jz.modle.dto.CauseLoadDto; |
| | | import com.example.jz.modle.dto.PublicityDto; |
| | | import com.example.jz.modle.dto.PublicityLoadDto; |
| | | import com.example.jz.modle.entity.Publicity; |
| | | import com.example.jz.modle.entity.User; |
| | | import com.example.jz.service.PublicityService; |
| | | import lombok.SneakyThrows; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 公共宣传表(Publicity)表服务实现类 |
| | |
| | | |
| | | @Resource |
| | | private PublicityDao publicityDao; |
| | | |
| | | @Resource |
| | | private UserDao userDao; |
| | | |
| | | @Override |
| | | public Boolean undercarriage(Serializable id) { |
| | |
| | | public IPage<PublicityDto> findByPage(PageParam<PublicityDto> page, QueryWrapper<PublicityDto> publicityDtoQueryWrapper) { |
| | | return publicityDao.findByPage(page, publicityDtoQueryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | @SneakyThrows |
| | | public void loadFile(MultipartFile multipartFile) { |
| | | EasyExcel.read(multipartFile.getInputStream(), PublicityLoadDto.class, new AnalysisEventListener<PublicityLoadDto>(){ |
| | | |
| | | @Override |
| | | public void invoke(PublicityLoadDto data, AnalysisContext context) { |
| | | if (StringUtils.isNotBlank(data.getPublicityTitle()) && StringUtils.isNotBlank(data.getUserName())) { |
| | | Publicity publicity = new Publicity(); |
| | | publicity.setStatus(0); |
| | | BeanUtils.copyProperties(data,publicity); |
| | | publicity.setCtime(new Date()); |
| | | publicity.setCreator(userDao.selectOne(new QueryWrapper<User>().eq("real_name",data.getUserName())).getId()); |
| | | publicityDao.insert(publicity); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void doAfterAllAnalysed(AnalysisContext context) { |
| | | |
| | | } |
| | | }) .autoCloseStream(true) |
| | | .doReadAll(); |
| | | } |
| | | } |