| | |
| | | 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.RequestParam; |
| | | import com.stylefeng.guns.modular.system.model.TBranchOffice; |
| | | import com.stylefeng.guns.modular.system.service.ITBranchOfficeService; |
| | | |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 控制器 |
| | |
| | | |
| | | @Autowired |
| | | private ITBranchOfficeService tBranchOfficeService; |
| | | @Autowired |
| | | private ITSystemConfigService tSystemConfigService; |
| | | |
| | | /** |
| | | * 跳转到首页 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 跳转到详情 |
| | | */ |
| | | @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 condition) { |
| | | 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); |
| | | } |
| | | |