|
@@ -0,0 +1,78 @@
|
|
|
+package cn.rankin.userservice.service;
|
|
|
+
|
|
|
+import cn.rankin.common.utils.api.model.APIResult;
|
|
|
+import cn.rankin.common.utils.api.page.Page;
|
|
|
+import cn.rankin.common.utils.enums.BaseOrderEnum;
|
|
|
+import cn.rankin.common.utils.enums.BaseStatusEnum;
|
|
|
+import cn.rankin.common.utils.util.JpaSortUtil;
|
|
|
+import cn.rankin.data.api.cms.vo.UserTagStmt;
|
|
|
+import cn.rankin.data.api.user.dto.UserTagDTO;
|
|
|
+import cn.rankin.data.api.user.entity.Campus;
|
|
|
+import cn.rankin.data.api.user.entity.TerminalUser;
|
|
|
+import cn.rankin.data.api.user.entity.UserTag;
|
|
|
+import cn.rankin.userservice.repository.CampusRepository;
|
|
|
+import cn.rankin.userservice.repository.StmtRepository;
|
|
|
+import cn.rankin.userservice.repository.TerminalUserRepository;
|
|
|
+import cn.rankin.userservice.repository.UserTagRepository;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.LinkedHashMap;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import static cn.rankin.userservice.utils.DTOConverter.convert;
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+public class StmtService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private StmtRepository stmtRepository;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TerminalUserRepository terminalUserRepository;
|
|
|
+ @Autowired
|
|
|
+ private CampusRepository campusRepository;
|
|
|
+ @Autowired
|
|
|
+ private UserTagRepository userTagRepository;
|
|
|
+
|
|
|
+
|
|
|
+ public APIResult<Page<UserTagStmt>> userTagStmtPage(String merchantId, String campusId, Integer pageSize, Integer pageNo) {
|
|
|
+
|
|
|
+
|
|
|
+ long count = (long)stmtRepository.userCount(merchantId, campusId);
|
|
|
+
|
|
|
+ Page<UserTagStmt> page = new Page(count, pageNo, pageSize);
|
|
|
+ if (count == 0) {
|
|
|
+ return APIResult.ok(page);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<String> uids = stmtRepository.uidList(merchantId, campusId, page.getStart() , page.getPageSize());
|
|
|
+
|
|
|
+ List<UserTagStmt> data = new ArrayList<>();
|
|
|
+ uids.forEach(uid -> {
|
|
|
+ TerminalUser terminalUser = terminalUserRepository.find(uid);
|
|
|
+ if(null != terminalUser){
|
|
|
+ UserTagStmt stmt = new UserTagStmt();
|
|
|
+ stmt.setUCode(terminalUser.getCode());
|
|
|
+ stmt.setUid(uid);
|
|
|
+ stmt.setUName(terminalUser.getName());
|
|
|
+ Campus campus = campusRepository.find(terminalUser.getCampusId());
|
|
|
+ if(null != campus){
|
|
|
+ stmt.setCName(campus.getName());
|
|
|
+ }
|
|
|
+
|
|
|
+ stmt.setUserTags(userTagRepository.findUserTagByUidStatus(uid, BaseStatusEnum.NORMAL));
|
|
|
+
|
|
|
+ data.add(stmt);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ page.setList(data);
|
|
|
+ return APIResult.ok(page);
|
|
|
+ }
|
|
|
+}
|