|
@@ -1,14 +1,18 @@
|
|
|
package com.kioor.chat.service.impl;
|
|
|
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.kioor.chat.dao.ChatLogDao;
|
|
|
import com.kioor.chat.dto.ChatLogDTO;
|
|
|
import com.kioor.chat.entity.ChatLogEntity;
|
|
|
import com.kioor.chat.service.ChatLogService;
|
|
|
-import com.kioor.common.service.impl.CrudServiceImpl;
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
+import com.kioor.common.constant.Constant;
|
|
|
+import com.kioor.common.page.PageData;
|
|
|
+import com.kioor.common.service.impl.BaseServiceImpl;
|
|
|
+import com.kioor.common.utils.CommonUtils;
|
|
|
+import com.kioor.common.utils.ConvertUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
@@ -18,21 +22,61 @@ import java.util.Map;
|
|
|
* @since 3.0 2024-07-17
|
|
|
*/
|
|
|
@Service
|
|
|
-public class ChatLogServiceImpl extends CrudServiceImpl<ChatLogDao, ChatLogEntity, ChatLogDTO> implements ChatLogService {
|
|
|
+public class ChatLogServiceImpl extends BaseServiceImpl<ChatLogDao, ChatLogEntity> implements ChatLogService {
|
|
|
|
|
|
+ /**
|
|
|
+ * 分页
|
|
|
+ */
|
|
|
@Override
|
|
|
- public QueryWrapper<ChatLogEntity> getWrapper(Map<String, Object> params){
|
|
|
- QueryWrapper<ChatLogEntity> wrapper = new QueryWrapper<>();
|
|
|
+ public PageData<ChatLogDTO> page(Map<String, Object> params) {
|
|
|
|
|
|
- String type = (String)params.get("type");
|
|
|
- wrapper.eq(StringUtils.isNotBlank(type), "type", type);
|
|
|
- String chatPartnerId = (String)params.get("chatPartnerId");
|
|
|
- wrapper.eq(StringUtils.isNotBlank(chatPartnerId), "chat_partner_id", chatPartnerId);
|
|
|
- String editUser = (String)params.get("editUser");
|
|
|
- wrapper.eq(StringUtils.isNotBlank(editUser), "edit_user", editUser);
|
|
|
+ //分页
|
|
|
+ IPage<ChatLogEntity> page = getPage(params, Constant.CREATE_DATE, false);
|
|
|
|
|
|
- return wrapper;
|
|
|
+ //查询
|
|
|
+ List<ChatLogDTO> list = baseDao.getList(params);
|
|
|
+ //根据是否显示姓名和是否显示房号隐藏对应的数据
|
|
|
+ list.forEach(this::hiddenInformation);
|
|
|
+
|
|
|
+
|
|
|
+ return getPageData(list, page.getTotal(), ChatLogDTO.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<ChatLogDTO> list(Map<String, Object> params) {
|
|
|
+
|
|
|
+ //查询
|
|
|
+ List<ChatLogDTO> list = baseDao.getList(params);
|
|
|
+ //根据是否显示姓名和是否显示房号隐藏对应的数据
|
|
|
+ list.forEach(this::hiddenInformation);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ChatLogDTO get(Long id) {
|
|
|
+
|
|
|
+ ChatLogDTO dto = baseDao.get(id);
|
|
|
+ hiddenInformation(dto);
|
|
|
+ return dto;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void hiddenInformation(ChatLogDTO dto){
|
|
|
+ if(dto.getShowRoomFlag() != 1){
|
|
|
+ dto.setRoomName(CommonUtils.hiddenInformation(dto.getRoomName()));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void save(ChatLogDTO dto) {
|
|
|
+ ChatLogEntity entity = ConvertUtils.sourceToTarget(dto, ChatLogEntity.class);
|
|
|
+ insert(entity);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void update(ChatLogDTO dto) {
|
|
|
+ ChatLogEntity entity = ConvertUtils.sourceToTarget(dto, ChatLogEntity.class);
|
|
|
+
|
|
|
+ updateById(entity);
|
|
|
+ }
|
|
|
|
|
|
}
|