提交 e1b173e8 作者: panda 提交者: 余乾开

行业新闻相关接口

上级 fe1ca2cc
package com.mmc.csf.infomation.qo;
import com.mmc.csf.release.model.group.Page;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class IndustryNewsQO implements Serializable {
private static final long serialVersionUID = -46151544725013257L;
@ApiModelProperty(value = "新闻标题",example = "新闻标题")
private String newsTitle;
@ApiModelProperty(value = "开始时间")
private Date startTime;
@ApiModelProperty(value = "结束时间")
private Date endTime;
@ApiModelProperty(value = "页码", required = true)
@NotNull(message = "页码不能为空", groups = Page.class)
@Min(value = 1, groups = Page.class)
private Integer pageNo;
@ApiModelProperty(value = "每页显示数", required = true)
@NotNull(message = "每页显示数不能为空", groups = Page.class)
@Min(value = 1, groups = Page.class)
private Integer pageSize;
public void buildCurrentPage() {
this.pageNo = (pageNo - 1) * pageSize;
}
}
package com.mmc.csf.infomation.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
/**
* @author: zj
* @Date: 2023/5/19 11:23
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class IndustryNewsDTO implements Serializable {
private static final long serialVersionUID = 8479619142765659138L;
@ApiModelProperty(value = "id")
private Integer id;
@ApiModelProperty(value = "新闻标题")
private String newsTitle;
@ApiModelProperty(value = "作者")
private String newsAuthor;
@ApiModelProperty(value = "发布者id")
private Integer userAccountId;
@ApiModelProperty(value = "封面图")
private String surfaceImg;
@ApiModelProperty(value = "新闻内容")
private String newsContents;
@ApiModelProperty(value = "来源")
private String origin;
@ApiModelProperty(value = "创建时间")
private Date createTime;
@ApiModelProperty(value = "最新修改时间")
private Date updateTime;
}
package com.mmc.csf.infomation.vo; package com.mmc.csf.infomation.vo;
import com.mmc.csf.release.model.group.Create;
import com.mmc.csf.release.model.group.Others;
import com.mmc.csf.release.model.group.Update;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
/**
* @author: zj
* @Date: 2023/5/19 11:23
*/
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@Builder @Builder
public class IndustryNewsVO implements Serializable { public class IndustryNewsVO implements Serializable {
private static final long serialVersionUID = 8479619142765659138L; private static final long serialVersionUID = 8479619142765659138L;
@ApiModelProperty(value = "id") @ApiModelProperty(value = "id")
@NotNull(message = "修改id不能为空", groups = {Update.class})
private Integer id; private Integer id;
@ApiModelProperty(value = "新闻标题")
@ApiModelProperty(value = "新闻标题",example = "新闻标题")
@NotBlank(message = "文章标题不能为空",groups = {Create.class,Update.class})
private String newsTitle; private String newsTitle;
@ApiModelProperty(value = "作者")
@ApiModelProperty(value = "作者",example = "作者")
@NotBlank(message = "作者不能为空",groups = {Create.class,Update.class})
private String newsAuthor; private String newsAuthor;
@ApiModelProperty(value = "发布者id")
@ApiModelProperty(value = "创建人",hidden = true)
private Integer userAccountId; private Integer userAccountId;
@ApiModelProperty(value = "封面图") @ApiModelProperty(value = "封面图")
@NotBlank(message = "封面图不能为空",groups = {Create.class,Update.class})
private String surfaceImg; private String surfaceImg;
@ApiModelProperty(value = "新闻内容") @ApiModelProperty(value = "新闻内容")
private String newsContents; private String newsContents;
@ApiModelProperty(value = "创建时间")
private Date createTime; @ApiModelProperty(value = "来源",example = "来源")
@ApiModelProperty(value = "最新修改时间") private String origin;
private Date updateTime;
} }
...@@ -21,7 +21,7 @@ public class TenderApplyVO implements Serializable { ...@@ -21,7 +21,7 @@ public class TenderApplyVO implements Serializable {
@ApiModelProperty(value = "招标id") @ApiModelProperty(value = "招标id")
@NotNull(message = "招标id不能为空", groups = {Create.class}) @NotNull(message = "招标id不能为空", groups = {Create.class})
private Integer tenderNewsId; private Integer tenderNewsId;
@ApiModelProperty(value = "用户id") @ApiModelProperty(value = "用户id",hidden = true)
//@NotNull(message = "用户id不能为空", groups = {Create.class}) //@NotNull(message = "用户id不能为空", groups = {Create.class})
private Integer userAccountId; private Integer userAccountId;
@ApiModelProperty(value = "招标详情id") @ApiModelProperty(value = "招标详情id")
......
...@@ -396,7 +396,10 @@ public enum ResultEnum implements BaseErrorInfoInterface { ...@@ -396,7 +396,10 @@ public enum ResultEnum implements BaseErrorInfoInterface {
HELP_FAIL_ERROR("2009", "不能给自己助力哦!"), HELP_FAIL_ERROR("2009", "不能给自己助力哦!"),
ALREADY_BINDING_ERROR("2010", "优惠券已被绑定"), ALREADY_BINDING_ERROR("2010", "优惠券已被绑定"),
ALREADY_DIVIDE_ERROR("2011", "订单已分成"), ALREADY_DIVIDE_ERROR("2011", "订单已分成"),
DIVIDE_OBJ_NOT_EXIST("2012", "先点击确认添加分成对象"); DIVIDE_OBJ_NOT_EXIST("2012", "先点击确认添加分成对象"),
// 新闻行业
INDUSTRY_NEWS_TITLE_EXISTS("40200","文章标题存在");
/** /**
* 错误码 * 错误码
* *
......
...@@ -2,9 +2,12 @@ package com.mmc.csf.release.controller; ...@@ -2,9 +2,12 @@ package com.mmc.csf.release.controller;
import com.mmc.csf.common.util.web.ResultBody; import com.mmc.csf.common.util.web.ResultBody;
import com.mmc.csf.infomation.qo.IndustryCaseQO; import com.mmc.csf.infomation.qo.IndustryCaseQO;
import com.mmc.csf.infomation.vo.IndustryCaseVO; import com.mmc.csf.infomation.qo.IndustryNewsQO;
import com.mmc.csf.infomation.vo.IndustryNewsDTO;
import com.mmc.csf.infomation.vo.IndustryNewsVO; import com.mmc.csf.infomation.vo.IndustryNewsVO;
import com.mmc.csf.release.model.group.Create;
import com.mmc.csf.release.model.group.Page; import com.mmc.csf.release.model.group.Page;
import com.mmc.csf.release.model.group.Update;
import com.mmc.csf.release.service.IndustryNewsService; import com.mmc.csf.release.service.IndustryNewsService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -13,31 +16,51 @@ import io.swagger.annotations.ApiResponses; ...@@ -13,31 +16,51 @@ import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
/** /**
* @author: zj * @author: zj
* @Date: 2023/5/19 10:42 * @Date: 2023/5/19 10:42
*/ */
@Api(tags = {"行业新闻相关"}) @Api(tags = {"行业新闻-相关接口"})
@RestController @RestController
@RequestMapping("/industry-news/") @RequestMapping("/industry-news/")
public class IndustryNewsController { public class IndustryNewsController extends BaseController {
@Autowired @Autowired
private IndustryNewsService industryNewsService; private IndustryNewsService industryNewsService;
@ApiOperation(value = "新闻列表") @ApiOperation(value = "添加-行业新闻")
@ApiResponses({ @ApiResponse(code = 200, message = "OK", response = IndustryNewsVO.class) }) @ApiResponses({ @ApiResponse(code = 200, message = "OK", response = ResultBody.class) })
@PostMapping("listNewsPage") @PostMapping("insertIndustryNews")
public ResultBody listNewsPage(@Validated(value = {Page.class})@RequestBody IndustryCaseQO industryCaseQO, HttpServletRequest request){ public ResultBody insertIndustryNews(@RequestBody @Validated(Create.class) IndustryNewsVO industryNewsVO, HttpServletRequest request){
return industryNewsService.listNewsPage(industryCaseQO, request); return industryNewsService.insertIndustryNews(industryNewsVO, this.getUserLoginInfoFromRedis(request).getUserAccountId());
}
@ApiOperation(value = "修改-行业新闻")
@ApiResponses({ @ApiResponse(code = 200, message = "OK", response = ResultBody.class) })
@PostMapping("upDateIndustryNews")
public ResultBody upDateIndustryNews(@RequestBody @Validated(Update.class) IndustryNewsVO industryNewsVO, HttpServletRequest request){
return industryNewsService.upDateIndustryNews(industryNewsVO, this.getUserLoginInfoFromRedis(request).getUserAccountId());
} }
@ApiOperation(value = "新闻详情") @ApiOperation(value = "新闻详情")
@ApiResponses({ @ApiResponse(code = 200, message = "OK", response = IndustryNewsVO.class) }) @ApiResponses({ @ApiResponse(code = 200, message = "OK", response = IndustryNewsDTO.class) })
@GetMapping("details") @GetMapping("details")
public ResultBody details(@RequestParam Integer id){ public ResultBody<IndustryNewsDTO> details(@RequestParam Integer id){
return industryNewsService.details(id); return industryNewsService.details(id);
} }
@ApiOperation(value = "后台-新闻列表")
@ApiResponses({ @ApiResponse(code = 200, message = "OK", response = IndustryNewsDTO.class) })
@PostMapping("backgroundListNewsPage")
public ResultBody<IndustryNewsDTO> backgroundListNewsPage(@Validated(value = {Page.class})@RequestBody IndustryNewsQO industryNewsQO, HttpServletRequest request){
return industryNewsService.backgroundListNewsPage(industryNewsQO, request);
}
@ApiOperation(value = "web端-新闻列表")
@ApiResponses({ @ApiResponse(code = 200, message = "OK", response = IndustryNewsDTO.class) })
@PostMapping("listNewsPage")
public ResultBody<IndustryNewsDTO> listNewsPage(@Validated(value = {Page.class})@RequestBody IndustryCaseQO industryCaseQO, HttpServletRequest request){
return industryNewsService.listNewsPage(industryCaseQO, request);
}
} }
...@@ -101,12 +101,11 @@ public class TenderController extends BaseController{ ...@@ -101,12 +101,11 @@ public class TenderController extends BaseController{
return tenderService.listTenderApply(tenderApplyQO); return tenderService.listTenderApply(tenderApplyQO);
} }
@ApiOperation(value = "app往期招标快讯详情列表-分页") @ApiOperation(value = "web端-招投标列表")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = AppTenderInfoDTO.class)}) @ApiResponses({@ApiResponse(code = 200, message = "OK", response = AppTenderInfoDTO.class)})
@GetMapping(value = "info/app") @PostMapping(value = "listNewTenderInfo")
public ResultBody listTenderInfoApp(@RequestParam Integer pageNo, @RequestParam Integer pageSize, public ResultBody listNewTenderInfo(@Validated(value = {Page.class})@RequestBody IndustryCaseQO industryCaseQO, HttpServletRequest request){
@RequestParam Integer tenderNewsId, @RequestParam(required = false) Integer userAccountId){ return tenderService.listNewTenderInfo(industryCaseQO, this.getUserLoginInfoFromRedis(request), request);
return tenderService.listTenderInfoApp(pageNo, pageSize, tenderNewsId, userAccountId);
} }
@ApiOperation(value = "app最新招标快讯详情列表-分页") @ApiOperation(value = "app最新招标快讯详情列表-分页")
...@@ -117,10 +116,11 @@ public class TenderController extends BaseController{ ...@@ -117,10 +116,11 @@ public class TenderController extends BaseController{
return tenderService.listTenderInfoAppLatest(pageNo, pageSize, userAccountId); return tenderService.listTenderInfoAppLatest(pageNo, pageSize, userAccountId);
} }
@ApiOperation(value = "招投标列表") @ApiOperation(value = "app往期招标快讯详情列表-分页",hidden = true)
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = AppTenderInfoDTO.class)}) @ApiResponses({@ApiResponse(code = 200, message = "OK", response = AppTenderInfoDTO.class)})
@PostMapping(value = "listNewTenderInfo") @GetMapping(value = "info/app")
public ResultBody listNewTenderInfo(@Validated(value = {Page.class})@RequestBody IndustryCaseQO industryCaseQO, HttpServletRequest request){ public ResultBody listTenderInfoApp(@RequestParam Integer pageNo, @RequestParam Integer pageSize,
return tenderService.listNewTenderInfo(industryCaseQO, this.getUserLoginInfoFromRedis(request), request); @RequestParam Integer tenderNewsId, @RequestParam(required = false) Integer userAccountId){
return tenderService.listTenderInfoApp(pageNo, pageSize, tenderNewsId, userAccountId);
} }
} }
package com.mmc.csf.release.dao; package com.mmc.csf.release.dao;
import com.mmc.csf.infomation.qo.IndustryCaseQO; import com.mmc.csf.infomation.qo.IndustryCaseQO;
import com.mmc.csf.infomation.qo.IndustryNewsQO;
import com.mmc.csf.infomation.vo.IndustryNewsVO;
import com.mmc.csf.release.entity.IndustryNewsDO; import com.mmc.csf.release.entity.IndustryNewsDO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
...@@ -32,4 +34,14 @@ public interface IndustryNewsDao { ...@@ -32,4 +34,14 @@ public interface IndustryNewsDao {
* @return * @return
*/ */
IndustryNewsDO details(Integer id); IndustryNewsDO details(Integer id);
Integer count(IndustryNewsDO industryNewsDO);
Integer insert(IndustryNewsDO industryNewsDO);
Integer update(IndustryNewsDO industryNewsDO);
Integer countPage(IndustryNewsQO industryNewsQO);
List<IndustryNewsDO> backgroundListNewsPage(IndustryNewsQO industryNewsQO);
} }
package com.mmc.csf.release.entity; package com.mmc.csf.release.entity;
import com.mmc.csf.infomation.vo.IndustryNewsVO; import com.mmc.csf.infomation.vo.IndustryNewsDTO;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
...@@ -15,6 +17,7 @@ import java.util.Date; ...@@ -15,6 +17,7 @@ import java.util.Date;
@Data @Data
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@Builder
public class IndustryNewsDO implements Serializable { public class IndustryNewsDO implements Serializable {
private static final long serialVersionUID = 3296973167970903480L; private static final long serialVersionUID = 3296973167970903480L;
private Integer id; private Integer id;
...@@ -25,18 +28,30 @@ public class IndustryNewsDO implements Serializable { ...@@ -25,18 +28,30 @@ public class IndustryNewsDO implements Serializable {
private String newsContents; private String newsContents;
private Date createTime; private Date createTime;
private Date updateTime; private Date updateTime;
@ApiModelProperty(value = "来源")
private String origin;
public IndustryNewsVO buildIndustryNewsVO(){ public IndustryNewsDTO buildIndustryNewsDTO(){
return IndustryNewsVO.builder().id(id).newsTitle(newsTitle).newsAuthor(newsAuthor).userAccountId(userAccountId).surfaceImg(surfaceImg). return IndustryNewsDTO.builder().id(id).newsTitle(newsTitle).newsAuthor(newsAuthor).userAccountId(userAccountId).surfaceImg(surfaceImg).
newsContents(newsContents).createTime(createTime).updateTime(updateTime).build(); newsContents(newsContents).createTime(createTime).updateTime(updateTime).origin(origin).build();
} }
public IndustryNewsDO(IndustryNewsVO industryNewsVO){ public IndustryNewsDO(IndustryNewsDTO industryNewsDTO){
this.id = industryNewsVO.getId(); this.id = industryNewsDTO.getId();
this.newsTitle = industryNewsVO.getNewsTitle(); this.newsTitle = industryNewsDTO.getNewsTitle();
this.newsAuthor = industryNewsVO.getNewsAuthor(); this.newsAuthor = industryNewsDTO.getNewsAuthor();
this.userAccountId = industryNewsVO.getUserAccountId(); this.userAccountId = industryNewsDTO.getUserAccountId();
this.surfaceImg = industryNewsVO.getSurfaceImg(); this.surfaceImg = industryNewsDTO.getSurfaceImg();
this.newsContents = industryNewsVO.getNewsContents(); this.newsContents = industryNewsDTO.getNewsContents();
}
public IndustryNewsDO(Integer id, String newsTitle, String newsAuthor, Integer userAccountId, String surfaceImg, String newsContents, String origin) {
this.id = id;
this.newsTitle = newsTitle;
this.newsAuthor = newsAuthor;
this.userAccountId = userAccountId;
this.surfaceImg = surfaceImg;
this.newsContents = newsContents;
this.origin = origin;
} }
} }
...@@ -2,6 +2,9 @@ package com.mmc.csf.release.service; ...@@ -2,6 +2,9 @@ package com.mmc.csf.release.service;
import com.mmc.csf.common.util.web.ResultBody; import com.mmc.csf.common.util.web.ResultBody;
import com.mmc.csf.infomation.qo.IndustryCaseQO; import com.mmc.csf.infomation.qo.IndustryCaseQO;
import com.mmc.csf.infomation.qo.IndustryNewsQO;
import com.mmc.csf.infomation.vo.IndustryNewsDTO;
import com.mmc.csf.infomation.vo.IndustryNewsVO;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
...@@ -11,7 +14,7 @@ import javax.servlet.http.HttpServletRequest; ...@@ -11,7 +14,7 @@ import javax.servlet.http.HttpServletRequest;
*/ */
public interface IndustryNewsService { public interface IndustryNewsService {
/** /**
* 新闻列表 * 新闻列表-web
* @param industryCaseQO * @param industryCaseQO
* @param request * @param request
* @return * @return
...@@ -24,4 +27,19 @@ public interface IndustryNewsService { ...@@ -24,4 +27,19 @@ public interface IndustryNewsService {
* @return * @return
*/ */
ResultBody details(Integer id); ResultBody details(Integer id);
/**
* 新闻插入
*/
ResultBody insertIndustryNews(IndustryNewsVO industryNewsVO, Integer userAccountId);
/**
* 新闻编辑
*/
ResultBody upDateIndustryNews(IndustryNewsVO industryNewsVO, Integer userAccountId);
/**
* 新闻列表-后台
*/
ResultBody<IndustryNewsDTO> backgroundListNewsPage(IndustryNewsQO industryNewsQO, HttpServletRequest request);
} }
...@@ -2,7 +2,10 @@ package com.mmc.csf.release.service.impl; ...@@ -2,7 +2,10 @@ package com.mmc.csf.release.service.impl;
import com.mmc.csf.common.util.page.PageResult; import com.mmc.csf.common.util.page.PageResult;
import com.mmc.csf.common.util.web.ResultBody; import com.mmc.csf.common.util.web.ResultBody;
import com.mmc.csf.common.util.web.ResultEnum;
import com.mmc.csf.infomation.qo.IndustryCaseQO; import com.mmc.csf.infomation.qo.IndustryCaseQO;
import com.mmc.csf.infomation.qo.IndustryNewsQO;
import com.mmc.csf.infomation.vo.IndustryNewsDTO;
import com.mmc.csf.infomation.vo.IndustryNewsVO; import com.mmc.csf.infomation.vo.IndustryNewsVO;
import com.mmc.csf.release.constant.TokenConstant; import com.mmc.csf.release.constant.TokenConstant;
import com.mmc.csf.release.dao.IndustryNewsDao; import com.mmc.csf.release.dao.IndustryNewsDao;
...@@ -42,16 +45,53 @@ public class IndustryNewsServiceImpl implements IndustryNewsService { ...@@ -42,16 +45,53 @@ public class IndustryNewsServiceImpl implements IndustryNewsService {
Integer pageNo = industryCaseQO.getPageNo(); Integer pageNo = industryCaseQO.getPageNo();
industryCaseQO.buildCurrentPage(); industryCaseQO.buildCurrentPage();
List<IndustryNewsDO> industryNewsDOList = industryNewsDao.listNewsPage(industryCaseQO); List<IndustryNewsDO> industryNewsDOList = industryNewsDao.listNewsPage(industryCaseQO);
List<IndustryNewsVO> industryNewsVOS = industryNewsDOList.stream().map(IndustryNewsDO::buildIndustryNewsVO).collect(Collectors.toList()); List<IndustryNewsDTO> industryNewsDTOS = industryNewsDOList.stream().map(IndustryNewsDO::buildIndustryNewsDTO).collect(Collectors.toList());
return ResultBody.success(PageResult.buildPage(pageNo, industryCaseQO.getPageSize(), count, industryNewsVOS)); return ResultBody.success(PageResult.buildPage(pageNo, industryCaseQO.getPageSize(), count, industryNewsDTOS));
} }
@Override @Override
public ResultBody details(Integer id) { public ResultBody details(Integer id) {
IndustryNewsDO industryNewsDO = industryNewsDao.details(id); IndustryNewsDO industryNewsDO = industryNewsDao.details(id);
if (industryNewsDO!= null) { if (industryNewsDO!= null) {
return ResultBody.success(industryNewsDO.buildIndustryNewsVO()); return ResultBody.success(industryNewsDO.buildIndustryNewsDTO());
} }
return ResultBody.success(); return ResultBody.success();
} }
@Override
public ResultBody insertIndustryNews(IndustryNewsVO param, Integer userAccountId) {
IndustryNewsDO industryNewsDO = IndustryNewsDO.builder().newsTitle(param.getNewsTitle()).build();
Integer count = industryNewsDao.count(industryNewsDO);
if(count>0){
return ResultBody.error(ResultEnum.INDUSTRY_NEWS_TITLE_EXISTS);
}
industryNewsDO = new IndustryNewsDO(param.getId(), param.getNewsTitle(), param.getNewsAuthor(), userAccountId, param.getSurfaceImg(), param.getNewsContents(), param.getOrigin());
industryNewsDao.insert(industryNewsDO);
return ResultBody.success();
}
@Override
public ResultBody upDateIndustryNews(IndustryNewsVO param, Integer userAccountId) {
IndustryNewsDO industryNewsDO = IndustryNewsDO.builder().newsTitle(param.getNewsTitle()).build();
Integer count = industryNewsDao.count(industryNewsDO);
if(count>0){
return ResultBody.error(ResultEnum.INDUSTRY_NEWS_TITLE_EXISTS);
}
industryNewsDO = new IndustryNewsDO(param.getId(), param.getNewsTitle(), param.getNewsAuthor(), userAccountId, param.getSurfaceImg(), param.getNewsContents(), param.getOrigin());
industryNewsDao.update(industryNewsDO);
return ResultBody.success();
}
@Override
public ResultBody<IndustryNewsDTO> backgroundListNewsPage(IndustryNewsQO industryNewsQO, HttpServletRequest request) {
Integer count = industryNewsDao.countPage(industryNewsQO);
if (count == 0) {
return ResultBody.success(PageResult.buildPage(industryNewsQO.getPageNo(), industryNewsQO.getPageSize(), count));
}
Integer pageNo = industryNewsQO.getPageNo();
industryNewsQO.buildCurrentPage();
List<IndustryNewsDO> industryNewsDOList = industryNewsDao.backgroundListNewsPage(industryNewsQO);
List<IndustryNewsDTO> industryNewsDTOS = industryNewsDOList.stream().map(IndustryNewsDO::buildIndustryNewsDTO).collect(Collectors.toList());
return ResultBody.success(PageResult.buildPage(pageNo, industryNewsQO.getPageSize(), count, industryNewsDTOS));
}
} }
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.mmc.csf.release.dao.IndustryNewsDao"> <mapper namespace="com.mmc.csf.release.dao.IndustryNewsDao">
<select id="countListNewsPage" resultType="java.lang.Integer" parameterType="com.mmc.csf.infomation.qo.IndustryCaseQO"> <select id="countListNewsPage" resultType="java.lang.Integer"
parameterType="com.mmc.csf.infomation.qo.IndustryCaseQO">
select count(*) from industry_news select count(*) from industry_news
where is_deleted = 0 where is_deleted = 0
<if test=" userIds != null "> <if test=" userIds != null ">
...@@ -17,13 +18,15 @@ ...@@ -17,13 +18,15 @@
</if> </if>
</select> </select>
<select id="listNewsPage" resultType="com.mmc.csf.release.entity.IndustryNewsDO" parameterType="com.mmc.csf.infomation.qo.IndustryCaseQO"> <select id="listNewsPage" resultType="com.mmc.csf.release.entity.IndustryNewsDO"
parameterType="com.mmc.csf.infomation.qo.IndustryCaseQO">
select id, select id,
news_title, news_title,
news_author, news_author,
user_account_id, user_account_id,
surface_img, surface_img,
news_contents, news_contents,
origin,
create_time, create_time,
update_time update_time
from industry_news from industry_news
...@@ -43,14 +46,118 @@ ...@@ -43,14 +46,118 @@
<select id="details" resultType="com.mmc.csf.release.entity.IndustryNewsDO"> <select id="details" resultType="com.mmc.csf.release.entity.IndustryNewsDO">
select id, select id,
news_title,
news_author,
user_account_id,
surface_img,
news_contents,
origin,
create_time,
update_time
from industry_news
where is_deleted = 0
and id = #{id}
</select>
<select id="count" resultType="java.lang.Integer" parameterType="com.mmc.csf.release.entity.IndustryNewsDO">
select count(*)
from industry_news
<where>
is_deleted = 0
<if test="newsTitle != null and newsTitle != ''">
and news_title = #{newsTitle}
</if>
<if test="newsAuthor != null and newsAuthor != ''">
and news_author = #{newsAuthor}
</if>
<if test="userAccountId != null">
and user_account_id = #{userAccountId}
</if>
<if test="surfaceImg != null and surfaceImg != ''">
and surface_img = #{surfaceImg}
</if>
<if test="newsContents != null and newsContents != ''">
and news_contents = #{newsContents}
</if>
<if test="origin != null and origin != ''">
and origin = #{origin}
</if>
</where>
</select>
<insert id="insert" parameterType="com.mmc.csf.release.entity.IndustryNewsDO" useGeneratedKeys="true"
keyColumn="id">
insert into industry_news(news_title, news_author, user_account_id, surface_img, news_contents, origin,
create_time)
values (#{newsTitle}, #{newsAuthor}, #{userAccountId}, #{surfaceImg}, #{newsContents}, #{origin}, now())
</insert>
<update id="update" parameterType="com.mmc.csf.release.entity.IndustryNewsDO">
update industry_news
<set>
<if test="newsTitle != null and newsTitle != ''">
news_title = #{newsTitle},
</if>
<if test="newsAuthor != null and newsAuthor != ''">
news_author = #{newsAuthor},
</if>
<if test="userAccountId != null">
user_account_id = #{userAccountId},
</if>
<if test="surfaceImg != null and surfaceImg != ''">
surface_img = #{surfaceImg},
</if>
<if test="newsContents != null">
news_contents = #{newsContents},
</if>
<if test="origin != null and origin != ''">
origin = #{origin},
</if>
</set>
where is_deleted = 0 and id = #{id}
</update>
<select id="countPage" parameterType="com.mmc.csf.infomation.qo.IndustryNewsQO" resultType="java.lang.Integer">
select count(*)
from industry_news
<where>
is_deleted = 0
<if test="newsTitle != null and newsTitle != ''">
and news_title like concat('%',#{newsTitle},'%')
</if>
<if test="startTime != null">
and create_time &gt;= #{startTime}
</if>
<if test="endTime != null">
and create_time &lt;= #{endTime}
</if>
</where>
</select>
<select id="backgroundListNewsPage" parameterType="com.mmc.csf.infomation.qo.IndustryNewsQO"
resultType="com.mmc.csf.release.entity.IndustryNewsDO">
select id,
news_title, news_title,
news_author, news_author,
user_account_id, user_account_id,
surface_img, surface_img,
news_contents, news_contents,
origin,
create_time, create_time,
update_time update_time
from industry_news from industry_news
where is_deleted = 0 and id = #{id} <where>
is_deleted = 0
<if test="newsTitle != null and newsTitle != ''">
and news_title like concat('%',#{newsTitle},'%')
</if>
<if test="startTime != null">
and create_time &gt;= #{startTime}
</if>
<if test="endTime != null">
and create_time &lt;= #{endTime}
</if>
</where>
order by create_time desc
limit #{pageNo}, #{pageSize}
</select> </select>
</mapper> </mapper>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论