Skip to content

Commit 5835d5d

Browse files
committed
Merge commit '68a860eeeea2093440fe0382f2e0b25c428bfd3f'
2 parents 8c6e774 + 68a860e commit 5835d5d

File tree

5 files changed

+35
-11
lines changed

5 files changed

+35
-11
lines changed

backend/src/main/java/com/mumu/image/DTO/ImgDTO.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
package com.mumu.image.DTO;
22

3-
import com.fasterxml.jackson.annotation.JsonFormat;
43
import lombok.Data;
5-
import lombok.Getter;
64
import org.springframework.format.annotation.DateTimeFormat;
75
import org.springframework.http.ResponseEntity;
8-
import org.springframework.web.multipart.MultipartFile;
96

10-
import java.time.LocalDateTime;
117
import java.util.Date;
128
import java.util.List;
139
@Data
@@ -25,8 +21,10 @@ public class ImgDTO {
2521
private Integer userId;
2622
private ResponseEntity<byte[]> img;
2723
private List<String> peoples;
24+
private List<String> peoples_nickname;
2825
private List<String> tags;
2926
//duplicated
3027
private String name;
28+
private String nickname;
3129
private String tagName;
3230
}

backend/src/main/java/com/mumu/image/controller/PeopleController.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package com.mumu.image.controller;
22

33

4+
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
45
import com.mumu.image.DTO.ImgDTO;
6+
import com.mumu.image.entity.People;
57
import com.mumu.image.mapper.ImgMapper;
8+
import com.mumu.image.mapper.PeopleMapper;
69
import com.mumu.image.service.PeopleService;
710
import com.mumu.utils.AjaxJson;
811
import io.swagger.annotations.ApiOperation;
@@ -25,13 +28,25 @@
2528
public class PeopleController {
2629
@Autowired
2730
private PeopleService peopleService;
31+
@Autowired
32+
private PeopleMapper peopleMapper;
2833

2934
@ApiOperation(value = "更新people name", tags = "people类")
3035
@PostMapping("/update")
3136
public AjaxJson update(@RequestParam int userId, @RequestBody List<String> names) {
3237
return AjaxJson.getSuccessData(peopleService.checkAndInsertPeople(userId, names));
3338
}
3439

40+
@ApiOperation(value = "修改people name", tags = "people类")
41+
@PostMapping("/change")
42+
public AjaxJson change(@RequestParam int userId, @RequestParam String name,@RequestParam String nickname) {
43+
return AjaxJson.getSuccessData(peopleService.update(new LambdaUpdateWrapper<People>()
44+
.eq(People::getUserId,userId)
45+
.eq(People::getName,name)
46+
.set(People::getNickname,nickname)
47+
));
48+
}
49+
3550
@ApiOperation(value = "删除people name", tags = "people类")
3651
@PostMapping("/delete")
3752
public AjaxJson delete(@RequestParam int userId, @RequestBody List<String> names) {

backend/src/main/java/com/mumu/image/entity/People.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,7 @@ public class People implements Serializable {
2929

3030
private Boolean valid;
3131

32+
private String nickname;
33+
3234

3335
}

backend/src/main/java/com/mumu/image/service/impl/ImgServiceImpl.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ public List<ImgDTO> getImagesByTags(ImgDTO img, int offset, int limit, Date star
7474
// 1️⃣ 先查询符合条件的图片ID
7575
List<Integer> imgIds = mapper.selectJoinList(Integer.class, new MPJLambdaWrapper<Img>()
7676
.select(Img::getImgId) // 只查询 imgId
77-
.eq(img.getAlbumId()!=null,Img::getAlbumId, img.getAlbumId())
77+
.eq(img.getAlbumId() != null && img.getAlbumId() != -1, Img::getAlbumId, img.getAlbumId())
78+
.isNull(img.getAlbumId() != null && img.getAlbumId() == -1, Img::getAlbumId)
7879
.eq(img.getUserId() != null, Img::getUserId, img.getUserId())
7980
.eq(img.getImgId() != null, Img::getImgId, img.getImgId())
8081
.eq(Img::getValid, true)
@@ -111,6 +112,7 @@ public List<ImgDTO> getImagesByTags(ImgDTO img, int offset, int limit, Date star
111112
.selectAll(Img.class) // 查询所有图片字段
112113
.select(Tag::getTagName) // 查询 tagName
113114
.select(People::getName) // 查询 peopleName
115+
.select(People::getNickname)
114116
.leftJoin(ImgTag.class, ImgTag::getImgId, Img::getImgId)
115117
.leftJoin(Tag.class, Tag::getTagId, ImgTag::getTagId)
116118
.leftJoin(ImgPeople.class, ImgPeople::getImgId, Img::getImgId)
@@ -133,6 +135,7 @@ public List<ImgDTO> getImagesByTags(ImgDTO img, int offset, int limit, Date star
133135
dto.setTags(new ArrayList<>());
134136
dto.setAlbumId(image.getAlbumId());
135137
dto.setPeoples(new ArrayList<>());
138+
dto.setPeoples_nickname(new ArrayList<>());
136139
// String imgName = String.format("%d.jpeg", image.getImgId());
137140
// dto.setImg(minioUtilS.download(imgName, ImgPath));
138141
return dto;
@@ -145,8 +148,14 @@ public List<ImgDTO> getImagesByTags(ImgDTO img, int offset, int limit, Date star
145148
}
146149
// 收集 peopleName
147150
if (image.getName() != null) {
148-
if (!imgMap.get(image.getImgId()).getPeoples().contains(image.getName()))
151+
if (!imgMap.get(image.getImgId()).getPeoples().contains(image.getName())) {
149152
imgMap.get(image.getImgId()).getPeoples().add(image.getName());
153+
if (image.getNickname() != null) {
154+
imgMap.get(image.getImgId()).getPeoples_nickname().add(image.getNickname());
155+
} else {
156+
imgMap.get(image.getImgId()).getPeoples_nickname().add(image.getName());
157+
}
158+
}
150159
}
151160
}
152161

backend/table.sql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ CREATE TABLE `img_tag`
3737
PRIMARY KEY (`it_id`)
3838
);
3939

40-
CREATE TABLE `people`
41-
(
42-
`people_id` int NOT NULL AUTO_INCREMENT,
40+
CREATE TABLE `people` (
41+
`people_id` int NOT NULL AUTO_INCREMENT,
4342
`name` text,
44-
`user_id` int DEFAULT NULL,
45-
`valid` tinyint(1) NOT NULL DEFAULT '1',
43+
`user_id` int DEFAULT NULL,
44+
`valid` tinyint(1) NOT NULL DEFAULT 1,
45+
`nickname` text AS (`name`) STORED, -- `TEXT` 类型通常需要 STORED
4646
PRIMARY KEY (`people_id`)
4747
);
4848
CREATE TABLE `tag`

0 commit comments

Comments
 (0)