评估申请的代码架构

This commit is contained in:
2026-04-29 19:01:02 +08:00
parent d547b61843
commit 521cc30f94
10 changed files with 679 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
package com.rj.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.rj.entity.LbAssessmentApplication;
import java.util.Map;
public interface ILbAssessmentApplicationService extends IService<LbAssessmentApplication> {
Map<String, Object> add(LbAssessmentApplication entity);
Map<String, Object> update(LbAssessmentApplication entity);
Map<String, Object> deleteById(String id);
Map<String, Object> pageQuery(Integer current,
Integer size,
Long tenantId,
String applicantName,
String applicantPhone,
String colleagueName,
String teamLeaderName);
}

View File

@@ -0,0 +1,25 @@
package com.rj.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.rj.entity.LbPurchaseApply;
import java.time.LocalDate;
import java.util.Map;
public interface ILbPurchaseApplyService extends IService<LbPurchaseApply> {
Map<String, Object> add(LbPurchaseApply entity);
Map<String, Object> update(LbPurchaseApply entity);
Map<String, Object> deleteById(Long id);
Map<String, Object> pageQuery(Integer current,
Integer size,
String tenantId,
String applyUser,
String applyPhone,
String colleagueName,
String teamLeader,
LocalDate applyDate);
}

View File

@@ -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.LbAssessmentApplication;
import com.rj.mapper.LbAssessmentApplicationMapper;
import com.rj.service.ILbAssessmentApplicationService;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@Service
public class LbAssessmentApplicationServiceImpl
extends ServiceImpl<LbAssessmentApplicationMapper, LbAssessmentApplication>
implements ILbAssessmentApplicationService {
@Override
public Map<String, Object> add(LbAssessmentApplication 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(LbAssessmentApplication 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<LbAssessmentApplication> queryWrapper = new LambdaQueryWrapper<>();
if (tenantId != null) {
queryWrapper.eq(LbAssessmentApplication::getTenantId, tenantId);
}
if (applicantName != null && !applicantName.trim().isEmpty()) {
queryWrapper.like(LbAssessmentApplication::getApplicantName, applicantName.trim());
}
if (applicantPhone != null && !applicantPhone.trim().isEmpty()) {
queryWrapper.like(LbAssessmentApplication::getApplicantPhone, applicantPhone.trim());
}
if (colleagueName != null && !colleagueName.trim().isEmpty()) {
queryWrapper.like(LbAssessmentApplication::getColleagueName, colleagueName.trim());
}
if (teamLeaderName != null && !teamLeaderName.trim().isEmpty()) {
queryWrapper.like(LbAssessmentApplication::getTeamLeaderName, teamLeaderName.trim());
}
queryWrapper.orderByDesc(LbAssessmentApplication::getUpdatedAt)
.orderByDesc(LbAssessmentApplication::getCreatedAt);
Page<LbAssessmentApplication> 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;
}
}
}

View File

@@ -0,0 +1,160 @@
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.LbPurchaseApply;
import com.rj.mapper.LbPurchaseApplyMapper;
import com.rj.service.ILbPurchaseApplyService;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
@Service
public class LbPurchaseApplyServiceImpl
extends ServiceImpl<LbPurchaseApplyMapper, LbPurchaseApply>
implements ILbPurchaseApplyService {
@Override
public Map<String, Object> add(LbPurchaseApply entity) {
Map<String, Object> result = new HashMap<>();
try {
if (entity.getTenantId() == null || entity.getTenantId().trim().isEmpty()) {
result.put("success", false);
result.put("message", "tenantId不能为空");
return result;
}
if (entity.getApplyUser() == null || entity.getApplyUser().trim().isEmpty()) {
result.put("success", false);
result.put("message", "applyUser不能为空");
return result;
}
if (entity.getApplyPhone() == null || entity.getApplyPhone().trim().isEmpty()) {
result.put("success", false);
result.put("message", "applyPhone不能为空");
return result;
}
if (entity.getApplyDate() == null) {
result.put("success", false);
result.put("message", "applyDate不能为空");
return result;
}
LocalDateTime now = LocalDateTime.now();
if (entity.getCreateTime() == null) {
entity.setCreateTime(now);
}
entity.setUpdateTime(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(LbPurchaseApply entity) {
Map<String, Object> result = new HashMap<>();
try {
if (entity.getId() == null) {
result.put("success", false);
result.put("message", "id不能为空");
return result;
}
entity.setUpdateTime(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(Long 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,
String tenantId,
String applyUser,
String applyPhone,
String colleagueName,
String teamLeader,
LocalDate applyDate) {
Map<String, Object> result = new HashMap<>();
try {
if (current == null || current < 1) {
current = 1;
}
if (size == null || size < 1) {
size = 10;
}
LambdaQueryWrapper<LbPurchaseApply> queryWrapper = new LambdaQueryWrapper<>();
if (tenantId != null && !tenantId.trim().isEmpty()) {
queryWrapper.eq(LbPurchaseApply::getTenantId, tenantId.trim());
}
if (applyUser != null && !applyUser.trim().isEmpty()) {
queryWrapper.like(LbPurchaseApply::getApplyUser, applyUser.trim());
}
if (applyPhone != null && !applyPhone.trim().isEmpty()) {
queryWrapper.like(LbPurchaseApply::getApplyPhone, applyPhone.trim());
}
if (colleagueName != null && !colleagueName.trim().isEmpty()) {
queryWrapper.like(LbPurchaseApply::getColleagueName, colleagueName.trim());
}
if (teamLeader != null && !teamLeader.trim().isEmpty()) {
queryWrapper.like(LbPurchaseApply::getTeamLeader, teamLeader.trim());
}
if (applyDate != null) {
queryWrapper.eq(LbPurchaseApply::getApplyDate, applyDate);
}
queryWrapper.orderByDesc(LbPurchaseApply::getUpdateTime)
.orderByDesc(LbPurchaseApply::getCreateTime);
Page<LbPurchaseApply> 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;
}
}
}