|
@@ -8,19 +8,17 @@ import com.nuliji.tools.Transform;
|
|
|
import com.qxgmat.data.constants.enums.status.DirectionStatus;
|
|
|
import com.qxgmat.data.constants.enums.user.AskTarget;
|
|
|
import com.qxgmat.data.constants.enums.user.MoneyRange;
|
|
|
-import com.qxgmat.data.dao.entity.Manager;
|
|
|
-import com.qxgmat.data.dao.entity.Question;
|
|
|
-import com.qxgmat.data.dao.entity.User;
|
|
|
-import com.qxgmat.data.dao.entity.UserAsk;
|
|
|
-import com.qxgmat.dto.admin.extend.ManagerExtendDto;
|
|
|
-import com.qxgmat.dto.admin.extend.QuestionExtendDto;
|
|
|
-import com.qxgmat.dto.admin.extend.UserExtendDto;
|
|
|
+import com.qxgmat.data.dao.entity.*;
|
|
|
+import com.qxgmat.dto.admin.extend.*;
|
|
|
import com.qxgmat.dto.admin.request.UserAskDto;
|
|
|
import com.qxgmat.dto.admin.request.UserAskOrderDto;
|
|
|
+import com.qxgmat.dto.admin.response.UserAskDetailDto;
|
|
|
import com.qxgmat.dto.admin.response.UserAskListDto;
|
|
|
+import com.qxgmat.help.ShiroHelp;
|
|
|
import com.qxgmat.service.ManagerService;
|
|
|
import com.qxgmat.service.UsersService;
|
|
|
import com.qxgmat.service.inline.ManagerLogService;
|
|
|
+import com.qxgmat.service.inline.QuestionNoService;
|
|
|
import com.qxgmat.service.inline.QuestionService;
|
|
|
import com.qxgmat.service.inline.UserAskService;
|
|
|
import io.swagger.annotations.Api;
|
|
@@ -33,39 +31,83 @@ import org.springframework.web.bind.annotation.*;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpSession;
|
|
|
import java.util.Collection;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
@RestController("AdminUserAskController")
|
|
|
-@RequestMapping("/admin/user_ask")
|
|
|
+@RequestMapping("/admin/user/ask")
|
|
|
@Api(tags = "用户提问接口", description = "用户提问相关", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
public class UserAskController {
|
|
|
@Autowired
|
|
|
private ManagerLogService managerLogService;
|
|
|
+ @Autowired
|
|
|
+ private ShiroHelp shiroHelp;
|
|
|
|
|
|
@Autowired
|
|
|
private UserAskService userAskService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private QuestionService questionService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private QuestionNoService questionNoService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private UsersService usersService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private ManagerService managerService;
|
|
|
|
|
|
-
|
|
|
@RequestMapping(value = "/edit", method = RequestMethod.PUT)
|
|
|
@ApiOperation(value = "修改提问信息", httpMethod = "PUT")
|
|
|
public Response<Boolean> edit(@RequestBody @Validated UserAskDto dto, HttpServletRequest request) {
|
|
|
UserAsk entity = Transform.dtoToEntity(dto);
|
|
|
+ if(!entity.getAnswer().isEmpty()){
|
|
|
+
|
|
|
+ entity.setAnswerTime(new Date());
|
|
|
+ entity.setAnswerStatus(1);
|
|
|
+ }
|
|
|
+
|
|
|
+ Manager manager = shiroHelp.getLoginManager();
|
|
|
+ entity.setManagerId(manager.getId());
|
|
|
entity = userAskService.edit(entity);
|
|
|
+ userAskService.updateOrder(dto.getOther());
|
|
|
managerLogService.log(request);
|
|
|
return ResponseHelp.success(true);
|
|
|
}
|
|
|
|
|
|
- @RequestMapping(value = "/order", method = RequestMethod.PUT)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @RequestMapping(value = "/detail", method = RequestMethod.PUT)
|
|
|
@ApiOperation(value = "修改提问排序", httpMethod = "PUT")
|
|
|
- public Response<Boolean> order(@RequestBody @Validated UserAskOrderDto dto, HttpServletRequest request) {
|
|
|
- userAskService.order(dto.getId(), dto.getOrder());
|
|
|
- return ResponseHelp.success(true);
|
|
|
+ public Response<UserAskDetailDto> detail(@RequestParam int id, HttpServletRequest request) {
|
|
|
+ UserAsk entity = userAskService.get(id);
|
|
|
+ UserAskDetailDto dto = Transform.convert(entity, UserAskDetailDto.class);
|
|
|
+
|
|
|
+ if (entity.getManagerId() != null && entity.getManagerId() > 0){
|
|
|
+ Manager manager = managerService.get(entity.getManagerId());
|
|
|
+ if (manager != null)
|
|
|
+ dto.setManager(Transform.convert(manager, ManagerExtendDto.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ User user = usersService.get(entity.getUserId());
|
|
|
+ dto.setUser(Transform.convert(user, UserExtendDto.class));
|
|
|
+
|
|
|
+ Question question = questionService.get(entity.getQuestionId());
|
|
|
+ dto.setQuestion(Transform.convert(question, QuestionExtendDto.class));
|
|
|
+
|
|
|
+ QuestionNo questionNo = questionNoService.get(entity.getQuestionNoId());
|
|
|
+ dto.setQuestionNo(Transform.convert(questionNo, QuestionNoExtendDto.class));
|
|
|
+
|
|
|
+
|
|
|
+ List<UserAsk> userAskList = userAskService.listByQuestion(entity.getQuestionId(), null);
|
|
|
+ dto.setOthers(Transform.convert(userAskList, UserAskExtendDto.class));
|
|
|
+ return ResponseHelp.success(dto);
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
|
@@ -74,8 +116,8 @@ public class UserAskController {
|
|
|
@RequestParam(required = false, defaultValue = "1") int page,
|
|
|
@RequestParam(required = false, defaultValue = "100") int size,
|
|
|
@RequestParam(required = false) int category,
|
|
|
- @RequestParam(required = false, name = "user_id") int userId,
|
|
|
- @RequestParam(required = false, name = "question_id") int questionId,
|
|
|
+ @RequestParam(required = false, name = "user_id") Number userId,
|
|
|
+ @RequestParam(required = false, name = "question_no_id") Number questionNoId,
|
|
|
@RequestParam(required = false, name="target") String target,
|
|
|
@RequestParam(required = false, name="status") Integer status,
|
|
|
@RequestParam(required = false, name="show_status") Integer showStatus,
|
|
@@ -83,14 +125,18 @@ public class UserAskController {
|
|
|
@RequestParam(required = false, defaultValue = "id") String order,
|
|
|
@RequestParam(required = false, defaultValue = "desc") String direction,
|
|
|
HttpSession session) {
|
|
|
- Page<UserAsk> p = userAskService.listWithUser(page, size, category, userId, questionId, AskTarget.ValueOf(target), status, showStatus, MoneyRange.ValueOf(moneyRang), order, DirectionStatus.ValueOf(direction));
|
|
|
+ Page<UserAsk> p = userAskService.listWithUser(page, size, category, userId, questionNoId, AskTarget.ValueOf(target), status, showStatus, MoneyRange.ValueOf(moneyRang), order, DirectionStatus.ValueOf(direction));
|
|
|
List<UserAskListDto> pr = Transform.convert(p, UserAskListDto.class);
|
|
|
|
|
|
|
|
|
Collection questionIds = Transform.getIds(p, UserAsk.class, "questionId");
|
|
|
List<Question> questionList = questionService.select(questionIds);
|
|
|
- List<QuestionExtendDto> questionExtendDtoList = Transform.convert(questionList, QuestionExtendDto.class);
|
|
|
- Transform.combine(pr, questionExtendDtoList, UserAskListDto.class, "questionId", "question", QuestionExtendDto.class, "id");
|
|
|
+ Transform.combine(pr, questionList, UserAskListDto.class, "questionId", "question", Question.class, "id", QuestionExtendDto.class);
|
|
|
+
|
|
|
+
|
|
|
+ Collection questionNoIds = Transform.getIds(p, UserAsk.class, "questionNoId");
|
|
|
+ List<QuestionNo> questionNoList = questionNoService.select(questionNoIds);
|
|
|
+ Transform.combine(pr, questionNoList, UserAskListDto.class, "questionNoId", "question", QuestionNo.class, "id", QuestionNoExtendDto.class);
|
|
|
|
|
|
|
|
|
Collection userIds = Transform.getIds(p, UserAsk.class, "userId");
|