运营商同步生成用户账号,停用启用关联启动
This commit is contained in:
@ -2,7 +2,15 @@ package com.ruoyi.operation.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.exception.RRException;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.framework.shiro.service.SysPasswordService;
|
||||
import com.ruoyi.system.domain.Zoning;
|
||||
import com.ruoyi.system.service.ISysAreaHnService;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@ -36,6 +44,15 @@ public class CompanyController extends BaseController
|
||||
@Autowired
|
||||
private ICompanyService companyService;
|
||||
|
||||
@Autowired
|
||||
private ISysUserService userService;
|
||||
|
||||
@Autowired
|
||||
private SysPasswordService passwordService;
|
||||
|
||||
@Autowired
|
||||
private ISysAreaHnService areaHnService;
|
||||
|
||||
@RequiresPermissions("operation:company:view")
|
||||
@GetMapping()
|
||||
public String company()
|
||||
@ -88,8 +105,39 @@ public class CompanyController extends BaseController
|
||||
@ResponseBody
|
||||
public AjaxResult addSave(Company company)
|
||||
{
|
||||
if (StringUtils.isNotEmpty(company.getPhone())
|
||||
&& UserConstants.USER_PHONE_NOT_UNIQUE.equals(companyService.checkPhoneUnique(company)))
|
||||
{
|
||||
return error("新增失败,手机号码已存在");
|
||||
}
|
||||
company.setCreateBy(getLoginName());
|
||||
return toAjax(companyService.insertCompany(company));
|
||||
int flag = companyService.insertCompany(company);
|
||||
if(flag > 0) {
|
||||
// 创建运营商成功,添加运营商账号
|
||||
SysUser user = new SysUser();
|
||||
user.setSalt("");
|
||||
String password = UserConstants.DEFAULT_PASSWORD;
|
||||
user.setLoginName(company.getPhone());
|
||||
user.setUserName(company.getCompanyName());
|
||||
user.setUserType(UserConstants.USER_TYPE_02);
|
||||
user.setPhonenumber(company.getPhone());
|
||||
user.setPassword(passwordService.encryptPassword(user.getLoginName(), password, user.getSalt()));
|
||||
//所属区域转换省市县乡村组字段
|
||||
Zoning zoning = areaHnService.getAreaSuperior(company.getCitys());
|
||||
user.setCityCode(zoning.getCityCode());
|
||||
user.setCityName(zoning.getCityName());
|
||||
user.setDistrictCode(zoning.getDistrictCode());
|
||||
user.setDistrictName(zoning.getDistrictName());
|
||||
user.setTownCode(zoning.getTownCode());
|
||||
user.setTownName(zoning.getTownName());
|
||||
user.setCreateBy(getLoginName());
|
||||
user.setCreateTime(DateUtils.getNowDate());
|
||||
user.setUpdateTime(DateUtils.getNowDate());
|
||||
user.setStatus("0");
|
||||
user.setCreateById(getUserId());
|
||||
userService.insertUser(user);
|
||||
}
|
||||
return toAjax(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -113,6 +161,11 @@ public class CompanyController extends BaseController
|
||||
@ResponseBody
|
||||
public AjaxResult editSave(Company company)
|
||||
{
|
||||
if (StringUtils.isNotEmpty(company.getPhone())
|
||||
&& UserConstants.USER_PHONE_NOT_UNIQUE.equals(companyService.checkPhoneUnique(company)))
|
||||
{
|
||||
return error("修改失败,手机号码已存在");
|
||||
}
|
||||
company.setUpdateBy(getLoginName());
|
||||
return toAjax(companyService.updateCompany(company));
|
||||
}
|
||||
@ -136,6 +189,15 @@ public class CompanyController extends BaseController
|
||||
@ResponseBody
|
||||
public AjaxResult changeStatus(Company company)
|
||||
{
|
||||
int flag = companyService.changeStatus(company);
|
||||
if(flag >0) {
|
||||
// 运营商启用停用,同时启用停用用户信息
|
||||
SysUser user = userService.selectUserByPhoneNumber(company.getPhone());
|
||||
if(user != null) {
|
||||
user.setStatus(company.getStatus());
|
||||
userService.changeStatus(user);
|
||||
}
|
||||
}
|
||||
return toAjax(companyService.changeStatus(company));
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,6 +19,14 @@ public interface CompanyMapper
|
||||
*/
|
||||
public Company selectCompanyById(Long id);
|
||||
|
||||
/**
|
||||
* 根据手机号查询运营商信息
|
||||
*
|
||||
* @param phone 手机号
|
||||
* @return 运营商对象
|
||||
*/
|
||||
Company checkPhoneUnique(String phone);
|
||||
|
||||
/**
|
||||
* 查询运营商列表
|
||||
*
|
||||
|
||||
@ -27,6 +27,17 @@ public interface ICompanyService
|
||||
*/
|
||||
public List<Company> selectCompanyList(Company company);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 校验手机号是否唯一
|
||||
*
|
||||
* @param company 运营商信息
|
||||
* @return 结果("0"表示唯一,"1"表示重复)
|
||||
*/
|
||||
public String checkPhoneUnique(Company company);
|
||||
|
||||
|
||||
/**
|
||||
* 新增运营商
|
||||
*
|
||||
|
||||
@ -1,7 +1,12 @@
|
||||
package com.ruoyi.operation.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.operation.mapper.CompanyMapper;
|
||||
@ -45,6 +50,18 @@ public class CompanyServiceImpl implements ICompanyService
|
||||
return companyMapper.selectCompanyList(company);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String checkPhoneUnique(Company company){
|
||||
Long companyId = StringUtils.isNull(company.getId()) ? -1L : company.getId();
|
||||
Company info = companyMapper.checkPhoneUnique(company.getPhone());
|
||||
if (StringUtils.isNotNull(info) && info.getId().longValue() != companyId.longValue())
|
||||
{
|
||||
return UserConstants.USER_PHONE_NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.USER_PHONE_UNIQUE;
|
||||
}
|
||||
/**
|
||||
* 新增运营商
|
||||
*
|
||||
|
||||
@ -166,7 +166,7 @@ public class SysUserController extends BaseController
|
||||
user.setVillageName(zoning.getVillageName());
|
||||
user.setGroupId(zoning.getGroupId());
|
||||
user.setGroupName(zoning.getGroupName());
|
||||
|
||||
user.setStatus("0");
|
||||
return toAjax(userService.insertUser(user));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user