|
|
@ -19,21 +19,35 @@ package com.epmet.service.impl; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.OrderItem; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
import com.epmet.constant.UserAdviceConstant; |
|
|
|
import com.epmet.dao.UserAdviceDao; |
|
|
|
import com.epmet.dto.UserAdviceDTO; |
|
|
|
import com.epmet.dto.form.AdviceListFormDTO; |
|
|
|
import com.epmet.dto.form.ReplyAdviceFormDTO; |
|
|
|
import com.epmet.dto.result.AdviceDetailResultDTO; |
|
|
|
import com.epmet.entity.UserAdviceEntity; |
|
|
|
import com.epmet.entity.UserAdviceImgEntity; |
|
|
|
import com.epmet.redis.UserAdviceRedis; |
|
|
|
import com.epmet.service.UserAdviceImgService; |
|
|
|
import com.epmet.service.UserAdviceService; |
|
|
|
import io.jsonwebtoken.lang.Collections; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.poi.ss.formula.functions.T; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.context.annotation.Bean; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
@ -50,6 +64,9 @@ public class UserAdviceServiceImpl extends BaseServiceImpl<UserAdviceDao, UserAd |
|
|
|
@Autowired |
|
|
|
private UserAdviceRedis userAdviceRedis; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private UserAdviceImgService userAdviceImgService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<UserAdviceDTO> page(Map<String, Object> params) { |
|
|
|
IPage<UserAdviceEntity> page = baseDao.selectPage( |
|
|
@ -66,8 +83,8 @@ public class UserAdviceServiceImpl extends BaseServiceImpl<UserAdviceDao, UserAd |
|
|
|
return ConvertUtils.sourceToTarget(entityList, UserAdviceDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
private QueryWrapper<UserAdviceEntity> getWrapper(Map<String, Object> params){ |
|
|
|
String id = (String)params.get(FieldConstant.ID_HUMP); |
|
|
|
private QueryWrapper<UserAdviceEntity> getWrapper(Map<String, Object> params) { |
|
|
|
String id = (String) params.get(FieldConstant.ID_HUMP); |
|
|
|
|
|
|
|
QueryWrapper<UserAdviceEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|
|
@ -112,6 +129,95 @@ public class UserAdviceServiceImpl extends BaseServiceImpl<UserAdviceDao, UserAd |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void replyAdvice(ReplyAdviceFormDTO dto, String loginUserId) { |
|
|
|
baseDao.replyAdvice(dto.getAdviceId(),dto.getReplyContent(),dto.getGovContent(),loginUserId); |
|
|
|
//检验是否已经回复过
|
|
|
|
UserAdviceEntity userAdviceEntity = baseDao.selectById(dto.getAdviceId()); |
|
|
|
if (StringUtils.isNotBlank(userAdviceEntity.getReplyContent()) || StringUtils.isNotBlank(userAdviceEntity.getReplyUserId())) { |
|
|
|
throw new RenException("该建议已被回复,不能再次回复"); |
|
|
|
} |
|
|
|
//更新advice表
|
|
|
|
baseDao.replyAdvice(dto.getAdviceId(), dto.getReplyContent(), dto.getGovContent(), loginUserId); |
|
|
|
//如果govImg不为空,插入advice_img表
|
|
|
|
List<String> govImgList = dto.getGovImgList(); |
|
|
|
if (!Collections.isEmpty(govImgList)) { |
|
|
|
List<UserAdviceImgEntity> userAdviceImgEntities = new ArrayList<>(); |
|
|
|
for (int i = 0; i < govImgList.size(); i++) { |
|
|
|
//最多存三张图片
|
|
|
|
if (i == 3) { |
|
|
|
break; |
|
|
|
} |
|
|
|
UserAdviceImgEntity entity = new UserAdviceImgEntity(); |
|
|
|
entity.setImgUrl(govImgList.get(i)); |
|
|
|
entity.setAdviceId(dto.getAdviceId()); |
|
|
|
entity.setType("oper"); |
|
|
|
userAdviceImgEntities.add(entity); |
|
|
|
} |
|
|
|
userAdviceImgService.insertBatch(userAdviceImgEntities); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param adviceId |
|
|
|
* @return com.epmet.dto.result.AdviceDetailResultDTO |
|
|
|
* @Description 建议详情 |
|
|
|
* @Author liushaowen |
|
|
|
* @Date 2020/11/6 17:19 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public AdviceDetailResultDTO adviceDetail(String adviceId) { |
|
|
|
UserAdviceEntity userAdviceEntity = baseDao.selectById(adviceId); |
|
|
|
AdviceDetailResultDTO adviceDetailResultDTO = new AdviceDetailResultDTO(); |
|
|
|
BeanUtils.copyProperties(userAdviceEntity, adviceDetailResultDTO); |
|
|
|
adviceDetailResultDTO.setAdviceId(userAdviceEntity.getId()); |
|
|
|
adviceDetailResultDTO.setAdviceTime(userAdviceEntity.getCreatedTime()); |
|
|
|
//拼接建议类型
|
|
|
|
if (!"*".equals(userAdviceEntity.getAdviceType())) { |
|
|
|
StringBuilder type = new StringBuilder(); |
|
|
|
if (userAdviceEntity.getAdviceType().contains("gov")) { |
|
|
|
type.append(UserAdviceConstant.GOV_TYPE_TEXT); |
|
|
|
} |
|
|
|
if (userAdviceEntity.getAdviceType().contains("software")) { |
|
|
|
if (type.length() != 0) { |
|
|
|
type.append(","); |
|
|
|
} |
|
|
|
type.append(UserAdviceConstant.SOFTWARE_TYPE_TEXT); |
|
|
|
} |
|
|
|
adviceDetailResultDTO.setAdviceType(type.toString()); |
|
|
|
} |
|
|
|
//获取建议图片
|
|
|
|
List<UserAdviceImgEntity> imgsByAdviceId = userAdviceImgService.getImgsByAdviceId(adviceId); |
|
|
|
List<String> govImgList = new ArrayList<>(); |
|
|
|
List<String> resiImgList = new ArrayList<>(); |
|
|
|
for (UserAdviceImgEntity entity : imgsByAdviceId) { |
|
|
|
if ("resi".equals(entity.getType())) { |
|
|
|
resiImgList.add(entity.getImgUrl()); |
|
|
|
} else if ("oper".equals(entity.getType())) { |
|
|
|
govImgList.add(entity.getImgUrl()); |
|
|
|
} |
|
|
|
} |
|
|
|
adviceDetailResultDTO.setImgList(resiImgList); |
|
|
|
adviceDetailResultDTO.setGovImgList(govImgList); |
|
|
|
return adviceDetailResultDTO; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param dto |
|
|
|
* @return com.epmet.commons.tools.page.PageData<com.epmet.dto.UserAdviceDTO> |
|
|
|
* @Description 查询建议列表 |
|
|
|
* @Author liushaowen |
|
|
|
* @Date 2020/11/9 10:41 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public PageData<UserAdviceDTO> adviceList(AdviceListFormDTO dto) { |
|
|
|
//page分页
|
|
|
|
Page<UserAdviceEntity> page = new Page<>(dto.getPageNo(), dto.getPageSize()); |
|
|
|
//时间降序
|
|
|
|
page.addOrder(OrderItem.desc(FieldConstant.CREATED_TIME)); |
|
|
|
|
|
|
|
//wrapper
|
|
|
|
QueryWrapper<UserAdviceEntity> wrapper = new QueryWrapper<>(); |
|
|
|
|
|
|
|
|
|
|
|
IPage<UserAdviceEntity> result = baseDao.selectPage(page,wrapper); |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|