|
@@ -0,0 +1,81 @@
|
|
|
+package com.zskk.shop.controller.h5;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
+import org.springframework.ui.Model;
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+
|
|
|
+import com.zskk.shop.controller.AbstractController;
|
|
|
+import com.zskk.shop.controller.bean.UserBean;
|
|
|
+import com.zskk.shop.dao.entry.FamilyPeople;
|
|
|
+import com.zskk.shop.exception.ErrorConstant;
|
|
|
+import com.zskk.shop.exception.ZSKKException;
|
|
|
+import com.zskk.shop.service.FamilyPeopleService;
|
|
|
+import com.zskk.shop.service.UserCenterService;
|
|
|
+
|
|
|
+@Controller
|
|
|
+@RequestMapping("/h5/family")
|
|
|
+public class H5FamilyController extends AbstractController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FamilyPeopleService familyPeopleService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UserCenterService userCenterService;
|
|
|
+
|
|
|
+ @RequestMapping("/list")
|
|
|
+ public String list(Model model){
|
|
|
+ UserBean userBean = this.getUser();
|
|
|
+ List<FamilyPeople> list = familyPeopleService.queryMyPeoples(userBean.getUserid());
|
|
|
+ model.addAttribute("list", list);
|
|
|
+ this.initUser(model);
|
|
|
+ return "/h5/family";
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping("goedit/{id}")
|
|
|
+ public String goedit(Model model, @PathVariable("id") Integer id){
|
|
|
+ FamilyPeople people = null;
|
|
|
+ if (id.equals(0)){
|
|
|
+ people = new FamilyPeople();
|
|
|
+ people.setId(0);
|
|
|
+ people.setIdcard("");
|
|
|
+ people.setSex(1);
|
|
|
+ people.setName("");
|
|
|
+ people.setPhone("");
|
|
|
+ }else{
|
|
|
+ people = familyPeopleService.queryMyPeople(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (people == null){
|
|
|
+ throw new ZSKKException(ErrorConstant.PARAM_ERROR);
|
|
|
+ }
|
|
|
+
|
|
|
+ model.addAttribute("people", people);
|
|
|
+ this.initUser(model);
|
|
|
+ return "/h5/edit_people";
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping("save")
|
|
|
+ public String goedit(Model model,
|
|
|
+ FamilyPeople people, @RequestParam("code") String code){
|
|
|
+
|
|
|
+ if (!userCenterService.checkCode(people.getPhone(), code)){
|
|
|
+ model.addAttribute("msg", "验证码错误");
|
|
|
+ return "/h5/op_error";
|
|
|
+ }
|
|
|
+
|
|
|
+ if (people.getId().equals(0)){
|
|
|
+ familyPeopleService.addMyPeople(this.getUser().getUserid(), people.getName(), people.getPhone(),
|
|
|
+ people.getIdcard(), people.getSex(), people.getBirth());
|
|
|
+ }else{
|
|
|
+ familyPeopleService.updateMyPeople(this.getUser().getUserid(), people.getId(), people.getName(), people.getPhone(),
|
|
|
+ people.getIdcard(), people.getSex(), people.getBirth());
|
|
|
+ }
|
|
|
+
|
|
|
+ return this.list(model);
|
|
|
+ }
|
|
|
+}
|