lisy
2023-08-02 d69f9a06fb73f9d5efea882a684d217f12e34a4f
cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TCityController.java
@@ -1,5 +1,7 @@
package com.dsh.guns.modular.system.controller.code;
import cn.hutool.crypto.SecureUtil;
import com.alibaba.nacos.common.utils.Md5Utils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dsh.course.entity.City;
@@ -12,10 +14,12 @@
import com.dsh.course.feignClient.competition.model.ListQuery;
import com.dsh.course.feignClient.competition.model.Participant;
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.service.ICityService;
import com.dsh.guns.modular.system.service.IStoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@@ -48,6 +52,8 @@
    @Autowired
    private IStoreService storeService;
    @Autowired
    private ICityService cityService;
    /**
@@ -55,26 +61,35 @@
     */
    @RequestMapping("")
    public String index(Model model) {
        return PREFIX + "TCompetition.html";
        List<TCity> list = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
        model.addAttribute("list",list);
        return PREFIX + "TCity.html";
    }
    /**
     * 跳转到添加车辆管理
     */
    @RequestMapping("/tCompetition_add")
    @RequestMapping("/tCity_add")
    public String tCompetitionAdd(Model model) {
        return PREFIX + "TCompetition_add.html";
        List<TCity> list = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
        model.addAttribute("list",list);
        return PREFIX + "TCity_add.html";
    }
    /**
     * 跳转到修改车辆管理
     */
    @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";
    }
@@ -89,10 +104,18 @@
    @RequestMapping(value = "/add")
    public Object list(Competition competition) {
    @ResponseBody
    public Object list(TCityManager manager) {
        try {
            competitionClient.add(competition);
            return SUCCESS_TIP;
            String pwd = SecureUtil.md5("a123456");
            manager.setPassword(pwd);
            manager.setState(1);
            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());
            cityClient.add(manager);
            return new SuccessTip<>();
        }catch (Exception e){
            e.printStackTrace();
            return ERROR;
@@ -100,10 +123,26 @@
    }
    @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());
            cityClient.update(manager);
            return new SuccessTip<>();
        }catch (Exception e){
            e.printStackTrace();
            return ERROR;
        }
    }
    @RequestMapping(value = "/onChange")
    @ResponseBody
    public Object onChange(Integer oneId) {
        try {
            TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, oneId));
            return cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId,one.getId()));
        }catch (Exception e){
            e.printStackTrace();
            return ERROR;
@@ -122,6 +161,43 @@
        }
    }
    @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 {
            TCityManager byId = cityClient.getById(id);
            byId.setPassword(SecureUtil.md5("a123456"));
            cityClient.update(byId);
            return SUCCESS_TIP;
        }catch (Exception e){
            e.printStackTrace();
            return ERROR;
        }
    }
    @RequestMapping(value = "/getPeopleFromId")
    public Object getPeopleFromId(Integer id,Integer state) {
        try {