|
|
|
@ -33,6 +33,7 @@ import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
|
|
|
|
|
import javax.imageio.ImageIO;
|
|
|
|
|
import javax.servlet.ServletOutputStream;
|
|
|
|
@ -262,31 +263,25 @@ public class EmployeeService {
|
|
|
|
|
* @throws WxErrorException
|
|
|
|
|
*/
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public Boolean updateUser(EmployeeDO employee) throws Exception {
|
|
|
|
|
public Boolean updateUser(Long id, String cpUserId,String mobile,String cpUserName,String alias) throws Exception {
|
|
|
|
|
PrivilageCpUserDO privilageCpUserDO = new PrivilageCpUserDO();
|
|
|
|
|
BeanUtils.copyProperties(employee, privilageCpUserDO);
|
|
|
|
|
privilageCpUserDO.setCpUserId(employee.getUserId());
|
|
|
|
|
|
|
|
|
|
privilageCpUserDO.setId(id);
|
|
|
|
|
privilageCpUserDO.setMobile(mobile);
|
|
|
|
|
privilageCpUserDO.setName(cpUserName);
|
|
|
|
|
privilageCpUserDO.setAlias(alias);
|
|
|
|
|
|
|
|
|
|
int update = privilageCpUserDOMapper.updateById(privilageCpUserDO);
|
|
|
|
|
if (update == 0) {
|
|
|
|
|
throw new Exception("修改成员失败");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//维护部门关系——删除原有部门关系
|
|
|
|
|
QueryWrapper<PrivilageCpUserDepartmentDO> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
queryWrapper.eq(DATABASE_CP_USER_ID_KEY, privilageCpUserDO.getId());
|
|
|
|
|
privilageCpUserDepartmentDOMapper.delete(queryWrapper);
|
|
|
|
|
|
|
|
|
|
Long[] departIds = employee.getDepartIds();
|
|
|
|
|
Integer[] orders = employee.getOrders();
|
|
|
|
|
Integer[] isLeaderInDept = employee.getIsLeaderInDept();
|
|
|
|
|
for (int i = 0; i < departIds.length; i++) {
|
|
|
|
|
PrivilageCpUserDepartmentDO relation = new PrivilageCpUserDepartmentDO(privilageCpUserDO.getId(), departIds[i], orders[i], isLeaderInDept[i]);
|
|
|
|
|
privilageCpUserDepartmentDOMapper.insert(relation);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//成功则添加用户到企业微信
|
|
|
|
|
EmployeeDO employee = new EmployeeDO();
|
|
|
|
|
employee.setName(cpUserName);
|
|
|
|
|
employee.setId(id);
|
|
|
|
|
employee.setAlias(alias);
|
|
|
|
|
employee.setUserId(cpUserId);
|
|
|
|
|
employee.setMobile(mobile);
|
|
|
|
|
qwMailListManageService.updateUser(employee);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|