add JournalController.listByIds
This commit is contained in:
@ -81,6 +81,7 @@ public class TimiServerDBConfig {
|
|||||||
mapperLocations.add("classpath:mapper/blog/**/*.xml");
|
mapperLocations.add("classpath:mapper/blog/**/*.xml");
|
||||||
mapperLocations.add("classpath:mapper/common/**/*.xml");
|
mapperLocations.add("classpath:mapper/common/**/*.xml");
|
||||||
mapperLocations.add("classpath:mapper/system/**/*.xml");
|
mapperLocations.add("classpath:mapper/system/**/*.xml");
|
||||||
|
mapperLocations.add("classpath:mapper/journal/**/*.xml");
|
||||||
mapperLocations.add("classpath:mapper/minecraft/**/*.xml");
|
mapperLocations.add("classpath:mapper/minecraft/**/*.xml");
|
||||||
for (int i = 0; i < mapperLocations.size(); i++) {
|
for (int i = 0; i < mapperLocations.size(); i++) {
|
||||||
resources.addAll(List.of(resourceResolver.getResources(mapperLocations.get(i))));
|
resources.addAll(List.of(resourceResolver.getResources(mapperLocations.get(i))));
|
||||||
|
|||||||
@ -0,0 +1,30 @@
|
|||||||
|
package com.imyeyu.api.modules.journal.bean;
|
||||||
|
|
||||||
|
import com.imyeyu.api.modules.journal.entity.Journal;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 经纬度位置
|
||||||
|
*
|
||||||
|
* @author 夜雨
|
||||||
|
* @since 2025-12-05 15:26
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class Location {
|
||||||
|
|
||||||
|
/** 经度 */
|
||||||
|
private Double lng;
|
||||||
|
|
||||||
|
/** 维度 */
|
||||||
|
private Double lat;
|
||||||
|
|
||||||
|
private String text;
|
||||||
|
|
||||||
|
public Location(Journal journal) {
|
||||||
|
this.lat = journal.getLat();
|
||||||
|
this.lng = journal.getLng();
|
||||||
|
this.text = journal.getLocation();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -6,7 +6,6 @@ import com.imyeyu.api.modules.common.bean.SettingKey;
|
|||||||
import com.imyeyu.api.modules.common.entity.Attachment;
|
import com.imyeyu.api.modules.common.entity.Attachment;
|
||||||
import com.imyeyu.api.modules.common.service.AttachmentService;
|
import com.imyeyu.api.modules.common.service.AttachmentService;
|
||||||
import com.imyeyu.api.modules.common.service.SettingService;
|
import com.imyeyu.api.modules.common.service.SettingService;
|
||||||
import com.imyeyu.api.modules.journal.bean.Location;
|
|
||||||
import com.imyeyu.api.modules.journal.bean.Travel;
|
import com.imyeyu.api.modules.journal.bean.Travel;
|
||||||
import com.imyeyu.api.modules.journal.entity.Journal;
|
import com.imyeyu.api.modules.journal.entity.Journal;
|
||||||
import com.imyeyu.api.modules.journal.service.JournalService;
|
import com.imyeyu.api.modules.journal.service.JournalService;
|
||||||
@ -35,6 +34,7 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -167,27 +167,30 @@ public class JournalController {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 所有记录日期列表
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@AOPLog
|
@AOPLog
|
||||||
@RequestRateLimit
|
@RequestRateLimit
|
||||||
@GetMapping("/list/date")
|
@PostMapping("/list/ids")
|
||||||
public Long[] listDate() {
|
public List<JournalResponse> listByIds(@RequestBody Long[] ids) {
|
||||||
return service.listDate();
|
List<JournalResponse> result = new ArrayList<>();
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
List<Journal> journals = service.listByIds(ids);
|
||||||
* 所有记录位置列表
|
for (int i = 0; i < journals.size(); i++) {
|
||||||
*
|
Journal journal = journals.get(i);
|
||||||
* @return
|
JournalResponse resp = new JournalResponse();
|
||||||
*/
|
Page<Attachment> attachPage = new Page<>();
|
||||||
@RequestRateLimit
|
{
|
||||||
@GetMapping("/list/location")
|
Attachment example = new Attachment();
|
||||||
public List<Location> listLocation() {
|
example.setBizType(Attachment.BizType.JOURNAL);
|
||||||
return null;
|
example.setBizId(journal.getId());
|
||||||
|
attachPage.setEqualsExample(example);
|
||||||
|
}
|
||||||
|
attachPage.setIndex(0);
|
||||||
|
attachPage.setSize(Long.MAX_VALUE);
|
||||||
|
resp.setItems(attachmentService.page(attachPage).getList());
|
||||||
|
BeanUtils.copyProperties(journal, resp);
|
||||||
|
result.add(resp);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -2,7 +2,8 @@ package com.imyeyu.api.modules.journal.mapper;
|
|||||||
|
|
||||||
import com.imyeyu.api.modules.journal.entity.Journal;
|
import com.imyeyu.api.modules.journal.entity.Journal;
|
||||||
import com.imyeyu.spring.mapper.BaseMapper;
|
import com.imyeyu.spring.mapper.BaseMapper;
|
||||||
import org.apache.ibatis.annotations.Select;
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 夜雨
|
* @author 夜雨
|
||||||
@ -10,6 +11,5 @@ import org.apache.ibatis.annotations.Select;
|
|||||||
*/
|
*/
|
||||||
public interface JournalMapper extends BaseMapper<Journal, Long> {
|
public interface JournalMapper extends BaseMapper<Journal, Long> {
|
||||||
|
|
||||||
@Select("SELECT created_at FROM `journal` WHERE `deleted_at` IS NULL")
|
List<Journal> listByIds(Long[] ids);
|
||||||
Long[] listDate();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,12 +19,12 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public interface JournalService extends PageableService<Journal>, GettableService<Journal, Long>, DeletableService<Long> {
|
public interface JournalService extends PageableService<Journal>, GettableService<Journal, Long>, DeletableService<Long> {
|
||||||
|
|
||||||
Long[] listDate() throws TimiException;
|
|
||||||
|
|
||||||
void create(JournalRequest request) throws TimiException;
|
void create(JournalRequest request) throws TimiException;
|
||||||
|
|
||||||
void update(UpdateRequest request) throws TimiException;
|
void update(UpdateRequest request) throws TimiException;
|
||||||
|
|
||||||
|
List<Journal> listByIds(Long... ids);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 过滤已存在瞬间
|
* 过滤已存在瞬间
|
||||||
*
|
*
|
||||||
|
|||||||
@ -59,11 +59,6 @@ public class JournalServiceImplement extends AbstractEntityService<Journal, Long
|
|||||||
return mapper;
|
return mapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Long[] listDate() throws TimiException {
|
|
||||||
return mapper.listDate();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||||
@Override
|
@Override
|
||||||
public void create(JournalRequest request) throws TimiException {
|
public void create(JournalRequest request) throws TimiException {
|
||||||
@ -140,6 +135,11 @@ public class JournalServiceImplement extends AbstractEntityService<Journal, Long
|
|||||||
attachmentService.deleteByBizId(Attachment.BizType.JOURNAL, id);
|
attachmentService.deleteByBizId(Attachment.BizType.JOURNAL, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Journal> listByIds(Long... ids) {
|
||||||
|
return mapper.listByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] filterExistMoment(String[] md5s) throws TimiException {
|
public String[] filterExistMoment(String[] md5s) throws TimiException {
|
||||||
if (TimiJava.isEmpty(md5s)) {
|
if (TimiJava.isEmpty(md5s)) {
|
||||||
|
|||||||
20
src/main/resources/mapper/journal/JournalMapper.xml
Normal file
20
src/main/resources/mapper/journal/JournalMapper.xml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
|
<mapper namespace="com.imyeyu.api.modules.journal.mapper.JournalMapper">
|
||||||
|
<sql id="table">journal</sql>
|
||||||
|
<select id="listByIds" resultType="com.imyeyu.api.modules.journal.entity.Journal">
|
||||||
|
SELECT
|
||||||
|
*
|
||||||
|
FROM
|
||||||
|
<include refid="table" />
|
||||||
|
WHERE
|
||||||
|
1 = 1
|
||||||
|
<if test="ids != null and 0 < ids.length">
|
||||||
|
AND `id` IN
|
||||||
|
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
AND deleted_at IS NULL
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user