便利查询--指定用户有权限直接获取当前数据库部分数据
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
package com.ai.da.controller;
|
||||
|
||||
|
||||
import com.ai.da.common.context.UserContext;
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.mapper.DesignMapper;
|
||||
import com.ai.da.mapper.TrialOrderMapper;
|
||||
import com.ai.da.mapper.entity.TrialOrder;
|
||||
import com.ai.da.model.dto.UserDesignStatisticDTO;
|
||||
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.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();
|
||||
if (accountId.equals(31L) || accountId.equals(87L) || accountId.equals(83L)){
|
||||
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();
|
||||
if (accountId.equals(31L) || accountId.equals(87L) || accountId.equals(83L)){
|
||||
List<UserDesignStatisticDTO> designStatistic = designMapper.getDesignStatistic(startTime, endTime);
|
||||
return Response.success(designStatistic);
|
||||
}else {
|
||||
return Response.fail("Sorry, you don't have permission");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.ai.da.mapper;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.entity.Collection;
|
||||
import com.ai.da.mapper.entity.Design;
|
||||
import com.ai.da.model.dto.UserDesignStatisticDTO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
@@ -14,4 +16,6 @@ public interface DesignMapper extends CommonMapper<Design> {
|
||||
|
||||
//返回插入数据后生成的主键
|
||||
Long insertDesign(Design design);
|
||||
|
||||
List<UserDesignStatisticDTO> getDesignStatistic(String startTime, String endTime);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.ai.da.model.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UserDesignStatisticDTO {
|
||||
|
||||
private Long accountId;
|
||||
|
||||
private Long useDesignTimes;
|
||||
|
||||
private String userEmail;
|
||||
|
||||
private String userName;
|
||||
|
||||
private String isTrial;
|
||||
}
|
||||
@@ -15,7 +15,7 @@ spring.security.jwtTokenPrefix=Bearer-
|
||||
spring.security.jwtExpiration=8640000000
|
||||
#spring security权限设置 认证了token还要认证权限 不然报错Full authentication is required to access this resource
|
||||
spring.security.ignorePaths=/,/favicon.ico,/doc.html,/webjars/**,/swagger-resources,/v2/api-docs,\
|
||||
/api/account/**,/api/element/**,/api/python/**,/api/design/**,/api/history/**,/api/library/**,/api/third/party/**,/api/generate/**,/api/workspace/**,/api/classification/**
|
||||
/api/account/**,/api/element/**,/api/python/**,/api/design/**,/api/history/**,/api/library/**,/api/third/party/**,/api/generate/**,/api/workspace/**,/api/classification/**,/api/inquiry/**
|
||||
spring.security.authApi=/auth/login
|
||||
|
||||
|
||||
|
||||
@@ -25,5 +25,19 @@
|
||||
#{switchCategory},
|
||||
#{createDate});
|
||||
</insert>
|
||||
|
||||
<select id="getDesignStatistic" resultType="com.ai.da.model.dto.UserDesignStatisticDTO" parameterType="String">
|
||||
select a.account_id,count(a.account_id) use_design_times,b.user_email,b.user_name,b.is_trial
|
||||
from t_design a
|
||||
left join `t_account` b
|
||||
on a.account_id = b.id
|
||||
<where>
|
||||
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
||||
a.create_date between #{startTime} and #{endTime}
|
||||
</if>
|
||||
</where>
|
||||
GROUP BY a.account_id
|
||||
ORDER BY a.account_id ASC;
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user