package com.mindskip.xzs.service.impl; import com.mindskip.xzs.domain.TextContent; import com.mindskip.xzs.repository.TextContentMapper; import com.mindskip.xzs.service.TextContentService; import com.mindskip.xzs.utility.JsonUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Date; import java.util.List; import java.util.function.Function; import java.util.stream.Collectors; @Service public class TextContentServiceImpl extends BaseServiceImpl implements TextContentService { private final TextContentMapper textContentMapper; @Autowired public TextContentServiceImpl(TextContentMapper textContentMapper) { super(textContentMapper); this.textContentMapper = textContentMapper; } @Override public TextContent selectById(Integer id) { return super.selectById(id); } @Override public int insertByFilter(TextContent record) { return super.insertByFilter(record); } @Override public int updateByIdFilter(TextContent record) { return super.updateByIdFilter(record); } @Override public TextContent jsonConvertInsert(List list, Date now, Function mapper) { String frameTextContent = null; if (null == mapper) { frameTextContent = JsonUtil.toJsonStr(list); } else { List mapList = list.stream().map(mapper).collect(Collectors.toList()); frameTextContent = JsonUtil.toJsonStr(mapList); } TextContent textContent = new TextContent(frameTextContent, now); return textContent; } @Override public TextContent jsonConvertUpdate(TextContent textContent, List list, Function mapper) { String frameTextContent = null; if (null == mapper) { frameTextContent = JsonUtil.toJsonStr(list); } else { List mapList = list.stream().map(mapper).collect(Collectors.toList()); frameTextContent = JsonUtil.toJsonStr(mapList); } textContent.setContent(frameTextContent); return textContent; } }