fangyuan
2022-11-21 c435158ed1ff587939314e84347ee6e38e8f25ec
接口调整及文件上传接口
31个文件已修改
1个文件已添加
4 文件已重命名
1个文件已删除
479 ■■■■ 已修改文件
.idea/compiler.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-common/src/main/java/com/ycl/bo/AdminUserDetails.java 66 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-platform/src/main/java/com/ycl/config/WebMvcConfig.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-platform/src/main/java/com/ycl/controller/ImageUploadController.java 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-platform/src/main/java/com/ycl/controller/NewsAdminController.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-platform/src/main/java/com/ycl/controller/NewsChannelColumnController.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-platform/src/main/java/com/ycl/controller/NewsChannelController.java 29 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-platform/src/main/java/com/ycl/controller/NewsColumnController.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-platform/src/main/java/com/ycl/controller/NewsColumnInformationController.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-platform/src/main/java/com/ycl/controller/NewsDepartmentController.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-platform/src/main/java/com/ycl/controller/NewsDutyController.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-platform/src/main/java/com/ycl/controller/NewsInformationController.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-platform/src/main/java/com/ycl/controller/NewsInformationPoliceController.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-platform/src/main/java/com/ycl/controller/NewsPoliceController.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-platform/src/main/java/com/ycl/entity/NewsChannel.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-platform/src/main/java/com/ycl/entity/NewsChannelColumn.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-platform/src/main/java/com/ycl/mapper/NewsChannelDao.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-platform/src/main/java/com/ycl/mapper/NewsInformationDao.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-platform/src/main/java/com/ycl/service/NewsChannelService.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-platform/src/main/java/com/ycl/service/NewsInformationService.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-platform/src/main/java/com/ycl/service/impl/NewsAdminServiceImpl.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-platform/src/main/java/com/ycl/service/impl/NewsChannelServiceImpl.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-platform/src/main/java/com/ycl/service/impl/NewsInformationServiceImpl.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-platform/src/main/resources/application-dev.yml 46 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-platform/src/main/resources/application.yml 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-platform/src/main/resources/mapper/NewsAdminDao.xml 补丁 | 查看 | 原始文档 | blame | 历史
ycl-platform/src/main/resources/mapper/NewsChannelColumnDao.xml 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-platform/src/main/resources/mapper/NewsChannelDao.xml 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-platform/src/main/resources/mapper/NewsColumnInformationDao.xml 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-platform/src/main/resources/mapper/NewsDepartmentDao.xml 补丁 | 查看 | 原始文档 | blame | 历史
ycl-platform/src/main/resources/mapper/NewsInformationDao.xml 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-platform/src/main/resources/mapper/NewsInformationPoliceDao.xml 补丁 | 查看 | 原始文档 | blame | 历史
ycl-platform/src/main/resources/mapper/NewsPoliceDao.xml 补丁 | 查看 | 原始文档 | blame | 历史
ycl-platform/target/classes/mapper/NewsChannelColumnDao.xml 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-platform/target/classes/mapper/NewsChannelDao.xml 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-platform/target/classes/mapper/NewsColumnInformationDao.xml 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-platform/target/classes/mapper/NewsInformationDao.xml 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.idea/compiler.xml
@@ -7,8 +7,8 @@
        <sourceOutputDir name="target/generated-sources/annotations" />
        <sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
        <outputRelativeToContentRoot value="true" />
        <module name="ycl-common" />
        <module name="ycl-platform" />
        <module name="ycl-common" />
      </profile>
    </annotationProcessing>
  </component>
ycl-common/src/main/java/com/ycl/bo/AdminUserDetails.java
File was deleted
ycl-platform/src/main/java/com/ycl/config/WebMvcConfig.java
@@ -17,6 +17,6 @@
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(this.Intercept())
                //需要验证请求路径 /*代表全部
                .addPathPatterns("/newsAdmin/text");
                .addPathPatterns("/newsAdmin/login");
    }
}
ycl-platform/src/main/java/com/ycl/controller/ImageUploadController.java
New file
@@ -0,0 +1,55 @@
package com.ycl.controller;
import com.ycl.api.CommonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.io.IOUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;
@RestController
@RequestMapping("upload")
@Api(tags = "图片上传")
public class ImageUploadController {
    @ApiOperation(value="上传图片")
    @RequestMapping(value = "/image", method = RequestMethod.POST)
    public CommonResult uploadImage(HttpServletRequest request, MultipartFile image) throws IOException {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        String filePath = "/images/" + sdf.format(new Date());
        String imageFolderPath = request.getServletContext().getRealPath(filePath);
        File imageFolder = new File(imageFolderPath);
        if (!imageFolder.exists()) {
            imageFolder.mkdirs();
        }
        StringBuilder imageUrl= new StringBuilder();
        imageUrl.append(request.getScheme())
                .append("://")
                .append(request.getServerName())
                .append(":")
                .append(request.getServerPort())
                .append(request.getContextPath())
                .append(filePath);
        String imageName = UUID.randomUUID() + "_" + image.getOriginalFilename().replaceAll(" ", "");
        try {
            IOUtils.write(image.getBytes(), new FileOutputStream(new File(imageFolder, imageName)));
            imageUrl.append("/").append(imageName);
            return CommonResult.success(imageUrl.toString());
        } catch (IOException e) {
            e.printStackTrace();
        }
        return CommonResult.failed("上传失败!");
    }
}
ycl-platform/src/main/java/com/ycl/controller/NewsAdminController.java
@@ -64,6 +64,7 @@
     * @return 所有数据
     */
    @GetMapping
    @ApiOperation(value = "查询所有数据")
    public R selectAll(Page<NewsAdmin> page, NewsAdmin newsAdmin) {
        return success(this.newsAdminService.page(page, new QueryWrapper<>(newsAdmin)));
    }
