|
@@ -1,23 +1,18 @@
|
|
package com.anyway.favor.controller;
|
|
package com.anyway.favor.controller;
|
|
|
|
|
|
-import com.anyway.favor.model.Favor;
|
|
|
|
import com.anyway.favor.model.FavorItem;
|
|
import com.anyway.favor.model.FavorItem;
|
|
-import com.anyway.favor.model.Person;
|
|
|
|
import com.anyway.favor.model.User;
|
|
import com.anyway.favor.model.User;
|
|
import com.anyway.favor.service.FavorItemService;
|
|
import com.anyway.favor.service.FavorItemService;
|
|
-import com.anyway.favor.service.FavorService;
|
|
|
|
-import com.anyway.favor.service.PersonService;
|
|
|
|
|
|
+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.stereotype.Controller;
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
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.bind.annotation.ResponseBody;
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
-import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
@@ -31,86 +26,34 @@ import java.util.Map;
|
|
@RequestMapping("/favorItem")
|
|
@RequestMapping("/favorItem")
|
|
public class FavorItemController {
|
|
public class FavorItemController {
|
|
@Autowired
|
|
@Autowired
|
|
- private FavorService favorService;
|
|
|
|
- @Autowired
|
|
|
|
private FavorItemService favorItemService;
|
|
private FavorItemService favorItemService;
|
|
- @Autowired
|
|
|
|
- private PersonService personService;
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 人情往来明细
|
|
|
|
- *
|
|
|
|
- * @param favorId
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- @RequestMapping("/listAll/{favorId}")
|
|
|
|
- @ResponseBody
|
|
|
|
- public R listAll(@PathVariable Long favorId) {
|
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
|
- map.put("favorId", favorId);
|
|
|
|
- List<FavorItem> favorItemList = favorItemService.findByCondition(map);
|
|
|
|
- return R.data(favorItemList);
|
|
|
|
- }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 跳转新增页面
|
|
|
|
|
|
+ * 跳转列表页面
|
|
*
|
|
*
|
|
* @param mv
|
|
* @param mv
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- @RequestMapping("/toAdd")
|
|
|
|
- public ModelAndView toAdd(ModelAndView mv) {
|
|
|
|
- mv.setViewName("edit");
|
|
|
|
- //人员列表
|
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
|
- map.put("createBy", SessionUtils.currentUserId());
|
|
|
|
- List<Person> personList = personService.findByCondition(map);
|
|
|
|
- mv.addObject("personList", personList);
|
|
|
|
- return mv;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 添加人情
|
|
|
|
- *
|
|
|
|
- * @param favor
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- @ResponseBody
|
|
|
|
- @RequestMapping("/add")
|
|
|
|
- public R add(@RequestBody Favor favor) {
|
|
|
|
- User currentUser = SessionUtils.currentUser();
|
|
|
|
- favor.setCreateBy(currentUser.getId());
|
|
|
|
- favor.setModifyBy(currentUser.getId());
|
|
|
|
- return favorService.add(favor) ? R.ok() : R.fail();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 跳转编辑人情页面
|
|
|
|
- *
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- @RequestMapping("/edit/{id}")
|
|
|
|
- public ModelAndView edit(@PathVariable Long id, ModelAndView mv) {
|
|
|
|
- mv.setViewName("edit2");
|
|
|
|
- Favor favor = favorService.findById(id);
|
|
|
|
- mv.addObject("favor", favor);
|
|
|
|
- //人员列表
|
|
|
|
- List<Person> personList = personService.findAll();
|
|
|
|
- mv.addObject("personList", personList);
|
|
|
|
|
|
+ @RequestMapping("/toList")
|
|
|
|
+ public ModelAndView toList(ModelAndView mv) {
|
|
|
|
+ mv.setViewName("/favorItem/list");
|
|
return mv;
|
|
return mv;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 更新人情
|
|
|
|
|
|
+ * 人情往来记录列表
|
|
*
|
|
*
|
|
- * @param favor
|
|
|
|
|
|
+ * @param pageQuery
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@ResponseBody
|
|
@ResponseBody
|
|
- @RequestMapping("/update")
|
|
|
|
- public R update(Favor favor) {
|
|
|
|
|
|
+ @RequestMapping("/listPage")
|
|
|
|
+ public R listPage(@RequestBody PageQuery<Map<String, Object>> pageQuery) {
|
|
User currentUser = SessionUtils.currentUser();
|
|
User currentUser = SessionUtils.currentUser();
|
|
- favor.setModifyBy(currentUser.getId());
|
|
|
|
- return favorService.update(favor) ? R.ok() : R.fail();
|
|
|
|
|
|
+ Map<String, Object> mapCondition = pageQuery.getTerms();
|
|
|
|
+ //查询和当前登录用户相关的人员
|
|
|
|
+// mapCondition.put("createBy", currentUser.getId());
|
|
|
|
+ List<FavorItem> favorItemList = favorItemService.findPage(pageQuery);
|
|
|
|
+ return R.page(favorItemList, pageQuery.getPage());
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
+}
|