src/main/java/com/smartearth/poiexcel/config/WebConfig.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/smartearth/poiexcel/controller/EntController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/smartearth/poiexcel/mapper/QiYeMapper.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/resources/mapper/QiYeMapper.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/smartearth/poiexcel/config/WebConfig.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,92 @@ package com.smartearth.poiexcel.config; import com.alibaba.fastjson.serializer.SerializerFeature; import com.alibaba.fastjson.support.config.FastJsonConfig; import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; import org.springframework.context.annotation.Configuration; import org.springframework.core.Ordered; import org.springframework.http.converter.HttpMessageConverter; import org.springframework.util.AntPathMatcher; import org.springframework.web.servlet.config.annotation.*; import java.nio.charset.StandardCharsets; import java.util.List; /** * Webé 置类 * @author WWW */ @Configuration public class WebConfig extends WebMvcConfigurationSupport { @Override public void addViewControllers(ViewControllerRegistry registry) { // 设置访é®è·¯å¾ä¸º â/â è·³è½¬å°æå®é¡µé¢ registry.addViewController("/").setViewName("redirect:/swagger-ui.html"); // 设置为æé«ä¼å 级 registry.setOrder(Ordered.HIGHEST_PRECEDENCE); } /** * swaggeræ§å¶ */ @Override protected void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/"); registry.addResourceHandler("/**").addResourceLocations("classpath:/static/"); super.addResourceHandlers(registry); } /** * 忽ç¥urlå°å大å°å */ @Override protected void configurePathMatch(PathMatchConfigurer configurer) { AntPathMatcher matcher = new AntPathMatcher(); matcher.setCaseSensitive(false); configurer.setPathMatcher(matcher); } /** * è·¨åè¯·æ± */ @Override protected void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") .allowCredentials(true) .allowedOrigins("*") .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") .allowedHeaders("*") .maxAge(3600); } /** * æ·»å ç»ä¸çæ¦æªå¨ */ @Override protected void addInterceptors(InterceptorRegistry registry) { super.addInterceptors(registry); } /** * å¤çjsonæ ¼å¼ï¼å¼nullç转æ¢ä¸º"" */ @Override public void configureMessageConverters(List<HttpMessageConverter<?>> converters) { FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter(); FastJsonConfig config = new FastJsonConfig(); config.setSerializerFeatures( SerializerFeature.WriteNullListAsEmpty, SerializerFeature.WriteMapNullValue, //SerializerFeature.WriteNullStringAsEmpty, SerializerFeature.WriteNullNumberAsZero, SerializerFeature.WriteNullBooleanAsFalse); // ç»ææ¯å¦æ ¼å¼å,é»è®¤ä¸ºfalse //SerializerFeature.PrettyFormat); converter.setFastJsonConfig(config); converter.setDefaultCharset(StandardCharsets.UTF_8); converters.add(converter); } } src/main/java/com/smartearth/poiexcel/controller/EntController.java
@@ -47,6 +47,21 @@ @Value("${address.code.url}") private String addressCodeUrl; @ApiOperation(value = "æ ¹æ®åç§°æ¨¡ç³æ¥è¯¢ä¼ä¸") @ApiImplicitParams({ @ApiImplicitParam(name = "name", value = "ä¼ä¸åç§°æå°å", dataType = "String", paramType = "query", example = "") }) @GetMapping({"/selectByName"}) public ResponseMsg<Object> selectByName(String name) { try { List<EntEntity> list = qiYeMapper.selectByName(StringHelper.getLikeStr(name)); return success(null == list ? 0 : list.size(), list); } catch (Exception ex) { return fail(ex, -1); } } @ApiOperation(value = "æ¥è¯¢ä»¤ç") @GetMapping({"/selectToken"}) public ResponseMsg<Object> selectToken() { @@ -59,7 +74,7 @@ } } @ApiOperation(value = "æ¥è¯¢ä¼ä¸") @ApiOperation(value = "æ¥è¯¢ä¼ä¸ä¿¡æ¯") @ApiImplicitParams({ @ApiImplicitParam(name = "token", value = "令ç", dataType = "String", paramType = "query", example = ""), @ApiImplicitParam(name = "startDate", value = "å¼å§æ¥æ", dataType = "String", paramType = "query", example = "2023-06-29"), @@ -130,7 +145,7 @@ } } @ApiOperation(value = "å页æ¥è¯¢") @ApiOperation(value = "å页æ¥è¯¢ä¼ä¸") @ApiImplicitParams({ @ApiImplicitParam(name = "pageSize", value = "æ¯é¡µæ¡æ°", dataType = "Integer", paramType = "query", example = "10"), @ApiImplicitParam(name = "pageIndex", value = "å页æ°ï¼ä»1å¼å§ï¼", dataType = "Integer", paramType = "query", example = "1") src/main/java/com/smartearth/poiexcel/mapper/QiYeMapper.java
@@ -15,6 +15,14 @@ @Repository public interface QiYeMapper { /** * æ ¹æ®åç§°æ¨¡ç³æ¥è¯¢ * * @param name * @return */ public List<EntEntity> selectByName(@Param("name") String name); /** * æ¥è¯¢è¡æ° * * @return src/main/resources/mapper/QiYeMapper.xml
@@ -1,6 +1,18 @@ <?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.smartearth.poiexcel.mapper.QiYeMapper"> <select id="selectByName" resultType="com.smartearth.poiexcel.entity.EntEntity"> select * from smart_earth.yz_qiyexinxi <where> <if test="name != null"> upper(entName) like #{name} or upper(address) like #{name} </if> </where> order by entName limit 10; </select> <select id="selectCount" resultType="java.lang.Integer"> select count(*) from smart_earth.yz_qiyexinxi