package com.panzhihua.applets.api; import com.panzhihua.common.controller.BaseController; import com.panzhihua.common.model.dtos.property.CommonPage; import com.panzhihua.common.model.vos.R; import com.panzhihua.common.model.vos.community.warehouse.ApplyStatistics; import com.panzhihua.common.model.vos.community.warehouse.ComActWarehouseApplyVO; import com.panzhihua.common.model.vos.community.warehouse.QRCodeVO; import com.panzhihua.common.service.community.CommunityService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.Date; /** * 物品申请表(ComActWarehouseApply)表控制层 * * @author makejava * @since 2021-10-09 17:13:53 */ @Slf4j @Api(tags = {"爱心义仓申领记录接口"}) @RestController @RequestMapping("comActWarehouseApply") public class ComActWarehouseApplyApi extends BaseController { /** * 服务对象 */ @Resource private CommunityService communityService; /** * 分页查询所有数据 * * @param commonPage 查询实体 * @return 所有数据 */ @ApiOperation(value = "分页查询所有数据",response = ComActWarehouseApplyVO.class) @PostMapping("queryAll") public R selectAll(@RequestBody CommonPage commonPage) { commonPage.setParamId(this.getCommunityId()); return this.communityService.comActWarehouseApplySelectAll(commonPage); } /** * 统计查询 * * @return 所有数据 */ @ApiOperation(value = "统计查询",response = ApplyStatistics.class) @GetMapping("selectStatics") public R selectAll() { return this.communityService.comActWarehouseApplySelectAll(this.getCommunityId()); } /** * 通过主键查询单条数据 * * @param id 主键 * @return 单条数据 */ @ApiOperation(value = "通过主键查询单条数据",response = ComActWarehouseApplyVO.class) @GetMapping("{id}") public R selectOne(@PathVariable("id") Integer id) { return this.communityService.comActWarehouseApplySelectOne(id); } /** * 新增数据 * * @param comActWarehouseApply 实体对象 * @return 新增结果 */ @ApiOperation("新增数据") @PostMapping public R insert(@RequestBody ComActWarehouseApplyVO comActWarehouseApply) { comActWarehouseApply.setCommunityId(this.getCommunityId()); comActWarehouseApply.setCreateTime(new Date()); comActWarehouseApply.setApplyUserId(this.getUserId()); comActWarehouseApply.setStatus(ComActWarehouseApplyVO.status.dcl); comActWarehouseApply.setApplyName(this.getLoginUserInfo().getName()!=null?this.getLoginUserInfo().getName():""); comActWarehouseApply.setApplyPhone(this.getLoginUserInfo().getPhone()!=null?this.getLoginUserInfo().getPhone():""); return this.communityService.comActWarehouseApplyInsert(comActWarehouseApply); } /** * 修改数据 * * @param comActWarehouseApply 实体对象 * @return 修改结果 */ @ApiOperation("修改数据") @PostMapping("/update") public R update(@RequestBody ComActWarehouseApplyVO comActWarehouseApply) { if(comActWarehouseApply.getStatus().equals(ComActWarehouseApplyVO.status.yqx)){ comActWarehouseApply.setCancelTime(new Date()); } if(comActWarehouseApply.getStatus().equals(ComActWarehouseApplyVO.status.dlq)||comActWarehouseApply.getStatus().equals(ComActWarehouseApplyVO.status.ybh)){ comActWarehouseApply.setSolveTime(new Date()); comActWarehouseApply.setSolveUserId(this.getUserId()); } if(comActWarehouseApply.getStatus().equals(ComActWarehouseApplyVO.status.ylq)){ comActWarehouseApply.setActualTime(new Date()); comActWarehouseApply.setWriteOffUserId(this.getUserId()); } return this.communityService.comActWarehouseApplyUpdate(comActWarehouseApply); } /** * 删除数据 * * @param id 主键结合 * @return 删除结果 */ @ApiOperation("删除数据") @GetMapping("del") public R delete(@RequestParam("id") Long id) { return this.communityService.comActWarehouseApplyDelete(id); } /** * 生成二维码 * @param qrCodeVO * @return */ @ApiOperation("生成二维码") @PostMapping("/getQRCode") public R getQRCode(@RequestBody QRCodeVO qrCodeVO){ return this.communityService.comActWarehouseApplyGetQRCode(qrCodeVO); } }