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);
}
/**
* 居民端 用户发布心理咨询问题
*
* @param formDto
* @return com.elink.esua.epdc.commons.tools.utils.Result
* @author work@yujt.net.cn
* @date 2020/6/15 13:54
*/
@PostMapping("submitQuestion")
public Result submitQuestion(@RequestBody PsychologyQuestionFormDTO formDto) throws Exception {
public Result submitQuestion(@RequestBody PsychologyQuestionFormDTO formDto) {
psychologyQuestionService.saveQuestion(formDto);
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")
public Result<List<PsychologyAnswerListUserResultDTO>> listUserQuestion(@RequestBody PsychologyAnswerFormDTO formDto) throws Exception {
//效验数据
ValidatorUtils.validateEntity(formDto, AddGroup.class, DefaultGroup.class);
public Result<List<PsychologyAnswerListUserResultDTO>> listUserQuestion(@RequestBody PsychologyAnswerFormDTO formDto) {
// 效验数据
ValidatorUtils.validateEntity(formDto);
List<PsychologyAnswerListUserResultDTO> data = psychologistService.listUserQuestion(formDto);
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")
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);
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")
public Result<List<PsychologyUnansweredResultDTO>> listUnansweredQuestion(@RequestBody PsychologyUnansweredFormDTO formDto) throws Exception {
//效验数据
ValidatorUtils.validateEntity(formDto, AddGroup.class, DefaultGroup.class);
public Result<List<PsychologyUnansweredResultDTO>> listUnansweredQuestion(@RequestBody PsychologyUnansweredFormDTO formDto) {
// 效验数据
ValidatorUtils.validateEntity(formDto);
List<PsychologyUnansweredResultDTO> data = psychologistService.listUnansweredQuestion(formDto);
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")
public Result<List<PsychologyAnswerOfMineResultDTO>> listMyQuestion(@RequestBody PsychologyAnswerFormDTO formDto) throws Exception {
UserDetail user = SecurityUser.getUser();
formDto.setUserId(user.getId().toString());
//效验数据
ValidatorUtils.validateEntity(formDto, AddGroup.class, DefaultGroup.class);
public Result<List<PsychologyAnswerOfMineResultDTO>> listMyQuestion(@RequestBody PsychologyAnswerFormDTO formDto) {
// 效验数据
ValidatorUtils.validateEntity(formDto);
List<PsychologyAnswerOfMineResultDTO> data = psychologistService.listMyQuestion(formDto);
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;
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.result.PsychologyAnswerUserInfoResultDTO;
import com.elink.esua.epdc.dto.psychology.form.PsychologyAnswerFormDTO;
import com.elink.esua.epdc.modules.psychology.entity.PsychologyAnswerEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -36,33 +34,12 @@ import java.util.List;
public interface PsychologyAnswerDao extends BaseDao<PsychologyAnswerEntity> {
/**
* 居民端-心理咨询-我的问题列表
* 根据用户id查询用户回答过的问题的id
*
* @return java.util.List<com.elink.esua.epdc.modules.psychology.entity.PsychologyAnswerEntity>
* @params [params]
* @author zhangyuan
* @since 2020/5/21 14:54
* @param dto
* @return java.util.List<java.lang.String>
* @author work@yujt.net.cn
* @date 2020/6/15 10:16
*/
List<PsychologyAnswerUserInfoResultDTO> listUserQuestion(@Param("questionId") String questionId);
/**
* 居民端-心理咨询-我的问题列表
*
* @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);
List<String> selectListAnsweredQuestionId(PsychologyAnswerFormDTO dto);
}

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.modules.psychology.entity.PsychologyQuestionEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -47,7 +48,7 @@ public interface PsychologyQuestionDao extends BaseDao<PsychologyQuestionEntity>
* @author zhangyuan
* @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
* @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
* @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.exception.RenException;
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.dto.psychology.PsychologistDTO;
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.PsychologyAnswerEntity;
import com.elink.esua.epdc.modules.psychology.service.PsychologistService;
import com.google.common.collect.Lists;
import org.apache.commons.lang3.StringUtils;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
@ -178,49 +180,36 @@ public class PsychologistServiceImpl extends BaseServiceImpl<PsychologistDao, Ps
@Override
public List<PsychologyAnswerListUserResultDTO> listUserQuestion(PsychologyAnswerFormDTO dto) {
// sql limit条件转换
dto.setPageIndex((dto.getPageIndex() - 1) * dto.getPageSize());
List<PsychologyAnswerListUserResultDTO> data = psychologyQuestionDao.listUserQuestion(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;
dto.setPageIndex((dto.getPageIndex() - NumConstant.ONE) * dto.getPageSize());
return psychologyQuestionDao.selectListUserQuestions(dto);
}
@Override
public List<PsychologyAnswerListResultDTO> listAllQuestion(PsychologyAnswerFormDTO dto) {
// sql limit条件转换
dto.setPageIndex((dto.getPageIndex() - 1) * dto.getPageSize());
List<PsychologyAnswerListResultDTO> data = psychologyQuestionDao.listAllQuestion(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;
dto.setPageIndex((dto.getPageIndex() - NumConstant.ONE) * dto.getPageSize());
return psychologyQuestionDao.selectListAllQuestions(dto);
}
@Override
public List<PsychologyUnansweredResultDTO> listUnansweredQuestion(PsychologyUnansweredFormDTO dto) {
dto.setUserId(String.valueOf(SecurityUser.getUserId()));
// sql limit条件转换
dto.setPageIndex((dto.getPageIndex() - 1) * dto.getPageSize());
dto.setPageIndex((dto.getPageIndex() - NumConstant.ONE) * dto.getPageSize());
return psychologyQuestionDao.listUnansweredQuestion(dto);
}
@Override
public List<PsychologyAnswerOfMineResultDTO> listMyQuestion(PsychologyAnswerFormDTO dto) {
List<String> questionIds = psychologyAnswerDao.listMyQuestion(dto.getUserId()).stream().map(PsychologyAnswerEntity::getQuestionId).collect(Collectors.toList());
dto.setQuestionIds(questionIds);
dto.setUserId(String.valueOf(SecurityUser.getUserId()));
// sql limit条件转换
dto.setPageIndex((dto.getPageIndex() - 1) * dto.getPageSize());
List<PsychologyAnswerOfMineResultDTO> data = psychologyQuestionDao.listMyQuestion(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;
dto.setPageIndex((dto.getPageIndex() - NumConstant.ONE) * dto.getPageSize());
List<String> questionIds = psychologyAnswerDao.selectListAnsweredQuestionId(dto);
if (CollUtil.isEmpty(questionIds)) {
return Lists.newArrayList();
}
return psychologyQuestionDao.selectlistAnsweredQuestion(questionIds);
}
}

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.tools.constant.FieldConstant;
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.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.form.PsychologyQuestionFormDTO;
import com.elink.esua.epdc.modules.psychology.dao.PsychologyQuestionDao;
@ -93,9 +94,9 @@ public class PsychologyQuestionServiceImpl extends BaseServiceImpl<PsychologyQue
@Override
@Transactional(rollbackFor = Exception.class)
public void saveQuestion(PsychologyQuestionFormDTO dto) {
if (NumConstant.ONE_STR.equals(dto.getAnonymousFlag())) {
dto.setUserName(PropertyConstant.PROPERTY_PSYCHOLOGY_ANONYMOUS_NAME);
dto.setUserAvatar(PropertyConstant.PROPERTY_PSYCHOLOGY_ANONYMOUS_AVATAR);
if (YesOrNoEnum.YES.value().equals(dto.getAnonymousFlag())) {
dto.setUserName(PsychologyConstant.PROPERTY_PSYCHOLOGY_ANONYMOUS_NAME);
dto.setUserAvatar(PsychologyConstant.PROPERTY_PSYCHOLOGY_ANONYMOUS_AVATAR);
}
PsychologyQuestionEntity entity = ConvertUtils.sourceToTarget(dto, PsychologyQuestionEntity.class);
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">
<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">
ID, NAME, AVATAR, MOBILE, SEX, USER_ID, MOTTO, BRIEF_INTRODUCTION, SORT,
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">
<resultMap type="com.elink.esua.epdc.modules.psychology.entity.PsychologyAnswerEntity" id="psychologyAnswerMap">
<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 id="selectListAnsweredQuestionId" resultType="java.lang.String">
SELECT
PSYCHOLOGIST_ID, PSYCHOLOGIST_NAME, ANSWER_CONTENT, date_format(CREATED_TIME, '%Y-%m-%d') AS ANSWER_TIME
DISTINCT(QUESTION_ID) AS QUESTION_ID
FROM
epdc_psychology_answer
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="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}
DEL_FLAG = '0'
AND PSYCHOLOGIST_ID = #{userId}
AND CREATED_TIME &lt;= STR_TO_DATE( #{timestamp}, '%Y-%m-%d %H:%i:%s' )
ORDER BY CREATED_TIME DESC
LIMIT #{pageIndex}, #{pageSize};
</select>
</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">
<resultMap type="com.elink.esua.epdc.modules.psychology.entity.PsychologyQuestionEntity" id="psychologyQuestionMap">
<result property="id" column="ID"/>
<result property="userId" column="USER_ID"/>
<result property="userName" column="USER_NAME"/>
<result property="userAvatar" column="USER_AVATAR"/>
<result property="questionContent" column="QUESTION_CONTENT"/>
<result property="anonymousFlag" column="ANONYMOUS_FLAG"/>
<result property="psychologistId" column="PSYCHOLOGIST_ID"/>
<result property="answerNum" column="ANSWER_NUM"/>
<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 id="selectListUserQuestionsMap" type="com.elink.esua.epdc.dto.psychology.result.PsychologyAnswerListUserResultDTO">
<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" />
<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>
<sql id="Base_Column_List">
ID, USER_ID, USER_NAME, USER_AVATAR, QUESTION_CONTENT, ANONYMOUS_FLAG, PSYCHOLOGIST_ID, ANSWER_NUM,
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 id="selectListUserQuestions" resultMap="selectListUserQuestionsMap">
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
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
DEL_FLAG = '0'
<if test="userId != null and userId != ''">
AND USER_ID = #{userId}
</if>
ORDER BY
CREATED_TIME DESC
pq.DEL_FLAG = '0'
and pq.USER_ID = #{userId}
AND pq.CREATED_TIME &lt;= STR_TO_DATE( #{timestamp}, '%Y-%m-%d %H:%i:%s' )
ORDER BY pq.CREATED_TIME DESC
LIMIT #{pageIndex}, #{pageSize};
</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
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
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
DEL_FLAG = '0'
pq.DEL_FLAG = '0'
AND pq.CREATED_TIME &lt;= STR_TO_DATE( #{timestamp}, '%Y-%m-%d %H:%i:%s' )
ORDER BY
CREATED_TIME DESC
LIMIT #{pageIndex}, #{pageSize};
pq.CREATED_TIME DESC
LIMIT #{pageIndex}, #{pageSize};
</select>
<select id="listUnansweredQuestion" resultType="com.elink.esua.epdc.dto.psychology.result.PsychologyUnansweredResultDTO">
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
epdc_psychology_question
epdc_psychology_question
WHERE
DEL_FLAG = '0'
AND ANSWER_NUM = 0
<if test="designated_flag == '0' or designated_flag == 0">
AND PSYCHOLOGIST_ID = ''
</if>
<if test="designated_flag == '1' or designated_flag == 1">
AND PSYCHOLOGIST_ID != ''
AND PSYCHOLOGIST_ID IS NOT NULL
</if>
ORDER BY
CREATED_TIME DESC
DEL_FLAG = '0'
AND ANSWER_NUM = 0
AND CREATED_TIME &lt;= STR_TO_DATE( #{timestamp}, '%Y-%m-%d %H:%i:%s' )
<choose>
<when test='designatedFlag == "0"'>AND PSYCHOLOGIST_ID = ''</when>
<otherwise>AND PSYCHOLOGIST_ID = #{userId}</otherwise>
</choose>
ORDER BY CREATED_TIME DESC
LIMIT #{pageIndex}, #{pageSize};
</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
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
epdc_psychology_question
epdc_psychology_question pq
LEFT JOIN epdc_psychology_answer pa ON pa.QUESTION_ID = pq.ID
WHERE
DEL_FLAG = '0'
<if test="questionIds != null and questionIds.size() > 0">
AND ID IN
<foreach item="questionId" collection="questionIds" open="(" separator="," close=")">
#{questionId}
</foreach>
</if>
pq.id in <foreach collection="questionIds" item="item" open="(" separator="," close=")">#{item}</foreach>
and pa.DEL_FLAG = '0'
ORDER BY
CREATED_TIME DESC
LIMIT #{pageIndex}, #{pageSize};
pa.CREATED_TIME DESC
</select>
<update id="updateQuestion">

Loading…
Cancel
Save