| | |
| | | package com.dsh.guns.modular.system.controller.code; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.dsh.course.feignClient.account.CityManagerClient; |
| | | import com.dsh.course.feignClient.account.CoachClient; |
| | | import com.dsh.course.feignClient.account.CoachTypeClient; |
| | |
| | | import com.dsh.guns.modular.system.model.CoachChangeStateVO; |
| | | import com.dsh.guns.modular.system.model.CoachQuery; |
| | | import com.dsh.guns.modular.system.model.Store; |
| | | import com.dsh.guns.modular.system.model.TStore; |
| | | import com.dsh.guns.modular.system.service.IStoreService; |
| | | import com.dsh.guns.modular.system.util.ResultUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Controller; |
| | |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | |
| | | /** |
| | |
| | | */ |
| | | @RequestMapping("") |
| | | public String index(Model model) { |
| | | |
| | | Integer objectType = UserExt.getUser().getObjectType(); |
| | | Integer objectId = UserExt.getUser().getObjectId(); |
| | | List<Coach> list1=coachClient.getProvince(); |
| | | CoachQuery coachQuery = new CoachQuery(); |
| | | coachQuery.setStoreIds(new ArrayList<>()); |
| | | List<CoachSerchVO> data = coachClient.listAll(coachQuery); |
| | | |
| | | List<String> province = new ArrayList<>(); |
| | | for (Coach coach : list1) { |
| | | for (CoachSerchVO coach : data) { |
| | | province.add(coach.getProvince()); |
| | | } |
| | | HashSet<String> set = new HashSet<String>(province); |
| | | String roleid = UserExt.getUser().getRoleid(); |
| | | model.addAttribute("role",roleid); |
| | | model.addAttribute("data",data); |
| | | model.addAttribute("list",province); |
| | | model.addAttribute("list",set); |
| | | model.addAttribute("objectType",objectType); |
| | | model.addAttribute("objectId",objectId); |
| | | return PREFIX + "TCoach.html"; |
| | |
| | | @RequestMapping(value = "/getCity") |
| | | @ResponseBody |
| | | public List<Coach> getCity(String province) { |
| | | return coachClient.getCity(province); |
| | | List<Coach> city = coachClient.getCity(province); |
| | | List<Coach> res = new ArrayList<>(); |
| | | List<String> list = new ArrayList<>(); |
| | | for (Coach coach : city) { |
| | | if (!list.contains(coach.getCity())){ |
| | | res.add(coach); |
| | | list.add(coach.getCity()); |
| | | } |
| | | } |
| | | return res; |
| | | } |
| | | |
| | | /** |
| | |
| | | CoachQuery coachQuery = new CoachQuery(); |
| | | List<CoachSerchVO> data = coachClient.listAll(coachQuery); |
| | | List<CoachType> list = coachTypeClient.list(); |
| | | |
| | | String roleid = UserExt.getUser().getRoleid(); |
| | | model.addAttribute("role",roleid); |
| | | model.addAttribute("data",data); |
| | |
| | | model.addAttribute("coachType",list); |
| | | return PREFIX + "TCoach_add.html"; |
| | | } |
| | | |
| | | /** |
| | | * 添加教练 |
| | | */ |
| | |
| | | public ResultUtil addCoach(@RequestBody Coach coach) { |
| | | Integer objectId = UserExt.getUser().getObjectId(); |
| | | if (UserExt.getUser().getObjectType() == 2){ |
| | | CityManager cityManager = cityManagerClient.queryCityManagerById(objectId); |
| | | coach.setProvince(cityManager.getProvince()); |
| | | coach.setProvinceCode(cityManager.getProvinceCode()); |
| | | coach.setCity(cityManager.getCity()); |
| | | coach.setCityCode(cityManager.getCityCode()); |
| | | coach.setCityManagerId(objectId); |
| | | |
| | | } |
| | | if (coach.getDiploma().equals("")) coach.setDiploma(null); |
| | | if (coach.getDiploma().equals("")) { |
| | | coach.setDiploma(null); |
| | | } |
| | | if (coach.getCertificateImg().equals("") ){ |
| | | coach.setCertificateImg(null); |
| | | } |
| | |
| | | coachClient.changeState(vo); |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | /** |
| | | * 跳转修改教练页面 |
| | | */ |
| | |
| | | model.addAttribute("type",0); |
| | | String[] split = data.get(0).getCertificateImg().split(","); |
| | | List<String> pictures = new ArrayList<>(Arrays.asList(split)); |
| | | model.addAttribute("pictures",pictures); |
| | | model.addAttribute("pictures",data.get(0).getCertificateImg()); |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
| | | String birthday = format.format(data.get(0).getBirthday()); |
| | | model.addAttribute("birthday",birthday); |
| | | model.addAttribute("diploma",data.get(0).getDiploma()); |
| | | return PREFIX + "TCoach_edit.html"; |
| | | } |
| | | /** |
| | |
| | | /** |
| | | * 获取教练列表 |
| | | */ |
| | | @Autowired |
| | | private IStoreService storeService; |
| | | @RequestMapping(value = "/list") |
| | | @ResponseBody |
| | | public List<CoachSerchVO> list(String province, String city, String name, String phone) { |
| | |
| | | coachQuery.setCity(city); |
| | | coachQuery.setName(name); |
| | | coachQuery.setPhone(phone); |
| | | Integer objectType = UserExt.getUser().getObjectType(); |
| | | if (objectType == 1){ |
| | | Integer objectId = UserExt.getUser().getObjectId(); |
| | | coachQuery.setOperatorId(objectId); |
| | | } |
| | | if (objectType == 2){ |
| | | Integer objectId = UserExt.getUser().getObjectId(); |
| | | coachQuery.setOperatorId(objectId); |
| | | } |
| | | |
| | | return coachClient.listAll(coachQuery); |
| | | } |
| | | } |