Browse Source

Merge branch 'feature/yujt_AppendP2' of http://121.42.41.42:7070/r/epdc-cloud-property-yushan into feature/yujt_AppendP2

hotfix/yujt_opt
zhangyuan 5 years ago
parent
commit
8707917876
  1. 66
      epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/psychology/controller/AppPsychologistController.java
  2. 37
      epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/psychology/dao/PsychologyAnswerDao.java
  3. 7
      epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/psychology/dao/PsychologyQuestionDao.java
  4. 43
      epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/psychology/service/impl/PsychologistServiceImpl.java
  5. 9
      epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/psychology/service/impl/PsychologyQuestionServiceImpl.java
  6. 18
      epdc-cloud-property/src/main/resources/mapper/psychology/PsychologistDao.xml
  7. 58
      epdc-cloud-property/src/main/resources/mapper/psychology/PsychologyAnswerDao.xml
  8. 150
      epdc-cloud-property/src/main/resources/mapper/psychology/PsychologyQuestionDao.xml

66
epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/psychology/controller/AppPsychologistController.java

@ -76,42 +76,80 @@ public class AppPsychologistController {
return new Result<PsychologistInfoResultDTO>().ok(data); return new Result<PsychologistInfoResultDTO>().ok(data);
} }
/**
* 居民端 用户发布心理咨询问题
*
* @param formDto
* @return com.elink.esua.epdc.commons.tools.utils.Result
* @author work@yujt.net.cn
* @date 2020/6/15 13:54
*/
@PostMapping("submitQuestion") @PostMapping("submitQuestion")
public Result submitQuestion(@RequestBody PsychologyQuestionFormDTO formDto) throws Exception { public Result submitQuestion(@RequestBody PsychologyQuestionFormDTO formDto) {
psychologyQuestionService.saveQuestion(formDto); psychologyQuestionService.saveQuestion(formDto);
return new Result(); return new Result();
} }
/**
* 居民端 用户提问的心理咨询问题列表
*
* @param formDto
* @return com.elink.esua.epdc.commons.tools.utils.Result<java.util.List < com.elink.esua.epdc.dto.psychology.result.PsychologyAnswerListUserResultDTO>>
* @author work@yujt.net.cn
* @date 2020/6/15 11:20
*/
@GetMapping("listUserQuestion") @GetMapping("listUserQuestion")
public Result<List<PsychologyAnswerListUserResultDTO>> listUserQuestion(@RequestBody PsychologyAnswerFormDTO formDto) throws Exception { public Result<List<PsychologyAnswerListUserResultDTO>> listUserQuestion(@RequestBody PsychologyAnswerFormDTO formDto) {
//效验数据 // 效验数据
ValidatorUtils.validateEntity(formDto, AddGroup.class, DefaultGroup.class); ValidatorUtils.validateEntity(formDto);
List<PsychologyAnswerListUserResultDTO> data = psychologistService.listUserQuestion(formDto); List<PsychologyAnswerListUserResultDTO> data = psychologistService.listUserQuestion(formDto);
return new Result<List<PsychologyAnswerListUserResultDTO>>().ok(data); return new Result<List<PsychologyAnswerListUserResultDTO>>().ok(data);
} }
/**
* 居民端心理咨询问题列表
*
* @param formDto
* @return com.elink.esua.epdc.commons.tools.utils.Result<java.util.List < com.elink.esua.epdc.dto.psychology.result.PsychologyAnswerListResultDTO>>
* @author work@yujt.net.cn
* @date 2020/6/15 13:36
*/
@GetMapping("listQuestion") @GetMapping("listQuestion")
public Result<List<PsychologyAnswerListResultDTO>> listAllQuestion(@RequestBody PsychologyAnswerFormDTO formDto) throws Exception { public Result<List<PsychologyAnswerListResultDTO>> listAllQuestion(@RequestBody PsychologyAnswerFormDTO formDto) {
//效验数据 //效验数据
ValidatorUtils.validateEntity(formDto, AddGroup.class, DefaultGroup.class); ValidatorUtils.validateEntity(formDto);
List<PsychologyAnswerListResultDTO> data = psychologistService.listAllQuestion(formDto); List<PsychologyAnswerListResultDTO> data = psychologistService.listAllQuestion(formDto);
return new Result<List<PsychologyAnswerListResultDTO>>().ok(data); return new Result<List<PsychologyAnswerListResultDTO>>().ok(data);
} }
/**
* 工作端获取待回答的心理咨询问题列表
*
* @param formDto
* @return com.elink.esua.epdc.commons.tools.utils.Result<java.util.List < com.elink.esua.epdc.dto.psychology.result.PsychologyUnansweredResultDTO>>
* @author work@yujt.net.cn
* @date 2020/6/15 13:35
*/
@GetMapping("listUnansweredQuestion") @GetMapping("listUnansweredQuestion")
public Result<List<PsychologyUnansweredResultDTO>> listUnansweredQuestion(@RequestBody PsychologyUnansweredFormDTO formDto) throws Exception { public Result<List<PsychologyUnansweredResultDTO>> listUnansweredQuestion(@RequestBody PsychologyUnansweredFormDTO formDto) {
//效验数据 // 效验数据
ValidatorUtils.validateEntity(formDto, AddGroup.class, DefaultGroup.class); ValidatorUtils.validateEntity(formDto);
List<PsychologyUnansweredResultDTO> data = psychologistService.listUnansweredQuestion(formDto); List<PsychologyUnansweredResultDTO> data = psychologistService.listUnansweredQuestion(formDto);
return new Result<List<PsychologyUnansweredResultDTO>>().ok(data); return new Result<List<PsychologyUnansweredResultDTO>>().ok(data);
} }
/**
* 工作端我回答过的问题列表
*
* @param formDto
* @return com.elink.esua.epdc.commons.tools.utils.Result<java.util.List < com.elink.esua.epdc.dto.psychology.result.PsychologyAnswerOfMineResultDTO>>
* @author work@yujt.net.cn
* @date 2020/6/15 10:09
*/
@GetMapping("listMyQuestion") @GetMapping("listMyQuestion")
public Result<List<PsychologyAnswerOfMineResultDTO>> listMyQuestion(@RequestBody PsychologyAnswerFormDTO formDto) throws Exception { public Result<List<PsychologyAnswerOfMineResultDTO>> listMyQuestion(@RequestBody PsychologyAnswerFormDTO formDto) {
UserDetail user = SecurityUser.getUser(); // 效验数据
formDto.setUserId(user.getId().toString()); ValidatorUtils.validateEntity(formDto);
//效验数据
ValidatorUtils.validateEntity(formDto, AddGroup.class, DefaultGroup.class);
List<PsychologyAnswerOfMineResultDTO> data = psychologistService.listMyQuestion(formDto); List<PsychologyAnswerOfMineResultDTO> data = psychologistService.listMyQuestion(formDto);
return new Result<List<PsychologyAnswerOfMineResultDTO>>().ok(data); return new Result<List<PsychologyAnswerOfMineResultDTO>>().ok(data);
} }

