打卡12

所花时间(包括上课):

 2h

代码量(行):

 150左右

搏客量(篇):

 1

了解到的知识点:

spring boot

备注(其他):

 
package com.leap.jixianceshiboot.controller;

import com.leap.jixianceshiboot.entity.Policy;
import com.leap.jixianceshiboot.entity.PolicyTypeCount;
import com.leap.jixianceshiboot.service.PolicyQueryService;
import com.leap.jixianceshiboot.util.PageBean;
import com.leap.jixianceshiboot.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/policyQuery")
@CrossOrigin
public class PolicyQueryController {
@Autowired
private PolicyQueryService policyQueryService;



@GetMapping
public Result<PageBean<Policy>> getPolicy(
Integer pageNum,
Integer pageSize,
@RequestParam(required = false) String name,
@RequestParam(required = false) String document,
@RequestParam(required = false) String organ,
@RequestParam(required = false) String text
){
PageBean<Policy> pageBean = policyQueryService.getPolicy(pageNum, pageSize, name, document, organ, text);
return Result.success(pageBean);
}
@GetMapping("/types")
public ResponseEntity<List<PolicyTypeCount>> getPolicyCountByTypes() {
List<PolicyTypeCount> counts = policyQueryService.getPolicyCountsByType();
return ResponseEntity.ok(counts);
}

@GetMapping("/Get")
public Result<PageBean<Policy>> GetPolicy1(
@RequestParam(required = false) String type
){
Integer pageNum = 1;
Integer pageSize = 8;
PageBean<Policy> pageBean = policyQueryService.getPolicy1(pageNum, pageSize, type);
return Result.success(pageBean);
}


//获取当前库中所有的政策信息
@GetMapping("getAll")
public List<Policy> getAll(){
return policyQueryService.getAll();
}
//根据名字中的关键字模糊查询
@GetMapping("/query")
public List<Policy> queryPolicy(@RequestParam(required = false) String name){
List<Policy> result = policyQueryService.queryPolicy(name);
return result;
}

}
<?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.leap.jixianceshiboot.mapper.PolicyQueryMapper">
<!--动态sql-->
<select id="getPolicy" resultType="com.leap.jixianceshiboot.entity.Policy">
select * from policy
<where>
<if test="name!=null">
name like CONCAT('%', #{name}, '%')
</if>

<if test="document!=null">
and document=#{document}
</if>

<if test="organ!=null">
and organ=#{organ}
</if>

<if test="text!=null">
and text like CONCAT('%', #{text}, '%')
</if>
</where>
</select>

<select id="findPolicyCountsByType" resultType="com.leap.jixianceshiboot.entity.PolicyTypeCount">
SELECT type, COUNT(*) as count
FROM policy
GROUP BY type
</select>

<select id="getPolicy1" resultType="com.leap.jixianceshiboot.entity.Policy">
select * from policy where type = #{type}
</select>
<select id="queryPolicy" resultType="com.leap.jixianceshiboot.entity.Policy">
SELECT * FROM policy WHERE name LIKE CONCAT('%', #{name}, '%');
</select>
<select id="getAll" resultType="com.leap.jixianceshiboot.entity.Policy">
select * from policy
</select>


</mapper>
posted @   平安喜乐×  阅读(2)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
· SQL Server 2025 AI相关能力初探
· 为什么 退出登录 或 修改密码 无法使 token 失效
点击右上角即可分享
微信分享提示