| | |
| | | package com.stylefeng.guns.modular.system.controller.general; |
| | | |
| | | import cn.hutool.crypto.SecureUtil; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.stylefeng.guns.core.base.controller.BaseController; |
| | | import com.stylefeng.guns.core.base.tips.SuccessTip; |
| | | import com.stylefeng.guns.core.common.constant.state.ManagerStatus; |
| | | import com.stylefeng.guns.core.exception.GunsException; |
| | | import com.stylefeng.guns.core.exception.ServiceExceptionEnum; |
| | | import com.stylefeng.guns.core.shiro.ShiroKit; |
| | |
| | | import org.apache.poi.hssf.usermodel.HSSFWorkbook; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.transaction.annotation.Propagation; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | |
| | | private ITDriverService tDriverService; |
| | | @Autowired |
| | | private ITDriverWorkService tDriverWorkService; |
| | | @Autowired |
| | | private IUserService userService; |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | |
| | | */ |
| | | @RequestMapping(value = "/add") |
| | | @ResponseBody |
| | | @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRES_NEW) |
| | | public Object add(TAgent tAgent) { |
| | | |
| | | String[] split1 = tAgent.getArea().split("/"); |
| | |
| | | int count = tAgentService.selectCount(new EntityWrapper<TAgent>().eq("provinceName", split1[0]).eq("cityName",split1[1])); |
| | | if(count>0){ |
| | | return new SuccessTip(500,"该代理商已存在!"); |
| | | } |
| | | |
| | | int count1 = userService.selectCount(new EntityWrapper<User>().eq("account", tAgent.getAccount())); |
| | | if (count1 > 0){ |
| | | return new SuccessTip(500,"该账号已存在!"); |
| | | } |
| | | |
| | | tAgent.setPrincipal(tAgent.getPrincipal().replace(" ","")); |
| | |
| | | tAgent.setCityName(city.getName()); |
| | | tAgent.setCityCode(city.getCode()); |
| | | tAgentService.insert(tAgent); |
| | | |
| | | //添加User对象 |
| | | User user = new User(); |
| | | user.setAccount(tAgent.getAccount()); |
| | | user.setSalt(ShiroKit.getRandomSalt(5)); |
| | | user.setPassword(ShiroKit.md5(tAgent.getPassword(), user.getSalt())); |
| | | user.setStatus(ManagerStatus.OK.getCode()); |
| | | user.setRoleid("2"); |
| | | user.setDeptid(25); |
| | | user.setCreatetime(new Date()); |
| | | user.setRoleType(3); |
| | | user.setObjectId(tAgent.getId()); |
| | | user.setName(tAgent.getPrincipal()); |
| | | user.setSex(1); |
| | | userService.insert(user); |
| | | |
| | | return SUCCESS_TIP; |
| | | } |
| | | |