@@ -75,6 +76,7 @@
     * @return 单条数据
     */
    @GetMapping("{id}")
    @ApiOperation(value = "按id查询数据")
    public R selectOne(@PathVariable Serializable id) {
        return success(this.newsAdminService.getById(id));
    }
@@ -86,6 +88,7 @@
     * @return 新增结果
     */
    @PostMapping
    @ApiOperation(value = "新增数据")
    public R insert(@RequestBody NewsAdmin newsAdmin) {
        return success(this.newsAdminService.save(newsAdmin));
    }
@@ -97,6 +100,7 @@
     * @return 修改结果
     */
    @PutMapping
    @ApiOperation(value = "修改数据")
    public R update(@RequestBody NewsAdmin newsAdmin) {
        return success(this.newsAdminService.updateById(newsAdmin));
    }
@@ -108,6 +112,7 @@
     * @return 删除结果
     */
    @DeleteMapping
    @ApiOperation(value = "删除数据")
    public R delete(@RequestParam("idList") List<Long> idList) {
        return success(this.newsAdminService.removeByIds(idList));
    }
ycl-platform/src/main/java/com/ycl/controller/NewsChannelColumnController.java
@@ -7,11 +7,17 @@
import com.baomidou.mybatisplus.extension.api.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
@@ -22,12 +28,16 @@
 */
@RestController
@RequestMapping("newsChannelColumn")
@Api(tags = "频道栏目中间表控制层")
public class NewsChannelColumnController extends ApiController {
    /**
     * 服务对象
     */
    @Resource
    private NewsChannelColumnService newsChannelColumnService;
    @Autowired
    private NewsColumnService newsColumnService;
    /**
     * 分页查询所有数据
@@ -37,6 +47,7 @@
     * @return 所有数据
     */
    @GetMapping
    @ApiOperation(value = "查询所有数据")
    public R selectAll(Page<NewsChannelColumn> page, NewsChannelColumn newsChannelColumn) {
        return success(this.newsChannelColumnService.page(page, new QueryWrapper<>(newsChannelColumn)));
    }
@@ -48,6 +59,7 @@
     * @return 单条数据
     */
    @GetMapping("{id}")
    @ApiOperation(value = "按id查询数据")
    public R selectOne(@PathVariable Serializable id) {
        return success(this.newsChannelColumnService.getById(id));
    }
@@ -59,6 +71,7 @@
     * @return 新增结果
     */
    @PostMapping
    @ApiOperation(value = "新增数据")
    public R insert(@RequestBody NewsChannelColumn newsChannelColumn) {
        return success(this.newsChannelColumnService.save(newsChannelColumn));
    }
@@ -70,6 +83,7 @@
     * @return 修改结果
     */
    @PutMapping
    @ApiOperation(value = "修改数据")
    public R update(@RequestBody NewsChannelColumn newsChannelColumn) {
        return success(this.newsChannelColumnService.updateById(newsChannelColumn));
    }
@@ -81,8 +95,26 @@
     * @return 删除结果
     */
    @DeleteMapping
    @ApiOperation(value = "删除数据")
    public R delete(@RequestParam("idList") List<Long> idList) {
        return success(this.newsChannelColumnService.removeByIds(idList));
    }
    /**
     * 通过频道id查对应栏目
     *
     * @param id 频道id
     * @return 删除结果
     */
    @GetMapping("channel/{id}")
    @ApiOperation(value = "按频道id查询栏目")
    public R selectColumnByChannelId(@PathVariable Serializable id) {
        List<NewsChannelColumn> newsChannelColumns = newsChannelColumnService.list(new QueryWrapper<NewsChannelColumn>().eq("channel_id", id));
        List<NewsColumn> resultList=new ArrayList<>();
        for (NewsChannelColumn newsChannelColumn:newsChannelColumns){
            resultList.add(newsColumnService.getById(newsChannelColumn.getColumnId()));
        }
        return success(resultList);
    }
}
ycl-platform/src/main/java/com/ycl/controller/NewsChannelController.java
@@ -7,7 +7,12 @@
import com.baomidou.mybatisplus.extension.api.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ycl.entity.NewsChannel;
import com.ycl.entity.NewsChannelColumn;
import com.ycl.service.NewsChannelColumnService;
import com.ycl.service.NewsChannelService;
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;
@@ -22,6 +27,7 @@
 */