37
epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/psychology/dao/PsychologyAnswerDao.java

@ -18,11 +18,9 @@
package com.elink.esua.epdc.modules.psychology.dao; package com.elink.esua.epdc.modules.psychology.dao;
import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; import com.elink.esua.epdc.commons.mybatis.dao.BaseDao;
import com.elink.esua.epdc.dto.psychology.result.PsychologyAnswerInfoResultDTO; import com.elink.esua.epdc.dto.psychology.form.PsychologyAnswerFormDTO;
import com.elink.esua.epdc.dto.psychology.result.PsychologyAnswerUserInfoResultDTO;
import com.elink.esua.epdc.modules.psychology.entity.PsychologyAnswerEntity; import com.elink.esua.epdc.modules.psychology.entity.PsychologyAnswerEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@ -36,33 +34,12 @@ import java.util.List;
public interface PsychologyAnswerDao extends BaseDao<PsychologyAnswerEntity> { public interface PsychologyAnswerDao extends BaseDao<PsychologyAnswerEntity> {
/** /**
* 居民端-心理咨询-我的问题列表 * 根据用户id查询用户回答过的问题的id
* *
* @return java.util.List<com.elink.esua.epdc.modules.psychology.entity.PsychologyAnswerEntity> * @param dto
* @params [params] * @return java.util.List<java.lang.String>
* @author zhangyuan * @author work@yujt.net.cn
* @since 2020/5/21 14:54 * @date 2020/6/15 10:16
*/ */
List<PsychologyAnswerUserInfoResultDTO> listUserQuestion(@Param("questionId") String questionId); List<String> selectListAnsweredQuestionId(PsychologyAnswerFormDTO dto);
/**
* 居民端-心理咨询-我的问题列表
*
* @return java.util.List<com.elink.esua.epdc.modules.psychology.entity.PsychologyAnswerInfoResultDTO>
* @params [params]
* @author zhangyuan
* @since 2020/5/21 14:54
*/
List<PsychologyAnswerInfoResultDTO> listAllQuestion(@Param("questionId") String questionId);
/**
* 工作端--心理咨询-我回答的问题列表
*
* @return java.util.List<com.elink.esua.epdc.modules.psychology.entity.PsychologyAnswerEntity>
* @params [params]
* @author zhangyuan
* @since 2020/5/21 14:54
*/
List<PsychologyAnswerEntity> listMyQuestion(@Param("userId") String userId);
} }

