sys_msg_todo相关

dev2.0
wj 1 year ago
parent e88a9046d3
commit 4b0099fa2d

@ -0,0 +1,34 @@
package com.glxp.api.config;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.glxp.api.config.serializer.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import java.time.LocalDate;
import java.time.LocalDateTime;
@Configuration
public class JacksonConfig {
@Bean
@Primary
// @ConditionalOnMissingBean(ObjectMapper.class)
public ObjectMapper jacksonObjectMapper(Jackson2ObjectMapperBuilder builder) {
ObjectMapper objectMapper = builder.createXmlMapper(false).build();
SimpleModule simpleModule = new SimpleModule();
simpleModule.addSerializer(Long.class, new LongJsonSerializer());
simpleModule.addDeserializer(Long.class, new LongJsonDeserializer());
simpleModule.addSerializer(LocalDate.class, new LocalDateJsonSerializer());
simpleModule.addDeserializer(LocalDate.class, new LocalDateJsonDeserializer());
simpleModule.addSerializer(LocalDateTime.class, new LocalDateTimeJsonSerializer());
simpleModule.addDeserializer(LocalDateTime.class, new LocalDateTimeJsonDeserializer());
objectMapper.registerModule(simpleModule);
return objectMapper;
}
}

@ -0,0 +1,17 @@
package com.glxp.api.config.serializer;
import cn.hutool.json.JSONNull;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import org.springframework.boot.jackson.JsonComponent;
import java.io.IOException;
@JsonComponent
public class JsonNullSerializer extends JsonSerializer<JSONNull> {
@Override
public void serialize(JSONNull jsonNull, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
jsonGenerator.writeNull();
}
}

@ -0,0 +1,32 @@
package com.glxp.api.config.serializer;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.StrUtil;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import lombok.extern.slf4j.Slf4j;
import java.io.IOException;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
/**
* Long
*/
@Slf4j
public class LocalDateJsonDeserializer extends JsonDeserializer<LocalDate> {
@Override
public LocalDate deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
String value = p.getText();
try {
return StrUtil.isEmpty(value) ? null : LocalDateTimeUtil.parseDate(value, DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN));
} catch (Exception e) {
log.error("日期格式解析错误", e);
return null;
}
}
}

@ -0,0 +1,23 @@
package com.glxp.api.config.serializer;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.LocalDateTimeUtil;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import java.io.IOException;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
/**
* Longjs 14
*/
public class LocalDateJsonSerializer extends JsonSerializer<LocalDate> {
@Override
public void serialize(LocalDate value, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
String text = (value == null ? null : LocalDateTimeUtil.format(value, DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN)));
jsonGenerator.writeString(text);
}
}

@ -0,0 +1,32 @@
package com.glxp.api.config.serializer;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.StrUtil;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import lombok.extern.slf4j.Slf4j;
import java.io.IOException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
/**
* Long
*/
@Slf4j
public class LocalDateTimeJsonDeserializer extends JsonDeserializer<LocalDateTime> {
@Override
public LocalDateTime deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
String value = p.getText();
try {
return StrUtil.isEmpty(value) ? null : LocalDateTimeUtil.parse(value, DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN));
} catch (Exception e) {
log.error("日期格式解析错误", e);
return null;
}
}
}

@ -0,0 +1,23 @@
package com.glxp.api.config.serializer;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.LocalDateTimeUtil;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import java.io.IOException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
/**
* Longjs 14
*/
public class LocalDateTimeJsonSerializer extends JsonSerializer<LocalDateTime> {
@Override
public void serialize(LocalDateTime value, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
String text = (value == null ? null : LocalDateTimeUtil.format(value, DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN)));
jsonGenerator.writeString(text);
}
}

@ -0,0 +1,23 @@
package com.glxp.api.config.serializer;
import cn.hutool.core.util.StrUtil;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import lombok.extern.slf4j.Slf4j;
import java.io.IOException;
/**
* Long
*/
@Slf4j
public class LongJsonDeserializer extends JsonDeserializer<Long> {
@Override
public Long deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
String value = p.getText();
return StrUtil.isEmpty(value) ? null : Long.parseLong(value);
}
}

@ -0,0 +1,25 @@
package com.glxp.api.config.serializer;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import java.io.IOException;
/**
* Longjs 14
*/
public class LongJsonSerializer extends JsonSerializer<Long> {
@Override
public void serialize(Long value, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
String text = (value == null ? null : String.valueOf(value));
if (text != null) {
if (text.length() > 14) {
jsonGenerator.writeString(text);
} else {
jsonGenerator.writeNumber(text);
}
}
}
}

