Procházet zdrojové kódy

修改数据源注解

dos před 8 měsíci
rodič
revize
704c66b70f

+ 5 - 1
game-business/src/main/java/com/game/business/controller/AppAgentController.java

@@ -12,6 +12,7 @@ import com.game.common.annotation.Anonymous;
 import com.game.common.core.domain.HttpRet;
 import com.game.common.utils.MessageUtils;
 import com.game.common.utils.SecurityUtils;
+import com.game.common.utils.StringUtils;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -38,10 +39,13 @@ public class AppAgentController {
      * 首页
      */
     @PostMapping(value = "/index")
-    @ApiOperation(value = "首页", notes = "首页")
+    @ApiOperation(value = "用户代理统计", notes = "用户代理统计")
     public HttpRet<AppUserAgentJournalIndexVO> index(AgentIndexDto agentIndexDto)
     {
         Long userId = SecurityUtils.getUserId();
+        if(null != agentIndexDto.getUserId()){
+            userId = agentIndexDto.getUserId();
+        }
         AppUserAgentJournalIndexVO vo = new AppUserAgentJournalIndexVO();
         Date nowDate = DateUtil.date();
         if(agentIndexDto.getType() == 1){

+ 3 - 0
game-business/src/main/java/com/game/business/dto/AgentIndexDto.java

@@ -11,4 +11,7 @@ public class AgentIndexDto {
     @ApiModelProperty(value = "类型 0:本月  1:上月  不传默认查询本月")
     private int type = 0;
 
+    @ApiModelProperty(value = "用户id,不传则查询本账号信息")
+    private Long userId;
+
 }

+ 6 - 0
game-business/src/main/java/com/game/business/service/IAppUserAgentService.java

@@ -58,4 +58,10 @@ public interface IAppUserAgentService extends IService<AppUserAgent> {
      * @return 结果
      */
     public int deleteAppUserAgentById(Long id);
+
+    /**
+     * 统计用户代理
+     *
+     * */
+    public int countAgent(Long userId,String beginTime,String endTime);
 }

+ 19 - 6
game-business/src/main/java/com/game/business/service/impl/AppUserAgentServiceImpl.java

@@ -1,8 +1,10 @@
 package com.game.business.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import java.util.List;
         import com.game.common.utils.DateUtils;
+import com.game.common.utils.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.game.business.mapper.AppUserAgentMapper;
@@ -29,7 +31,6 @@ public class AppUserAgentServiceImpl extends ServiceImpl<AppUserAgentMapper, App
      * @return 用户代理表
      */
     @Override
-    @DataSource(DataSourceType.SLAVE)
     public AppUserAgent selectAppUserAgentById(Long id) {
         return appUserAgentMapper.selectAppUserAgentById(id);
     }
@@ -41,7 +42,6 @@ public class AppUserAgentServiceImpl extends ServiceImpl<AppUserAgentMapper, App
      * @return 用户代理表
      */
     @Override
-    @DataSource(DataSourceType.SLAVE)
     public List<AppUserAgent> selectAppUserAgentList(AppUserAgent appUserAgent) {
         return appUserAgentMapper.selectAppUserAgentList(appUserAgent);
     }
@@ -53,7 +53,6 @@ public class AppUserAgentServiceImpl extends ServiceImpl<AppUserAgentMapper, App
      * @return 结果
      */
     @Override
-    @DataSource(DataSourceType.SLAVE)
     public int insertAppUserAgent(AppUserAgent appUserAgent) {
                 appUserAgent.setCreateTime(DateUtils.getNowDate());
             return appUserAgentMapper.insertAppUserAgent(appUserAgent);
@@ -66,7 +65,6 @@ public class AppUserAgentServiceImpl extends ServiceImpl<AppUserAgentMapper, App
      * @return 结果
      */
     @Override
-    @DataSource(DataSourceType.SLAVE)
     public int updateAppUserAgent(AppUserAgent appUserAgent) {
                 appUserAgent.setUpdateTime(DateUtils.getNowDate());
         return appUserAgentMapper.updateAppUserAgent(appUserAgent);
@@ -79,7 +77,6 @@ public class AppUserAgentServiceImpl extends ServiceImpl<AppUserAgentMapper, App
      * @return 结果
      */
     @Override
-    @DataSource(DataSourceType.SLAVE)
     public int deleteAppUserAgentByIds(Long[] ids) {
         return appUserAgentMapper.deleteAppUserAgentByIds(ids);
     }
@@ -91,8 +88,24 @@ public class AppUserAgentServiceImpl extends ServiceImpl<AppUserAgentMapper, App
      * @return 结果
      */
     @Override
-    @DataSource(DataSourceType.SLAVE)
     public int deleteAppUserAgentById(Long id) {
         return appUserAgentMapper.deleteAppUserAgentById(id);
     }
+
+    /**
+     * 统计用户代理人数
+     * */
+    @Override
+    public int countAgent(Long userId, String beginTime, String endTime) {
+        LambdaQueryWrapper<AppUserAgent> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(AppUserAgent::getPid,userId);
+        if(StringUtils.isNotBlank(beginTime)){
+            queryWrapper.ge(AppUserAgent::getCreateTime,beginTime);
+        }
+        if(StringUtils.isNotBlank(endTime)){
+            queryWrapper.le(AppUserAgent::getCreateTime,endTime);
+        }
+        queryWrapper.eq(AppUserAgent::getAuditStatus,"1");
+        return appUserAgentMapper.selectCount(queryWrapper).intValue();
+    }
 }