@RestController
@RequestMapping("newsChannel")
@Api(tags = "频道管理")
public class NewsChannelController extends ApiController {
    /**
     * 服务对象
@@ -29,16 +35,18 @@
    @Resource
    private NewsChannelService newsChannelService;
    @Autowired
    private NewsChannelColumnService newsChannelColumnService;
    /**
     * 分页查询所有数据
     *
     * @param page 分页对象
     * @param newsChannel 查询实体
     * @return 所有数据
     */
    @GetMapping
    public R selectAll(Page<NewsChannel> page, NewsChannel newsChannel) {
        return success(this.newsChannelService.page(page, new QueryWrapper<>(newsChannel)));
    @ApiOperation(value = "查询所有数据")
    public R selectAll() {
        return success(this.newsChannelService.selectAllChannel());
    }
    /**
@@ -48,6 +56,7 @@
     * @return 单条数据
     */
    @GetMapping("{id}")
    @ApiOperation(value = "按id查询数据")
    public R selectOne(@PathVariable Serializable id) {
        return success(this.newsChannelService.getById(id));
    }
@@ -59,8 +68,12 @@
     * @return 新增结果
     */
    @PostMapping
    @ApiOperation(value = "新增数据")
    public R insert(@RequestBody NewsChannel newsChannel) {
        return success(this.newsChannelService.save(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()));
        return success(result);
    }
    /**
@@ -70,7 +83,11 @@
     * @return 修改结果
     */
    @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()));
        return success(this.newsChannelService.updateById(newsChannel));
    }
@@ -81,8 +98,10 @@
     * @return 删除结果
     */
    @DeleteMapping
    @ApiOperation(value = "删除数据")
    public R delete(@RequestParam("idList") List<Long> idList) {
        return success(this.newsChannelService.removeByIds(idList));
    }
}
ycl-platform/src/main/java/com/ycl/controller/NewsColumnController.java
@@ -6,8 +6,11 @@
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.entity.NewsColumn;
import com.ycl.service.NewsColumnService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@@ -22,6 +25,7 @@
 */
@RestController
@RequestMapping("newsColumn")
@Api(tags = "栏目管理")
public class NewsColumnController extends ApiController {
    /**
     * 服务对象
@@ -37,6 +41,7 @@
     * @return 所有数据
     */
    @GetMapping
    @ApiOperation(value = "查询所有数据")
    public R selectAll(Page<NewsColumn> page, NewsColumn newsColumn) {
        return success(this.newsColumnService.page(page, new QueryWrapper<>(newsColumn)));
    }
@@ -48,6 +53,7 @@
     * @return 单条数据
     */
    @GetMapping("{id}")
    @ApiOperation(value = "按id查询数据")
    public R selectOne(@PathVariable Serializable id) {
        return success(this.newsColumnService.getById(id));
    }
@@ -59,6 +65,7 @@
     * @return 新增结果
     */
    @PostMapping
    @ApiOperation(value = "新增数据")
    public R insert(@RequestBody NewsColumn newsColumn) {
        return success(this.newsColumnService.save(newsColumn));
    }
@@ -70,6 +77,7 @@
     * @return 修改结果
     */
    @PutMapping
    @ApiOperation(value = "修改数据")
    public R update(@RequestBody NewsColumn newsColumn) {
        return success(this.newsColumnService.updateById(newsColumn));
    }
@@ -81,8 +89,10 @@
     * @return 删除结果
     */
    @DeleteMapping
    @ApiOperation(value = "删除数据")
    public R delete(@RequestParam("idList") List<Long> idList) {
        return success(this.newsColumnService.removeByIds(idList));
    }
}
ycl-platform/src/main/java/com/ycl/controller/NewsColumnInformationController.java
@@ -7,11 +7,17 @@
import com.baomidou.mybatisplus.extension.api.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ycl.entity.NewsColumnInformation;
import com.ycl.entity.NewsInformation;
import com.ycl.service.NewsColumnInformationService;
import com.ycl.service.NewsInformationService;
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;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
@@ -22,6 +28,7 @@
 */
