feat: bug修复
This commit is contained in:
@@ -31,15 +31,16 @@ public class UserController {
|
||||
|
||||
@Resource
|
||||
private AuthUserDomainService authUserDomainService;
|
||||
/**
|
||||
* @description: 用户注册
|
||||
|
||||
/**
|
||||
* @description: 用户注册
|
||||
* @param: []
|
||||
* @return: com.landaiqing.auth.common.entity.Result<java.lang.Boolean>
|
||||
* @return: com.landaiqing.auth.common.entity.Result<java.lang.Boolean>
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/19 13:57
|
||||
*/
|
||||
*/
|
||||
@PostMapping("register")
|
||||
public Result<Boolean> register(@RequestBody AuthUserDTO authUserDTO){
|
||||
public Result<Boolean> register(@RequestBody AuthUserDTO authUserDTO) {
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("UserController.register.dto:{}", JSON.toJSONString(authUserDTO));
|
||||
@@ -52,15 +53,16 @@ public class UserController {
|
||||
return Result.fail("注册用户失败");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @description: 修改用户信息
|
||||
* @param: [authUserDTO]
|
||||
* @return: com.landaiqing.auth.common.entity.Result<java.lang.Boolean>
|
||||
|
||||
/**
|
||||
* @description: 修改用户信息
|
||||
* @param: [authUserDTO]
|
||||
* @return: com.landaiqing.auth.common.entity.Result<java.lang.Boolean>
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/19 14:38
|
||||
*/
|
||||
*/
|
||||
@PostMapping("update")
|
||||
public Result<Boolean> update(@RequestBody AuthUserDTO authUserDTO){
|
||||
public Result<Boolean> update(@RequestBody AuthUserDTO authUserDTO) {
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("UserController.update.dto:{}", JSON.toJSONString(authUserDTO));
|
||||
@@ -73,20 +75,21 @@ public class UserController {
|
||||
return Result.fail("更新用户信息失败");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @description: 用户启用/禁用
|
||||
* @param: [authUserDTO]
|
||||
* @return: com.landaiqing.auth.common.entity.Result<java.lang.Boolean>
|
||||
|
||||
/**
|
||||
* @description: 用户启用/禁用
|
||||
* @param: [authUserDTO]
|
||||
* @return: com.landaiqing.auth.common.entity.Result<java.lang.Boolean>
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/19 14:56
|
||||
*/
|
||||
*/
|
||||
@PostMapping("changeStatus")
|
||||
public Result<Boolean> changeStatus(@RequestBody AuthUserDTO authUserDTO){
|
||||
public Result<Boolean> changeStatus(@RequestBody AuthUserDTO authUserDTO) {
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("UserController.changeStatus.dto:{}", JSON.toJSONString(authUserDTO));
|
||||
}
|
||||
Preconditions.checkNotNull(authUserDTO.getStatus(),"用户名状态不能为空");
|
||||
Preconditions.checkNotNull(authUserDTO.getStatus(), "用户名状态不能为空");
|
||||
AuthUserBO authUserBO = AuthUserDTOConverter.INSTANCE.convertDTOToBO(authUserDTO);
|
||||
return Result.ok(authUserDomainService.update(authUserBO));
|
||||
} catch (Exception e) {
|
||||
@@ -96,15 +99,15 @@ public class UserController {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* @description: 删除用户
|
||||
* @param: [authUserDTO]
|
||||
* @return: com.landaiqing.auth.common.entity.Result<java.lang.Boolean>
|
||||
* @param: [authUserDTO]
|
||||
* @return: com.landaiqing.auth.common.entity.Result<java.lang.Boolean>
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/19 14:50
|
||||
*/
|
||||
*/
|
||||
@PostMapping("delete")
|
||||
public Result<Boolean> delete(@RequestBody AuthUserDTO authUserDTO){
|
||||
public Result<Boolean> delete(@RequestBody AuthUserDTO authUserDTO) {
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("UserController.update.dto:{}", JSON.toJSONString(authUserDTO));
|
||||
@@ -134,10 +137,54 @@ public class UserController {
|
||||
return "当前会话是否登录:" + StpUtil.isLogin();
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 获取用户信息
|
||||
* @param: [authUserDTO]
|
||||
* @return: com.landaiqing.auth.common.entity.Result<com.landaiqing.auth.application.dto.AuthUserDTO>
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/26 18:54
|
||||
*/
|
||||
@RequestMapping("getUserInfo")
|
||||
public Result<AuthUserDTO> getUserInfo(@RequestBody AuthUserDTO authUserDTO) {
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("UserController.getUserInfo.dto:{}", JSON.toJSONString(authUserDTO));
|
||||
}
|
||||
Preconditions.checkArgument(!StringUtils.isBlank(authUserDTO.getUserName()), "用户名不能为空");
|
||||
AuthUserBO authUserBO = AuthUserDTOConverter.INSTANCE.convertDTOToBO(authUserDTO);
|
||||
AuthUserBO userInfo = authUserDomainService.getUserInfo(authUserBO);
|
||||
AuthUserDTO authUserDTO1 = AuthUserDTOConverter.INSTANCE.convertBOToDTO(userInfo);
|
||||
return Result.ok(authUserDTO1);
|
||||
} catch (Exception e) {
|
||||
log.error("UserController.getUserInfo.error:{}", e.getMessage(), e);
|
||||
return Result.fail("获取用户信息失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 用户退出
|
||||
* @param: [userName]
|
||||
* @return: com.landaiqing.auth.common.entity.Result<com.landaiqing.auth.application.dto.AuthUserDTO>
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/26 19:08
|
||||
*/
|
||||
@RequestMapping("logout")
|
||||
public Result logout(@RequestParam String userName) {
|
||||
try {
|
||||
|
||||
log.info("UserController.logout.dto:{}", userName);
|
||||
Preconditions.checkArgument(!StringUtils.isBlank(userName), "用户名不能为空");
|
||||
StpUtil.logout(userName);
|
||||
return Result.ok();
|
||||
} catch (Exception e) {
|
||||
log.error("UserController.logout.error:{}", e.getMessage(), e);
|
||||
return Result.fail("用户登出失败");
|
||||
}
|
||||
}
|
||||
|
||||
private void checkUserInfo(@RequestBody AuthUserDTO authUserDTO) {
|
||||
Preconditions.checkArgument(!StringUtils.isBlank(authUserDTO.getUserName()),"用户名不能为空");
|
||||
Preconditions.checkArgument(!StringUtils.isBlank(authUserDTO.getEmail()),"邮箱不能为空");
|
||||
Preconditions.checkArgument(!StringUtils.isBlank(authUserDTO.getPassword()),"密码不能为空");
|
||||
Preconditions.checkArgument(!StringUtils.isBlank(authUserDTO.getUserName()), "用户名不能为空");
|
||||
Preconditions.checkArgument(!StringUtils.isBlank(authUserDTO.getEmail()), "邮箱不能为空");
|
||||
Preconditions.checkArgument(!StringUtils.isBlank(authUserDTO.getPassword()), "密码不能为空");
|
||||
}
|
||||
}
|
||||
|
@@ -24,5 +24,7 @@ public interface AuthUserDomainService {
|
||||
Object delete(AuthUserBO authUserBO);
|
||||
|
||||
Object doLogin(String validCode);
|
||||
|
||||
AuthUserBO getUserInfo(AuthUserBO authUserBO);
|
||||
}
|
||||
|
||||
|
@@ -18,6 +18,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.LinkedList;
|
||||
@@ -135,4 +136,17 @@ public class AuthUserDomainServiceImpl implements AuthUserDomainService {
|
||||
SaTokenInfo tokenInfo = StpUtil.getTokenInfo();
|
||||
return tokenInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthUserBO getUserInfo(AuthUserBO authUserBO) {
|
||||
AuthUser authUser = new AuthUser();
|
||||
authUser.setUserName(authUserBO.getUserName());
|
||||
List<AuthUser> userList = authUserService.queryByCondition(authUser);
|
||||
if (CollectionUtils.isEmpty(userList)) {
|
||||
return new AuthUserBO();
|
||||
}
|
||||
AuthUser user = userList.get(0);
|
||||
AuthUserBO authUserBO1 = AuthUserBOConverter.INSTANCE.convertEntityToBO(user);
|
||||
return authUserBO1;
|
||||
}
|
||||
}
|
||||
|
@@ -3,7 +3,9 @@ package com.landaiqing.subject.application.controller;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.landaiqing.subject.application.convert.SubjectCategoryDTOConverter;
|
||||
import com.landaiqing.subject.application.convert.SubjectLabelDTOConverter;
|
||||
import com.landaiqing.subject.application.dto.SubjectCategoryDTO;
|
||||
import com.landaiqing.subject.application.dto.SubjectLabelDTO;
|
||||
import com.landaiqing.subject.common.entity.Result;
|
||||
import com.landaiqing.subject.domain.entity.SubjectCategoryBO;
|
||||
import com.landaiqing.subject.domain.service.SubjectCategoryDomainService;
|
||||
@@ -12,6 +14,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -152,4 +155,37 @@ public class SubjectCategoryController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 查询分类及标签一次性
|
||||
* @param: [subjectCategoryDTO]
|
||||
* @return: com.landaiqing.subject.common.entity.Result<java.util.List < com.landaiqing.subject.application.dto.SubjectCategoryDTO>>
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/26 20:43
|
||||
*/
|
||||
@PostMapping("/queryCategoryAndLabel")
|
||||
public Result<List<SubjectCategoryDTO>> queryCategoryAndLabel(@RequestBody SubjectCategoryDTO subjectCategoryDTO) {
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("SubjectCategoryController.queryCategoryAndLabel.dto:{}"
|
||||
, JSON.toJSONString(subjectCategoryDTO));
|
||||
}
|
||||
Preconditions.checkNotNull(subjectCategoryDTO.getId(), "分类id不能为空");
|
||||
SubjectCategoryBO subjectCategoryBO = SubjectCategoryDTOConverter.INSTANCE.
|
||||
convertDtoToCategoryBO(subjectCategoryDTO);
|
||||
List<SubjectCategoryBO> subjectCategoryBOList = subjectCategoryDomainService.queryCategoryAndLabel(subjectCategoryBO);
|
||||
List<SubjectCategoryDTO> dtoList = new LinkedList<>();
|
||||
subjectCategoryBOList.forEach(bo -> {
|
||||
SubjectCategoryDTO dto = SubjectCategoryDTOConverter.INSTANCE.convertBoToCategoryDTO(bo);
|
||||
List<SubjectLabelDTO> labelDTOList = SubjectLabelDTOConverter.INSTANCE.convertBOToLabelDTOList(bo.getLabelBOList());
|
||||
dto.setLabelDTOList(labelDTOList);
|
||||
dtoList.add(dto);
|
||||
});
|
||||
|
||||
return Result.ok(dtoList);
|
||||
} catch (Exception e) {
|
||||
log.error("SubjectCategoryController.queryCategoryAndLabel.error:{}", e.getMessage(), e);
|
||||
return Result.fail("查询失败");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -20,6 +20,7 @@ public interface SubjectCategoryDTOConverter {
|
||||
SubjectCategoryBO convertDtoToCategoryBO(SubjectCategoryDTO subjectCategoryDTO);
|
||||
|
||||
SubjectCategoryDTO convertBoToCategoryDTO(SubjectCategoryBO subjectCategoryBO);
|
||||
|
||||
List<SubjectCategoryDTO> convertBoToCategoryDTOList(List<SubjectCategoryBO> subjectCategoryDTO);
|
||||
|
||||
}
|
||||
|
@@ -42,7 +42,10 @@ public class SubjectCategoryDTO implements Serializable {
|
||||
* 数量
|
||||
*/
|
||||
private Integer count;
|
||||
|
||||
/**
|
||||
* 标签信息
|
||||
*/
|
||||
private List<SubjectLabelDTO> labelDTOList;
|
||||
|
||||
|
||||
}
|
||||
|
@@ -4,6 +4,7 @@ import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 题目分类(SubjectCategory)实体类
|
||||
@@ -33,7 +34,15 @@ public class SubjectCategoryBO implements Serializable {
|
||||
* 父级id
|
||||
*/
|
||||
private Long parentId;
|
||||
/**
|
||||
* 数量
|
||||
*/
|
||||
private Integer count;
|
||||
/**
|
||||
* 变迁bo数量
|
||||
*/
|
||||
|
||||
private List<SubjectLabelBO> labelBOList;
|
||||
|
||||
}
|
||||
|
||||
|
@@ -35,4 +35,12 @@ public interface SubjectCategoryDomainService {
|
||||
* @date: 2024/2/14 14:58
|
||||
*/
|
||||
Boolean delete(SubjectCategoryBO subjectCategoryBO);
|
||||
/**
|
||||
* @description: 查询及标签
|
||||
* @param: [subjectCategoryBO]
|
||||
* @return: java.util.List<com.landaiqing.subject.domain.entity.SubjectCategoryBO>
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/26 21:14
|
||||
*/
|
||||
List<SubjectCategoryBO> queryCategoryAndLabel(SubjectCategoryBO subjectCategoryBO);
|
||||
}
|
||||
|
@@ -5,14 +5,23 @@ import com.landaiqing.subject.common.enums.CategoryTypeEnum;
|
||||
import com.landaiqing.subject.common.enums.IsDeletedFlagEnum;
|
||||
import com.landaiqing.subject.domain.convert.SubjectCategoryConverter;
|
||||
import com.landaiqing.subject.domain.entity.SubjectCategoryBO;
|
||||
import com.landaiqing.subject.domain.entity.SubjectLabelBO;
|
||||
import com.landaiqing.subject.domain.service.SubjectCategoryDomainService;
|
||||
import com.landaiqing.subject.infra.basic.entity.SubjectCategory;
|
||||
import com.landaiqing.subject.infra.basic.entity.SubjectLabel;
|
||||
import com.landaiqing.subject.infra.basic.entity.SubjectMapping;
|
||||
import com.landaiqing.subject.infra.basic.service.SubjectCategoryService;
|
||||
import com.landaiqing.subject.infra.basic.service.SubjectLabelService;
|
||||
import com.landaiqing.subject.infra.basic.service.SubjectMappingService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@@ -20,6 +29,11 @@ public class SubjectCategoryDomainServiceImpl implements SubjectCategoryDomainSe
|
||||
@Resource
|
||||
private SubjectCategoryService subjectCategoryService;
|
||||
|
||||
@Resource
|
||||
private SubjectMappingService subjectMappingService;
|
||||
@Resource
|
||||
private SubjectLabelService subjectLabelService;
|
||||
|
||||
/**
|
||||
* @description: 新增分类
|
||||
* @param: [subjectCategoryBO]
|
||||
@@ -56,6 +70,10 @@ public class SubjectCategoryDomainServiceImpl implements SubjectCategoryDomainSe
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("SubjectCategoryController.queryPrimaryCategory.boList:{}", JSON.toJSONString(boList));
|
||||
}
|
||||
boList.forEach(bo -> {
|
||||
Integer subjectCount = subjectCategoryService.querySubjectCount(bo.getId());
|
||||
bo.setCount(subjectCount);
|
||||
});
|
||||
return boList;
|
||||
}
|
||||
|
||||
@@ -87,4 +105,49 @@ public class SubjectCategoryDomainServiceImpl implements SubjectCategoryDomainSe
|
||||
int count = subjectCategoryService.update(subjectCategory);
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 查询分类及标签
|
||||
* @param: [subjectCategoryBO]
|
||||
* @return: java.util.List<com.landaiqing.subject.domain.entity.SubjectCategoryBO>
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/26 20:46
|
||||
*/
|
||||
@Override
|
||||
public List<SubjectCategoryBO> queryCategoryAndLabel(SubjectCategoryBO subjectCategoryBO) {
|
||||
// 查询当前分类下的所以的分类
|
||||
SubjectCategory subjectCategory = new SubjectCategory();
|
||||
subjectCategory.setParentId(subjectCategoryBO.getId());
|
||||
subjectCategory.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
|
||||
List<SubjectCategory> subjectCategoryList = subjectCategoryService.queryCategory(subjectCategory);
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("SubjectCategoryController.queryCategoryAndLabel.subjectCategoryList:{}"
|
||||
, JSON.toJSONString(subjectCategoryList));
|
||||
}
|
||||
List<SubjectCategoryBO> categoryBOList = SubjectCategoryConverter.INSTANCE.convertBoToCategory(subjectCategoryList);
|
||||
// 一次获取标签信息
|
||||
categoryBOList.forEach(category -> {
|
||||
SubjectMapping subjectMapping = new SubjectMapping();
|
||||
subjectMapping.setCategoryId(category.getId());
|
||||
List<SubjectMapping> mappingList = subjectMappingService.queryLabelId(subjectMapping);
|
||||
if (CollectionUtils.isEmpty(mappingList)) {
|
||||
return;
|
||||
}
|
||||
List<Long> labelIdList = mappingList.stream().map(SubjectMapping::getLabelId).collect(Collectors.toList());
|
||||
List<SubjectLabel> subjectLabelList = subjectLabelService.batchQueryById(labelIdList);
|
||||
List<SubjectLabelBO> labelBOList = new LinkedList<>();
|
||||
subjectLabelList.forEach(label -> {
|
||||
SubjectLabelBO subjectLabelBO = new SubjectLabelBO();
|
||||
subjectLabelBO.setId(label.getId());
|
||||
subjectLabelBO.setLabelName(label.getLabelName());
|
||||
subjectLabelBO.setCategoryId(label.getCategoryId());
|
||||
subjectLabelBO.setSortNum(label.getSortNum());
|
||||
labelBOList.add(subjectLabelBO);
|
||||
});
|
||||
category.setLabelBOList(labelBOList);
|
||||
|
||||
});
|
||||
|
||||
return categoryBOList;
|
||||
}
|
||||
}
|
||||
|
@@ -70,5 +70,7 @@ public interface SubjectCategoryDao {
|
||||
int deleteById(Long id);
|
||||
|
||||
List<SubjectCategory> queryCategory(SubjectCategory subjectCategory);
|
||||
|
||||
Integer querySubjectCount(Long id);
|
||||
}
|
||||
|
||||
|
@@ -49,4 +49,6 @@ public interface SubjectCategoryService {
|
||||
* @return
|
||||
*/
|
||||
List<SubjectCategory> queryCategory(SubjectCategory subjectCategory);
|
||||
|
||||
Integer querySubjectCount(Long id);
|
||||
}
|
||||
|
@@ -75,4 +75,9 @@ public class SubjectCategoryServiceImpl implements SubjectCategoryService {
|
||||
public List<SubjectCategory> queryCategory(SubjectCategory subjectCategory) {
|
||||
return this.subjectCategoryDao.queryCategory(subjectCategory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer querySubjectCount(Long id) {
|
||||
return this.subjectCategoryDao.querySubjectCount(id);
|
||||
}
|
||||
}
|
||||
|
@@ -105,6 +105,13 @@
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="querySubjectCount" resultType="java.lang.Integer">
|
||||
select count(distinct subject_id)
|
||||
from subject_mapping a,
|
||||
subject_label b
|
||||
where a.label_id=b.id
|
||||
and b.category_id=#{id}
|
||||
</select>
|
||||
|
||||
<!--新增所有列-->
|
||||
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
|
||||
|
Reference in New Issue
Block a user