package com.stylefeng.guns.modular.system.controller.general;
|
|
import com.alibaba.fastjson.JSONObject;
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import com.stylefeng.guns.core.base.controller.BaseController;
|
import com.stylefeng.guns.core.shiro.ShiroKit;
|
import com.stylefeng.guns.modular.system.model.TAppUser;
|
import com.stylefeng.guns.modular.system.model.TSystemConfig;
|
import com.stylefeng.guns.modular.system.model.User;
|
import com.stylefeng.guns.modular.system.service.ITSystemConfigService;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.util.StringUtils;
|
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.RequestParam;
|
import com.stylefeng.guns.modular.system.model.TBranchOffice;
|
import com.stylefeng.guns.modular.system.service.ITBranchOfficeService;
|
|
import java.util.Objects;
|
|
/**
|
* 控制器
|
*
|
* @author fengshuonan
|
* @Date 2023-02-21 11:17:18
|
*/
|
@Controller
|
@RequestMapping("/tBranchOffice")
|
public class TBranchOfficeController extends BaseController {
|
|
private String PREFIX = "/system/tBranchOffice/";
|
|
@Autowired
|
private ITBranchOfficeService tBranchOfficeService;
|
@Autowired
|
private ITSystemConfigService tSystemConfigService;
|
|
/**
|
* 跳转到首页
|
*/
|
@RequestMapping("")
|
public String index() {
|
return PREFIX + "tBranchOffice.html";
|
}
|
|
/**
|
* 跳转到添加
|
*/
|
@RequestMapping("/tBranchOffice_add")
|
public String tBranchOfficeAdd() {
|
return PREFIX + "tBranchOffice_add.html";
|
}
|
|
/**
|
* 跳转到修改
|
*/
|
@RequestMapping("/tBranchOffice_update/{tBranchOfficeId}")
|
public String tBranchOfficeUpdate(@PathVariable Integer tBranchOfficeId, Model model) {
|
TBranchOffice tBranchOffice = tBranchOfficeService.selectById(tBranchOfficeId);
|
model.addAttribute("item",tBranchOffice);
|
LogObjectHolder.me().set(tBranchOffice);
|
return PREFIX + "tBranchOffice_edit.html";
|
}
|
|
/**
|
* 跳转到详情
|
*/
|
@RequestMapping("/tBranchOfficeDetail")
|
public String tBranchOfficeDetail(Integer tBranchOfficeId, Model model) {
|
tBranchOfficeService.tBranchOfficeDetail(tBranchOfficeId,model);
|
TSystemConfig tSystemConfig = tSystemConfigService.selectOne(new EntityWrapper<TSystemConfig>().eq("type", 3));
|
JSONObject jsonObject = JSONObject.parseObject(tSystemConfig.getContent());
|
model.addAttribute("num2",jsonObject.getInteger("num2"));
|
model.addAttribute("num3",jsonObject.getInteger("num3"));
|
return PREFIX + "tBranchOfficeDetail.html";
|
}
|
|
/**
|
* 获取列表
|
*/
|
@RequestMapping(value = "/list")
|
@ResponseBody
|
public Object list(String branchOfficeName,String principal,String principalPhone,Integer operatingBusiness ,Integer status) {
|
EntityWrapper<TBranchOffice> wrapper = new EntityWrapper<>();
|
// 分公司名称
|
if(StringUtils.hasLength(branchOfficeName)){
|
wrapper.like("branchOfficeName",branchOfficeName);
|
}
|
// 负责人
|
if(StringUtils.hasLength(principal)){
|
wrapper.like("principal",principal);
|
}
|
// 负责人电话
|
if(StringUtils.hasLength(principalPhone)){
|
wrapper.like("principalPhone",principalPhone);
|
}
|
// 经营业务
|
if(Objects.nonNull(operatingBusiness)){
|
wrapper.eq("operatingBusiness",operatingBusiness);
|
}
|
// 状态
|
if(Objects.nonNull(status)){
|
wrapper.eq("status",status);
|
}
|
// 判断代理商 分公司
|
Integer roleType = Objects.requireNonNull(ShiroKit.getUser()).getRoleType();
|
Integer objectId = Objects.requireNonNull(ShiroKit.getUser()).getObjectId();
|
if(2 == roleType){
|
// 分公司
|
wrapper.eq("id",objectId);
|
}
|
if(3 == roleType){
|
// 代理商
|
wrapper.eq("agentId",objectId);
|
}
|
return tBranchOfficeService.selectList(wrapper);
|
}
|
|
/**
|
* 启用分公司
|
*/
|
@RequestMapping(value = "/start")
|
@ResponseBody
|
public Object start(Integer id) {
|
TBranchOffice tBranchOffice = tBranchOfficeService.selectById(id);
|
tBranchOffice.setStatus(1);
|
tBranchOfficeService.updateById(tBranchOffice);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 冻结分公司
|
*/
|
@RequestMapping(value = "/stop")
|
@ResponseBody
|
public Object updateStatus(Integer id) {
|
TBranchOffice tBranchOffice = tBranchOfficeService.selectById(id);
|
tBranchOffice.setStatus(2);
|
tBranchOfficeService.updateById(tBranchOffice);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 获取列表
|
*/
|
@RequestMapping(value = "/list-back")
|
@ResponseBody
|
public Object listBack(String condition) {
|
return tBranchOfficeService.selectList(null);
|
}
|
|
/**
|
* 新增
|
*/
|
@RequestMapping(value = "/add")
|
@ResponseBody
|
public Object add(TBranchOffice tBranchOffice) {
|
tBranchOfficeService.insert(tBranchOffice);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 删除
|
*/
|
@RequestMapping(value = "/delete")
|
@ResponseBody
|
public Object delete(@RequestParam Integer tBranchOfficeId) {
|
tBranchOfficeService.deleteById(tBranchOfficeId);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 修改
|
*/
|
@RequestMapping(value = "/update")
|
@ResponseBody
|
public Object update(TBranchOffice tBranchOffice) {
|
tBranchOfficeService.updateById(tBranchOffice);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 详情
|
*/
|
@RequestMapping(value = "/detail/{tBranchOfficeId}")
|
@ResponseBody
|
public Object detail(@PathVariable("tBranchOfficeId") Integer tBranchOfficeId) {
|
return tBranchOfficeService.selectById(tBranchOfficeId);
|
}
|
}
|