@RestController
@RequestMapping("newsColumnInformation")
@Api(tags = "栏目咨询中间表控制层")
public class NewsColumnInformationController extends ApiController {
    /**
     * 服务对象
@@ -29,6 +36,8 @@
    @Resource
    private NewsColumnInformationService newsColumnInformationService;
    @Autowired
    private NewsInformationService newsInformationService;
    /**
     * 分页查询所有数据
     *
@@ -37,6 +46,7 @@
     * @return 所有数据
     */
    @GetMapping
    @ApiOperation(value = "查询所有数据")
    public R selectAll(Page<NewsColumnInformation> page, NewsColumnInformation newsColumnInformation) {
        return success(this.newsColumnInformationService.page(page, new QueryWrapper<>(newsColumnInformation)));
    }
@@ -48,6 +58,7 @@
     * @return 单条数据
     */
    @GetMapping("{id}")
    @ApiOperation(value = "按id查询数据")
    public R selectOne(@PathVariable Serializable id) {
        return success(this.newsColumnInformationService.getById(id));
    }
@@ -59,6 +70,7 @@
     * @return 新增结果
     */
    @PostMapping
    @ApiOperation(value = "新增数据")
    public R insert(@RequestBody NewsColumnInformation newsColumnInformation) {
        return success(this.newsColumnInformationService.save(newsColumnInformation));
    }
@@ -70,6 +82,7 @@
     * @return 修改结果
     */
    @PutMapping
    @ApiOperation(value = "修改数据")
    public R update(@RequestBody NewsColumnInformation newsColumnInformation) {
        return success(this.newsColumnInformationService.updateById(newsColumnInformation));
    }
@@ -81,8 +94,25 @@
     * @return 删除结果
     */
    @DeleteMapping
    @ApiOperation(value = "删除数据")
    public R delete(@RequestParam("idList") List<Long> idList) {
        return success(this.newsColumnInformationService.removeByIds(idList));
    }
}
    /**
     * 通过栏目id查对应资讯
     *
     * @param id 栏目id
     * @return 资讯查询结果
     */
    @GetMapping("column/{id}")
    @ApiOperation(value = "按")
    public R selectInformationByColumnId(@PathVariable Serializable id) {
        List<NewsColumnInformation> newsColumnInformationList = newsColumnInformationService.list(new QueryWrapper<NewsColumnInformation>().eq("column_id", id));
        List<NewsInformation> resultList=new ArrayList<>();
        for (NewsColumnInformation newsColumnInformation:newsColumnInformationList){
            resultList.add(newsInformationService.selectInformationById(newsColumnInformation.getInformationId()));
        }
        return success(resultList);
    }}
ycl-platform/src/main/java/com/ycl/controller/NewsDepartmentController.java
@@ -8,6 +8,8 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ycl.entity.NewsDepartment;
import com.ycl.service.NewsDepartmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@@ -22,6 +24,7 @@
 */
