| | |
| | | import cn.hutool.crypto.SecureUtil; |
| | | import com.alibaba.nacos.common.utils.Md5Utils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.dsh.course.entity.City; |
| | | import com.dsh.course.feignClient.account.CityClient; |
| | | import com.dsh.course.feignClient.account.model.CityListQuery; |
| | | import com.dsh.course.feignClient.account.model.TCityManager; |
| | | import com.dsh.course.feignClient.competition.CompetitionClient; |
| | | import com.dsh.course.feignClient.competition.model.Competition; |
| | | import com.dsh.course.feignClient.competition.model.GetPeopleQuery; |
| | | import com.dsh.course.feignClient.competition.model.ListQuery; |
| | | import com.dsh.course.feignClient.competition.model.Participant; |
| | | import com.dsh.course.feignClient.competition.model.*; |
| | | import com.dsh.course.mapper.UserMapper; |
| | | import com.dsh.guns.core.base.controller.BaseController; |
| | | import com.dsh.guns.core.base.tips.SuccessTip; |
| | | import com.dsh.guns.core.common.constant.factory.PageFactory; |
| | | import com.dsh.guns.core.util.ToolUtil; |
| | | import com.dsh.guns.modular.system.model.TCity; |
| | | import com.dsh.guns.modular.system.model.TStore; |
| | | import com.dsh.guns.modular.system.model.User; |
| | | import com.dsh.guns.modular.system.service.ICityService; |
| | | import com.dsh.guns.modular.system.service.IStoreService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | @Autowired |
| | | private ICityService cityService; |
| | | |
| | | @Resource |
| | | private UserMapper userMapper; |
| | | |
| | | |
| | | /** |
| | | * 跳转到车辆管理首页 |
| | |
| | | /** |
| | | * 跳转到修改车辆管理 |
| | | */ |
| | | @RequestMapping("/tCompetition_update/{id}") |
| | | public String tCarUpdate(@PathVariable Integer id, Model model) { |
| | | Competition competition = competitionClient.queryById(id); |
| | | model.addAttribute("item",competition); |
| | | return PREFIX + "tCompetition_edit.html"; |
| | | @RequestMapping("/tCity_update/{id}") |
| | | public String tCityUpdate(@PathVariable Integer id, Model model) { |
| | | TCityManager byId = cityClient.getById(id); |
| | | model.addAttribute("item",byId); |
| | | List<TCity> list = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0)); |
| | | model.addAttribute("list",list); |
| | | TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, byId.getProvinceCode())); |
| | | List<TCity> list1 = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId,one.getId() )); |
| | | model.addAttribute("list1",list1); |
| | | return PREFIX + "tCity_edit.html"; |
| | | } |
| | | |
| | | |
| | |
| | | manager.setProvince(one.getName()); |
| | | TCity one1 = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, manager.getCityCode())); |
| | | manager.setCity(one1.getName()); |
| | | cityClient.add(manager); |
| | | List<User> users = userMapper.selectList(new LambdaQueryWrapper<User>().eq(User::getAccount, manager.getPhone())); |
| | | if(users.size()>0){ |
| | | return "5001"; |
| | | } |
| | | Integer add = cityClient.add(manager); |
| | | User user = new User(); |
| | | user.setPhone(manager.getPhone()); |
| | | user.setAccount(manager.getPhone()); |
| | | user.setRoleid(manager.getPhone()); |
| | | user.setRoleid("3"); |
| | | user.setName(manager.getName()); |
| | | user.setPassword(SecureUtil.md5("a123456")); |
| | | user.setCreatetime(new Date()); |
| | | user.setObjectId(add); |
| | | user.setObjectType(2); |
| | | userMapper.insert(user); |
| | | |
| | | return new SuccessTip<>(); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | } |
| | | |
| | | @RequestMapping(value = "/update") |
| | | public Object update(Competition competition) { |
| | | @ResponseBody |
| | | public Object update(TCityManager manager) { |
| | | try { |
| | | competitionClient.update(competition); |
| | | return SUCCESS_TIP; |
| | | TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, manager.getProvinceCode())); |
| | | manager.setProvince(one.getName()); |
| | | TCity one1 = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, manager.getCityCode())); |
| | | manager.setCity(one1.getName()); |
| | | List<User> users = userMapper.selectList(new LambdaQueryWrapper<User>().eq(User::getAccount, manager.getPhone()).ne(User::getObjectId,manager.getId())); |
| | | if(users.size()>0){ |
| | | return "5001"; |
| | | } |
| | | |
| | | User user = userMapper.selectOne(new LambdaQueryWrapper<User>().eq(User::getObjectType, 2).eq(User::getObjectId, manager.getId())); |
| | | user.setAccount(manager.getPhone()); |
| | | user.setName(manager.getName()); |
| | | user.setPhone(manager.getPhone()); |
| | | userMapper.updateById(user); |
| | | |
| | | cityClient.update(manager); |
| | | return new SuccessTip<>(); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ERROR; |
| | |
| | | @RequestMapping(value = "/onChange") |
| | | @ResponseBody |
| | | public Object onChange(Integer oneId) { |
| | | if (oneId == null) { |
| | | return null; |
| | | } |
| | | try { |
| | | TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, oneId)); |
| | | return cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId,one.getId())); |
| | | QueryWrapper<TCity> query = new QueryWrapper<TCity>().eq("parent_id", one.getId()); |
| | | return cityService.list(query); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ERROR; |
| | |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "/freeze") |
| | | @ResponseBody |
| | | public Object freeze(Integer id) { |
| | | try { |
| | | cityClient.freeze(id); |
| | | return SUCCESS_TIP; |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ERROR; |
| | | } |
| | | } |
| | | @RequestMapping(value = "/unfreeze") |
| | | @ResponseBody |
| | | public Object unfreeze(Integer id) { |
| | | try { |
| | | cityClient.unfreeze(id); |
| | | return SUCCESS_TIP; |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ERROR; |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "/pwd") |
| | | @ResponseBody |
| | | public Object pwd(Integer id) { |
| | | try { |
| | | userMapper.selectOne(new LambdaQueryWrapper<User>().eq(User::getObjectId,id).eq(User::getObjectType,2)); |
| | | return SUCCESS_TIP; |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ERROR; |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "/getPeopleFromId") |
| | | public Object getPeopleFromId(Integer id,Integer state) { |
| | | try { |
| | | Page<Object> page = new PageFactory<>().defaultPage(); |
| | | Page<Participant> data = competitionClient.getPeopleFromId(new GetPeopleQuery(page.getSize(),page.getCurrent(),id,state)); |
| | | Page<CompetitionUser> data = competitionClient.getPeopleFromId(new GetPeopleQuery(page.getSize(),page.getCurrent(),id,state)); |
| | | return super.packForBT(data); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |