New file |
| | |
| | | package com.panzhihua.grid_backstage.api; |
| | | |
| | | |
| | | import com.panzhihua.common.controller.BaseController; |
| | | import com.panzhihua.common.model.dtos.grid.*; |
| | | import com.panzhihua.common.model.vos.LoginUserInfoVO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.community.ComActVO; |
| | | import com.panzhihua.common.model.vos.grid.EventDetailsVO; |
| | | import com.panzhihua.common.model.vos.grid.EventVO; |
| | | import com.panzhihua.common.service.grid.GridService; |
| | | import com.panzhihua.common.utlis.ClazzUtils; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * |
| | | * @author cedoo email:cedoo(a)qq.com |
| | | * @version 1.0 |
| | | * @since 1.0 |
| | | * @date 2021-05-26 |
| | | * */ |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/event") |
| | | @Api(tags = {"事件管理(开发中..) @chendong"}) |
| | | public class EventManageApi extends BaseController { |
| | | |
| | | @Resource |
| | | private GridService gridService; |
| | | |
| | | |
| | | private boolean isCommonType(Integer eventType){ |
| | | if(eventType==null){ |
| | | return false; |
| | | } |
| | | boolean inType = eventType==1 | eventType==2 |eventType==3| eventType==4| eventType==5; |
| | | return inType; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 事件列表 |
| | | * @param pageEventManageDTO 查找事件 |
| | | * @return 查找结果 |
| | | */ |
| | | @GetMapping("/usersList") |
| | | @ApiOperation(value = "事件列表", response= EventVO.class) |
| | | R usersList(@Validated @ModelAttribute PageEventManageDTO pageEventManageDTO){ |
| | | ClazzUtils.setIfStringIsEmpty(pageEventManageDTO); |
| | | if(!isCommonType(pageEventManageDTO.getEventType())){ |
| | | return R.fail(400, "事件类型错误"); |
| | | } |
| | | LoginUserInfoVO loginUserInfoVO = this.getLoginUserInfo(); |
| | | pageEventManageDTO.setUserId(loginUserInfoVO.getUserId()); |
| | | pageEventManageDTO.setCommunityId(loginUserInfoVO.getCommunityId()); |
| | | return gridService.queryEventToManage(pageEventManageDTO); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 事件标为无效 |
| | | * @param eventRevokeDTO 修改事件传递对象 |
| | | * @return 修改结果 |
| | | */ |
| | | @PutMapping("/markInvalid") |
| | | @ApiOperation(value = "事件标为无效", response = R.class) |
| | | R revoke(@Validated @RequestBody EventRevokeDTO eventRevokeDTO){ |
| | | ClazzUtils.setIfStringIsEmpty(eventRevokeDTO); |
| | | LoginUserInfoVO loginUserInfoVO = getLoginUserInfo(); |
| | | eventRevokeDTO.setUserId(loginUserInfoVO.getUserId()); |
| | | eventRevokeDTO.setUserName(loginUserInfoVO.getName()); |
| | | return gridService.markEventInvalid(eventRevokeDTO); |
| | | } |
| | | /** |
| | | * 新增并发布事件事件 |
| | | * @param commonEventCommunityAddDTO 添加事件传递对象 |
| | | * @return 新增结果 |
| | | */ |
| | | @PostMapping("/release") |
| | | @ApiOperation(value = "新增并发布事件", response = R.class) |
| | | R add(@Validated @RequestBody CommonEventCommunityAddDTO commonEventCommunityAddDTO){ |
| | | ClazzUtils.setIfStringIsEmpty(commonEventCommunityAddDTO); |
| | | if(!isCommonType(commonEventCommunityAddDTO.getEventType())){ |
| | | return R.fail(400, "事件类型错误"); |
| | | } |
| | | LoginUserInfoVO loginUserInfoVO = this.getLoginUserInfo(); |
| | | commonEventCommunityAddDTO.setUserId(loginUserInfoVO.getUserId()); |
| | | commonEventCommunityAddDTO.setUserName(loginUserInfoVO.getName()); |
| | | commonEventCommunityAddDTO.setPhone(loginUserInfoVO.getPhone()); |
| | | return gridService.addCommon(commonEventCommunityAddDTO); |
| | | } |
| | | |
| | | /** |
| | | * 查询事件详细信息 |
| | | * @param id 事件 id |
| | | * @return 查找结果 |
| | | */ |
| | | @GetMapping("/{id}") |
| | | @ApiOperation(value = "查询事件详细信息") |
| | | R<EventDetailsVO> details(@PathVariable("id") Long id){ |
| | | return gridService.eventDetails(id); |
| | | } |
| | | |
| | | /** |
| | | * 删除 |
| | | * @param eventDeleteDTO 删除事件传递对象 |
| | | * @return 删除结果 |
| | | */ |
| | | @DeleteMapping() |
| | | @ApiOperation(value = "删除事件", response = R.class) |
| | | R delete(@Validated @RequestBody EventDeleteDTO eventDeleteDTO){ |
| | | ClazzUtils.setIfStringIsEmpty(eventDeleteDTO); |
| | | eventDeleteDTO.setUserId(this.getUserId()); |
| | | return gridService.delete(eventDeleteDTO); |
| | | } |
| | | /** |
| | | * 重新发布事件 |
| | | * @param commonEventRepublishDTO 重新发布事件传递对象 |
| | | * @return 修改结果 |
| | | */ |
| | | @PutMapping("/republish") |
| | | @ApiOperation(value = "重新发布已标为失效的事件", response = R.class) |
| | | R republish(@Validated @RequestBody CommonEventRepublishDTO commonEventRepublishDTO){ |
| | | ClazzUtils.setIfStringIsEmpty(commonEventRepublishDTO); |
| | | LoginUserInfoVO loginUserInfoVO = this.getLoginUserInfo(); |
| | | commonEventRepublishDTO.setUserId(loginUserInfoVO.getUserId()); |
| | | commonEventRepublishDTO.setUserName(loginUserInfoVO.getName()); |
| | | return gridService.republishInvalidEvent(commonEventRepublishDTO); |
| | | } |
| | | |
| | | /** |
| | | * 查询社区列表 |
| | | * @return 查找结果 |
| | | */ |
| | | @GetMapping("/actList") |
| | | @ApiOperation(value = "查询社区列表", response = ComActVO.class) |
| | | R actList(){ |
| | | return gridService.actList(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 处理事件 |
| | | * @param commonEventDealDTO 修改事件传递对象 |
| | | * @return 处理结果 |
| | | */ |
| | | @PutMapping("/deal") |
| | | @ApiOperation(value = "处理事件", response = R.class) |
| | | R deal(@Validated @RequestBody CommonEventDealDTO commonEventDealDTO){ |
| | | ClazzUtils.setIfStringIsEmpty(commonEventDealDTO); |
| | | if(commonEventDealDTO.getNeedVerify()==null){ |
| | | return R.fail("是否验证不能为空"); |
| | | } |
| | | LoginUserInfoVO loginUserInfoVO = new LoginUserInfoVO(); |
| | | commonEventDealDTO.setUserId(loginUserInfoVO.getUserId()); |
| | | commonEventDealDTO.setUserName(loginUserInfoVO.getName()); |
| | | commonEventDealDTO.setOperateType(1); |
| | | commonEventDealDTO.setCommunityId(loginUserInfoVO.getCommunityId()); |
| | | return gridService.dealEvent(commonEventDealDTO); |
| | | } |
| | | |
| | | } |