@RestController
@RequestMapping("newsDepartment")
@Api(tags = "机构管理")
public class NewsDepartmentController extends ApiController {
    /**
     * 服务对象
@@ -37,6 +40,7 @@
     * @return 所有数据
     */
    @GetMapping
    @ApiOperation(value = "查询所有数据")
    public R selectAll(Page<NewsDepartment> page, NewsDepartment newsDepartment) {
        return success(this.newsDepartmentService.page(page, new QueryWrapper<>(newsDepartment)));
    }
@@ -48,6 +52,7 @@
     * @return 单条数据
     */
    @GetMapping("{id}")
    @ApiOperation(value = "按id查询数据")
    public R selectOne(@PathVariable Serializable id) {
        return success(this.newsDepartmentService.getById(id));
    }
@@ -59,6 +64,7 @@
     * @return 新增结果
     */
    @PostMapping
    @ApiOperation(value = "新增数据")
    public R insert(@RequestBody NewsDepartment newsDepartment) {
        return success(this.newsDepartmentService.save(newsDepartment));
    }
@@ -70,6 +76,7 @@
     * @return 修改结果
     */
    @PutMapping
    @ApiOperation(value = "修改数据")
    public R update(@RequestBody NewsDepartment newsDepartment) {
        return success(this.newsDepartmentService.updateById(newsDepartment));
    }
@@ -81,6 +88,7 @@
     * @return 删除结果
     */
    @DeleteMapping
    @ApiOperation(value = "删除数据")
    public R delete(@RequestParam("idList") List<Long> idList) {
        return success(this.newsDepartmentService.removeByIds(idList));
    }
ycl-platform/src/main/java/com/ycl/controller/NewsDutyController.java
@@ -8,6 +8,8 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ycl.entity.NewsDuty;
import com.ycl.service.NewsDutyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@@ -22,6 +24,7 @@
 */
@RestController
@RequestMapping("newsDuty")
@Api(tags = "值班管理")
public class NewsDutyController extends ApiController {
    /**
     * 服务对象
@@ -37,6 +40,7 @@
     * @return 所有数据
     */
    @GetMapping
    @ApiOperation(value = "查询所有数据")
    public R selectAll(Page<NewsDuty> page, NewsDuty newsDuty) {
        return success(this.newsDutyService.page(page, new QueryWrapper<>(newsDuty)));
    }
@@ -48,6 +52,7 @@
     * @return 单条数据
     */
    @GetMapping("{id}")
    @ApiOperation(value = "按id查询数据")
    public R selectOne(@PathVariable Serializable id) {
        return success(this.newsDutyService.getById(id));
    }
@@ -59,6 +64,7 @@
     * @return 新增结果
     */
    @PostMapping
    @ApiOperation(value = "新增数据")
    public R insert(@RequestBody NewsDuty newsDuty) {
        return success(this.newsDutyService.save(newsDuty));
    }
@@ -70,6 +76,7 @@
     * @return 修改结果
     */
    @PutMapping
    @ApiOperation(value = "修改数据")
    public R update(@RequestBody NewsDuty newsDuty) {
        return success(this.newsDutyService.updateById(newsDuty));
    }
@@ -81,6 +88,7 @@
     * @return 删除结果
     */
    @DeleteMapping
    @ApiOperation(value = "删除数据")
    public R delete(@RequestParam("idList") List<Long> idList) {
        return success(this.newsDutyService.removeByIds(idList));
    }
ycl-platform/src/main/java/com/ycl/controller/NewsInformationController.java
@@ -5,23 +5,24 @@
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.api.ApiController;
import com.baomidou.mybatisplus.extension.api.R;
import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ycl.entity.NewsColumnInformation;
import com.ycl.entity.NewsInformation;
import com.ycl.entity.NewsInformationPolice;
import com.ycl.entity.NewsPolice;
import com.ycl.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import sun.nio.ch.IOUtil;
import javax.annotation.Resource;
import java.io.Serializable;
import java.sql.SQLException;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
/**
 * 资讯表(NewsInformation)表控制层
@@ -31,6 +32,7 @@
 */
@RestController
@RequestMapping("newsInformation")
@Api(tags = "资讯管理")
public class NewsInformationController extends ApiController {
    /**
     * 服务对象
@@ -49,13 +51,13 @@
    /**
     * 分页查询所有数据
     *
     * @param page 分页对象
     * @param newsInformation 查询实体
     * @return 所有数据
     */
    @GetMapping
    public R selectAll(Page<NewsInformation> page, NewsInformation newsInformation) {
        return success(this.newsInformationService.page(page, new QueryWrapper<>(newsInformation).orderByDesc("publish_time")));
    @ApiOperation(value = "查询所有数据")
    public R selectAll() {
        return success(this.newsInformationService.selectAllInformation());
    }
    /**
@@ -65,6 +67,7 @@
     * @return 单条数据
     */
    @GetMapping("{id}")
    @ApiOperation(value = "按id查询数据")
    public R selectOne(@PathVariable Serializable id) {
        return success(this.newsInformationService.getById(id));
    }
@@ -77,6 +80,7 @@
     */
    @Transactional(rollbackFor = SQLException.class)
    @PostMapping
    @ApiOperation(value = "新增数据")
    public R insert(@RequestBody NewsInformation newsInformation) {
        Integer saveResult = this.newsInformationService.insertOneInformation(newsInformation);
        Integer informationId=newsInformation.getId();
@@ -107,6 +111,8 @@
     * @return 修改结果
     */
    @PutMapping
    @ApiOperation(value = "修改数据")
    @Transactional
    public R update(@RequestBody NewsInformation newsInformation) {
        Integer informationId = newsInformation.getId();
        if (newsInformation.getIsSign()==0){
@@ -127,7 +133,7 @@
        for (String columnId:newsInformation.getColumnId()){
            newsColumnInformationService.save(NewsColumnInformation.builder().columnId(Integer.parseInt(columnId)).informationId(informationId).build());
        }
        return success(this.newsInformationService.updateById(newsInformation));
        return success(this.newsInformationService.updateInformationById(newsInformation));
    }
    /**
@@ -137,6 +143,7 @@
     * @return 删除结果
     */
    @DeleteMapping
    @ApiOperation(value = "删除数据")
    public R delete(@RequestParam("idList") List<Long> idList) {
        return success(this.newsInformationService.removeByIds(idList));
    }
ycl-platform/src/main/java/com/ycl/controller/NewsInformationPoliceController.java
@@ -8,6 +8,8 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ycl.entity.NewsInformationPolice;
import com.ycl.service.NewsInformationPoliceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@@ -22,6 +24,7 @@
 */
@RestController
@RequestMapping("newsInformationPolice")
@Api(tags = "资讯警员中间表控制层")
public class NewsInformationPoliceController extends ApiController {
    /**
     * 服务对象
@@ -37,6 +40,7 @@
     * @return 所有数据
     */
    @GetMapping
    @ApiOperation(value = "查询所有数据")
    public R selectAll(Page<NewsInformationPolice> page, NewsInformationPolice newsInformationPolice) {
        return success(this.newsInformationPoliceService.page(page, new QueryWrapper<>(newsInformationPolice)));
    }
@@ -48,6 +52,7 @@
     * @return 单条数据
     */
    @GetMapping("{id}")
    @ApiOperation(value = "按id查询数据")
    public R selectOne(@PathVariable Serializable id) {
        return success(this.newsInformationPoliceService.getById(id));
    }
@@ -59,6 +64,7 @@
     * @return 新增结果
     */
    @PostMapping
    @ApiOperation(value = "新增数据")
    public R insert(@RequestBody NewsInformationPolice newsInformationPolice) {
        return success(this.newsInformationPoliceService.save(newsInformationPolice));
    }
@@ -70,6 +76,7 @@
     * @return 修改结果
     */
    @PutMapping
    @ApiOperation(value = "修改数据或签收状态")
    public R updateSignStatus(@RequestBody NewsInformationPolice newsInformationPolice) {
        if (newsInformationPolice.getId()==null){
            QueryWrapper<NewsInformationPolice> wrapper = new QueryWrapper<>();
@@ -88,6 +95,7 @@
     * @return 删除结果
     */
    @DeleteMapping
    @ApiOperation(value = "删除数据")
    public R delete(@RequestParam("idList") List<Long> idList) {
        return success(this.newsInformationPoliceService.removeByIds(idList));
    }
@@ -99,6 +107,7 @@
     * @return 单条数据
     */
    @GetMapping("information/{id}")
    @ApiOperation(value = "按资讯id查询总数和已阅人数")
    public R selectListByInformationId(@PathVariable Serializable id) {
        int sum = this.newsInformationPoliceService.count(new QueryWrapper<NewsInformationPolice>().eq("news_information_id", id));
        int sign = this.newsInformationPoliceService.count(new QueryWrapper<NewsInformationPolice>().eq("news_information_id", id).eq("is_sign",1));
ycl-platform/src/main/java/com/ycl/controller/NewsPoliceController.java
@@ -9,6 +9,8 @@
import com.ycl.entity.NewsPolice;
import com.ycl.service.NewsAdminService;
import com.ycl.service.NewsPoliceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
@@ -27,6 +29,7 @@
 */
@RestController
@RequestMapping("newsPolice")
@Api(tags = "警员管理")
public class NewsPoliceController extends ApiController {
    /**
     * 服务对象
@@ -45,6 +48,7 @@
     * @return 所有数据
     */
    @GetMapping
    @ApiOperation(value = "查询所有数据")
    public R selectAll(Page<NewsPolice> page, NewsPolice newsPolice) {
        return success(this.newsPoliceService.page(page, new QueryWrapper<>(newsPolice)));
    }
@@ -56,6 +60,7 @@
     * @return 单条数据
     */
    @GetMapping("{id}")
    @ApiOperation(value = "按id查询数据")
    public R selectOne(@PathVariable Serializable id) {
        return success(this.newsPoliceService.getById(id));
    }
@@ -68,6 +73,7 @@
     */
    @Transactional(rollbackFor = SQLException.class)
    @PostMapping
    @ApiOperation(value = "新增数据")
    public R insert(@RequestBody NewsPolice newsPolice) {
        this.newsPoliceService.save(newsPolice);
        return success(newsAdminService.autoCreateAdmin(newsPolice));
@@ -80,6 +86,7 @@
     * @return 修改结果
     */
    @PutMapping
    @ApiOperation(value = "修改数据")
    public R update(@RequestBody NewsPolice newsPolice) {
        return success(this.newsPoliceService.updateById(newsPolice));
    }
@@ -91,6 +98,7 @@
     * @return 删除结果
     */
    @DeleteMapping
    @ApiOperation(value = "删除数据")
    public R delete(@RequestParam("idList") List<Long> idList) {
        return success(this.newsPoliceService.removeByIds(idList));
    }
ycl-platform/src/main/java/com/ycl/entity/NewsChannel.java
@@ -2,6 +2,8 @@
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.io.Serializable;
import java.sql.Date;
import java.util.List;
@@ -21,6 +23,7 @@
    //频道编码ps名称首字母
    private String code;
    //创建时间
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;
    //栏目id
    private List<String> columnId;
ycl-platform/src/main/java/com/ycl/entity/NewsChannelColumn.java
@@ -2,6 +2,9 @@
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.AllArgsConstructor;
import lombok.Builder;
import java.io.Serializable;
/**
@@ -11,6 +14,8 @@
 * @since 2022-11-17 11:38:27
 */
@SuppressWarnings("serial")
@Builder
@AllArgsConstructor
public class NewsChannelColumn extends Model<NewsChannelColumn> {
    
    private Integer id;
@@ -18,7 +23,6 @@
    private Integer channelId;
    //栏目id
    private Integer columnId;
    public Integer getId() {
        return id;
ycl-platform/src/main/java/com/ycl/mapper/NewsChannelDao.java
@@ -31,5 +31,9 @@
*/
int insertOrUpdateBatch(@Param("entities") List<NewsChannel> entities);
int insertOneChannel(@Param("entity") NewsChannel entity);
List<NewsChannel> selectAllChannel();
}
ycl-platform/src/main/java/com/ycl/mapper/NewsInformationDao.java
@@ -33,5 +33,10 @@
int insertOneInformation(@Param("entity") NewsInformation entity);
NewsInformation selectInformationById(@Param("InformationId") Integer InformationId);
List<NewsInformation> selectAllInformation();
int updateInformationById(@Param("entity") NewsInformation entity);
}
ycl-platform/src/main/java/com/ycl/service/NewsChannelService.java
@@ -2,6 +2,9 @@
import com.baomidou.mybatisplus.extension.service.IService;
import com.ycl.entity.NewsChannel;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
 * 频道表(NewsChannel)表服务接口
@@ -10,6 +13,8 @@
 * @since 2022-11-17 11:38:27
 */
public interface NewsChannelService extends IService<NewsChannel> {
    int insertOneChannel(@Param("entity") NewsChannel entity);
    List<NewsChannel> selectAllChannel();
}
ycl-platform/src/main/java/com/ycl/service/NewsInformationService.java
@@ -2,6 +2,9 @@
import com.baomidou.mybatisplus.extension.service.IService;
import com.ycl.entity.NewsInformation;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
 * 资讯表(NewsInformation)表服务接口
@@ -11,5 +14,11 @@
 */
public interface NewsInformationService extends IService<NewsInformation> {
    int insertOneInformation(NewsInformation entity);
    NewsInformation selectInformationById(Integer InformationId);
    List<NewsInformation> selectAllInformation();
    int updateInformationById(NewsInformation entity);
}
ycl-platform/src/main/java/com/ycl/service/impl/NewsAdminServiceImpl.java
@@ -5,6 +5,7 @@
import com.ycl.entity.NewsAdmin;
import com.ycl.entity.NewsPolice;
import com.ycl.service.NewsAdminService;
import com.ycl.utils.MD5Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@@ -33,7 +34,7 @@
    public Integer autoCreateAdmin(NewsPolice newsPolice) {
        NewsAdmin admin = new NewsAdmin();
        admin.setUsername(newsPolice.getRname());
        admin.setPassword(defaultPassword);
        admin.setPassword(MD5Util.md5Encrypt32Lower(defaultPassword));
        admin.setCreateTime(new Date());
        admin.setStatus(1);
        admin.setNewsPoliceId(newsPolice.getId());
ycl-platform/src/main/java/com/ycl/service/impl/NewsChannelServiceImpl.java
@@ -4,7 +4,10 @@
import com.ycl.mapper.NewsChannelDao;
import com.ycl.entity.NewsChannel;
import com.ycl.service.NewsChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
 * 频道表(NewsChannel)表服务实现类
@@ -15,5 +18,17 @@
@Service("newsChannelService")
public class NewsChannelServiceImpl extends ServiceImpl<NewsChannelDao, NewsChannel> implements NewsChannelService {
    @Autowired
    NewsChannelDao newsChannelDao;
    @Override
    public int insertOneChannel(NewsChannel entity) {
        return newsChannelDao.insertOneChannel(entity);
    }
    @Override
    public List<NewsChannel> selectAllChannel() {
        return newsChannelDao.selectAllChannel();
    }
}
ycl-platform/src/main/java/com/ycl/service/impl/NewsInformationServiceImpl.java
@@ -4,9 +4,10 @@
import com.ycl.mapper.NewsInformationDao;
import com.ycl.entity.NewsInformation;
import com.ycl.service.NewsInformationService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
 * 资讯表(NewsInformation)表服务实现类
@@ -24,5 +25,20 @@
    public int insertOneInformation(NewsInformation entity) {
        return newsInformationDao.insertOneInformation(entity);
    }
    @Override
    public NewsInformation selectInformationById(Integer InformationId) {
        return newsInformationDao.selectInformationById(InformationId);
    }
    @Override
    public List<NewsInformation> selectAllInformation() {
        return newsInformationDao.selectAllInformation();
    }
    @Override
    public int updateInformationById(NewsInformation entity) {
        return newsInformationDao.updateInformationById(entity);
    }
}
ycl-platform/src/main/resources/application-dev.yml
@@ -6,20 +6,20 @@
    context-path: /air
    compression: true
fdfs:
  fileUrl: http://140.143.152.226:8410/
  groupName: sczhzf
  soTimeout: 1500
  connectTimeout: 600
  trackerList: #TrackerList参数,支持多个
    - 140.143.152.226:22122
#fdfs:
#  fileUrl: http://140.143.152.226:8410/
#  groupName: sczhzf
#  soTimeout: 1500
#  connectTimeout: 600
#  trackerList: #TrackerList参数,支持多个
#    - 140.143.152.226:22122
cfg:
  res: d://resources
  media-res: 140.143.152.226/media/
  snow-flake:
    datacenterId: 1
    machineId: 1
#cfg:
#  res: d://resources
#  media-res: 140.143.152.226/media/
#  snow-flake:
#    datacenterId: 1
#    machineId: 1
spring:
  redis:
@@ -53,16 +53,16 @@
    testOnReturn: false
    poolPreparedStatements: true
    maxOpenPreparedStatements: 20
e-mail:
  sendHost: smtp.qq.com
  username: 1723292425@qq.com
  password: qizcitupatzoeeij
SMS:
  ecName: ycl
  apId: 1
  sign: sign
  url: http://localhost:8082/sccg/text/sms_res
#e-mail:
#  sendHost: smtp.qq.com
#  username: 1723292425@qq.com
#  password: qizcitupatzoeeij
#
#SMS:
#  ecName: ycl
#  apId: 1
#  sign: sign
#  url: http://localhost:8082/sccg/text/sms_res
admin:
  defaultPassword: 111111
ycl-platform/src/main/resources/application.yml
@@ -32,13 +32,13 @@
  expiration: 604800 #JWT的超期限时间(60*60*24*7)
  tokenHead: 'Bearer ' #JWT负载中拿到开头
redis:
  database: sccg
  key:
    admin: 'ums:admin'
    resourceList: 'ums:menuList'
  expire:
    common: 86400 # 24小时
#redis:
#  database: sccg
#  key:
#    admin: 'ums:admin'
#    resourceList: 'ums:menuList'
#  expire:
#    common: 86400 # 24小时
#MP配置
mybatis-plus:
ycl-platform/src/main/resources/mapper/NewsAdminDao.xml
ycl-platform/src/main/resources/mapper/NewsChannelColumnDao.xml
@@ -24,7 +24,8 @@
            (#{entity.channelId}, #{entity.columnId})
        </foreach>
        on duplicate key update
         channel_id = values(channel_id) , column_id = values(column_id)     </insert>
         channel_id = values(channel_id) , column_id = values(column_id)
        </insert>
</mapper>
ycl-platform/src/main/resources/mapper/NewsChannelDao.xml
@@ -25,7 +25,16 @@
            (#{entity.name}, #{entity.code}, #{entity.createTime})
        </foreach>
        on duplicate key update
         name = values(name) , code = values(code) , create_time = values(create_time)     </insert>
         name = values(name) , code = values(code) , create_time = values(create_time)
    </insert>
    <insert id="insertOneChannel" keyProperty="id" useGeneratedKeys="true">
        insert into news_website.news_channel(name, code, create_time)
        values (#{entity.name}, #{entity.code}, #{entity.createTime})
    </insert>
    <select id="selectAllChannel" resultType="com.ycl.entity.NewsChannel">
        select * from news_channel
    </select>
</mapper>
ycl-platform/src/main/resources/mapper/NewsColumnInformationDao.xml
@@ -24,7 +24,8 @@
            (#{entity.columnId}, #{entity.informationId})
        </foreach>
        on duplicate key update
         column_id = values(column_id) , information_id = values(information_id)     </insert>
         column_id = values(column_id) , information_id = values(information_id)
    </insert>
</mapper>
ycl-platform/src/main/resources/mapper/NewsDepartmentDao.xml
ycl-platform/src/main/resources/mapper/NewsInformationDao.xml
@@ -34,7 +34,19 @@
    <insert id="insertOneInformation" keyProperty="id" useGeneratedKeys="true">
        insert into news_website.news_information(title, content, publish_time, is_sign, create_time, send_to, image_url)
        values (#{entity.title}, #{entity.content}, #{entity.publishTime}, #{entity.isSign}, #{entity.createTime}, #{entity.sendTo}, #{entity.imageUrl})
    </insert>
    <select id="selectInformationById" resultType="com.ycl.entity.NewsInformation" parameterType="int">
        select * from  news_information where id=#{InformationId}
    </select>
    <select id="selectAllInformation" resultType="com.ycl.entity.NewsInformation">
        select * from  news_information
    </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}
        where id=#{entity.id}
    </update>
</mapper>
ycl-platform/src/main/resources/mapper/NewsInformationPoliceDao.xml
ycl-platform/src/main/resources/mapper/NewsPoliceDao.xml
ycl-platform/target/classes/mapper/NewsChannelColumnDao.xml
@@ -24,7 +24,8 @@
            (#{entity.channelId}, #{entity.columnId})
        </foreach>
        on duplicate key update
         channel_id = values(channel_id) , column_id = values(column_id)     </insert>
         channel_id = values(channel_id) , column_id = values(column_id)
        </insert>
</mapper>
ycl-platform/target/classes/mapper/NewsChannelDao.xml
@@ -25,7 +25,16 @@
            (#{entity.name}, #{entity.code}, #{entity.createTime})
        </foreach>
        on duplicate key update
         name = values(name) , code = values(code) , create_time = values(create_time)     </insert>
         name = values(name) , code = values(code) , create_time = values(create_time)
    </insert>
    <insert id="insertOneChannel" keyProperty="id" useGeneratedKeys="true">
        insert into news_website.news_channel(name, code, create_time)
        values (#{entity.name}, #{entity.code}, #{entity.createTime})
    </insert>
    <select id="selectAllChannel" resultType="com.ycl.entity.NewsChannel">
        select * from news_channel
    </select>
</mapper>
ycl-platform/target/classes/mapper/NewsColumnInformationDao.xml
@@ -24,7 +24,8 @@
            (#{entity.columnId}, #{entity.informationId})
        </foreach>
        on duplicate key update
         column_id = values(column_id) , information_id = values(information_id)     </insert>
         column_id = values(column_id) , information_id = values(information_id)
    </insert>
</mapper>
ycl-platform/target/classes/mapper/NewsInformationDao.xml
@@ -34,7 +34,19 @@
    <insert id="insertOneInformation" keyProperty="id" useGeneratedKeys="true">
        insert into news_website.news_information(title, content, publish_time, is_sign, create_time, send_to, image_url)
        values (#{entity.title}, #{entity.content}, #{entity.publishTime}, #{entity.isSign}, #{entity.createTime}, #{entity.sendTo}, #{entity.imageUrl})
    </insert>
    <select id="selectInformationById" resultType="com.ycl.entity.NewsInformation" parameterType="int">
        select * from  news_information where id=#{InformationId}
    </select>
    <select id="selectAllInformation" resultType="com.ycl.entity.NewsInformation">
        select * from  news_information
    </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}
        where id=#{entity.id}
    </update>
</mapper>