评估申请的代码架构
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
package com.rj.controller;
|
||||
|
||||
import com.rj.entity.LbAssessmentApplication;
|
||||
import com.rj.service.ILbAssessmentApplicationService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/lbAssessmentApplication")
|
||||
@Tag(name = "申请评估", description = "lb_assessment_application增删改查与分页")
|
||||
public class LbAssessmentApplicationController {
|
||||
|
||||
@Autowired
|
||||
private ILbAssessmentApplicationService lbAssessmentApplicationService;
|
||||
|
||||
@PostMapping("/add")
|
||||
@Operation(summary = "新增")
|
||||
public ResponseEntity<Map<String, Object>> add(
|
||||
@Parameter(description = "实体", required = true) @RequestBody LbAssessmentApplication entity) {
|
||||
Map<String, Object> result = lbAssessmentApplicationService.add(entity);
|
||||
Boolean success = (Boolean) result.get("success");
|
||||
if (success != null && success) {
|
||||
return ResponseEntity.ok(result);
|
||||
}
|
||||
return ResponseEntity.badRequest().body(result);
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "编辑")
|
||||
public ResponseEntity<Map<String, Object>> update(
|
||||
@Parameter(description = "实体", required = true) @RequestBody LbAssessmentApplication entity) {
|
||||
Map<String, Object> result = lbAssessmentApplicationService.update(entity);
|
||||
Boolean success = (Boolean) result.get("success");
|
||||
if (success != null && success) {
|
||||
return ResponseEntity.ok(result);
|
||||
}
|
||||
return ResponseEntity.badRequest().body(result);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
@Operation(summary = "删除")
|
||||
public ResponseEntity<Map<String, Object>> delete(
|
||||
@Parameter(description = "主键ID(UUID)", required = true) @PathVariable String id) {
|
||||
Map<String, Object> result = lbAssessmentApplicationService.deleteById(id);
|
||||
Boolean success = (Boolean) result.get("success");
|
||||
if (success != null && success) {
|
||||
return ResponseEntity.ok(result);
|
||||
}
|
||||
return ResponseEntity.badRequest().body(result);
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "分页查询")
|
||||
public ResponseEntity<Map<String, Object>> list(
|
||||
@RequestParam(defaultValue = "1") Integer current,
|
||||
@RequestParam(defaultValue = "10") Integer size,
|
||||
@RequestParam(required = false) Long tenantId,
|
||||
@RequestParam(required = false) String applicantName,
|
||||
@RequestParam(required = false) String applicantPhone,
|
||||
@RequestParam(required = false) String colleagueName,
|
||||
@RequestParam(required = false) String teamLeaderName) {
|
||||
Map<String, Object> result = lbAssessmentApplicationService.pageQuery(
|
||||
current, size, tenantId, applicantName, applicantPhone, colleagueName, teamLeaderName
|
||||
);
|
||||
Boolean success = (Boolean) result.get("success");
|
||||
if (success != null && success) {
|
||||
return ResponseEntity.ok(result);
|
||||
}
|
||||
return ResponseEntity.internalServerError().body(result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.rj.controller;
|
||||
|
||||
import com.rj.entity.LbPurchaseApply;
|
||||
import com.rj.service.ILbPurchaseApplyService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/lbPurchaseApply")
|
||||
@Tag(name = "进货申请", description = "lb_purchase_apply增删改查与分页")
|
||||
public class LbPurchaseApplyController {
|
||||
|
||||
@Autowired
|
||||
private ILbPurchaseApplyService lbPurchaseApplyService;
|
||||
|
||||
@PostMapping("/add")
|
||||
@Operation(summary = "新增")
|
||||
public ResponseEntity<Map<String, Object>> add(
|
||||
@Parameter(description = "实体", required = true) @RequestBody LbPurchaseApply entity) {
|
||||
Map<String, Object> result = lbPurchaseApplyService.add(entity);
|
||||
Boolean success = (Boolean) result.get("success");
|
||||
if (success != null && success) {
|
||||
return ResponseEntity.ok(result);
|
||||
}
|
||||
return ResponseEntity.badRequest().body(result);
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "编辑")
|
||||
public ResponseEntity<Map<String, Object>> update(
|
||||
@Parameter(description = "实体", required = true) @RequestBody LbPurchaseApply entity) {
|
||||
Map<String, Object> result = lbPurchaseApplyService.update(entity);
|
||||
Boolean success = (Boolean) result.get("success");
|
||||
if (success != null && success) {
|
||||
return ResponseEntity.ok(result);
|
||||
}
|
||||
return ResponseEntity.badRequest().body(result);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
@Operation(summary = "删除")
|
||||
public ResponseEntity<Map<String, Object>> delete(
|
||||
@Parameter(description = "主键ID", required = true) @PathVariable Long id) {
|
||||
Map<String, Object> result = lbPurchaseApplyService.deleteById(id);
|
||||
Boolean success = (Boolean) result.get("success");
|
||||
if (success != null && success) {
|
||||
return ResponseEntity.ok(result);
|
||||
}
|
||||
return ResponseEntity.badRequest().body(result);
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "分页查询")
|
||||
public ResponseEntity<Map<String, Object>> list(
|
||||
@RequestParam(defaultValue = "1") Integer current,
|
||||
@RequestParam(defaultValue = "10") Integer size,
|
||||
@RequestParam(required = false) String tenantId,
|
||||
@RequestParam(required = false) String applyUser,
|
||||
@RequestParam(required = false) String applyPhone,
|
||||
@RequestParam(required = false) String colleagueName,
|
||||
@RequestParam(required = false) String teamLeader,
|
||||
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate applyDate) {
|
||||
Map<String, Object> result = lbPurchaseApplyService.pageQuery(
|
||||
current, size, tenantId, applyUser, applyPhone, colleagueName, teamLeader, applyDate
|
||||
);
|
||||
Boolean success = (Boolean) result.get("success");
|
||||
if (success != null && success) {
|
||||
return ResponseEntity.ok(result);
|
||||
}
|
||||
return ResponseEntity.internalServerError().body(result);
|
||||
}
|
||||
}
|
||||
68
src/main/java/com/rj/entity/LbAssessmentApplication.java
Normal file
68
src/main/java/com/rj/entity/LbAssessmentApplication.java
Normal file
@@ -0,0 +1,68 @@
|
||||
package com.rj.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("lb_assessment_application")
|
||||
@Schema(description = "申请评估表")
|
||||
public class LbAssessmentApplication implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId("id")
|
||||
@Schema(description = "主键ID(UUID)")
|
||||
private String id;
|
||||
|
||||
@TableField("tenant_id")
|
||||
@Schema(description = "租户ID")
|
||||
private Long tenantId;
|
||||
|
||||
@TableField("applicant_name")
|
||||
@Schema(description = "申请人")
|
||||
private String applicantName;
|
||||
|
||||
@TableField("applicant_phone")
|
||||
@Schema(description = "申请人电话")
|
||||
private String applicantPhone;
|
||||
|
||||
@TableField("applicant_age")
|
||||
@Schema(description = "年龄")
|
||||
private Integer applicantAge;
|
||||
|
||||
@TableField("work_experience")
|
||||
@Schema(description = "从业经历")
|
||||
private String workExperience;
|
||||
|
||||
@TableField("colleague_name")
|
||||
@Schema(description = "同事姓名")
|
||||
private String colleagueName;
|
||||
|
||||
@TableField("colleague_phone")
|
||||
@Schema(description = "同事电话")
|
||||
private String colleaguePhone;
|
||||
|
||||
@TableField("team_leader_name")
|
||||
@Schema(description = "团队长姓名")
|
||||
private String teamLeaderName;
|
||||
|
||||
@TableField("application_datetime")
|
||||
@Schema(description = "申请日期时间")
|
||||
private LocalDateTime applicationDatetime;
|
||||
|
||||
@TableField("created_at")
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@TableField("updated_at")
|
||||
@Schema(description = "修改时间")
|
||||
private LocalDateTime updatedAt;
|
||||
}
|
||||
74
src/main/java/com/rj/entity/LbPurchaseApply.java
Normal file
74
src/main/java/com/rj/entity/LbPurchaseApply.java
Normal file
@@ -0,0 +1,74 @@
|
||||
package com.rj.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("lb_purchase_apply")
|
||||
@Schema(description = "进货申请信息表")
|
||||
public class LbPurchaseApply implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
@Schema(description = "主键ID")
|
||||
private Long id;
|
||||
|
||||
@TableField("tenant_id")
|
||||
@Schema(description = "租户id")
|
||||
private String tenantId;
|
||||
|
||||
@TableField("apply_user")
|
||||
@Schema(description = "申请人")
|
||||
private String applyUser;
|
||||
|
||||
@TableField("apply_phone")
|
||||
@Schema(description = "申请人电话")
|
||||
private String applyPhone;
|
||||
|
||||
@TableField("try_date")
|
||||
@Schema(description = "试用日期")
|
||||
private String tryDate;
|
||||
|
||||
@TableField("age")
|
||||
@Schema(description = "年龄")
|
||||
private Integer age;
|
||||
|
||||
@TableField("work_experience")
|
||||
@Schema(description = "从业经历")
|
||||
private String workExperience;
|
||||
|
||||
@TableField("colleague_name")
|
||||
@Schema(description = "同事姓名")
|
||||
private String colleagueName;
|
||||
|
||||
@TableField("colleague_phone")
|
||||
@Schema(description = "同事电话")
|
||||
private String colleaguePhone;
|
||||
|
||||
@TableField("team_leader")
|
||||
@Schema(description = "团队长")
|
||||
private String teamLeader;
|
||||
|
||||
@TableField("apply_date")
|
||||
@Schema(description = "申请日期")
|
||||
private LocalDate applyDate;
|
||||
|
||||
@TableField("create_time")
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@TableField("update_time")
|
||||
@Schema(description = "更新时间")
|
||||
private LocalDateTime updateTime;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.rj.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.rj.entity.LbAssessmentApplication;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface LbAssessmentApplicationMapper extends BaseMapper<LbAssessmentApplication> {
|
||||
}
|
||||
9
src/main/java/com/rj/mapper/LbPurchaseApplyMapper.java
Normal file
9
src/main/java/com/rj/mapper/LbPurchaseApplyMapper.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package com.rj.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.rj.entity.LbPurchaseApply;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface LbPurchaseApplyMapper extends BaseMapper<LbPurchaseApply> {
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
25
src/main/java/com/rj/service/ILbPurchaseApplyService.java
Normal file
25
src/main/java/com/rj/service/ILbPurchaseApplyService.java
Normal 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);
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user