2024-03-04 16:33:23 +08:00
|
|
|
package com.ai.da.controller;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.ai.da.common.context.UserContext;
|
|
|
|
|
import com.ai.da.common.response.Response;
|
2024-03-15 15:38:56 +08:00
|
|
|
import com.ai.da.mapper.primary.DesignMapper;
|
|
|
|
|
import com.ai.da.mapper.primary.TrialOrderMapper;
|
|
|
|
|
import com.ai.da.mapper.primary.entity.TrialOrder;
|
2024-03-04 16:33:23 +08:00
|
|
|
import com.ai.da.model.dto.UserDesignStatisticDTO;
|
2024-04-22 13:09:44 +08:00
|
|
|
import io.netty.util.internal.StringUtil;
|
2024-03-04 16:33:23 +08:00
|
|
|
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;
|
2024-04-22 13:09:44 +08:00
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.Date;
|
2024-03-04 16:33:23 +08:00
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
@Api(tags = "便利查询")
|
|
|
|
|
@Slf4j
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping("/api/inquiry")
|
|
|
|
|
public class ConvenientInquiryController {
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private TrialOrderMapper trialOrderMapper;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private DesignMapper designMapper;
|
|
|
|
|
|
|
|
|
|
@ApiOperation("获取当前所有试用用户")
|
|
|
|
|
@GetMapping("/getTrial")
|
|
|
|
|
public Response<List<TrialOrder>> getTrial(){
|
|
|
|
|
Long accountId = UserContext.getUserHolder().getId();
|
2024-04-23 11:02:53 +08:00
|
|
|
if (accountId.equals(31L) || accountId.equals(87L) || accountId.equals(83L) || accountId.equals(6L) || accountId.equals(4L) || accountId.equals(73L)){
|
2024-03-04 16:33:23 +08:00
|
|
|
List<TrialOrder> trialOrders = trialOrderMapper.selectList(null);
|
|
|
|
|
return Response.success(trialOrders);
|
|
|
|
|
}else {
|
|
|
|
|
return Response.fail("Sorry, you don't have permission");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation("获取指定时间区间内所有用户design的使用情况")
|
|
|
|
|
@GetMapping("/getDesignStatistic")
|
|
|
|
|
public Response<List<UserDesignStatisticDTO>> getDesignStatistic(@RequestParam String startTime,@RequestParam String endTime){
|
|
|
|
|
Long accountId = UserContext.getUserHolder().getId();
|
2024-04-23 11:02:53 +08:00
|
|
|
if (accountId.equals(31L) || accountId.equals(87L) || accountId.equals(83L) || accountId.equals(6L) || accountId.equals(4L) || accountId.equals(73L)){
|
2024-04-22 13:09:44 +08:00
|
|
|
if (StringUtil.isNullOrEmpty(startTime)) startTime = "2024-02-01 00:00:00";
|
|
|
|
|
if (StringUtil.isNullOrEmpty(endTime)){
|
|
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
endTime = simpleDateFormat.format(date);
|
|
|
|
|
}
|
2024-03-04 16:33:23 +08:00
|
|
|
List<UserDesignStatisticDTO> designStatistic = designMapper.getDesignStatistic(startTime, endTime);
|
|
|
|
|
return Response.success(designStatistic);
|
|
|
|
|
}else {
|
|
|
|
|
return Response.fail("Sorry, you don't have permission");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|