|
@@ -2,17 +2,22 @@ package com.anyway.favor.controller;
|
|
|
|
|
|
import com.anyway.favor.model.FavorItem;
|
|
import com.anyway.favor.model.FavorItem;
|
|
import com.anyway.favor.model.User;
|
|
import com.anyway.favor.model.User;
|
|
|
|
+import com.anyway.favor.model.vo.FavorItemVo;
|
|
import com.anyway.favor.service.FavorItemService;
|
|
import com.anyway.favor.service.FavorItemService;
|
|
|
|
+import com.anyway.favor.service.FavorService;
|
|
|
|
+import com.anyway.favor.service.GiftService;
|
|
|
|
+import com.anyway.favor.service.PersonService;
|
|
import com.anyway.util.PageQuery;
|
|
import com.anyway.util.PageQuery;
|
|
import com.anyway.util.R;
|
|
import com.anyway.util.R;
|
|
import com.anyway.util.SessionUtils;
|
|
import com.anyway.util.SessionUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
-import org.springframework.stereotype.Controller;
|
|
|
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
-import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
-import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
@@ -22,38 +27,44 @@ import java.util.Map;
|
|
* @author liuchuanwei
|
|
* @author liuchuanwei
|
|
* @date 2024-02-24
|
|
* @date 2024-02-24
|
|
*/
|
|
*/
|
|
-@Controller
|
|
|
|
|
|
+@RestController
|
|
@RequestMapping("/favorItem")
|
|
@RequestMapping("/favorItem")
|
|
public class FavorItemController {
|
|
public class FavorItemController {
|
|
@Autowired
|
|
@Autowired
|
|
private FavorItemService favorItemService;
|
|
private FavorItemService favorItemService;
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 跳转列表页面
|
|
|
|
- *
|
|
|
|
- * @param mv
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- @RequestMapping("/toList")
|
|
|
|
- public ModelAndView toList(ModelAndView mv) {
|
|
|
|
- mv.setViewName("/favorItem/list");
|
|
|
|
- return mv;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private PersonService personService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private FavorService favorService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private GiftService giftService;
|
|
/**
|
|
/**
|
|
- * 人情往来记录列表
|
|
|
|
|
|
+ * 人情明细分页
|
|
*
|
|
*
|
|
* @param pageQuery
|
|
* @param pageQuery
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- @ResponseBody
|
|
|
|
- @RequestMapping("/listPage")
|
|
|
|
- public R listPage(@RequestBody PageQuery<Map<String, Object>> pageQuery) {
|
|
|
|
|
|
+ @GetMapping("/listPage")
|
|
|
|
+ public R<List<FavorItemVo>> listPage(@RequestBody PageQuery<Map<String, Object>> pageQuery) {
|
|
User currentUser = SessionUtils.currentUser();
|
|
User currentUser = SessionUtils.currentUser();
|
|
- Map<String, Object> mapCondition = pageQuery.getTerms();
|
|
|
|
|
|
+ Map<String, Object> mapCondition = pageQuery.getTerms(new HashMap<>());
|
|
//查询和当前登录用户相关的人员
|
|
//查询和当前登录用户相关的人员
|
|
-// mapCondition.put("createBy", currentUser.getId());
|
|
|
|
|
|
+ mapCondition.put("createBy", currentUser.getId());
|
|
|
|
+ mapCondition.put("sortName", "id");
|
|
|
|
+ mapCondition.put("sortOrder", "asc");
|
|
List<FavorItem> favorItemList = favorItemService.findPage(pageQuery);
|
|
List<FavorItem> favorItemList = favorItemService.findPage(pageQuery);
|
|
- return R.page(favorItemList, pageQuery.getPage());
|
|
|
|
|
|
+ //补充人情明细的关联信息
|
|
|
|
+ List<FavorItemVo> favorItemVoList = new ArrayList<>();
|
|
|
|
+ for (FavorItem favorItem : favorItemList) {
|
|
|
|
+ FavorItemVo favorItemVo = new FavorItemVo(favorItem);
|
|
|
|
+ favorItemVo.setFavor(favorService.findById(favorItem.getFavorId()));
|
|
|
|
+ favorItemVo.setHoldPerson(personService.findById(favorItemVo.getFavor().getHoldPersonId()));
|
|
|
|
+ favorItemVo.setReceivePerson(personService.findById(favorItem.getReceivePersonId()));
|
|
|
|
+ favorItemVo.setReturnGift(giftService.findById(favorItem.getReturnGiftId()));
|
|
|
|
+ favorItemVo.setGivePerson(personService.findById(favorItem.getGivePersonId()));
|
|
|
|
+ favorItemVo.setGiveGift(giftService.findById(favorItem.getGiveGiftId()));
|
|
|
|
+ favorItemVoList.add(favorItemVo);
|
|
|
|
+ }
|
|
|
|
+ return R.page(favorItemVoList, pageQuery.getPage());
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
+}
|