From ecad870fe1896c8c3e48506d50bb5818974253bf Mon Sep 17 00:00:00 2001 From: fangyuan <527392886@qq.com> Date: 星期一, 16 一月 2023 11:33:58 +0800 Subject: [PATCH] 机场公安前后端联调内容 --- ycl-common/src/main/java/com/ycl/config/WebConfig.java | 3 ycl-platform/src/main/java/com/ycl/controller/NewsDutyController.java | 3 ycl-platform/src/main/java/com/ycl/controller/NewsInformationController.java | 50 ++++--- ycl-platform/src/main/java/com/ycl/entity/NewsDuty.java | 3 ycl-platform/src/main/java/com/ycl/mapper/NewsInformationDao.java | 2 ycl-platform/src/main/resources/application-dev.yml | 8 + ycl-platform/src/main/java/com/ycl/controller/NewsColumnController.java | 17 + ycl-platform/src/main/java/com/ycl/entity/NewsAdmin.java | 2 ycl-platform/pom.xml | 101 +++++++------- ycl-platform/src/main/java/com/ycl/controller/NewsAdminController.java | 22 +++ pom.xml | 1 ycl-platform/src/main/java/com/ycl/dto/ColumnDto.java | 19 ++ ycl-platform/src/main/java/com/ycl/config/Intercept.java | 33 ++-- ycl-platform/src/main/resources/mapper/NewsInformationDao.xml | 25 +++ ycl-platform/src/main/java/com/ycl/config/WebMvcConfig.java | 8 ycl-platform/src/main/java/com/ycl/controller/NewsChannelController.java | 22 +- ycl-platform/src/main/java/com/ycl/config/PageHelperConfig.java | 32 ++++ ycl-platform/src/main/java/com/ycl/entity/NewsChannel.java | 11 - ycl-platform/src/main/java/com/ycl/controller/NewsDepartmentController.java | 3 ycl-platform/src/main/resources/application.yml | 3 ycl-platform/src/main/java/com/ycl/controller/NewsColumnInformationController.java | 41 +++++ ycl-platform/src/main/java/com/ycl/config/Knife4jSwaggerConfig.java | 2 ycl-platform/src/main/java/com/ycl/entity/NewsColumn.java | 1 23 files changed, 281 insertions(+), 131 deletions(-) diff --git a/pom.xml b/pom.xml index 7a7ae8b..3b32e6f 100644 --- a/pom.xml +++ b/pom.xml @@ -51,7 +51,6 @@ <modules> <module>ycl-platform</module> <module>ycl-common</module> -<!-- <module>ycl-generator</module>--> </modules> <dependencies> diff --git a/ycl-common/src/main/java/com/ycl/config/WebConfig.java b/ycl-common/src/main/java/com/ycl/config/WebConfig.java index f581c46..e2f3a65 100644 --- a/ycl-common/src/main/java/com/ycl/config/WebConfig.java +++ b/ycl-common/src/main/java/com/ycl/config/WebConfig.java @@ -23,7 +23,8 @@ // 鍏佽cookies璺ㄥ煙 config.setAllowCredentials(true); // #鍏佽鍚戣鏈嶅姟鍣ㄦ彁浜よ姹傜殑URI锛�*琛ㄧず鍏ㄩ儴鍏佽锛屽湪SpringMVC涓紝濡傛灉璁炬垚*锛屼細鑷姩杞垚褰撳墠璇锋眰澶翠腑鐨凮rigin - config.addAllowedOrigin("*"); +// config.addAllowedOrigin("*"); + config.addAllowedOriginPattern("*"); // #鍏佽璁块棶鐨勫ご淇℃伅,*琛ㄧず鍏ㄩ儴 config.addAllowedHeader("*"); // 棰勬璇锋眰鐨勭紦瀛樻椂闂达紙绉掞級锛屽嵆鍦ㄨ繖涓椂闂存閲岋紝瀵逛簬鐩稿悓鐨勮法鍩熻姹備笉浼氬啀棰勬浜� diff --git a/ycl-platform/pom.xml b/ycl-platform/pom.xml index 0a272ba..1687ccf 100644 --- a/ycl-platform/pom.xml +++ b/ycl-platform/pom.xml @@ -1,51 +1,50 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>com.ycl</groupId> - <artifactId>ycl-airport-server</artifactId> - <version>1.0-SNAPSHOT</version> - </parent> - - <groupId>com.ycl</groupId> - <artifactId>ycl-platform</artifactId> - <version>1.0.0</version> - <name>ycl-platform</name> - <description>鍚庣妯″潡</description> - - <properties> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - </properties> - - - <dependencies> - <dependency> - <groupId>com.ycl</groupId> - <artifactId>ycl-common</artifactId> - <version>1.0.0</version> - </dependency> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-test</artifactId> - <scope>test</scope> - </dependency> -<!-- <dependency>--> -<!-- <groupId>com.ycl</groupId>--> -<!-- <artifactId>ycl-generator</artifactId>--> -<!-- <version>1.0.0</version>--> -<!-- <scope>compile</scope>--> -<!-- </dependency>--> - </dependencies> - - <build> - <finalName>ycl-platform</finalName> - <plugins> - <plugin> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-maven-plugin</artifactId> - </plugin> - </plugins> - </build> - -</project> +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>com.ycl</groupId> + <artifactId>ycl-airport-server</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + + <groupId>com.ycl</groupId> + <artifactId>ycl-platform</artifactId> + <version>1.0.0</version> + <name>ycl-platform</name> + <description>鍚庣妯″潡</description> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + + <dependencies> + <dependency> + <groupId>com.ycl</groupId> + <artifactId>ycl-common</artifactId> + <version>1.0.0</version> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>com.github.pagehelper</groupId> + <artifactId>pagehelper</artifactId> + <version>4.1.6</version> + </dependency> + </dependencies> + + <build> + <finalName>ycl-platform</finalName> + <plugins> + <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + </plugin> + </plugins> + </build> + +</project> diff --git a/ycl-platform/src/main/java/com/ycl/config/Intercept.java b/ycl-platform/src/main/java/com/ycl/config/Intercept.java index b6887d1..3391fea 100644 --- a/ycl-platform/src/main/java/com/ycl/config/Intercept.java +++ b/ycl-platform/src/main/java/com/ycl/config/Intercept.java @@ -21,32 +21,31 @@ public class Intercept implements HandlerInterceptor { @Resource - NewsAdminService newsAdminService; - @Resource NewsIpService newsIpService; @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException { - List<String> ips = newsIpService.list().stream().map(item->item.getIpAddess()).collect(Collectors.toList()); - if (!ips.contains(request.getRemoteAddr())){ + List<String> ips = newsIpService.list().stream().map(item -> item.getIpAddess()).collect(Collectors.toList()); + if (!ips.contains(request.getRemoteAddr())) { return false; + } - String token = request.getHeader("token"); - JwtTokenUtil jwtTokenUtil = new JwtTokenUtil(); - if (token==null||token.isEmpty()){ +// String token = request.getHeader("token"); +// JwtTokenUtil jwtTokenUtil = new JwtTokenUtil(); +// if (token==null||token.isEmpty()){ // response.sendRedirect(""); // return true; - throw new ApiException("鐢ㄦ埛鏈櫥褰�"); - } - AuthInfo authInfo = jwtTokenUtil.parseToken(token); - if (authInfo == null) { - throw new ApiException("鏈璇佺敤鎴�"); - } - if (newsAdminService.getOne(new LambdaQueryWrapper<NewsAdmin>().eq(NewsAdmin::getUsername, authInfo.getUsername())) == null) { - throw new ApiException("涓嶆槸绯荤粺鐢ㄦ埛"); - } else { +// throw new ApiException("鐢ㄦ埛鏈櫥褰�"); +// } +// AuthInfo authInfo = jwtTokenUtil.parseToken(token); +// if (authInfo == null) { +// throw new ApiException("鏈璇佺敤鎴�"); +// } +// if (newsAdminService.getOne(new LambdaQueryWrapper<NewsAdmin>().eq(NewsAdmin::getUsername, authInfo.getUsername())) == null) { +// throw new ApiException("涓嶆槸绯荤粺鐢ㄦ埛"); +// } else { return true; - } +// } } diff --git a/ycl-platform/src/main/java/com/ycl/config/Knife4jSwaggerConfig.java b/ycl-platform/src/main/java/com/ycl/config/Knife4jSwaggerConfig.java index c105502..dec1e73 100644 --- a/ycl-platform/src/main/java/com/ycl/config/Knife4jSwaggerConfig.java +++ b/ycl-platform/src/main/java/com/ycl/config/Knife4jSwaggerConfig.java @@ -38,7 +38,7 @@ return new ApiInfoBuilder() .title("鏈哄満鍏畨鏂囨。绠$悊绯荤粺") .description("鏈哄満鍏畨鍚庡彴妯″潡") - .version("1.0").contact(new Contact("lyq",null,null)) + .version("1.0").contact(new Contact("fy",null,null)) .build(); } diff --git a/ycl-platform/src/main/java/com/ycl/config/PageHelperConfig.java b/ycl-platform/src/main/java/com/ycl/config/PageHelperConfig.java new file mode 100644 index 0000000..7dc4bc6 --- /dev/null +++ b/ycl-platform/src/main/java/com/ycl/config/PageHelperConfig.java @@ -0,0 +1,32 @@ +package com.ycl.config; + +import com.github.pagehelper.PageHelper; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.util.Properties; + +/*** + * 鍒嗛〉閰嶇疆 + * @author:lcj + */ +@Configuration +public class PageHelperConfig { + + /** + * 閰嶇疆mybatis鐨勫垎椤垫彃浠秔ageHelper + * + * @return + */ + @Bean + public PageHelper pageHelper() { + PageHelper pageHelper = new PageHelper(); + Properties properties = new Properties(); + properties.setProperty("offsetAsPageNum", "true"); + properties.setProperty("rowBoundsWithCount", "true"); + properties.setProperty("reasonable", "true"); + properties.setProperty("dialect", "postgresql");//閰嶇疆postgresql鏁版嵁搴撶殑鏂硅█鏀寔Oracle,Mysql,MariaDB,SQLite,Hsqldb,PostgreSQL鍏鏁版嵁搴� + pageHelper.setProperties(properties); + return pageHelper; + } +} \ No newline at end of file diff --git a/ycl-platform/src/main/java/com/ycl/config/WebMvcConfig.java b/ycl-platform/src/main/java/com/ycl/config/WebMvcConfig.java index 44ad238..02b825a 100644 --- a/ycl-platform/src/main/java/com/ycl/config/WebMvcConfig.java +++ b/ycl-platform/src/main/java/com/ycl/config/WebMvcConfig.java @@ -19,9 +19,9 @@ @Override public void addInterceptors(InterceptorRegistry registry) { - registry.addInterceptor(this.Intercept()) - //闇�瑕侀獙璇佽姹傝矾寰� /*浠h〃鍏ㄩ儴 - .addPathPatterns("/*") - .excludePathPatterns(urlsConfig.getUrls()); + registry.addInterceptor(this.Intercept()); +// 闇�瑕侀獙璇佽姹傝矾寰� /*浠h〃鍏ㄩ儴 +// .addPathPatterns("/*") +// .excludePathPatterns(urlsConfig.getUrls()); } } diff --git a/ycl-platform/src/main/java/com/ycl/controller/NewsAdminController.java b/ycl-platform/src/main/java/com/ycl/controller/NewsAdminController.java index 1fd419a..708c2ae 100644 --- a/ycl-platform/src/main/java/com/ycl/controller/NewsAdminController.java +++ b/ycl-platform/src/main/java/com/ycl/controller/NewsAdminController.java @@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.api.ApiController; import com.baomidou.mybatisplus.extension.api.R; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.github.pagehelper.PageHelper; import com.ycl.api.CommonResult; import com.ycl.entity.NewsAdmin; import com.ycl.pojo.dto.LoginParam; @@ -50,8 +51,25 @@ } else { if (admin.getPassword().equals(MD5Util.md5Encrypt32Lower(loginParam.getPassword()))) { JwtTokenUtil jwtTokenUtil = new JwtTokenUtil(); - return CommonResult.success(jwtTokenUtil.generateToken(admin.getId(), admin.getUsername())); + } else { + return CommonResult.failed("瀵嗙爜閿欒"); + } + } + } + + @PostMapping("/login/reception") + @ApiOperation(value = "鍓嶅彴鐧诲綍") + @SneakyThrows + public CommonResult Reception(@RequestBody LoginParam loginParam) { + NewsAdmin admin = newsAdminService.getOne(new LambdaQueryWrapper<NewsAdmin>().eq(NewsAdmin::getUsername, loginParam.getUsername())); + if (admin == null) { + return CommonResult.failed("鐢ㄦ埛涓嶅瓨鍦�"); + } else { + if (admin.getPassword().equals(MD5Util.md5Encrypt32Lower(loginParam.getPassword()))) { + + + return CommonResult.success(admin.getNewsPoliceId()); } else { return CommonResult.failed("瀵嗙爜閿欒"); } @@ -67,6 +85,8 @@ @GetMapping @ApiOperation(value = "鏌ヨ鎵�鏈夋暟鎹�") public R selectAll(Page<NewsAdmin> page, NewsAdmin newsAdmin) { + page.setTotal(newsAdminService.count()); + PageHelper.startPage(new Long(page.getCurrent()).intValue(),new Long(page.getSize()).intValue()); return success(this.newsAdminService.page(page, new QueryWrapper<>(newsAdmin))); } diff --git a/ycl-platform/src/main/java/com/ycl/controller/NewsChannelController.java b/ycl-platform/src/main/java/com/ycl/controller/NewsChannelController.java index 070ef4e..fc86ef8 100644 --- a/ycl-platform/src/main/java/com/ycl/controller/NewsChannelController.java +++ b/ycl-platform/src/main/java/com/ycl/controller/NewsChannelController.java @@ -35,8 +35,6 @@ @Resource private NewsChannelService newsChannelService; - @Autowired - private NewsChannelColumnService newsChannelColumnService; /** * 鍒嗛〉鏌ヨ鎵�鏈夋暟鎹� @@ -55,11 +53,11 @@ * @param id 涓婚敭 * @return 鍗曟潯鏁版嵁 */ - @GetMapping("{id}") - @ApiOperation(value = "鎸塱d鏌ヨ鏁版嵁") - public R selectOne(@PathVariable Serializable id) { - return success(this.newsChannelService.getById(id)); - } +// @GetMapping("{id}") +// @ApiOperation(value = "鎸塱d鏌ヨ鏁版嵁") +// public R selectOne(@PathVariable Serializable id) { +// return success(this.newsChannelService.getById(id)); +// } /** * 鏂板鏁版嵁 @@ -71,8 +69,8 @@ @ApiOperation(value = "鏂板鏁版嵁") public R insert(@RequestBody NewsChannel newsChannel) { int result = this.newsChannelService.insertOneChannel(newsChannel); - List<String> columnId = newsChannel.getColumnId(); - columnId.stream().forEach(item->newsChannelColumnService.save(NewsChannelColumn.builder().channelId(newsChannel.getId()).columnId(Integer.parseInt(item)).build())); +// List<String> columnId = newsChannel.getColumnId(); +// columnId.stream().forEach(item->newsChannelColumnService.save(NewsChannelColumn.builder().channelId(newsChannel.getId()).columnId(Integer.parseInt(item)).build())); return success(result); } @@ -85,9 +83,9 @@ @PutMapping @ApiOperation(value = "淇敼鏁版嵁") public R update(@RequestBody NewsChannel newsChannel) { - List<String> columnId = newsChannel.getColumnId(); - newsChannelColumnService.remove(new QueryWrapper<NewsChannelColumn>().eq("channel_id",newsChannel.getId())); - columnId.stream().forEach(item->newsChannelColumnService.save(NewsChannelColumn.builder().channelId(newsChannel.getId()).columnId(Integer.parseInt(item)).build())); +// List<String> columnId = newsChannel.getColumnId(); +// newsChannelColumnService.remove(new QueryWrapper<NewsChannelColumn>().eq("channel_id",newsChannel.getId())); +// columnId.stream().forEach(item->newsChannelColumnService.save(NewsChannelColumn.builder().channelId(newsChannel.getId()).columnId(Integer.parseInt(item)).build())); return success(this.newsChannelService.updateById(newsChannel)); } diff --git a/ycl-platform/src/main/java/com/ycl/controller/NewsColumnController.java b/ycl-platform/src/main/java/com/ycl/controller/NewsColumnController.java index 716e22b..973c586 100644 --- a/ycl-platform/src/main/java/com/ycl/controller/NewsColumnController.java +++ b/ycl-platform/src/main/java/com/ycl/controller/NewsColumnController.java @@ -6,11 +6,14 @@ import com.baomidou.mybatisplus.extension.api.ApiController; import com.baomidou.mybatisplus.extension.api.R; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.ycl.entity.NewsChannel; +import com.ycl.dto.ColumnDto; +import com.ycl.entity.NewsChannelColumn; import com.ycl.entity.NewsColumn; +import com.ycl.service.NewsChannelColumnService; import com.ycl.service.NewsColumnService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -32,6 +35,9 @@ */ @Resource private NewsColumnService newsColumnService; + + @Autowired + private NewsChannelColumnService newsChannelColumnService; /** * 鍒嗛〉鏌ヨ鎵�鏈夋暟鎹� @@ -61,13 +67,16 @@ /** * 鏂板鏁版嵁 * - * @param newsColumn 瀹炰綋瀵硅薄 + * @param columnDto 瀹炰綋瀵硅薄 * @return 鏂板缁撴灉 */ @PostMapping @ApiOperation(value = "鏂板鏁版嵁") - public R insert(@RequestBody NewsColumn newsColumn) { - return success(this.newsColumnService.save(newsColumn)); + public R insert(@RequestBody ColumnDto columnDto) { + List<String> columnId = columnDto.getChannelId(); + this.newsColumnService.save(columnDto.getNewsColumn()); + columnId.stream().forEach(item->newsChannelColumnService.save(NewsChannelColumn.builder().channelId(Integer.parseInt(item)).columnId(columnDto.getNewsColumn().getId()).build())); + return success(columnDto).setMsg("鎵ц鎴愬姛"); } /** diff --git a/ycl-platform/src/main/java/com/ycl/controller/NewsColumnInformationController.java b/ycl-platform/src/main/java/com/ycl/controller/NewsColumnInformationController.java index 3602d24..538a5f9 100644 --- a/ycl-platform/src/main/java/com/ycl/controller/NewsColumnInformationController.java +++ b/ycl-platform/src/main/java/com/ycl/controller/NewsColumnInformationController.java @@ -3,13 +3,17 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.api.ApiController; import com.baomidou.mybatisplus.extension.api.R; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; import com.ycl.entity.NewsColumnInformation; import com.ycl.entity.NewsInformation; import com.ycl.service.NewsColumnInformationService; import com.ycl.service.NewsInformationService; +import com.ycl.vo.depart.UmsDepartVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; @@ -18,7 +22,10 @@ import javax.annotation.Resource; import java.io.Serializable; import java.util.ArrayList; +import java.util.Collections; import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; /** * 鏍忕洰鍜ㄨ涓棿琛�(NewsColumnInformation)琛ㄦ帶鍒跺眰 @@ -106,13 +113,39 @@ * @return 璧勮鏌ヨ缁撴灉 */ @GetMapping("column/{id}") - @ApiOperation(value = "鎸�") - public R selectInformationByColumnId(@PathVariable Serializable id) { + @ApiOperation(value = "鎸夋爮鐩甶d鏌ヨ璁伅") + public R selectInformationByColumnId(@PathVariable Serializable id ,@RequestParam(value = "pageNum", required = false,defaultValue = "1")Integer pageNum,@RequestParam(value = "pageSize", required = false,defaultValue = "10")Integer pageSize) { List<NewsColumnInformation> newsColumnInformationList = newsColumnInformationService.list(new QueryWrapper<NewsColumnInformation>().eq("column_id", id)); List<NewsInformation> resultList=new ArrayList<>(); + IPage<NewsInformation> page = new Page<>(pageNum, pageSize); for (NewsColumnInformation newsColumnInformation:newsColumnInformationList){ resultList.add(newsInformationService.selectInformationById(newsColumnInformation.getInformationId())); } - return success(resultList); - }} + page.setTotal(resultList.size()); + if (pageSize>resultList.size()){ + page.setRecords(resultList); + } + else { + List<List<NewsInformation>> lists = split8(resultList, pageSize); + page.setRecords(lists.get(pageNum-1)); + } + return success(page); + } + + public static <T> List<List<T>> split8(List<T> list,int splitSize){ + // 姣忎唤涓暟 splitSize + if( null == list || list.isEmpty() ){ return Collections.emptyList(); } + // 鍒楄〃鍏冪礌鏁帮紝鎬讳唤鏁� + int size = list.size(), cnt = (size + splitSize - 1 ) / splitSize; + return Stream + .iterate(0,i -> i+1 ) + .limit(cnt) + .parallel() + .map(i -> list.parallelStream().skip( i * splitSize ).limit(splitSize).collect(Collectors.toList())) + .filter(a -> !a.isEmpty()) + .collect(Collectors.toList()); + } + + +} diff --git a/ycl-platform/src/main/java/com/ycl/controller/NewsDepartmentController.java b/ycl-platform/src/main/java/com/ycl/controller/NewsDepartmentController.java index 4468ebe..f03f7b9 100644 --- a/ycl-platform/src/main/java/com/ycl/controller/NewsDepartmentController.java +++ b/ycl-platform/src/main/java/com/ycl/controller/NewsDepartmentController.java @@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.api.ApiController; import com.baomidou.mybatisplus.extension.api.R; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.github.pagehelper.PageHelper; import com.ycl.entity.NewsDepartment; import com.ycl.service.NewsDepartmentService; import io.swagger.annotations.Api; @@ -42,6 +43,8 @@ @GetMapping @ApiOperation(value = "鏌ヨ鎵�鏈夋暟鎹�") public R selectAll(Page<NewsDepartment> page, NewsDepartment newsDepartment) { + page.setTotal(newsDepartmentService.count()); + PageHelper.startPage(new Long(page.getCurrent()).intValue(),new Long(page.getSize()).intValue()); return success(this.newsDepartmentService.page(page, new QueryWrapper<>(newsDepartment))); } diff --git a/ycl-platform/src/main/java/com/ycl/controller/NewsDutyController.java b/ycl-platform/src/main/java/com/ycl/controller/NewsDutyController.java index 0f7d55f..3f4e10d 100644 --- a/ycl-platform/src/main/java/com/ycl/controller/NewsDutyController.java +++ b/ycl-platform/src/main/java/com/ycl/controller/NewsDutyController.java @@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.api.ApiController; import com.baomidou.mybatisplus.extension.api.R; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.github.pagehelper.PageHelper; import com.ycl.entity.NewsDuty; import com.ycl.service.NewsDutyService; import io.swagger.annotations.Api; @@ -42,6 +43,8 @@ @GetMapping @ApiOperation(value = "鏌ヨ鎵�鏈夋暟鎹�") public R selectAll(Page<NewsDuty> page, NewsDuty newsDuty) { + page.setTotal(newsDutyService.count()); + PageHelper.startPage(new Long(page.getCurrent()).intValue(),new Long(page.getSize()).intValue()); return success(this.newsDutyService.page(page, new QueryWrapper<>(newsDuty))); } diff --git a/ycl-platform/src/main/java/com/ycl/controller/NewsInformationController.java b/ycl-platform/src/main/java/com/ycl/controller/NewsInformationController.java index bc16c12..48c451a 100644 --- a/ycl-platform/src/main/java/com/ycl/controller/NewsInformationController.java +++ b/ycl-platform/src/main/java/com/ycl/controller/NewsInformationController.java @@ -68,8 +68,8 @@ */ @GetMapping("{id}") @ApiOperation(value = "鎸塱d鏌ヨ鏁版嵁") - public R selectOne(@PathVariable Serializable id) { - return success(this.newsInformationService.getById(id)); + public R selectOne(@PathVariable Integer id) { + return success(this.newsInformationService.selectInformationById(id)); } /** @@ -114,25 +114,27 @@ @ApiOperation(value = "淇敼鏁版嵁") @Transactional public R update(@RequestBody NewsInformation newsInformation) { - Integer informationId = newsInformation.getId(); - if (newsInformation.getIsSign()==0){ - newsInformationPoliceService.remove(new QueryWrapper<NewsInformationPolice>().eq("news_information_id",informationId)); - List<String> departmentIds = newsInformation.getDepartmentId(); - for (String departmentId:departmentIds){ - QueryWrapper<NewsPolice> wrapper = new QueryWrapper(); - wrapper.eq("news_department_id",departmentId); - List<NewsPolice> list = policeService.list(wrapper); - if (!list.isEmpty()){ - for (NewsPolice newsPolice:list){ - newsInformationPoliceService.save(NewsInformationPolice.builder().newsPoliceId(newsPolice.getId()).newsInformationId(informationId).isSign(0).build()); - } - } - } - } - newsColumnInformationService.remove(new QueryWrapper<NewsColumnInformation>().eq("information_id",informationId)); - for (String columnId:newsInformation.getColumnId()){ - newsColumnInformationService.save(NewsColumnInformation.builder().columnId(Integer.parseInt(columnId)).informationId(informationId).build()); - } +// Integer informationId = newsInformation.getId(); +// if (newsInformation.getIsSign()==0){ +// newsInformationPoliceService.remove(new QueryWrapper<NewsInformationPolice>().eq("news_information_id",informationId)); +// List<String> departmentIds = newsInformation.getDepartmentId(); +// for (String departmentId:departmentIds){ +// QueryWrapper<NewsPolice> wrapper = new QueryWrapper(); +// wrapper.eq("news_department_id",departmentId); +// List<NewsPolice> list = policeService.list(wrapper); +// if (!list.isEmpty()){ +// for (NewsPolice newsPolice:list){ +// newsInformationPoliceService.save(NewsInformationPolice.builder().newsPoliceId(newsPolice.getId()).newsInformationId(informationId).isSign(0).build()); +// } +// } +// } +// } +// newsColumnInformationService.remove(new QueryWrapper<NewsColumnInformation>().eq("information_id",informationId)); +// for (String columnId:newsInformation.getColumnId()){ +// newsColumnInformationService.save(NewsColumnInformation.builder().columnId(Integer.parseInt(columnId)).informationId(informationId).build()); +// } + +// return success(this.newsInformationService.updateInformationById(newsInformation)); return success(this.newsInformationService.updateInformationById(newsInformation)); } @@ -145,6 +147,12 @@ @DeleteMapping @ApiOperation(value = "鍒犻櫎鏁版嵁") public R delete(@RequestParam("idList") List<Long> idList) { + if (idList==null||idList.size()==0){ + return failed("璇烽�夋嫨涓�涓埞杞﹀啘鎴峰璞�"); + } + for (long id:idList){ + newsColumnInformationService.remove(new QueryWrapper<NewsColumnInformation>().eq("information_id",id)); + } return success(this.newsInformationService.removeByIds(idList)); } } diff --git a/ycl-platform/src/main/java/com/ycl/dto/ColumnDto.java b/ycl-platform/src/main/java/com/ycl/dto/ColumnDto.java new file mode 100644 index 0000000..5f296e9 --- /dev/null +++ b/ycl-platform/src/main/java/com/ycl/dto/ColumnDto.java @@ -0,0 +1,19 @@ +package com.ycl.dto; + +import com.ycl.entity.NewsColumn; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; +@Getter +@Setter +public class ColumnDto { + //棰戦亾id + @ApiModelProperty("棰戦亾id") + private List<String> channelId; + + //鏍忕洰瀹炰綋绫� + @ApiModelProperty("鏍忕洰瀹炰綋绫�") + private NewsColumn newsColumn; +} diff --git a/ycl-platform/src/main/java/com/ycl/entity/NewsAdmin.java b/ycl-platform/src/main/java/com/ycl/entity/NewsAdmin.java index f3cfdbe..136a384 100644 --- a/ycl-platform/src/main/java/com/ycl/entity/NewsAdmin.java +++ b/ycl-platform/src/main/java/com/ycl/entity/NewsAdmin.java @@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.extension.activerecord.Model; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import java.io.Serializable; @@ -35,6 +36,7 @@ private String note; //鍒涘缓鏃堕棿 @ApiModelProperty("鍒涘缓鏃堕棿") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date createTime; //甯愬彿鍚敤鐘舵�侊細0->绂佺敤锛�1->鍚敤 @ApiModelProperty("甯愬彿鍚敤鐘舵��") diff --git a/ycl-platform/src/main/java/com/ycl/entity/NewsChannel.java b/ycl-platform/src/main/java/com/ycl/entity/NewsChannel.java index fa66012..654b347 100644 --- a/ycl-platform/src/main/java/com/ycl/entity/NewsChannel.java +++ b/ycl-platform/src/main/java/com/ycl/entity/NewsChannel.java @@ -30,17 +30,6 @@ @ApiModelProperty("鍒涘缓鏃堕棿") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date createTime; - //鏍忕洰id - @ApiModelProperty("鏍忕洰id") - private List<String> columnId; - - public List<String> getColumnId() { - return columnId; - } - - public void setColumnId(List<String> columnId) { - this.columnId = columnId; - } public Integer getId() { return id; diff --git a/ycl-platform/src/main/java/com/ycl/entity/NewsColumn.java b/ycl-platform/src/main/java/com/ycl/entity/NewsColumn.java index fcebcf0..7ee34bb 100644 --- a/ycl-platform/src/main/java/com/ycl/entity/NewsColumn.java +++ b/ycl-platform/src/main/java/com/ycl/entity/NewsColumn.java @@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty; import java.io.Serializable; +import java.util.List; /** * 鏍忕洰琛�(NewsColumn)琛ㄥ疄浣撶被 diff --git a/ycl-platform/src/main/java/com/ycl/entity/NewsDuty.java b/ycl-platform/src/main/java/com/ycl/entity/NewsDuty.java index 7037114..e4b0452 100644 --- a/ycl-platform/src/main/java/com/ycl/entity/NewsDuty.java +++ b/ycl-platform/src/main/java/com/ycl/entity/NewsDuty.java @@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.extension.activerecord.Model; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import java.io.Serializable; @@ -25,9 +26,11 @@ private String jobTitle; //鍒涘缓鏃堕棿 @ApiModelProperty("鍒涘缓鏃堕棿") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date createTime; //鍊肩彮鏃堕棿 @ApiModelProperty("鍊肩彮鏃ユ湡") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date dutyTime; diff --git a/ycl-platform/src/main/java/com/ycl/mapper/NewsInformationDao.java b/ycl-platform/src/main/java/com/ycl/mapper/NewsInformationDao.java index 76cc06a..51b8ca6 100644 --- a/ycl-platform/src/main/java/com/ycl/mapper/NewsInformationDao.java +++ b/ycl-platform/src/main/java/com/ycl/mapper/NewsInformationDao.java @@ -38,5 +38,7 @@ List<NewsInformation> selectAllInformation(); int updateInformationById(@Param("entity") NewsInformation entity); + + } diff --git a/ycl-platform/src/main/resources/application-dev.yml b/ycl-platform/src/main/resources/application-dev.yml index 7551e16..334a160 100644 --- a/ycl-platform/src/main/resources/application-dev.yml +++ b/ycl-platform/src/main/resources/application-dev.yml @@ -1,5 +1,5 @@ server: - port: 8082 + port: 8099 tomcat: uri-encoding: UTF-8 servlet: @@ -53,6 +53,12 @@ testOnReturn: false poolPreparedStatements: true maxOpenPreparedStatements: 20 + #閰嶇疆pageHelper + pageHelper: + reasonable: "true" + supportMethodsArguments: "true" + returnPageInfo: check + params: count=countSql #e-mail: # sendHost: smtp.qq.com # username: 1723292425@qq.com diff --git a/ycl-platform/src/main/resources/application.yml b/ycl-platform/src/main/resources/application.yml index d44ab8a..d7d28ea 100644 --- a/ycl-platform/src/main/resources/application.yml +++ b/ycl-platform/src/main/resources/application.yml @@ -73,4 +73,5 @@ - /**/*.js - /**/*.css - /**/*.png - - /newsAdmin/login + - /**/*.ico +# - /newsAdmin/login diff --git a/ycl-platform/src/main/resources/mapper/NewsInformationDao.xml b/ycl-platform/src/main/resources/mapper/NewsInformationDao.xml index a2921bd..c51a481 100644 --- a/ycl-platform/src/main/resources/mapper/NewsInformationDao.xml +++ b/ycl-platform/src/main/resources/mapper/NewsInformationDao.xml @@ -45,7 +45,30 @@ </select> <update id="updateInformationById" parameterType="com.ycl.entity.NewsInformation"> - update news_information set title=#{entity.title},content=#{entity.content},publish_time=#{entity.publishTime}, is_sign=#{entity.isSign}, create_time=#{entity.createTime}, send_to=#{entity.sendTo}, image_url=#{entity.imageUrl} + update news_information + <trim prefix="set" suffixOverrides=","> + <if test="entity.title!=null and entity.title!=''"> + title=#{entity.title}, + </if> + <if test="entity.content!=null and entity.content!=''"> + content=#{entity.content}, + </if> + <if test="entity.publishTime!=null "> + publish_time=#{entity.publishTime}, + </if> + <if test="entity.isSign!=null and entity.isSign!=''"> + is_sign=#{entity.isSign}, + </if> + <if test="entity.createTime!=null "> + create_time=#{entity.createTime}, + </if> + <if test="entity.sendTo!=null and entity.sendTo!=''"> + send_to=#{entity.sendTo}, + </if> + <if test="entity.imageUrl!=null and entity.imageUrl!=''"> + image_url=#{entity.imageUrl}, + </if> + </trim> where id=#{entity.id} </update> </mapper> -- Gitblit v1.8.0