|
@@ -2,14 +2,12 @@ package com.ruoyi.zzb.study.service;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.ruoyi.common.annotation.DataSource;
|
|
|
+import com.ruoyi.common.core.domain.entity.SysUser;
|
|
|
import com.ruoyi.common.enums.DataSourceType;
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
-import com.ruoyi.zzb.base.domain.BasePersonInfo;
|
|
|
-import com.ruoyi.zzb.base.mapper.BasePersonInfoMapper;
|
|
|
import com.ruoyi.zzb.study.domain.StudyDocInfo;
|
|
|
import com.ruoyi.zzb.study.domain.StudyViewLogInfo;
|
|
|
import com.ruoyi.zzb.study.domain.UserSearchParam;
|
|
@@ -20,6 +18,7 @@ import com.ruoyi.zzb.study.mapper.StudyViewLogInfoMapper;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
@Service
|
|
|
@Slf4j
|
|
@@ -37,13 +36,14 @@ public class StudyService {
|
|
|
|
|
|
|
|
|
public Page<StudyDocInfo> findAllInfo(UserSearchParam searchParam) {
|
|
|
- //分页参数
|
|
|
+ //分页参数
|
|
|
Page<StudyDocInfo> rowPage = new Page(searchParam.getPageIndex(), searchParam.getPageSize());
|
|
|
|
|
|
//查询条件
|
|
|
LambdaQueryWrapper<StudyDocInfo> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- if(StringUtils.isNotEmpty(searchParam.getTitle()))
|
|
|
-
|
|
|
+ if(StringUtils.isNotEmpty(searchParam.getTitle())){
|
|
|
+ queryWrapper.like(StudyDocInfo::getTitle,searchParam.getTitle());
|
|
|
+ }
|
|
|
|
|
|
//排序
|
|
|
queryWrapper.orderByAsc(StudyDocInfo::getOrderNum);
|
|
@@ -54,27 +54,29 @@ public class StudyService {
|
|
|
|
|
|
}
|
|
|
|
|
|
- public JSONObject findByWrapper(String id) {
|
|
|
- JSONObject resultData = new JSONObject();
|
|
|
- QueryWrapper<StudyDocInfo> queryWrapper = new QueryWrapper();
|
|
|
-// queryWrapper.like(false,"username","aaa");
|
|
|
- queryWrapper.eq(StringUtils.isNotEmpty(id),"DOC_ID",id);
|
|
|
+ public StudyDocInfo findDocInfoById(String id) {
|
|
|
+ LambdaQueryWrapper<StudyDocInfo> queryWrapper = new LambdaQueryWrapper();
|
|
|
+ queryWrapper.eq(StudyDocInfo::getDocId,id);
|
|
|
|
|
|
StudyDocInfo studyDocInfo= studyDocInfoMapper.selectOne(queryWrapper);
|
|
|
- System.out.println(JSONObject.toJSONString(studyDocInfo));
|
|
|
-
|
|
|
- resultData.put("records",studyDocInfo);
|
|
|
-
|
|
|
- return resultData;
|
|
|
+ return studyDocInfo;
|
|
|
}
|
|
|
|
|
|
public boolean saveDocInfo(StudyDocInfo studyDocInfo) {
|
|
|
int i = studyDocInfoMapper.insert(studyDocInfo);
|
|
|
+ if( i!=1 ){
|
|
|
+ throw new RuntimeException("数据写入失败,成功0条,入参:"+JSONObject.toJSONString(studyDocInfo));
|
|
|
+ }
|
|
|
+
|
|
|
return i == 1;
|
|
|
}
|
|
|
|
|
|
public boolean deleteById(String id) {
|
|
|
int i = studyDocInfoMapper.deleteById(id);
|
|
|
+
|
|
|
+ if( i!=1 ){
|
|
|
+ throw new RuntimeException("数据删除失败,docId不存在:"+id);
|
|
|
+ }
|
|
|
return i == 1;
|
|
|
}
|
|
|
|
|
@@ -83,20 +85,16 @@ public class StudyService {
|
|
|
UpdateWrapper<StudyDocInfo> updateWrapper = new UpdateWrapper<>();
|
|
|
updateWrapper.eq("DOC_ID",updatePageViewNumVO.getDocId()).set("PAGE_VIEW_NUM", updatePageViewNumVO.getPageViewNum());
|
|
|
Integer i = studyDocInfoMapper.update(null, updateWrapper);
|
|
|
+
|
|
|
+ if( i!=1 ){
|
|
|
+ throw new RuntimeException("修改文章浏览量失败,docId不存在:"+updatePageViewNumVO.getDocId());
|
|
|
+ }
|
|
|
return i == 1;
|
|
|
}
|
|
|
|
|
|
- public boolean saveViewLogInfo(SaveViewLogVO saveViewLogVO) {
|
|
|
- //获取人员信息
|
|
|
-
|
|
|
- QueryWrapper<BasePersonInfo> queryPersonWrapper = new QueryWrapper();
|
|
|
- queryPersonWrapper.eq("USER_ID",saveViewLogVO.getUserId());
|
|
|
- queryPersonWrapper.eq("STATUS",0); //非禁用用户
|
|
|
- BasePersonInfo personInfo =basePersonInfoMapper.selectOne(queryPersonWrapper);
|
|
|
+ @Transactional
|
|
|
+ public boolean saveViewLogInfo(SaveViewLogVO saveViewLogVO,SysUser sysUser) {
|
|
|
|
|
|
- if(personInfo == null){
|
|
|
- return false;
|
|
|
- }
|
|
|
|
|
|
//记录浏览量+1
|
|
|
UpdateWrapper<StudyDocInfo> updateDocWrapper = new UpdateWrapper<>();
|
|
@@ -105,29 +103,33 @@ public class StudyService {
|
|
|
Integer j = studyDocInfoMapper.update(null,updateDocWrapper);
|
|
|
|
|
|
if(j != 1){
|
|
|
- return false;
|
|
|
+ throw new RuntimeException("记录浏览量更新异常,docId不存在:"+saveViewLogVO.getDocId());
|
|
|
}
|
|
|
|
|
|
//保存访问记录
|
|
|
StudyViewLogInfo studyViewLogInfo = new StudyViewLogInfo();
|
|
|
studyViewLogInfo.setDocId(saveViewLogVO.getDocId());
|
|
|
studyViewLogInfo.setUserId(saveViewLogVO.getUserId());
|
|
|
- studyViewLogInfo.setUserName(personInfo.getName());
|
|
|
- studyViewLogInfo.setUserIdcard(personInfo.getIdcard());
|
|
|
- studyViewLogInfo.setUserPoliceNo(personInfo.getPoliceNo());
|
|
|
- studyViewLogInfo.setParentDeptCode(personInfo.getParentDeptCode());
|
|
|
- studyViewLogInfo.setParentDeptName(personInfo.getParentDeptName());
|
|
|
- studyViewLogInfo.setDeptCode(personInfo.getDeptCode());
|
|
|
- studyViewLogInfo.setDeptName(personInfo.getDeptName());
|
|
|
+ studyViewLogInfo.setUserName(sysUser.getNickName());
|
|
|
+ studyViewLogInfo.setUserIdcard(sysUser.getIdCard());
|
|
|
+ studyViewLogInfo.setUserPoliceNo(sysUser.getPoliceNo());
|
|
|
+ studyViewLogInfo.setParentDeptCode(sysUser.getDept().getParentId()+"");
|
|
|
+ studyViewLogInfo.setParentDeptName(sysUser.getDept().getParentName());
|
|
|
+ studyViewLogInfo.setDeptCode(sysUser.getDept().getDeptId()+"");
|
|
|
+ studyViewLogInfo.setDeptName(sysUser.getDept().getDeptName());
|
|
|
int i = studyViewLogInfoMapper.insert(studyViewLogInfo);
|
|
|
|
|
|
+ if(i != 1){
|
|
|
+ throw new RuntimeException("保存访问记录日志保存失败:"+JSONObject.toJSONString(studyViewLogInfo));
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
return i == 1 && j ==1;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- /**
|
|
|
+ /**
|
|
|
* 分页查询用户列表
|
|
|
*/
|
|
|
public Page<StudyDocInfo> findInfoByTitle(UserSearchParam searchParam)
|
|
@@ -150,4 +152,15 @@ public class StudyService {
|
|
|
return rowPage;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ public boolean updateById(StudyDocInfo studyDocInfo) {
|
|
|
+
|
|
|
+ int i = studyDocInfoMapper.updateById(studyDocInfo);
|
|
|
+ if(i != 1){
|
|
|
+ throw new RuntimeException("docId不存在:"+studyDocInfo.getDocId());
|
|
|
+ }
|
|
|
+ return i == 1;
|
|
|
+ }
|
|
|
+
|
|
|
}
|