Pu Zhibing
2025-06-06 b1f2f102034b4433201225b67a9fc78c08e532f0
ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TCompanyController.java
@@ -7,20 +7,18 @@
import com.baomidou.mybatisplus.plugins.Page;
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.core.common.constant.factory.PageFactory;
import com.stylefeng.guns.core.log.LogObjectHolder;
import com.stylefeng.guns.core.shiro.ShiroKit;
import com.stylefeng.guns.core.util.DateUtil;
import com.stylefeng.guns.core.util.SinataUtil;
import com.stylefeng.guns.modular.system.model.*;
import com.stylefeng.guns.modular.system.service.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
import com.stylefeng.guns.core.log.LogObjectHolder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.ArrayList;
import java.util.Date;
@@ -299,6 +297,7 @@
        }
        tCompany.setType(2);  //2:分公司
        tCompany.setState(0); //0:正常
        tCompany.setSuperiorId(1);
        tCompany.setInsertTime(new Date());
        tCompanyService.insert(tCompany);
@@ -323,18 +322,20 @@
    }
    //添加经营区域
    public void addSocpe(String subArr,Integer id){
        tCompanyCityService.delete(new EntityWrapper<TCompanyCity>().eq("companyId", id));
        JSONArray jsonArray = JSON.parseArray(subArr);
        int size = jsonArray.size();
        for (int i = 0; i < size; i++){
        List<TCompanyCity> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            JSONObject jsonObject = jsonArray.getJSONObject(i);
            TCompanyCity tCompanyCity = tCompanyCityService.selectOne(new EntityWrapper<TCompanyCity>().eq("id", jsonObject.getInteger("recordId")).eq("companyId", id));
            if (SinataUtil.isEmpty(tCompanyCity)){
                tCompanyCity = new TCompanyCity();
                tCompanyCity.setCityId(jsonObject.getInteger("cityId"));
                tCompanyCity.setCompanyId(id);
                tCompanyCity.setState(1);
                tCompanyCityService.insert(tCompanyCity);
            }
            TCompanyCity tCompanyCity = new TCompanyCity();
            tCompanyCity.setCityId(jsonObject.getInteger("cityId"));
            tCompanyCity.setCompanyId(id);
            tCompanyCity.setState(1);
            list.add(tCompanyCity);
        }
        if(list.size() > 0){
            tCompanyCityService.insertBatch(list);
        }
    }
@@ -350,9 +351,6 @@
            return "error";
        }
        tCompany.setType(3);  //2:分公司
        if (ShiroKit.getUser().getRoleType() == 2){
            tCompany.setSuperiorId(ShiroKit.getUser().getObjectId());
        }
        tCompany.setState(0); //0:正常
        tCompany.setInsertTime(new Date());
        tCompanyService.insert(tCompany);
@@ -408,6 +406,7 @@
            user.setSalt(ShiroKit.getRandomSalt(5));
            user.setPassword(ShiroKit.md5(password, user.getSalt()));
        }
        tCompany.setSuperiorId(1);
        tCompanyService.updateById(tCompany);
        user.setName(tCompany.getName());
        userService.updateById(user);