@ -3,10 +3,10 @@ package com.glxp.api.controller.system;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageInfo;
import com.glxp.api.common.res.BaseResponse; import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils; import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.entity.system.SysMsgTodoEntity; import com.glxp.api.entity.system.SysMsgTodoEntity;
import com.glxp.api.entity.system.SysRemindMsgEntity;
import com.glxp.api.req.system.SysMsgTodoQuery; import com.glxp.api.req.system.SysMsgTodoQuery;
import com.glxp.api.res.PageSimpleResponse; import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.service.system.SysMsgTodoService; import com.glxp.api.service.system.SysMsgTodoService;
@ -16,6 +16,8 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController @RestController
@RequiredArgsConstructor @RequiredArgsConstructor
public class SysMsgTodoController { public class SysMsgTodoController {
@ -24,14 +26,11 @@ public class SysMsgTodoController {
@PostMapping("/spms/sysMsgTodo/page") @PostMapping("/spms/sysMsgTodo/page")
public BaseResponse page(@RequestBody SysMsgTodoQuery query) { public BaseResponse page(@RequestBody SysMsgTodoQuery query) {
Page<SysMsgTodoEntity> page = new Page<>(query.getPage(), query.getLimit()); List<SysMsgTodoVo> msgTodoVos = sysMsgTodoService.pageOfVo(query);
page = sysMsgTodoService.page(page, PageInfo<SysMsgTodoVo> page = new PageInfo<>(msgTodoVos);
Wrappers.lambdaQuery(SysMsgTodoEntity.class)
.orderByDesc(SysMsgTodoEntity::getCreateTime)
);
PageSimpleResponse<SysMsgTodoVo> simpleResponse = new PageSimpleResponse<>(); PageSimpleResponse<SysMsgTodoVo> simpleResponse = new PageSimpleResponse<>();
simpleResponse.setTotal(page.getTotal()); simpleResponse.setTotal(page.getTotal());
simpleResponse.setList(BeanUtil.copyToList(page.getRecords(), SysMsgTodoVo.class)); simpleResponse.setList(BeanUtil.copyToList(msgTodoVos, SysMsgTodoVo.class));
return ResultVOUtils.success(simpleResponse); return ResultVOUtils.success(simpleResponse);
} }

@ -2,12 +2,17 @@ package com.glxp.api.dao.system;
import com.glxp.api.entity.system.SysMsgTodoEntity; import com.glxp.api.entity.system.SysMsgTodoEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.glxp.api.req.system.SysMsgTodoQuery;
import com.glxp.api.vo.system.SysMsgTodoVo;
import java.util.List;
/** /**
* sys_msg_todoMapper * sys_msg_todoMapper
*/ */
public interface SysMsgTodoMapper extends BaseMapper<SysMsgTodoEntity> { public interface SysMsgTodoMapper extends BaseMapper<SysMsgTodoEntity> {
List<SysMsgTodoVo> pageOfVo(SysMsgTodoQuery query);
} }

@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import com.glxp.api.enums.DealStatusEnum;
import com.glxp.api.enums.PushStatusEnum; import com.glxp.api.enums.PushStatusEnum;
import com.glxp.api.enums.TodoMsgTypeEnum; import com.glxp.api.enums.TodoMsgTypeEnum;
import lombok.Data; import lombok.Data;
@ -46,7 +47,7 @@ public class SysMsgTodoEntity {
* *
*/ */
@TableField(value = "dealStatus") @TableField(value = "dealStatus")
private Integer dealStatus; private DealStatusEnum dealStatus;
/** /**
* 12:3 * 12:3

@ -0,0 +1,20 @@
package com.glxp.api.enums;
import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum DealStatusEnum {
NOT_CONFIRMED("not_confirmed", 1, "未处理"),
CONFIRMED("confirmed", 2, "已处理"),
;
final String key;
@EnumValue
final Integer value;
final String desc;
}

@ -10,8 +10,8 @@ public enum PushStatusEnum {
NOT_PUSHED("not_pushed", 1, "未推送"), NOT_PUSHED("not_pushed", 1, "未推送"),
push_success("push_success", 2, "推送成功"), PUSH_SUCCESS("push_success", 2, "推送成功"),
push_fail("push_fail", 3, "推送失败"), PUSH_FAIL("push_fail", 3, "推送失败"),
; ;
final String key; final String key;

@ -1,8 +1,19 @@
package com.glxp.api.req.system; package com.glxp.api.req.system;
import com.glxp.api.enums.DealStatusEnum;
import com.glxp.api.enums.PushStatusEnum;
import com.glxp.api.enums.TodoMsgTypeEnum;
import com.glxp.api.util.page.ListPageRequest; import com.glxp.api.util.page.ListPageRequest;
import lombok.Data; import lombok.Data;
@Data @Data
public class SysMsgTodoQuery extends ListPageRequest { public class SysMsgTodoQuery extends ListPageRequest {
TodoMsgTypeEnum msgType;
PushStatusEnum pushStatus;
DealStatusEnum dealStatus;
String invCode;
String deptCode;
} }

@ -2,10 +2,15 @@ package com.glxp.api.service.system;
import com.glxp.api.entity.system.SysMsgTodoEntity; import com.glxp.api.entity.system.SysMsgTodoEntity;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.glxp.api.req.system.SysMsgTodoQuery;
import com.glxp.api.vo.system.SysMsgTodoVo;
import java.util.List;
/** /**
* sys_msg_todoService * sys_msg_todoService
*/ */
public interface SysMsgTodoService extends IService<SysMsgTodoEntity> { public interface SysMsgTodoService extends IService<SysMsgTodoEntity> {
List<SysMsgTodoVo> pageOfVo(SysMsgTodoQuery query);
} }

@ -1,11 +1,16 @@
package com.glxp.api.service.system.impl; package com.glxp.api.service.system.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.glxp.api.entity.system.SysMsgTodoEntity; import com.glxp.api.entity.system.SysMsgTodoEntity;
import com.glxp.api.req.system.SysMsgTodoQuery;
import com.glxp.api.service.system.SysMsgTodoService; import com.glxp.api.service.system.SysMsgTodoService;
import com.glxp.api.dao.system.SysMsgTodoMapper; import com.glxp.api.dao.system.SysMsgTodoMapper;
import com.glxp.api.vo.system.SysMsgTodoVo;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
/** /**
* sys_msg_todoService * sys_msg_todoService
*/ */
@ -13,6 +18,12 @@ import org.springframework.stereotype.Service;
public class SysMsgTodoServiceImpl extends ServiceImpl<SysMsgTodoMapper, SysMsgTodoEntity> public class SysMsgTodoServiceImpl extends ServiceImpl<SysMsgTodoMapper, SysMsgTodoEntity>
implements SysMsgTodoService { implements SysMsgTodoService {
@Override
public List<SysMsgTodoVo> pageOfVo(SysMsgTodoQuery query) {
PageHelper.startPage(query.getPage(), query.getLimit(), true);
return super.baseMapper.pageOfVo(query);
}
} }

@ -8,6 +8,11 @@ public class SysMsgTodoVo extends SysMsgTodoEntity {
String msgTypeName; String msgTypeName;
String pushStatusName; String pushStatusName;
String dealStatusName;
String invName;
String deptName;
public String getMsgTypeName() { public String getMsgTypeName() {
if (super.getMsgType() != null) { if (super.getMsgType() != null) {
@ -22,4 +27,11 @@ public class SysMsgTodoVo extends SysMsgTodoEntity {
} }
return pushStatusName; return pushStatusName;
} }
public String getDealStatusName() {
if (super.getDealStatus() != null) {
return super.getDealStatus().getDesc();
}
return dealStatusName;
}
} }

@ -396,6 +396,9 @@
<if test="spUse != null"> <if test="spUse != null">
AND auth_warehouse.spUse = #{spUse} AND auth_warehouse.spUse = #{spUse}
</if> </if>
<if test="deptCode != null and deptCode!=''">
AND auth_dept.code = #{deptCode}
</if>
</where> </where>
GROUP BY auth_warehouse.code GROUP BY auth_warehouse.code
</select> </select>

@ -3,4 +3,28 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.glxp.api.dao.system.SysMsgTodoMapper"> <mapper namespace="com.glxp.api.dao.system.SysMsgTodoMapper">
<select id="pageOfVo" resultType="com.glxp.api.vo.system.SysMsgTodoVo">
select *,aw.name invName,ad.name deptName
from sys_msg_todo smt
left join auth_warehouse aw on aw.code = smt.invCode
left join auth_dept ad on ad.code = smt.deptCode
<where>
<if test="msgType!=null">
and smt.msgType = #{msgType}
</if>
<if test="pushStatus!=null">
and smt.pushStatus = #{pushStatus}
</if>
<if test="dealStatus!=null">
and smt.dealStatus = #{dealStatus}
</if>
<if test="invCode!=null and invCode!=''">
and smt.invCode = #{invCode}
</if>
<if test="deptCode!=null and deptCode!=''">
and smt.deptCode = #{deptCode}
</if>
</where>
order by smt.createTime desc
</select>
</mapper> </mapper>

Loading…
Cancel
Save