Browse Source

查询和详情页信息已完成

dev_ycq
21819 2 years ago
parent
commit
c28a598834
  1. 30
      mailbox-outer-admin/src/main/java/com/biutag/outeradmin/controller/MailController.java
  2. 4
      mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/FormData.java

30
mailbox-outer-admin/src/main/java/com/biutag/outeradmin/controller/MailController.java

@ -2,14 +2,19 @@ package com.biutag.outeradmin.controller;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.biutag.outeradmin.entity.FormData; import com.biutag.outeradmin.entity.FormData;
import com.biutag.outeradmin.entity.Mail; import com.biutag.outeradmin.entity.Mail;
import com.biutag.outeradmin.entity.MailID; import com.biutag.outeradmin.entity.MailID;
import com.biutag.outeradmin.mapper.MailMapper; import com.biutag.outeradmin.mapper.MailMapper;
import com.biutag.outeradmin.service.MailService; import com.biutag.outeradmin.service.MailService;
import com.biutag.util.StringUtils;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.Collection;
import java.util.List; import java.util.List;
@RequiredArgsConstructor @RequiredArgsConstructor
@ -39,22 +44,29 @@ public class MailController {
* @return 指定信件json * @return 指定信件json
*/ */
@RequestMapping("/list-submit") @RequestMapping("/list-submit")
@ResponseBody
public String siftList(@RequestBody String form) { public String siftList(@RequestBody String form) {
//todo 这里根据表单数据查询数据库,记得删掉
System.out.println(form);
FormData formData = JSON.parseObject(form, FormData.class); FormData formData = JSON.parseObject(form, FormData.class);
QueryWrapper<Mail> queryWrapper = new QueryWrapper<>(); QueryWrapper<Mail> queryWrapper = new QueryWrapper<>();
queryWrapper.like(formData.getContactName() != null, "contact_name", formData.getContactName()) queryWrapper.lambda().like(StringUtils.isNotEmpty(formData.getContactName()), Mail::getContactName, formData.getContactName())
.like(formData.getContactPhone() != null, "contact_phone", formData.getContactPhone()) .like(StringUtils.isNotEmpty(formData.getContactPhone()), Mail::getContactPhone, formData.getContactPhone())
.like(formData.getContactIdCard() != null, "contact_id_card", formData.getContactIdCard()) .like(StringUtils.isNotEmpty(formData.getContactIdCard()), Mail::getContactIdCard, formData.getContactIdCard())
.like(formData.getId() != null, "id", formData.getId()) .like(StringUtils.isNotEmpty(formData.getId()), Mail::getId, formData.getId())
.like(formData.getContent() != null, "contact_email", formData.getContent()) .like(StringUtils.isNotEmpty(formData.getContent()), Mail::getContent, formData.getContent());
// .like(formData.getEvaluate() != null, "evaluate", formData.getEvaluate()) if (CollectionUtils.isNotEmpty(formData.getDate()) && formData.getDate().size() == 2) {
.inSql("create_time", "select * from mail where between " queryWrapper.lambda().between(Mail::getCreateTime, formData.getDate().get(0), formData.getDate().get(1));
+ formData.getDate()[0] + " and " + formData.getDate()[1]); }
return JSON.toJSONString(mailMapper.selectList(queryWrapper)); return JSON.toJSONString(mailMapper.selectList(queryWrapper));
} }
/**
* 查询指定信件详情
* @param id 信件ID
* @return 指定信件详情json
*/
@RequestMapping("/detail") @RequestMapping("/detail")
public String detail(@RequestBody String id) { public String detail(@RequestBody String id) {
MailID mailID = JSON.parseObject(id, MailID.class); MailID mailID = JSON.parseObject(id, MailID.class);

4
mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/FormData.java

@ -2,9 +2,11 @@ package com.biutag.outeradmin.entity;
import lombok.Data; import lombok.Data;
import java.util.List;
@Data @Data
public class FormData { public class FormData {
private String[] date; private List<String> date;
private String contactName; private String contactName;
private String contactPhone; private String contactPhone;
private String contactIdCard; private String contactIdCard;

Loading…
Cancel
Save