7
epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/psychology/dao/PsychologyQuestionDao.java

@ -27,6 +27,7 @@ import com.elink.esua.epdc.dto.psychology.result.PsychologyAnswerOfMineResultDTO
import com.elink.esua.epdc.dto.psychology.result.PsychologyUnansweredResultDTO; import com.elink.esua.epdc.dto.psychology.result.PsychologyUnansweredResultDTO;
import com.elink.esua.epdc.modules.psychology.entity.PsychologyQuestionEntity; import com.elink.esua.epdc.modules.psychology.entity.PsychologyQuestionEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@ -47,7 +48,7 @@ public interface PsychologyQuestionDao extends BaseDao<PsychologyQuestionEntity>
* @author zhangyuan * @author zhangyuan
* @since 2020/5/21 14:54 * @since 2020/5/21 14:54
*/ */
List<PsychologyAnswerListUserResultDTO> listUserQuestion(PsychologyAnswerFormDTO dto); List<PsychologyAnswerListUserResultDTO> selectListUserQuestions(PsychologyAnswerFormDTO dto);
/** /**
* 居民端-心理咨询-问题列表 * 居民端-心理咨询-问题列表
@ -57,7 +58,7 @@ public interface PsychologyQuestionDao extends BaseDao<PsychologyQuestionEntity>
* @author zhangyuan * @author zhangyuan
* @since 2020/5/21 14:54 * @since 2020/5/21 14:54
*/ */
List<PsychologyAnswerListResultDTO> listAllQuestion(PsychologyAnswerFormDTO dto); List<PsychologyAnswerListResultDTO> selectListAllQuestions(PsychologyAnswerFormDTO dto);
/** /**
* 工作端--待解答的心理咨询问题列表 * 工作端--待解答的心理咨询问题列表
@ -77,7 +78,7 @@ public interface PsychologyQuestionDao extends BaseDao<PsychologyQuestionEntity>
* @author zhangyuan * @author zhangyuan
* @since 2020/5/21 14:54 * @since 2020/5/21 14:54
*/ */
List<PsychologyAnswerOfMineResultDTO> listMyQuestion(PsychologyAnswerFormDTO dto); List<PsychologyAnswerOfMineResultDTO> selectlistAnsweredQuestion(@Param("questionIds") List<String> questionIds);
/** /**
* 查询问题详情 * 查询问题详情

43
epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/psychology/service/impl/PsychologistServiceImpl.java

@ -26,6 +26,7 @@ import com.elink.esua.epdc.commons.tools.constant.FieldConstant;
import com.elink.esua.epdc.commons.tools.constant.NumConstant; import com.elink.esua.epdc.commons.tools.constant.NumConstant;
import com.elink.esua.epdc.commons.tools.exception.RenException; import com.elink.esua.epdc.commons.tools.exception.RenException;
import com.elink.esua.epdc.commons.tools.page.PageData; import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.commons.tools.security.user.SecurityUser;
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; import com.elink.esua.epdc.commons.tools.utils.ConvertUtils;
import com.elink.esua.epdc.dto.psychology.PsychologistDTO; import com.elink.esua.epdc.dto.psychology.PsychologistDTO;
import com.elink.esua.epdc.dto.psychology.form.PsychologistFormDTO; import com.elink.esua.epdc.dto.psychology.form.PsychologistFormDTO;
@ -40,6 +41,7 @@ import com.elink.esua.epdc.modules.psychology.entity.PsychologistEntity;
import com.elink.esua.epdc.modules.psychology.entity.PsychologistTitleRelationEntity; import com.elink.esua.epdc.modules.psychology.entity.PsychologistTitleRelationEntity;
import com.elink.esua.epdc.modules.psychology.entity.PsychologyAnswerEntity; import com.elink.esua.epdc.modules.psychology.entity.PsychologyAnswerEntity;
import com.elink.esua.epdc.modules.psychology.service.PsychologistService; import com.elink.esua.epdc.modules.psychology.service.PsychologistService;
import com.google.common.collect.Lists;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.checkerframework.checker.units.qual.A; import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -178,49 +180,36 @@ public class PsychologistServiceImpl extends BaseServiceImpl<PsychologistDao, Ps
@Override @Override
public List<PsychologyAnswerListUserResultDTO> listUserQuestion(PsychologyAnswerFormDTO dto) { public List<PsychologyAnswerListUserResultDTO> listUserQuestion(PsychologyAnswerFormDTO dto) {
// sql limit条件转换 // sql limit条件转换
dto.setPageIndex((dto.getPageIndex() - 1) * dto.getPageSize()); dto.setPageIndex((dto.getPageIndex() - NumConstant.ONE) * dto.getPageSize());
List<PsychologyAnswerListUserResultDTO> data = psychologyQuestionDao.listUserQuestion(dto); return psychologyQuestionDao.selectListUserQuestions(dto);
data.forEach(item -> {
List<PsychologyAnswerUserInfoResultDTO> list = psychologyAnswerDao.listUserQuestion(item.getId());
item.setAnswerList(list.size() == 0 ? new ArrayList<>() : ConvertUtils.sourceToTarget(list, PsychologyAnswerUserInfoResultDTO.class));
});
return data;
} }
@Override @Override
public List<PsychologyAnswerListResultDTO> listAllQuestion(PsychologyAnswerFormDTO dto) { public List<PsychologyAnswerListResultDTO> listAllQuestion(PsychologyAnswerFormDTO dto) {
// sql limit条件转换 // sql limit条件转换
dto.setPageIndex((dto.getPageIndex() - 1) * dto.getPageSize()); dto.setPageIndex((dto.getPageIndex() - NumConstant.ONE) * dto.getPageSize());
List<PsychologyAnswerListResultDTO> data = psychologyQuestionDao.listAllQuestion(dto); return psychologyQuestionDao.selectListAllQuestions(dto);
data.forEach(item -> {
List<PsychologyAnswerInfoResultDTO> list = psychologyAnswerDao.listAllQuestion(item.getId());
item.setAnswerList(list.size() == 0 ? new ArrayList<>() : ConvertUtils.sourceToTarget(list, PsychologyAnswerInfoResultDTO.class));
});
return data;
} }
@Override @Override
public List<PsychologyUnansweredResultDTO> listUnansweredQuestion(PsychologyUnansweredFormDTO dto) { public List<PsychologyUnansweredResultDTO> listUnansweredQuestion(PsychologyUnansweredFormDTO dto) {
dto.setUserId(String.valueOf(SecurityUser.getUserId()));
// sql limit条件转换 // sql limit条件转换
dto.setPageIndex((dto.getPageIndex() - 1) * dto.getPageSize()); dto.setPageIndex((dto.getPageIndex() - NumConstant.ONE) * dto.getPageSize());
return psychologyQuestionDao.listUnansweredQuestion(dto); return psychologyQuestionDao.listUnansweredQuestion(dto);
} }
@Override @Override
public List<PsychologyAnswerOfMineResultDTO> listMyQuestion(PsychologyAnswerFormDTO dto) { public List<PsychologyAnswerOfMineResultDTO> listMyQuestion(PsychologyAnswerFormDTO dto) {
List<String> questionIds = psychologyAnswerDao.listMyQuestion(dto.getUserId()).stream().map(PsychologyAnswerEntity::getQuestionId).collect(Collectors.toList()); dto.setUserId(String.valueOf(SecurityUser.getUserId()));
dto.setQuestionIds(questionIds);
// sql limit条件转换 // sql limit条件转换
dto.setPageIndex((dto.getPageIndex() - 1) * dto.getPageSize()); dto.setPageIndex((dto.getPageIndex() - NumConstant.ONE) * dto.getPageSize());
List<PsychologyAnswerOfMineResultDTO> data = psychologyQuestionDao.listMyQuestion(dto); List<String> questionIds = psychologyAnswerDao.selectListAnsweredQuestionId(dto);
data.forEach(item -> { if (CollUtil.isEmpty(questionIds)) {
List<PsychologyAnswerUserInfoResultDTO> list = psychologyAnswerDao.listUserQuestion(item.getId()); return Lists.newArrayList();
item.setAnswerList(list.size() == 0 ? new ArrayList<>() : ConvertUtils.sourceToTarget(list, PsychologyAnswerUserInfoResultDTO.class)); }
}); return psychologyQuestionDao.selectlistAnsweredQuestion(questionIds);
return data;
} }
} }

9
epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/psychology/service/impl/PsychologyQuestionServiceImpl.java

@ -22,9 +22,10 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl;
import com.elink.esua.epdc.commons.tools.constant.FieldConstant; import com.elink.esua.epdc.commons.tools.constant.FieldConstant;
import com.elink.esua.epdc.commons.tools.constant.NumConstant; import com.elink.esua.epdc.commons.tools.constant.NumConstant;
import com.elink.esua.epdc.commons.tools.enums.YesOrNoEnum;
import com.elink.esua.epdc.commons.tools.page.PageData; import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; import com.elink.esua.epdc.commons.tools.utils.ConvertUtils;
import com.elink.esua.epdc.dto.constant.PropertyConstant; import com.elink.esua.epdc.dto.constant.PsychologyConstant;
import com.elink.esua.epdc.dto.psychology.PsychologyQuestionDTO; import com.elink.esua.epdc.dto.psychology.PsychologyQuestionDTO;
import com.elink.esua.epdc.dto.psychology.form.PsychologyQuestionFormDTO; import com.elink.esua.epdc.dto.psychology.form.PsychologyQuestionFormDTO;
import com.elink.esua.epdc.modules.psychology.dao.PsychologyQuestionDao; import com.elink.esua.epdc.modules.psychology.dao.PsychologyQuestionDao;
@ -93,9 +94,9 @@ public class PsychologyQuestionServiceImpl extends BaseServiceImpl<PsychologyQue
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void saveQuestion(PsychologyQuestionFormDTO dto) { public void saveQuestion(PsychologyQuestionFormDTO dto) {
if (NumConstant.ONE_STR.equals(dto.getAnonymousFlag())) { if (YesOrNoEnum.YES.value().equals(dto.getAnonymousFlag())) {
dto.setUserName(PropertyConstant.PROPERTY_PSYCHOLOGY_ANONYMOUS_NAME); dto.setUserName(PsychologyConstant.PROPERTY_PSYCHOLOGY_ANONYMOUS_NAME);
dto.setUserAvatar(PropertyConstant.PROPERTY_PSYCHOLOGY_ANONYMOUS_AVATAR); dto.setUserAvatar(PsychologyConstant.PROPERTY_PSYCHOLOGY_ANONYMOUS_AVATAR);
} }
PsychologyQuestionEntity entity = ConvertUtils.sourceToTarget(dto, PsychologyQuestionEntity.class); PsychologyQuestionEntity entity = ConvertUtils.sourceToTarget(dto, PsychologyQuestionEntity.class);
insert(entity); insert(entity);

18
epdc-cloud-property/src/main/resources/mapper/psychology/PsychologistDao.xml

@ -3,24 +3,6 @@
<mapper namespace="com.elink.esua.epdc.modules.psychology.dao.PsychologistDao"> <mapper namespace="com.elink.esua.epdc.modules.psychology.dao.PsychologistDao">
<resultMap type="com.elink.esua.epdc.modules.psychology.entity.PsychologistEntity" id="psychologistMap">
<result property="id" column="ID"/>
<result property="name" column="NAME"/>
<result property="avatar" column="AVATAR"/>
<result property="mobile" column="MOBILE"/>
<result property="sex" column="SEX"/>
<result property="userId" column="USER_ID"/>
<result property="motto" column="MOTTO"/>
<result property="briefIntroduction" column="BRIEF_INTRODUCTION"/>
<result property="sort" column="SORT"/>
<result property="displayFlag" column="DISPLAY_FLAG"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
ID, NAME, AVATAR, MOBILE, SEX, USER_ID, MOTTO, BRIEF_INTRODUCTION, SORT, ID, NAME, AVATAR, MOBILE, SEX, USER_ID, MOTTO, BRIEF_INTRODUCTION, SORT,
DISPLAY_FLAG, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME DISPLAY_FLAG, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME

58
epdc-cloud-property/src/main/resources/mapper/psychology/PsychologyAnswerDao.xml

@ -3,58 +3,16 @@
<mapper namespace="com.elink.esua.epdc.modules.psychology.dao.PsychologyAnswerDao"> <mapper namespace="com.elink.esua.epdc.modules.psychology.dao.PsychologyAnswerDao">
<resultMap type="com.elink.esua.epdc.modules.psychology.entity.PsychologyAnswerEntity" id="psychologyAnswerMap"> <select id="selectListAnsweredQuestionId" resultType="java.lang.String">
<result property="id" column="ID"/>
<result property="questionId" column="QUESTION_ID"/>
<result property="psychologistId" column="PSYCHOLOGIST_ID"/>
<result property="psychologistName" column="PSYCHOLOGIST_NAME"/>
<result property="answerContent" column="ANSWER_CONTENT"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<sql id="Base_Column_List">
ID, QUESTION_ID, PSYCHOLOGIST_ID, PSYCHOLOGIST_NAME, ANSWER_CONTENT,
DEL_FLAG, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME
</sql>
<select id="listUserQuestion" resultType="com.elink.esua.epdc.dto.psychology.result.PsychologyAnswerUserInfoResultDTO">
SELECT SELECT
PSYCHOLOGIST_ID, PSYCHOLOGIST_NAME, ANSWER_CONTENT, date_format(CREATED_TIME, '%Y-%m-%d') AS ANSWER_TIME DISTINCT(QUESTION_ID) AS QUESTION_ID
FROM FROM
epdc_psychology_answer epdc_psychology_answer
WHERE WHERE
DEL_FLAG = '0' DEL_FLAG = '0'
<if test="questionId != null and questionId != ''"> AND PSYCHOLOGIST_ID = #{userId}
AND QUESTION_ID = #{questionId} AND CREATED_TIME &lt;= STR_TO_DATE( #{timestamp}, '%Y-%m-%d %H:%i:%s' )
</if> ORDER BY CREATED_TIME DESC
ORDER BY LIMIT #{pageIndex}, #{pageSize};
CREATED_TIME DESC
</select>
<select id="listAllQuestion" resultType="com.elink.esua.epdc.dto.psychology.result.PsychologyAnswerInfoResultDTO">
SELECT
PSYCHOLOGIST_ID, PSYCHOLOGIST_NAME, ANSWER_CONTENT
FROM
epdc_psychology_answer
WHERE
DEL_FLAG = '0'
<if test="questionId != null and questionId != ''">
AND QUESTION_ID = #{questionId}
</if>
ORDER BY
CREATED_TIME DESC
</select>
<select id="listMyQuestion" resultType="com.elink.esua.epdc.modules.psychology.entity.PsychologyAnswerEntity">
SELECT
DISTINCT(QUESTION_ID) AS QUESTION_ID
FROM
epdc_psychology_answer
WHERE
DEL_FLAG = '0'
AND PSYCHOLOGIST_ID = #{userId}
</select> </select>
</mapper> </mapper>

150
epdc-cloud-property/src/main/resources/mapper/psychology/PsychologyQuestionDao.xml

@ -3,90 +3,120 @@
<mapper namespace="com.elink.esua.epdc.modules.psychology.dao.PsychologyQuestionDao"> <mapper namespace="com.elink.esua.epdc.modules.psychology.dao.PsychologyQuestionDao">
<resultMap type="com.elink.esua.epdc.modules.psychology.entity.PsychologyQuestionEntity" id="psychologyQuestionMap"> <resultMap id="selectListUserQuestionsMap" type="com.elink.esua.epdc.dto.psychology.result.PsychologyAnswerListUserResultDTO">
<result property="id" column="ID"/> <result property="id" column="ID" />
<result property="userId" column="USER_ID"/> <result property="userId" column="ID" />
<result property="userName" column="USER_NAME"/> <result property="userName" column="ID" />
<result property="userAvatar" column="USER_AVATAR"/> <result property="userAvatar" column="ID" />
<result property="questionContent" column="QUESTION_CONTENT"/> <result property="questionContent" column="QUESTION_CONTENT" />
<result property="anonymousFlag" column="ANONYMOUS_FLAG"/> <result property="questionTime" column="QUESTION_TIME" />
<result property="psychologistId" column="PSYCHOLOGIST_ID"/> <collection property="answerList" ofType="com.elink.esua.epdc.dto.psychology.result.PsychologyAnswerUserInfoResultDTO">
<result property="answerNum" column="ANSWER_NUM"/> <result property="psychologistId" column="PSYCHOLOGIST_ID" />
<result property="displayFlag" column="DISPLAY_FLAG"/> <result property="psychologistName" column="PSYCHOLOGIST_NAME" />
<result property="delFlag" column="DEL_FLAG"/> <result property="answerContent" column="ANSWER_CONTENT" />
<result property="revision" column="REVISION"/> <result property="answerTime" column="ANSWER_TIME" />
<result property="createdBy" column="CREATED_BY"/> </collection>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap> </resultMap>
<sql id="Base_Column_List">
ID, USER_ID, USER_NAME, USER_AVATAR, QUESTION_CONTENT, ANONYMOUS_FLAG, PSYCHOLOGIST_ID, ANSWER_NUM, <select id="selectListUserQuestions" resultMap="selectListUserQuestionsMap">
DEL_FLAG, DISPLAY_FLAG, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME
</sql>
<select id="listUserQuestion" resultType="com.elink.esua.epdc.dto.psychology.result.PsychologyAnswerListUserResultDTO">
SELECT SELECT
ID, USER_ID, USER_NAME, USER_AVATAR, QUESTION_CONTENT, CREATED_TIME AS QUESTION_TIME pq.ID,
pq.USER_ID,pq.USER_NAME,pq.USER_AVATAR,
pq.QUESTION_CONTENT,
DATE_FORMAT( pq.CREATED_TIME, '%Y.%m.%d %H:%i' ) AS QUESTION_TIME,
pa.PSYCHOLOGIST_ID,
pa.PSYCHOLOGIST_NAME,
pa.ANSWER_CONTENT,
DATE_FORMAT( pa.CREATED_TIME, '%Y.%m.%d' ) AS ANSWER_TIME
FROM FROM
epdc_psychology_question epdc_psychology_question pq
LEFT JOIN epdc_psychology_answer pa ON pa.QUESTION_ID = pq.ID AND pa.DEL_FLAG = '0'
WHERE WHERE
DEL_FLAG = '0' pq.DEL_FLAG = '0'
<if test="userId != null and userId != ''"> and pq.USER_ID = #{userId}
AND USER_ID = #{userId} AND pq.CREATED_TIME &lt;= STR_TO_DATE( #{timestamp}, '%Y-%m-%d %H:%i:%s' )
</if> ORDER BY pq.CREATED_TIME DESC
ORDER BY
CREATED_TIME DESC
LIMIT #{pageIndex}, #{pageSize}; LIMIT #{pageIndex}, #{pageSize};
</select> </select>
<select id="listAllQuestion" resultType="com.elink.esua.epdc.dto.psychology.result.PsychologyAnswerListResultDTO"> <resultMap id="selectListAllQuestionsMap" type="com.elink.esua.epdc.dto.psychology.result.PsychologyAnswerListResultDTO">
<result property="id" column="ID" />
<result property="userId" column="ID" />
<result property="userName" column="ID" />
<result property="userAvatar" column="ID" />
<result property="questionContent" column="QUESTION_CONTENT" />
<collection property="answerList" ofType="com.elink.esua.epdc.dto.psychology.result.PsychologyAnswerInfoResultDTO">
<result property="psychologistId" column="PSYCHOLOGIST_ID" />
<result property="psychologistName" column="PSYCHOLOGIST_NAME" />
<result property="answerContent" column="ANSWER_CONTENT" />
</collection>
</resultMap>
<select id="selectListAllQuestions" resultMap="selectListAllQuestionsMap">
SELECT SELECT
ID, USER_ID, USER_NAME, USER_AVATAR, QUESTION_CONTENT pq.ID,
pq.USER_ID,pq.USER_NAME,pq.USER_AVATAR,
pq.QUESTION_CONTENT,
pa.PSYCHOLOGIST_ID,
pa.PSYCHOLOGIST_NAME,
pa.ANSWER_CONTENT
FROM FROM
epdc_psychology_question epdc_psychology_question pq
LEFT JOIN epdc_psychology_answer pa ON pa.QUESTION_ID = pq.ID AND pa.DEL_FLAG = '0'
WHERE WHERE
DEL_FLAG = '0' pq.DEL_FLAG = '0'
AND pq.CREATED_TIME &lt;= STR_TO_DATE( #{timestamp}, '%Y-%m-%d %H:%i:%s' )
ORDER BY ORDER BY
CREATED_TIME DESC pq.CREATED_TIME DESC
LIMIT #{pageIndex}, #{pageSize}; LIMIT #{pageIndex}, #{pageSize};
</select> </select>
<select id="listUnansweredQuestion" resultType="com.elink.esua.epdc.dto.psychology.result.PsychologyUnansweredResultDTO"> <select id="listUnansweredQuestion" resultType="com.elink.esua.epdc.dto.psychology.result.PsychologyUnansweredResultDTO">
SELECT SELECT
ID, QUESTION_CONTENT, CREATED_TIME AS QUESTION_TIME ID, QUESTION_CONTENT, DATE_FORMAT(CREATED_TIME, '%Y.%m.%d %H:%i' ) AS QUESTION_TIME
FROM FROM
epdc_psychology_question epdc_psychology_question
WHERE WHERE
DEL_FLAG = '0' DEL_FLAG = '0'
AND ANSWER_NUM = 0 AND ANSWER_NUM = 0
<if test="designated_flag == '0' or designated_flag == 0"> AND CREATED_TIME &lt;= STR_TO_DATE( #{timestamp}, '%Y-%m-%d %H:%i:%s' )
AND PSYCHOLOGIST_ID = '' <choose>
</if> <when test='designatedFlag == "0"'>AND PSYCHOLOGIST_ID = ''</when>
<if test="designated_flag == '1' or designated_flag == 1"> <otherwise>AND PSYCHOLOGIST_ID = #{userId}</otherwise>
AND PSYCHOLOGIST_ID != '' </choose>
AND PSYCHOLOGIST_ID IS NOT NULL ORDER BY CREATED_TIME DESC
</if>
ORDER BY
CREATED_TIME DESC
LIMIT #{pageIndex}, #{pageSize}; LIMIT #{pageIndex}, #{pageSize};
</select> </select>
<select id="listMyQuestion" resultType="com.elink.esua.epdc.dto.psychology.result.PsychologyAnswerOfMineResultDTO"> <resultMap id="userAnsweredQuestionResultMap" type="com.elink.esua.epdc.dto.psychology.result.PsychologyAnswerOfMineResultDTO">
<result property="id" column="ID" />
<result property="questionContent" column="QUESTION_CONTENT" />
<result property="questionTime" column="QUESTION_TIME" />
<collection property="answerList" ofType="com.elink.esua.epdc.dto.psychology.result.PsychologyAnswerUserInfoResultDTO">
<result property="psychologistId" column="PSYCHOLOGIST_ID" />
<result property="psychologistName" column="PSYCHOLOGIST_NAME" />
<result property="answerContent" column="ANSWER_CONTENT" />
<result property="answerTime" column="ANSWER_TIME" />
</collection>
</resultMap>
<select id="selectlistAnsweredQuestion" resultMap="userAnsweredQuestionResultMap">
SELECT SELECT
ID, QUESTION_CONTENT, CREATED_TIME AS QUESTION_TIME pq.ID,
pq.QUESTION_CONTENT,
DATE_FORMAT( pq.CREATED_TIME, '%Y.%m.%d %H:%i' ) AS QUESTION_TIME,
pa.PSYCHOLOGIST_ID,
pa.PSYCHOLOGIST_NAME,
pa.ANSWER_CONTENT,
DATE_FORMAT( pa.CREATED_TIME, '%Y.%m.%d' ) AS ANSWER_TIME
FROM FROM
epdc_psychology_question epdc_psychology_question pq
LEFT JOIN epdc_psychology_answer pa ON pa.QUESTION_ID = pq.ID
WHERE WHERE
DEL_FLAG = '0' pq.id in <foreach collection="questionIds" item="item" open="(" separator="," close=")">#{item}</foreach>
<if test="questionIds != null and questionIds.size() > 0"> and pa.DEL_FLAG = '0'
AND ID IN
<foreach item="questionId" collection="questionIds" open="(" separator="," close=")">
#{questionId}
</foreach>
</if>
ORDER BY ORDER BY
CREATED_TIME DESC pa.CREATED_TIME DESC
LIMIT #{pageIndex}, #{pageSize};
</select> </select>
<update id="updateQuestion"> <update id="updateQuestion">

Loading…
Cancel
Save