zhongrj
2024-03-25 f94f59a54dc86cba0a8c9035d11fe9947c8e6854
文章新增字段,反诈文章查看记录浏览记录积分
5 files modified
60 ■■■■■ changed files
src/main/java/org/springblade/modules/article/controller/ArticleController.java 6 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/article/entity/Article.java 7 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/article/entity/ArticleIntegralEntity.java 6 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/article/service/ArticleService.java 10 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/article/service/impl/ArticleServiceImpl.java 31 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/article/controller/ArticleController.java
@@ -219,15 +219,15 @@
    }
    /**
     * 通知公告表浏览数量加一
     * 通知公告表浏览数量加一(反诈的居民查看会得积分)
     */
    @PostMapping("/addNumber")
    @ApiOperationSupport(order = 8)
    @ApiOperation(value = "添加浏览数量", notes = "传入notice")
    public R addNumber(@Valid @RequestBody Article notice) {
    public R addNumber(@Valid @RequestBody ArticleVO notice) {
        UpdateWrapper<Article> objectUpdateWrapper = new UpdateWrapper<>();
        objectUpdateWrapper.setSql("view_number = view_number + 1");
        objectUpdateWrapper.eq("id", notice.getId());
        return R.status(articleService.update(null, objectUpdateWrapper));
        return R.status(articleService.updateArticle(objectUpdateWrapper,notice.getId(),notice.getHouseCode()));
    }
}
src/main/java/org/springblade/modules/article/entity/Article.java
@@ -28,8 +28,8 @@
    @TableField("title")
    private String title;
    /** 类型  0:文章 1经营性收支,2:物业招标 3:公益报名 4:选举调查 */
    @ApiModelProperty(value = "类型  0:文章 1经营性收支,2:物业招标 3:公益报名 4:选举调查", example = "")
    /** 类型  0:文章 1经营性收支,2:物业招标 3:公益报名 4:选举调查 5:反诈宣传 */
    @ApiModelProperty(value = "类型  0:文章 1经营性收支,2:物业招标 3:公益报名 4:选举调查 5:反诈宣传", example = "")
    @TableField("type")
    private Integer type;
@@ -136,4 +136,7 @@
    @ApiModelProperty(value = "小区id", example = "")
    @TableField("district_id")
    private String districtId;
    @ApiModelProperty(value = "分数", example = "")
    private Integer score;
}
src/main/java/org/springblade/modules/article/entity/ArticleIntegralEntity.java
@@ -43,6 +43,12 @@
     */
    @ApiModelProperty(value = "得分")
    private Integer score;
    /**
     * 地址编号
     */
    @ApiModelProperty(value = "地址编号")
    private String houseCode;
    /**
     * 创建人(浏览人用户id)
     */
src/main/java/org/springblade/modules/article/service/ArticleService.java
@@ -1,5 +1,6 @@
package org.springblade.modules.article.service;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springblade.modules.article.entity.Article;
@@ -65,4 +66,13 @@
    ArticleVO getArticleOne(ArticleVO article);
    List<ArticleVO> getArticleByDistrictId(ArticleVO article);
    /**
     * 文章信息更新
     * @param objectUpdateWrapper
     * @param id
     * @param houseCode
     * @return
     */
    boolean updateArticle(UpdateWrapper<Article> objectUpdateWrapper,Long id,String houseCode);
}
src/main/java/org/springblade/modules/article/service/impl/ArticleServiceImpl.java
@@ -1,5 +1,6 @@
package org.springblade.modules.article.service.impl;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -9,8 +10,10 @@
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.utils.SpringUtil;
import org.springblade.modules.article.entity.Article;
import org.springblade.modules.article.entity.ArticleIntegralEntity;
import org.springblade.modules.article.mapper.ArticleMapper;
import org.springblade.modules.article.service.ArticleService;
import org.springblade.modules.article.service.IArticleIntegralService;
import org.springblade.modules.article.vo.ArticleVO;
import org.springblade.modules.district.entity.DistrictEntity;
import org.springblade.modules.district.service.IDistrictService;
@@ -184,4 +187,32 @@
        article.setDistrictIdList(stringList);
        return baseMapper.getArticleByDistrictId(article);
    }
    /**
     * 文章信息更新
     * @param objectUpdateWrapper
     * @param id
     * @param houseCode
     * @return
     */
    @Override
    public boolean updateArticle(UpdateWrapper<Article> objectUpdateWrapper, Long id, String houseCode) {
        boolean update = update(null, objectUpdateWrapper);
        if (update){
            // 查询对应的文章
            Article article = getById(id);
            // 只有反诈的有浏览积分
            if (article.getType()==6) {
                // 添加浏览记录信息
                ArticleIntegralEntity integralEntity = new ArticleIntegralEntity();
                integralEntity.setScore(article.getScore());
                integralEntity.setArticleId(id);
                integralEntity.setHouseCode(houseCode);
                // 插入记录
                update = SpringUtils.getBean(IArticleIntegralService.class).save(integralEntity);
            }
        }
        // 返回
        return update;
    }
}