123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- package me.zhengjie.modules.thirdparty.v1;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import lombok.RequiredArgsConstructor;
- import me.zhengjie.annotation.AnonymousAccess;
- import me.zhengjie.annotation.Log;
- import me.zhengjie.annotation.rest.AnonymousPostMapping;
- import me.zhengjie.base.BaseResponse;
- import me.zhengjie.base.QueryPageParams;
- import me.zhengjie.domain.LocalStorage;
- import me.zhengjie.exception.BadRequestException;
- import me.zhengjie.modules.dm.daypc.domain.DmDayPc;
- import me.zhengjie.modules.dm.daypc.service.DmDayPcService;
- import me.zhengjie.modules.dm.daypc.service.dto.DmDayPcQueryCriteria;
- import me.zhengjie.modules.dm.foodPj.domain.DmFoodPj;
- import me.zhengjie.modules.dm.foodPj.service.DmFoodPjService;
- import me.zhengjie.modules.dm.order.domain.DmOrderItem;
- import me.zhengjie.modules.dm.order.domain.DmOrderRecord;
- import me.zhengjie.modules.dm.order.repository.DmOrderItemRepository;
- import me.zhengjie.modules.dm.order.repository.DmOrderRecordRepository;
- import me.zhengjie.modules.dm.service.domain.DmServicePj;
- import me.zhengjie.modules.dm.service.service.DmServicePjService;
- import me.zhengjie.modules.dmApp.domain.AppFoodPj;
- import me.zhengjie.modules.dmApp.service.AppFoodPjService;
- import me.zhengjie.service.LocalStorageService;
- import me.zhengjie.utils.FileUtil;
- import me.zhengjie.utils.SecurityUtils;
- import org.springframework.data.domain.Pageable;
- import org.springframework.http.HttpStatus;
- import org.springframework.http.ResponseEntity;
- import org.springframework.validation.annotation.Validated;
- import org.springframework.web.bind.annotation.*;
- import org.springframework.web.multipart.MultipartFile;
- import java.util.List;
- import java.util.Map;
- @RestController
- @RequiredArgsConstructor
- @Api(tags = "用户接口")
- @RequestMapping("/api/thirdparty/v1/open")
- public class OpenApiController {
- private final DmDayPcService dmDayPcService;
- private final DmServicePjService dmServicePjService;
- private final AppFoodPjService appFoodPjService;
- private final DmFoodPjService dmFoodPjService;
- private final LocalStorageService localStorageService;
- private final DmOrderRecordRepository dmOrderRecordRepository;
- private final DmOrderItemRepository orderItemRepository;
- @Log("获取今日菜品-App")
- @ApiOperation("获取今日菜品-App")
- @AnonymousPostMapping(value = "/foodRepository")
- public BaseResponse<Object> foodRepository(@RequestBody QueryPageParams<DmDayPcQueryCriteria> criteria, Pageable pageable){
- SecurityUtils.CheckApiAuth(criteria);
- return new BaseResponse<>(dmDayPcService.foodRepository());
- }
- @AnonymousPostMapping(value = "/createApp")
- @Log("新增服务评价")
- @ApiOperation("新增服务评价")
- public BaseResponse<Object> createApp(@RequestBody QueryPageParams<DmServicePj> resources){
- SecurityUtils.CheckApiAuth(resources);
- return new BaseResponse<>(dmServicePjService.createApp(resources.getQuery()));
- }
- @AnonymousPostMapping(value = "/appFoodPj")
- @Log("App菜品评价")
- @ApiOperation("App菜品评价")
- public BaseResponse<Object> appFoodPj(@RequestBody QueryPageParams<String> userCode) {
- SecurityUtils.CheckApiAuth(userCode);
- List<AppFoodPj> list = appFoodPjService.selectAppFoodPj(userCode.getQuery());
- return new BaseResponse<>(list);
- }
- @AnonymousPostMapping(value = "/createFoodPj")
- @Log("新增菜品评价")
- @ApiOperation("新增菜品评价")
- public BaseResponse<Object> createFoodPj(@RequestBody QueryPageParams<DmFoodPj> resources){
- SecurityUtils.CheckApiAuth(resources);
- return new BaseResponse<>(dmFoodPjService.createApp(resources.getQuery()));
- }
- @AnonymousPostMapping(value = "/pictures")
- @Log("上传图片")
- @ApiOperation("上传图片")
- public BaseResponse<Object> upload(@RequestParam String timestamp, @RequestParam String nonce, @RequestParam String name, @RequestParam("file") MultipartFile file){
- QueryPageParams params = new QueryPageParams();
- params.setNonce(nonce);
- params.setTimestamp(timestamp);
- SecurityUtils.CheckApiAuth(params);
- // 判断文件是否为图片
- String suffix = FileUtil.getExtensionName(file.getOriginalFilename());
- if(!FileUtil.IMAGE.equals(FileUtil.getFileType(suffix))){
- throw new BadRequestException("只能上传图片");
- }
- LocalStorage localStorage = localStorageService.create(name, file);
- return new BaseResponse<>(localStorage);
- }
- @AnonymousAccess
- @GetMapping(value = "/countOrderAmt")
- @Log("pc端运营食堂营业额")
- @ApiOperation("pc端运营食堂营业额")
- public ResponseEntity<Object> countOrderAmt(){
- return new ResponseEntity<>(dmOrderRecordRepository.countOrderAmt(),HttpStatus.OK);
- }
- @AnonymousAccess
- @GetMapping(value = "/hyFood")
- @Log("pc端运营最受欢迎菜品")
- @ApiOperation("pc端运营最受欢迎菜品")
- public ResponseEntity<Object> hyFood(){
- return new ResponseEntity<>(orderItemRepository.hyFood(),HttpStatus.OK);
- }
- @AnonymousPostMapping(value = "/countOrderAmtApp")
- @Log("App端运营食堂营业额")
- @ApiOperation("App端运营食堂营业额")
- public BaseResponse<Object> countOrderAmtApp(@RequestBody QueryPageParams<DmOrderRecord> criteria){
- SecurityUtils.CheckApiAuth(criteria);
- return new BaseResponse<>(dmOrderRecordRepository.countOrderAmt());
- }
- @AnonymousPostMapping(value = "/hyFoodApp")
- @Log("App端运营最受欢迎菜品")
- @ApiOperation("App端运营最受欢迎菜品")
- public BaseResponse<Object> hyFoodApp(@RequestBody QueryPageParams<DmOrderItem> criteria){
- SecurityUtils.CheckApiAuth(criteria);
- return new BaseResponse<>(orderItemRepository.hyFood());
- }
- }
|