From 6b2b032beb44799a2612c040b81d64fdce204c80 Mon Sep 17 00:00:00 2001 From: Qing Date: Sun, 18 Feb 2024 13:49:34 +0800 Subject: [PATCH] fix: SubjectLabel --- jc-club-auth/pom.xml | 25 +++++++++ .../src/main/java/com/landaiqing/App.java | 13 +++++ .../src/test/java/com/landaiqing/AppTest.java | 38 ++++++++++++++ jc-club-gateway/pom.xml | 25 +++++++++ .../src/main/java/com/landaiqing/App.java | 13 +++++ .../src/test/java/com/landaiqing/AppTest.java | 38 ++++++++++++++ .../application/dto/SubjectLabelDTO.java | 3 +- .../impl/SubjectLabelDomainServiceImpl.java | 51 ++++++++++++------- .../infra/basic/mapper/SubjectLabelDao.java | 2 +- .../basic/service/SubjectLabelService.java | 2 + .../service/impl/SubjectLabelServiceImpl.java | 5 ++ .../main/resources/mapper/SubjectLabelDao.xml | 3 +- 12 files changed, 196 insertions(+), 22 deletions(-) create mode 100644 jc-club-auth/pom.xml create mode 100644 jc-club-auth/src/main/java/com/landaiqing/App.java create mode 100644 jc-club-auth/src/test/java/com/landaiqing/AppTest.java create mode 100644 jc-club-gateway/pom.xml create mode 100644 jc-club-gateway/src/main/java/com/landaiqing/App.java create mode 100644 jc-club-gateway/src/test/java/com/landaiqing/AppTest.java diff --git a/jc-club-auth/pom.xml b/jc-club-auth/pom.xml new file mode 100644 index 0000000..cf85a59 --- /dev/null +++ b/jc-club-auth/pom.xml @@ -0,0 +1,25 @@ + + 4.0.0 + + com.landaiqing + jc-club-auth + 1.0-SNAPSHOT + jar + + jc-club-auth + http://maven.apache.org + + + UTF-8 + + + + + junit + junit + 3.8.1 + test + + + diff --git a/jc-club-auth/src/main/java/com/landaiqing/App.java b/jc-club-auth/src/main/java/com/landaiqing/App.java new file mode 100644 index 0000000..e623ea3 --- /dev/null +++ b/jc-club-auth/src/main/java/com/landaiqing/App.java @@ -0,0 +1,13 @@ +package com.landaiqing; + +/** + * Hello world! + * + */ +public class App +{ + public static void main( String[] args ) + { + System.out.println( "Hello World!" ); + } +} diff --git a/jc-club-auth/src/test/java/com/landaiqing/AppTest.java b/jc-club-auth/src/test/java/com/landaiqing/AppTest.java new file mode 100644 index 0000000..908567a --- /dev/null +++ b/jc-club-auth/src/test/java/com/landaiqing/AppTest.java @@ -0,0 +1,38 @@ +package com.landaiqing; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +} diff --git a/jc-club-gateway/pom.xml b/jc-club-gateway/pom.xml new file mode 100644 index 0000000..d8fefb8 --- /dev/null +++ b/jc-club-gateway/pom.xml @@ -0,0 +1,25 @@ + + 4.0.0 + + com.landaiqing + jc-club-gateway + 1.0-SNAPSHOT + jar + + jc-club-gateway + http://maven.apache.org + + + UTF-8 + + + + + junit + junit + 3.8.1 + test + + + diff --git a/jc-club-gateway/src/main/java/com/landaiqing/App.java b/jc-club-gateway/src/main/java/com/landaiqing/App.java new file mode 100644 index 0000000..e623ea3 --- /dev/null +++ b/jc-club-gateway/src/main/java/com/landaiqing/App.java @@ -0,0 +1,13 @@ +package com.landaiqing; + +/** + * Hello world! + * + */ +public class App +{ + public static void main( String[] args ) + { + System.out.println( "Hello World!" ); + } +} diff --git a/jc-club-gateway/src/test/java/com/landaiqing/AppTest.java b/jc-club-gateway/src/test/java/com/landaiqing/AppTest.java new file mode 100644 index 0000000..908567a --- /dev/null +++ b/jc-club-gateway/src/test/java/com/landaiqing/AppTest.java @@ -0,0 +1,38 @@ +package com.landaiqing; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +} diff --git a/jc-club-subject/jc-club-application/jc-club-application-controller/src/main/java/com/landaiqing/subject/application/dto/SubjectLabelDTO.java b/jc-club-subject/jc-club-application/jc-club-application-controller/src/main/java/com/landaiqing/subject/application/dto/SubjectLabelDTO.java index f6abf76..1fce7f6 100644 --- a/jc-club-subject/jc-club-application/jc-club-application-controller/src/main/java/com/landaiqing/subject/application/dto/SubjectLabelDTO.java +++ b/jc-club-subject/jc-club-application/jc-club-application-controller/src/main/java/com/landaiqing/subject/application/dto/SubjectLabelDTO.java @@ -3,7 +3,6 @@ package com.landaiqing.subject.application.dto; import lombok.Data; import java.io.Serializable; -import java.util.Date; /** * 题目标签DTO @@ -12,7 +11,7 @@ import java.util.Date; * @since 2024-02-14 17:08:06 */ @Data -public class SubjectLabelDTO implements Serializable { +public class SubjectLabelDTO implements Serializable { /** * 主键 */ diff --git a/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/service/impl/SubjectLabelDomainServiceImpl.java b/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/service/impl/SubjectLabelDomainServiceImpl.java index ddbdb7d..bcb30af 100644 --- a/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/service/impl/SubjectLabelDomainServiceImpl.java +++ b/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/service/impl/SubjectLabelDomainServiceImpl.java @@ -1,12 +1,15 @@ package com.landaiqing.subject.domain.service.impl; import com.alibaba.fastjson.JSON; +import com.landaiqing.subject.common.enums.CategoryTypeEnum; import com.landaiqing.subject.common.enums.IsDeletedFlagEnum; import com.landaiqing.subject.domain.convert.SubjectLabelConverter; import com.landaiqing.subject.domain.entity.SubjectLabelBO; import com.landaiqing.subject.domain.service.SubjectLabelDomainService; +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; @@ -27,6 +30,9 @@ public class SubjectLabelDomainServiceImpl implements SubjectLabelDomainService @Resource private SubjectMappingService subjectMappingService; + @Resource + private SubjectCategoryService subjectCategoryService; + /** * @description: 新增标签 * @param: [subjectLabelBO] @@ -63,13 +69,14 @@ public class SubjectLabelDomainServiceImpl implements SubjectLabelDomainService int count = subjectLabelService.update(subjectLabel); return count > 0; } - /** - * @description: 删除标签 - * @param: [subjectLabelBO] - * @return: java.lang.Boolean + + /** + * @description: 删除标签 + * @param: [subjectLabelBO] + * @return: java.lang.Boolean * @author landaiqing * @date: 2024/2/14 18:58 - */ + */ @Override public Boolean delete(SubjectLabelBO subjectLabelBO) { if (log.isInfoEnabled()) { @@ -81,28 +88,38 @@ public class SubjectLabelDomainServiceImpl implements SubjectLabelDomainService int count = subjectLabelService.update(subjectLabel); return count > 0; } - /** - * @description: 查询分类下的标签 - * @param: [subjectLabelBO] - * @return: java.util.List + + /** + * @description: 查询分类下的标签 + * @param: [subjectLabelBO] + * @return: java.util.List * @author landaiqing * @date: 2024/2/14 19:08 - */ + */ @Override public List queryLabelByCategoryId(SubjectLabelBO subjectLabelBO) { + //如果当前分类是1级分类,则查询所有标签 + SubjectCategory subjectCategory = subjectCategoryService.queryById(subjectLabelBO.getCategoryId()); + if(CategoryTypeEnum.PRIMARY.getCode()==subjectCategory.getCategoryType()){ + SubjectLabel subjectLabel=new SubjectLabel(); + subjectLabel.setCategoryId(subjectLabelBO.getCategoryId()); + List labelList= subjectLabelService.queryByCondition(subjectLabel); + List boList = SubjectLabelConverter.INSTANCE.convertLabelToBoList(labelList); + return boList; + } Long categoryId = subjectLabelBO.getCategoryId(); - SubjectMapping subjectMapping=new SubjectMapping(); + SubjectMapping subjectMapping = new SubjectMapping(); subjectMapping.setCategoryId(categoryId); subjectMapping.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode()); - List mappingList= subjectMappingService.queryLabelId(subjectMapping); - if(CollectionUtils.isEmpty(mappingList)){ + List mappingList = subjectMappingService.queryLabelId(subjectMapping); + if (CollectionUtils.isEmpty(mappingList)) { return Collections.emptyList(); } List labelIdList = mappingList.stream().map(SubjectMapping::getLabelId).collect(Collectors.toList()); - List labelList= subjectLabelService.batchQueryById(labelIdList); - List boList=new LinkedList<>(); - labelList.forEach(label->{ - SubjectLabelBO bo=new SubjectLabelBO(); + List labelList = subjectLabelService.batchQueryById(labelIdList); + List boList = new LinkedList<>(); + labelList.forEach(label -> { + SubjectLabelBO bo = new SubjectLabelBO(); bo.setId(label.getId()); bo.setLabelName(label.getLabelName()); bo.setCategoryId(categoryId); diff --git a/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/mapper/SubjectLabelDao.java b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/mapper/SubjectLabelDao.java index b04411a..2c90d98 100644 --- a/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/mapper/SubjectLabelDao.java +++ b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/mapper/SubjectLabelDao.java @@ -28,7 +28,7 @@ public interface SubjectLabelDao { * @param subjectLabel 分页对象 * @return 对象列表 */ - List queryAllByLimit(SubjectLabel subjectLabel); + List queryByCondition(SubjectLabel subjectLabel); /** * 统计总行数 diff --git a/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/SubjectLabelService.java b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/SubjectLabelService.java index ed07a30..db1dfc8 100644 --- a/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/SubjectLabelService.java +++ b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/SubjectLabelService.java @@ -49,4 +49,6 @@ public interface SubjectLabelService { boolean deleteById(Long id); List batchQueryById(@Param("list") List labelIdList); + + List queryByCondition(SubjectLabel subjectLabel); } diff --git a/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/impl/SubjectLabelServiceImpl.java b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/impl/SubjectLabelServiceImpl.java index c43e5a6..a616b6e 100644 --- a/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/impl/SubjectLabelServiceImpl.java +++ b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/impl/SubjectLabelServiceImpl.java @@ -71,4 +71,9 @@ public class SubjectLabelServiceImpl implements SubjectLabelService { public List batchQueryById(List labelIdList) { return this.subjectLabelDao.batchQueryById(labelIdList); } + + @Override + public List queryByCondition(SubjectLabel subjectLabel) { + return this.subjectLabelDao.queryByCondition(subjectLabel); + } } diff --git a/jc-club-subject/jc-club-infra/src/main/resources/mapper/SubjectLabelDao.xml b/jc-club-subject/jc-club-infra/src/main/resources/mapper/SubjectLabelDao.xml index 0a66877..28d4ed9 100644 --- a/jc-club-subject/jc-club-infra/src/main/resources/mapper/SubjectLabelDao.xml +++ b/jc-club-subject/jc-club-infra/src/main/resources/mapper/SubjectLabelDao.xml @@ -22,7 +22,7 @@ - select id,label_name,sort_num,category_id,created_by,created_time,update_by,update_time,is_deleted from subject_label @@ -55,7 +55,6 @@ and is_deleted = #{isDeleted} - limit #{pageable.offset}, #{pageable.pageSize}