21 changed files with 348 additions and 9 deletions
-
8.idea/.gitignore
-
22.idea/compiler.xml
-
10.idea/encodings.xml
-
20.idea/jarRepositories.xml
-
9.idea/lottery.iml
-
14.idea/misc.xml
-
8.idea/modules.xml
-
6.idea/vcs.xml
-
37lottery-system/lottery-pojo/src/main/java/com/lottery/vo/PageInfo.java
-
13lottery-system/lottery-pojo/src/main/java/com/lottery/vo/PrizeVo.java
-
10lottery-system/lottery-service/src/main/java/com/lottery/admin/controller/AdminGradeController.java
-
39lottery-system/lottery-service/src/main/java/com/lottery/admin/controller/AdminPrizeController.java
-
10lottery-system/lottery-service/src/main/java/com/lottery/admin/service/AdminGradeService.java
-
18lottery-system/lottery-service/src/main/java/com/lottery/admin/service/AdminPrizeService.java
-
26lottery-system/lottery-service/src/main/java/com/lottery/admin/service/Impl/AdminGradeServiceImpl.java
-
50lottery-system/lottery-service/src/main/java/com/lottery/admin/service/Impl/AdminPrizeServiceImpl.java
-
4lottery-system/lottery-service/src/main/java/com/lottery/api/mapper/IPrizeMapper.java
-
39lottery-system/lottery-service/src/main/java/com/lottery/config/MybatisPageConfig.java
-
2lottery-system/lottery-service/src/main/resources/application.yml
-
7lottery-system/lottery-service/src/main/resources/mapper/api/prizeMapper.xml
-
5lottery-system/pom.xml
@ -0,0 +1,8 @@ |
|||||
|
# Default ignored files |
||||
|
/shelf/ |
||||
|
/workspace.xml |
||||
|
# Editor-based HTTP Client requests |
||||
|
/httpRequests/ |
||||
|
# Datasource local storage ignored files |
||||
|
/dataSources/ |
||||
|
/dataSources.local.xml |
@ -0,0 +1,22 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<project version="4"> |
||||
|
<component name="CompilerConfiguration"> |
||||
|
<annotationProcessing> |
||||
|
<profile name="Maven default annotation processors profile" enabled="true"> |
||||
|
<sourceOutputDir name="target/generated-sources/annotations" /> |
||||
|
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" /> |
||||
|
<outputRelativeToContentRoot value="true" /> |
||||
|
<module name="lottery-service" /> |
||||
|
<module name="lottery-common" /> |
||||
|
<module name="lottery-pojo" /> |
||||
|
</profile> |
||||
|
</annotationProcessing> |
||||
|
</component> |
||||
|
<component name="JavacSettings"> |
||||
|
<option name="ADDITIONAL_OPTIONS_OVERRIDE"> |
||||
|
<module name="lottery-common" options="-parameters" /> |
||||
|
<module name="lottery-pojo" options="-parameters" /> |
||||
|
<module name="lottery-service" options="-parameters" /> |
||||
|
</option> |
||||
|
</component> |
||||
|
</project> |
@ -0,0 +1,10 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<project version="4"> |
||||
|
<component name="Encoding"> |
||||
|
<file url="file://$PROJECT_DIR$/lottery-system/lottery-common/src/main/java" charset="UTF-8" /> |
||||
|
<file url="file://$PROJECT_DIR$/lottery-system/lottery-pojo/src/main/java" charset="UTF-8" /> |
||||
|
<file url="file://$PROJECT_DIR$/lottery-system/lottery-service/src/main/java" charset="UTF-8" /> |
||||
|
<file url="file://$PROJECT_DIR$/lottery-system/src/main/java" charset="UTF-8" /> |
||||
|
<file url="file://$PROJECT_DIR$/lottery-system/src/main/resources" charset="UTF-8" /> |
||||
|
</component> |
||||
|
</project> |
@ -0,0 +1,20 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<project version="4"> |
||||
|
<component name="RemoteRepositoriesConfiguration"> |
||||
|
<remote-repository> |
||||
|
<option name="id" value="central" /> |
||||
|
<option name="name" value="Maven Central repository" /> |
||||
|
<option name="url" value="https://repo1.maven.org/maven2" /> |
||||
|
</remote-repository> |
||||
|
<remote-repository> |
||||
|
<option name="id" value="jboss.community" /> |
||||
|
<option name="name" value="JBoss Community repository" /> |
||||
|
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" /> |
||||
|
</remote-repository> |
||||
|
<remote-repository> |
||||
|
<option name="id" value="central" /> |
||||
|
<option name="name" value="Central Repository" /> |
||||
|
<option name="url" value="https://maven.aliyun.com/repository/public" /> |
||||
|
</remote-repository> |
||||
|
</component> |
||||
|
</project> |
@ -0,0 +1,9 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<module type="JAVA_MODULE" version="4"> |
||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true"> |
||||
|
<exclude-output /> |
||||
|
<content url="file://$MODULE_DIR$" /> |
||||
|
<orderEntry type="inheritedJdk" /> |
||||
|
<orderEntry type="sourceFolder" forTests="false" /> |
||||
|
</component> |
||||
|
</module> |
@ -0,0 +1,14 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<project version="4"> |
||||
|
<component name="ExternalStorageConfigurationManager" enabled="true" /> |
||||
|
<component name="MavenProjectsManager"> |
||||
|
<option name="originalFiles"> |
||||
|
<list> |
||||
|
<option value="$PROJECT_DIR$/lottery-system/pom.xml" /> |
||||
|
</list> |
||||
|
</option> |
||||
|
</component> |
||||
|
<component name="ProjectRootManager" version="2" project-jdk-name="11" project-jdk-type="JavaSDK"> |
||||
|
<output url="file://$PROJECT_DIR$/out" /> |
||||
|
</component> |
||||
|
</project> |
@ -0,0 +1,8 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<project version="4"> |
||||
|
<component name="ProjectModuleManager"> |
||||
|
<modules> |
||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/lottery.iml" filepath="$PROJECT_DIR$/.idea/lottery.iml" /> |
||||
|
</modules> |
||||
|
</component> |
||||
|
</project> |
@ -0,0 +1,6 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<project version="4"> |
||||
|
<component name="VcsDirectoryMappings"> |
||||
|
<mapping directory="" vcs="Git" /> |
||||
|
</component> |
||||
|
</project> |
@ -0,0 +1,37 @@ |
|||||
|
package com.lottery.vo; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @program: lottery |
||||
|
* @ClassName PageInfo |
||||
|
* @description: |
||||
|
* @author: wwl |
||||
|
* @create: 2025-07-15 10:20 |
||||
|
* @Version 1.0 |
||||
|
**/ |
||||
|
@Data |
||||
|
public class PageInfo<T> implements Serializable { |
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
private List<T> list; // 当前页数据 |
||||
|
private long total; // 总记录数 |
||||
|
private int pageNum; // 当前页码 |
||||
|
private int pageSize; // 每页数量 |
||||
|
private int pages; // 总页数 |
||||
|
|
||||
|
// 可以从Page对象构造 |
||||
|
public static <T> PageInfo<T> of(Page<?> page, List<T> list) { |
||||
|
PageInfo<T> pageInfo = new PageInfo<>(); |
||||
|
pageInfo.setList(list); |
||||
|
pageInfo.setTotal(page.getTotal()); |
||||
|
pageInfo.setPageNum((int) page.getCurrent()); |
||||
|
pageInfo.setPageSize((int) page.getSize()); |
||||
|
pageInfo.setPages((int) page.getPages()); |
||||
|
return pageInfo; |
||||
|
} |
||||
|
} |
@ -0,0 +1,39 @@ |
|||||
|
package com.lottery.admin.controller; |
||||
|
|
||||
|
import com.lottery.admin.service.AdminPrizeService; |
||||
|
import com.lottery.result.Result; |
||||
|
import com.lottery.vo.PageInfo; |
||||
|
import com.lottery.vo.PrizeVo; |
||||
|
import org.slf4j.Logger; |
||||
|
import org.slf4j.LoggerFactory; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestParam; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
/** |
||||
|
* @program: lottery |
||||
|
* @ClassName AdminPrizeController |
||||
|
* @description: |
||||
|
* @author: wwl |
||||
|
* @create: 2025-07-15 10:06 |
||||
|
* @Version 1.0 |
||||
|
**/ |
||||
|
@RestController |
||||
|
@RequestMapping("/admin/prize") |
||||
|
public class AdminPrizeController { |
||||
|
|
||||
|
@Autowired |
||||
|
private AdminPrizeService adminPrizeService; |
||||
|
|
||||
|
private final static Logger LOGGER = LoggerFactory.getLogger(AdminPrizeController.class); |
||||
|
|
||||
|
@GetMapping("list") |
||||
|
public Result<PageInfo<PrizeVo>> listPrize(@RequestParam(defaultValue = "1") int pageNum, @RequestParam(defaultValue = "10") int pageSize) { |
||||
|
LOGGER.info("列分页查询l礼品表, 页码: {}, 每页大小: {}", pageNum, pageSize); |
||||
|
|
||||
|
PageInfo<PrizeVo> pageInfo = adminPrizeService.pageListPrize(pageNum, pageSize); |
||||
|
return Result.success(pageInfo); |
||||
|
} |
||||
|
} |
@ -0,0 +1,18 @@ |
|||||
|
package com.lottery.admin.service; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||
|
import com.lottery.entity.Prize; |
||||
|
import com.lottery.vo.PageInfo; |
||||
|
import com.lottery.vo.PrizeVo; |
||||
|
|
||||
|
/** |
||||
|
* @program: lottery |
||||
|
* @ClassName AdminPrizeService |
||||
|
* @description: |
||||
|
* @author: wwl |
||||
|
* @create: 2025-07-15 10:07 |
||||
|
* @Version 1.0 |
||||
|
**/ |
||||
|
public interface AdminPrizeService extends IService<Prize> { |
||||
|
PageInfo<PrizeVo> pageListPrize(int pageNum, int pageSize); |
||||
|
} |
@ -0,0 +1,50 @@ |
|||||
|
package com.lottery.admin.service.Impl; |
||||
|
|
||||
|
import ch.qos.logback.classic.spi.EventArgUtil; |
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
|
import com.lottery.admin.service.AdminPrizeService; |
||||
|
import com.lottery.api.mapper.IGradeMapper; |
||||
|
import com.lottery.api.mapper.IPrizeMapper; |
||||
|
import com.lottery.entity.Prize; |
||||
|
import com.lottery.utils.ConvertBeanUtil; |
||||
|
import com.lottery.vo.PageInfo; |
||||
|
import com.lottery.vo.PrizeVo; |
||||
|
import net.bytebuddy.implementation.auxiliary.AuxiliaryType; |
||||
|
import org.hibernate.engine.jdbc.connections.internal.ConnectionValidator; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.lang.module.Configuration; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @program: lottery |
||||
|
* @ClassName AdminPrizeServiceImpl |
||||
|
* @description: |
||||
|
* @author: wwl |
||||
|
* @create: 2025-07-15 10:07 |
||||
|
* @Version 1.0 |
||||
|
**/ |
||||
|
@Service |
||||
|
public class AdminPrizeServiceImpl extends ServiceImpl<IPrizeMapper, Prize> implements AdminPrizeService { |
||||
|
|
||||
|
@Autowired |
||||
|
private IGradeMapper gradeMapper; |
||||
|
|
||||
|
@Autowired |
||||
|
private IPrizeMapper prizeMapper; |
||||
|
|
||||
|
@Override |
||||
|
public PageInfo<PrizeVo> pageListPrize(int pageNum, int pageSize) { |
||||
|
Page<Prize> page = new Page<>(pageNum, pageSize); |
||||
|
|
||||
|
//关联grade查询sort,prize表也按照g.sort排序 |
||||
|
LambdaQueryWrapper<Prize> prizeLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
||||
|
Page<Prize> pagePrize = prizeMapper.pageListPrize(page, prizeLambdaQueryWrapper); |
||||
|
|
||||
|
List<PrizeVo> prizeVos = ConvertBeanUtil.convertList(pagePrize.getRecords(), PrizeVo.class); |
||||
|
return PageInfo.of(pagePrize, prizeVos); |
||||
|
} |
||||
|
} |
@ -0,0 +1,39 @@ |
|||||
|
package com.lottery.config; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.DbType; |
||||
|
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; |
||||
|
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; |
||||
|
import org.springframework.context.annotation.Bean; |
||||
|
import org.springframework.context.annotation.Configuration; |
||||
|
|
||||
|
import java.util.Collections; |
||||
|
|
||||
|
/** |
||||
|
* @Author idea |
||||
|
* @Date: Created in 18:56 2023/7/23 |
||||
|
* @Description |
||||
|
*/ |
||||
|
@Configuration |
||||
|
public class MybatisPageConfig { |
||||
|
|
||||
|
/** |
||||
|
* 分页插件 3.5.X |
||||
|
*/ |
||||
|
@Bean |
||||
|
public PaginationInnerInterceptor paginationInnerInterceptor() { |
||||
|
PaginationInnerInterceptor paginationInterceptor = new PaginationInnerInterceptor(); |
||||
|
// 设置最大单页限制数量,默认 500 条,-1 不受限制 |
||||
|
paginationInterceptor.setMaxLimit(1000L); |
||||
|
paginationInterceptor.setDbType(DbType.MYSQL); |
||||
|
// 开启 count 的 join 优化,只针对部分 left join |
||||
|
paginationInterceptor.setOptimizeJoin(true); |
||||
|
return paginationInterceptor; |
||||
|
} |
||||
|
|
||||
|
@Bean |
||||
|
public MybatisPlusInterceptor mybatisPlusInterceptor(){ |
||||
|
MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor(); |
||||
|
mybatisPlusInterceptor.setInterceptors(Collections.singletonList(paginationInnerInterceptor())); |
||||
|
return mybatisPlusInterceptor; |
||||
|
} |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue