修改名称
This commit is contained in:
@@ -0,0 +1,154 @@
|
||||
package com.rj.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.rj.entity.LbAssessmentApply;
|
||||
import com.rj.mapper.LbAssessmentApplyMapper;
|
||||
import com.rj.service.ILbAssessmentApplyService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
@Service
|
||||
public class LbAssessmentApplyServiceImpl
|
||||
extends ServiceImpl<LbAssessmentApplyMapper, LbAssessmentApply>
|
||||
implements ILbAssessmentApplyService {
|
||||
|
||||
@Override
|
||||
public Map<String, Object> add(LbAssessmentApply entity) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
try {
|
||||
if (entity.getTenantId() == null) {
|
||||
result.put("success", false);
|
||||
result.put("message", "tenantId不能为空");
|
||||
return result;
|
||||
}
|
||||
if (entity.getApplicantName() == null || entity.getApplicantName().trim().isEmpty()) {
|
||||
result.put("success", false);
|
||||
result.put("message", "applicantName不能为空");
|
||||
return result;
|
||||
}
|
||||
if (entity.getApplicantPhone() == null || entity.getApplicantPhone().trim().isEmpty()) {
|
||||
result.put("success", false);
|
||||
result.put("message", "applicantPhone不能为空");
|
||||
return result;
|
||||
}
|
||||
|
||||
if (entity.getId() == null || entity.getId().trim().isEmpty()) {
|
||||
entity.setId(UUID.randomUUID().toString());
|
||||
}
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
if (entity.getCreatedAt() == null) {
|
||||
entity.setCreatedAt(now);
|
||||
}
|
||||
entity.setUpdatedAt(now);
|
||||
|
||||
boolean ok = this.save(entity);
|
||||
result.put("success", ok);
|
||||
result.put("message", ok ? "新增成功" : "新增失败");
|
||||
if (ok) {
|
||||
result.put("data", entity);
|
||||
}
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
result.put("success", false);
|
||||
result.put("message", "新增异常:" + e.getMessage());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> update(LbAssessmentApply entity) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
try {
|
||||
if (entity.getId() == null || entity.getId().trim().isEmpty()) {
|
||||
result.put("success", false);
|
||||
result.put("message", "id不能为空");
|
||||
return result;
|
||||
}
|
||||
entity.setUpdatedAt(LocalDateTime.now());
|
||||
boolean ok = this.updateById(entity);
|
||||
result.put("success", ok);
|
||||
result.put("message", ok ? "编辑成功" : "编辑失败");
|
||||
if (ok) {
|
||||
result.put("data", this.getById(entity.getId()));
|
||||
}
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
result.put("success", false);
|
||||
result.put("message", "编辑异常:" + e.getMessage());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> deleteById(String id) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
try {
|
||||
boolean ok = this.removeById(id);
|
||||
result.put("success", ok);
|
||||
result.put("message", ok ? "删除成功" : "删除失败");
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
result.put("success", false);
|
||||
result.put("message", "删除异常:" + e.getMessage());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> pageQuery(Integer current,
|
||||
Integer size,
|
||||
Long tenantId,
|
||||
String applicantName,
|
||||
String applicantPhone,
|
||||
String colleagueName,
|
||||
String teamLeaderName) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
try {
|
||||
if (current == null || current < 1) {
|
||||
current = 1;
|
||||
}
|
||||
if (size == null || size < 1) {
|
||||
size = 10;
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<LbAssessmentApply> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (tenantId != null) {
|
||||
queryWrapper.eq(LbAssessmentApply::getTenantId, tenantId);
|
||||
}
|
||||
if (applicantName != null && !applicantName.trim().isEmpty()) {
|
||||
queryWrapper.like(LbAssessmentApply::getApplicantName, applicantName.trim());
|
||||
}
|
||||
if (applicantPhone != null && !applicantPhone.trim().isEmpty()) {
|
||||
queryWrapper.like(LbAssessmentApply::getApplicantPhone, applicantPhone.trim());
|
||||
}
|
||||
if (colleagueName != null && !colleagueName.trim().isEmpty()) {
|
||||
queryWrapper.like(LbAssessmentApply::getColleagueName, colleagueName.trim());
|
||||
}
|
||||
if (teamLeaderName != null && !teamLeaderName.trim().isEmpty()) {
|
||||
queryWrapper.like(LbAssessmentApply::getTeamLeaderName, teamLeaderName.trim());
|
||||
}
|
||||
queryWrapper.orderByDesc(LbAssessmentApply::getUpdatedAt)
|
||||
.orderByDesc(LbAssessmentApply::getCreatedAt);
|
||||
|
||||
Page<LbAssessmentApply> page = this.page(new Page<>(current, size), queryWrapper);
|
||||
result.put("success", true);
|
||||
result.put("message", "查询成功");
|
||||
result.put("data", page.getRecords());
|
||||
result.put("total", page.getTotal());
|
||||
result.put("current", page.getCurrent());
|
||||
result.put("size", page.getSize());
|
||||
result.put("pages", page.getPages());
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
result.put("success", false);
|
||||
result.put("message", "查询异常:" + e.getMessage());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user