Quellcode durchsuchen

增加用户新增和修改编号重复验证

konghl vor 4 Jahren
Ursprung
Commit
fb9cfffd24

+ 45 - 2
security-protection-service/src/main/java/com/ai/bss/security/protection/service/impl/EmployeeManagementServiceImpl.java

112
		resultMap.put("field3", response.getData().getField3()); // 审核意见
112
		resultMap.put("field3", response.getData().getField3()); // 审核意见
113
		resultMap.put("field4", response.getData().getField4()); // 公司
113
		resultMap.put("field4", response.getData().getField4()); // 公司
114
114
115
		resultMap.put("pictureUrl",uploadFileService.getFileUrl(response.getData().getField1(), minioConfig.getBucketHeaderImage()));
116
		
115
		resultMap.put("pictureUrl",
116
				uploadFileService.getFileUrl(response.getData().getField1(), minioConfig.getBucketHeaderImage()));
117
117
		String employeePosition = response.getData().getMainJobPosition();
118
		String employeePosition = response.getData().getMainJobPosition();
118
		resultMap.put("employeePosition", employeePosition);
119
		resultMap.put("employeePosition", employeePosition);
119
120
128
		return CommonResponse.ok(resultMap);
129
		return CommonResponse.ok(resultMap);
129
	}
130
	}
130
131
132
	/**
133
	 * 是否存在用户编码
134
	 * @param code
135
	 * @param id
136
	 * @return 
137
	 * @return true:存在,false:不存在
138
	 */
139
	private boolean isExistEmployeeCode(String code, String id) {
140
		if (StringUtils.isBlank(code)) {
141
			return false;
142
		}
143
144
		UserDto userDto = new UserDto();
145
		userDto.setCode(code);
146
		CommonRequest<UserDto> request = new CommonRequest<UserDto>(userDto);
147
		CommonResponse<List<Map<String, Object>>> response = userDtoQuery.queryWorkEmployeeByUserCode(request);
148
149
		boolean result = false;
150
		if (!CollectionUtils.isEmpty(response.getData())) {
151
			if (StringUtils.isNotBlank(id)) {
152
				for (Map<String, Object> map : response.getData()) {
153
					if (code.equals(String.valueOf(map.get("code"))) && !id.equals(String.valueOf(map.get("id")))) {
154
						result = true;
155
						break;
156
					}
157
				}
158
			} else {
159
				result = true;
160
			}
161
		}
162
163
		return result;
164
	}
165
131
	@Override
166
	@Override
132
	public CommonResponse<Void> createEmployee(EmployeeDto employeeDto) throws Exception {
167
	public CommonResponse<Void> createEmployee(EmployeeDto employeeDto) throws Exception {
168
		if (isExistEmployeeCode(employeeDto.getCode(), null)) {
169
			return CommonResponse.fail("501", "编号已存在");
170
		}
171
133
		employeeDto.setField2(EbcConstant.AUDIT_STATUS_INI);
172
		employeeDto.setField2(EbcConstant.AUDIT_STATUS_INI);
134
		CommonRequest<EmployeeDto> request = new CommonRequest<EmployeeDto>(employeeDto);
173
		CommonRequest<EmployeeDto> request = new CommonRequest<EmployeeDto>(employeeDto);
135
		return employeeService.createWorkEmployee(request);
174
		return employeeService.createWorkEmployee(request);
137
176
138
	@Override
177
	@Override
139
	public CommonResponse<Void> modifyEmployee(EmployeeDto employeeDto) {
178
	public CommonResponse<Void> modifyEmployee(EmployeeDto employeeDto) {
179
		if (isExistEmployeeCode(employeeDto.getCode(), String.valueOf(employeeDto.getId()))) {
180
			return CommonResponse.fail("501", "编号已存在");
181
		}
182
140
		employeeDto.setField2(EbcConstant.AUDIT_STATUS_INI);
183
		employeeDto.setField2(EbcConstant.AUDIT_STATUS_INI);
141
		CommonRequest<EmployeeDto> request = CommonRequest.<EmployeeDto>builder().data(employeeDto).build();
184
		CommonRequest<EmployeeDto> request = CommonRequest.<EmployeeDto>builder().data(employeeDto).build();
142
		return employeeService.modifyEmployee(request);
185
		return employeeService.modifyEmployee(request);