Commit 234af950 authored by 姬鋆屾's avatar 姬鋆屾
parents afaac2d9 6f69d15c
......@@ -83,7 +83,28 @@ PRIMARY KEY (`id`)
ALTER TABLE `mortals_xhx_user` ADD COLUMN `photoPath` varchar(255) COMMENT '头像地址';
ALTER TABLE `mortals_xhx_user` ADD COLUMN `companyAdress` varchar(512) COMMENT '单位地址';
ALTER TABLE `mortals_xhx_user` ADD COLUMN `nickName` varchar(128) COMMENT '昵称';
INSERT INTO `mortals_xhx_task` (`name`, `taskKey`, `status`, `excuteService`, `excuteParam`, `excuteHost`, `excuteStrategy`, `excuteDate`, `excuteTime`, `remark`, `lastExcuteHost`, `lastExcuteTime`, `interimExcuteStatus`, `createTime`, `createUserId`, `createUserName`) VALUES ('员工名片日访问数初始化', 'StaffViewsByDayInit', '0', 'StaffViewsByDayInit', NULL, NULL, '1', '0', '00:00', NULL, NULL, NULL, '0', NULL, '1', '系统管理员');
ALTER TABLE `mortals_xhx_bussinesscard` ADD COLUMN `backdrop` varchar(256) COMMENT '名片背景';
ALTER TABLE `mortals_xhx_news` ADD COLUMN `upNums` tinyint(4) NOT NULL DEFAULT '0' COMMENT '点赞次数';
-- ----------------------------
-- 新闻点赞记录信息表
-- ----------------------------
DROP TABLE IF EXISTS `mortals_xhx_news_up`;
CREATE TABLE mortals_xhx_news_up(
`id` bigint(20) AUTO_INCREMENT COMMENT '序号,主键,自增长',
`newsId` bigint(20) COMMENT '新闻ID',
`upId` bigint(20) COMMENT '点赞人ID',
`upName` varchar(64) NOT NULL COMMENT '点赞人名称',
`sumUp` int(4) DEFAULT '0' COMMENT '累计分享次数',
`remark` varchar(255) COMMENT '备注',
`upTime` datetime NOT NULL COMMENT '点赞时间',
`createUserId` bigint(20) NOT NULL COMMENT '创建用户',
`createTime` datetime NOT NULL COMMENT '创建时间',
`updateUserId` bigint(20) COMMENT '更新用户',
`updateTime` datetime COMMENT '更新时间',
PRIMARY KEY (`id`)
,KEY `upName` (`upName`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='新闻点赞记录信息';
......@@ -113,6 +113,10 @@ public class UserEntity extends UserVo implements IUser {
* 单位地址
*/
private String companyAdress;
/**
* 昵称
*/
private String nickName;
public UserEntity(){}
......@@ -431,6 +435,14 @@ public class UserEntity extends UserVo implements IUser {
this.companyAdress = companyAdress;
}
public String getNickName() {
return nickName;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
@Override
public int hashCode() {
return this.getId().hashCode();
......@@ -502,5 +514,6 @@ public class UserEntity extends UserVo implements IUser {
this.photoPath = "";
this.companyAdress = "";
this.nickName = "";
}
}
\ No newline at end of file
......@@ -207,6 +207,11 @@ public class UserQuery extends UserEntity {
/** 单位地址排除列表 */
private List <String> companyAdressNotList;
/** 昵称 */
private List<String> nickNameList;
/** 昵称排除列表 */
private List <String> nickNameNotList;
/** OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4) */
private List<UserQuery> orConditionList;
......@@ -1294,6 +1299,30 @@ public class UserQuery extends UserEntity {
this.companyAdressNotList = companyAdressNotList;
}
public List<String> getCompanyAdressList() {
return companyAdressList;
}
public void setCompanyAdressList(List<String> companyAdressList) {
this.companyAdressList = companyAdressList;
}
public List<String> getNickNameList() {
return nickNameList;
}
public void setNickNameList(List<String> nickNameList) {
this.nickNameList = nickNameList;
}
public List<String> getNickNameNotList() {
return nickNameNotList;
}
public void setNickNameNotList(List<String> nickNameNotList) {
this.nickNameNotList = nickNameNotList;
}
/**
* 设置 用户ID,主键,自增长
* @param id
......
......@@ -26,7 +26,30 @@ public class NewsListInfo {
* 发布时间
*/
private Date publishTime;
/**
* 所属部门名称
*/
private String deptName;
/**
* 声明
*/
private String statement;
/**
* 文章来源
*/
private String source;
/**
* 责任编辑
*/
private String editor;
/**点赞状态**/
private Integer upStatus;
/**分享状态**/
private Integer shareStatus;
/**
* 头像地址
*/
private String photoPath;
}
package com.mortals.xhx.busiz.applets.web;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.common.Rest;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.IAuthTokenService;
import com.mortals.framework.service.IUser;
import com.mortals.xhx.base.system.user.model.UserEntity;
import com.mortals.xhx.base.system.user.model.UserQuery;
import com.mortals.xhx.base.system.user.service.UserService;
import com.mortals.xhx.busiz.applets.req.FavoriteReq;
import com.mortals.xhx.busiz.applets.req.LoginReq;
import com.mortals.xhx.busiz.applets.req.UserInfoReq;
import com.mortals.xhx.busiz.applets.rsp.FavoriteTypeListInfo;
import com.mortals.xhx.module.bussinesscard.model.BussinesscardEntity;
import com.mortals.xhx.module.bussinesscard.model.BussinesscardQuery;
......@@ -19,16 +15,12 @@ import com.mortals.xhx.module.favorites.model.*;
import com.mortals.xhx.module.favorites.service.FavoritesBusinesscardService;
import com.mortals.xhx.module.favorites.service.FavoritesNewsService;
import com.mortals.xhx.module.favorites.service.FavoritesProductService;
import com.mortals.xhx.module.favorites.web.FavoritesBusinesscardController;
import com.mortals.xhx.module.news.model.NewsEntity;
import com.mortals.xhx.module.news.model.NewsQuery;
import com.mortals.xhx.module.news.service.NewsService;
import com.mortals.xhx.module.product.model.ProductEntity;
import com.mortals.xhx.module.product.model.ProductQuery;
import com.mortals.xhx.module.product.service.ProductService;
import com.mortals.xhx.module.staff.model.StaffEntity;
import com.mortals.xhx.module.staff.model.StaffQuery;
import com.mortals.xhx.module.staff.service.StaffService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
......@@ -124,6 +116,57 @@ public class FavoriteApiController extends AbstractBaseController<FavoriteReq>{
return rest;
}
@RequestMapping("cancelFavorite")
public Rest<Object> cancelFavorite(@RequestBody FavoriteReq favoriteReq) throws Exception {
String busiDesc = "取消收藏产品/新闻/名片";
Rest<Object> rest = Rest.ok();
try {
Context context = this.getContext();
IUser iUser = authTokenService.getLoginUser(request);
if(ObjectUtils.isEmpty(iUser)){
rest = Rest.fail("获取个人信息失败");
}else {
if(!ObjectUtils.isEmpty(favoriteReq.getProductId()) && favoriteReq.getProductId() != 0){
FavoritesProductQuery query = new FavoritesProductQuery();
query.setUserId(iUser.getId());
query.setProductId(favoriteReq.getProductId());
FavoritesProductEntity favoritesProductEntity = favoritesProductService.selectOne(query);
if(favoritesProductEntity!=null) {
favoritesProductService.remove(favoritesProductEntity.getId(),context);
}
rest.setMsg("取消收藏产品成功");
}
if(!ObjectUtils.isEmpty(favoriteReq.getNewsId()) && favoriteReq.getNewsId() != 0){
FavoritesNewsEntity query = new FavoritesNewsEntity();
query.setUserId(iUser.getId());
query.setNewsId(favoriteReq.getNewsId());
FavoritesNewsEntity favoritesNewsEntity = favoritesNewsService.selectOne(query);
if(favoritesNewsEntity!=null) {
favoritesNewsService.remove(favoritesNewsEntity.getId(),context);
}
rest.setMsg("取消收藏新闻成功");
}
if(!ObjectUtils.isEmpty(favoriteReq.getStaffId()) && favoriteReq.getStaffId() != 0){
FavoritesBusinesscardEntity query = new FavoritesBusinesscardEntity();
query.setUserId(iUser.getId());
query.setStaffId(favoriteReq.getStaffId());
FavoritesBusinesscardEntity favoritesBusinesscardEntity = favoritesBusinesscardService.selectOne(query);
if(favoritesBusinesscardEntity!=null) {
favoritesBusinesscardService.remove(favoritesBusinesscardEntity.getId(), context);
}
rest.setMsg("取消收藏名片成功");
}
}
}catch (Exception e) {
log.error(busiDesc, e);
rest = Rest.fail(super.convertException(e));
}
return rest;
}
/**
* 查询收藏分类
......
package com.mortals.xhx.busiz.applets.web;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
......@@ -12,10 +11,6 @@ import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.base.system.user.model.UserQuery;
import com.mortals.xhx.base.system.user.service.UserService;
import com.mortals.xhx.busiz.applets.req.NewsReq;
import com.mortals.xhx.busiz.applets.rsp.NewsListInfo;
import com.mortals.xhx.common.utils.BeanUtil;
import com.mortals.xhx.module.category.model.CategoryQuery;
import com.mortals.xhx.module.category.service.CategoryService;
import com.mortals.xhx.module.dept.model.DeptQuery;
import com.mortals.xhx.module.dept.service.DeptService;
import com.mortals.xhx.module.news.model.NewsCategoryQuery;
......@@ -24,8 +19,6 @@ import com.mortals.xhx.module.news.model.NewsQuery;
import com.mortals.xhx.module.news.service.NewsCategoryService;
import com.mortals.xhx.module.news.service.NewsService;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.PostMapping;
......@@ -35,7 +28,6 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
......@@ -114,12 +106,12 @@ public class NewsApiController extends AbstractBaseController<NewsReq> {
query.setOrderColList(Arrays.asList(new OrderCol("createTime", OrderCol.DESCENDING)));
Result<NewsEntity> result = newsService.find(query, pageInfo, context);
List<NewsListInfo> collect = result.getList().stream().map(item -> {
NewsListInfo newsListInfo = new NewsListInfo();
BeanUtils.copyProperties(item, newsListInfo, BeanUtil.getNullPropertyNames(item));
return newsListInfo;
}).collect(Collectors.toList());
model.put(KEY_RESULT_DATA, collect);
// List<NewsListInfo> collect = result.getList().stream().map(item -> {
// NewsListInfo newsListInfo = new NewsListInfo();
// BeanUtils.copyProperties(item, newsListInfo, BeanUtil.getNullPropertyNames(item));
// return newsListInfo;
// }).collect(Collectors.toList());
model.put(KEY_RESULT_DATA, result.getList());
model.put(PAGEINFO_KEY, result.getPageInfo());
super.parsePageInfo(model, result.getPageInfo());
rest.setData(model);
......@@ -157,4 +149,108 @@ public class NewsApiController extends AbstractBaseController<NewsReq> {
}
return rest;
}
/**
* 新闻点赞
*/
@PostMapping(value = "up")
public Rest<NewsEntity> upNews(@RequestBody NewsReq newsReq) {
String busiDesc = "新闻点赞";
log.info("【{}】【请求体】--> {}", busiDesc, JSONObject.toJSONString(newsReq));
Rest<NewsEntity> rest = Rest.ok(busiDesc + " 【成功】");
Context context = this.getContext();
Map<String, Object> model = new HashMap<>();
try {
if (ObjectUtils.isEmpty(newsReq.getId())) {
throw new AppException("新闻id不能为空!");
}
NewsEntity newsEntity = newsService.upNews(newsReq.getId(),context,1);
rest.setData(newsEntity);
this.init(model, context);
rest.setDict(model.get("dict"));
recordSysLog(request, busiDesc + " 【成功】");
} catch (Exception e) {
log.error(busiDesc, e);
rest = Rest.fail(super.convertException(e));
}
return rest;
}
/**
* 新闻取消点赞
*/
@PostMapping(value = "cancelUp")
public Rest<NewsEntity> cancelUpNews(@RequestBody NewsReq newsReq) {
String busiDesc = "新闻点赞";
log.info("【{}】【请求体】--> {}", busiDesc, JSONObject.toJSONString(newsReq));
Rest<NewsEntity> rest = Rest.ok(busiDesc + " 【成功】");
Context context = this.getContext();
Map<String, Object> model = new HashMap<>();
try {
if (ObjectUtils.isEmpty(newsReq.getId())) {
throw new AppException("新闻id不能为空!");
}
NewsEntity newsEntity = newsService.upNews(newsReq.getId(),context,-1);
rest.setData(newsEntity);
this.init(model, context);
rest.setDict(model.get("dict"));
recordSysLog(request, busiDesc + " 【成功】");
} catch (Exception e) {
log.error(busiDesc, e);
rest = Rest.fail(super.convertException(e));
}
return rest;
}
/**
* 新闻浏览
*/
@PostMapping(value = "view")
public Rest<NewsEntity> viewNews(@RequestBody NewsReq newsReq) {
String busiDesc = "新闻浏览";
log.info("【{}】【请求体】--> {}", busiDesc, JSONObject.toJSONString(newsReq));
Rest<NewsEntity> rest = Rest.ok(busiDesc + " 【成功】");
Context context = this.getContext();
Map<String, Object> model = new HashMap<>();
try {
if (ObjectUtils.isEmpty(newsReq.getId())) {
throw new AppException("新闻id不能为空!");
}
NewsEntity newsEntity = newsService.viewNews(newsReq.getId(),context);
rest.setData(newsEntity);
this.init(model, context);
rest.setDict(model.get("dict"));
recordSysLog(request, busiDesc + " 【成功】");
} catch (Exception e) {
log.error(busiDesc, e);
rest = Rest.fail(super.convertException(e));
}
return rest;
}
/**
* 新闻分享
*/
@PostMapping(value = "share")
public Rest<NewsEntity> shareNews(@RequestBody NewsReq newsReq) {
String busiDesc = "新闻分享";
log.info("【{}】【请求体】--> {}", busiDesc, JSONObject.toJSONString(newsReq));
Rest<NewsEntity> rest = Rest.ok(busiDesc + " 【成功】");
Context context = this.getContext();
Map<String, Object> model = new HashMap<>();
try {
if (ObjectUtils.isEmpty(newsReq.getId())) {
throw new AppException("新闻id不能为空!");
}
NewsEntity newsEntity = newsService.shareNews(newsReq.getId(),context);
rest.setData(newsEntity);
this.init(model, context);
rest.setDict(model.get("dict"));
recordSysLog(request, busiDesc + " 【成功】");
} catch (Exception e) {
log.error(busiDesc, e);
rest = Rest.fail(super.convertException(e));
}
return rest;
}
}
......@@ -8,22 +8,12 @@ import com.mortals.framework.model.Context;
import com.mortals.framework.model.OrderCol;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result;
import com.mortals.xhx.busiz.applets.req.NewsReq;
import com.mortals.xhx.busiz.applets.req.ProductReq;
import com.mortals.xhx.busiz.applets.rsp.NewsListInfo;
import com.mortals.xhx.common.utils.BeanUtil;
import com.mortals.xhx.module.category.model.CategoryQuery;
import com.mortals.xhx.module.category.service.CategoryService;
import com.mortals.xhx.module.company.model.CompanyQuery;
import com.mortals.xhx.module.company.service.CompanyService;
import com.mortals.xhx.module.labels.model.LabelsQuery;
import com.mortals.xhx.module.labels.service.LabelsService;
import com.mortals.xhx.module.news.model.NewsEntity;
import com.mortals.xhx.module.news.model.NewsQuery;
import com.mortals.xhx.module.product.model.ProductCategoryQuery;
import com.mortals.xhx.module.product.model.ProductEntity;
import com.mortals.xhx.module.product.model.ProductQuery;
import com.mortals.xhx.module.product.service.ProductCategoryService;
import com.mortals.xhx.module.product.service.ProductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
......
......@@ -19,5 +19,8 @@ public class FeedbackVo extends BaseEntityLong {
/** 主键ID,主键,自增长列表 */
private List <Long> idList;
/**
* 头像地址
*/
private String photoPath;
}
\ No newline at end of file
package com.mortals.xhx.module.feedback.service.impl;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.util.StringUtils;
import com.mortals.xhx.base.system.user.model.UserEntity;
import com.mortals.xhx.base.system.user.model.UserQuery;
import com.mortals.xhx.base.system.user.service.UserService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException;
......@@ -7,6 +14,12 @@ import com.mortals.xhx.module.feedback.dao.FeedbackDao;
import com.mortals.xhx.module.feedback.model.FeedbackEntity;
import com.mortals.xhx.module.feedback.service.FeedbackService;
import lombok.extern.slf4j.Slf4j;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* FeedbackService
* 反馈信息 service实现
......@@ -18,4 +31,36 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
public class FeedbackServiceImpl extends AbstractCRUDServiceImpl<FeedbackDao, FeedbackEntity, Long> implements FeedbackService {
@Autowired
private UserService userService;
@Override
protected void saveBefore(FeedbackEntity entity, Context context) throws AppException {
super.saveBefore(entity,context);
if(StringUtils.isEmpty(entity.getTitle())){
entity.setTitle("来自微信小程序的反馈");
}
if(context!=null&&context.getUser()!=null){
UserEntity userEntity = userService.get(context.getUser().getId());
if(userEntity!=null){
entity.setFeedbackName(userEntity.getRealName());
}
}
}
@Override
protected void findAfter(FeedbackEntity params, PageInfo pageInfo, Context context, List<FeedbackEntity> list) throws AppException {
super.findAfter(params, pageInfo, context, list);
if(CollectionUtils.isNotEmpty(list)){
List<Long> userIdList = list.stream().map(FeedbackEntity::getCreateUserId).collect(Collectors.toList());
List<UserEntity> userList = userService.find(new UserQuery().idList(userIdList));
Map<Long,UserEntity> userMap = userList.parallelStream().collect(Collectors.toMap(x -> x.getId(), z -> z, (o, n) -> n));
for(FeedbackEntity item:list){
UserEntity userEntity = userMap.get(item.getCreateUserId());
if(userEntity!=null) {
item.setPhotoPath(userEntity.getPhotoPath());
}
}
}
}
}
\ No newline at end of file
package com.mortals.xhx.module.news.dao;
import com.mortals.framework.dao.ICRUDDao;
import com.mortals.xhx.module.news.model.NewsUpEntity;
import java.util.List;
/**
* 新闻点赞记录信息Dao
* 新闻点赞记录信息 DAO接口
*
* @author zxfei
* @date 2024-12-04
*/
public interface NewsUpDao extends ICRUDDao<NewsUpEntity,Long>{
}
package com.mortals.xhx.module.news.dao.ibatis;
import org.springframework.stereotype.Repository;
import com.mortals.xhx.module.news.dao.NewsUpDao;
import com.mortals.xhx.module.news.model.NewsUpEntity;
import java.util.Date;
import com.mortals.framework.dao.ibatis.BaseCRUDDaoMybatis;
import java.util.List;
/**
* 新闻点赞记录信息DaoImpl DAO接口
*
* @author zxfei
* @date 2024-12-04
*/
@Repository("newsUpDao")
public class NewsUpDaoImpl extends BaseCRUDDaoMybatis<NewsUpEntity,Long> implements NewsUpDao {
}
......@@ -80,6 +80,10 @@ public class NewsEntity extends NewsVo {
* 备注
*/
private String remark;
/**
* 点赞次数
*/
private Integer upNums;
@Override
public int hashCode() {
return this.getId().hashCode();
......@@ -104,7 +108,7 @@ public class NewsEntity extends NewsVo {
this.content = "";
this.top = 0;
this.viewNums = 0;
this.publishTime =null;
this.publishTime = new Date();
this.editor = "";
this.shareNums = 0;
this.deptId = null;
......@@ -112,5 +116,6 @@ public class NewsEntity extends NewsVo {
this.statement = "";
this.source = "";
this.remark = "";
this.upNums = 0;
}
}
\ No newline at end of file
......@@ -7,7 +7,7 @@ import com.mortals.xhx.module.news.model.NewsEntity;
* 新闻查询对象
*
* @author zxfei
* @date 2023-09-28
* @date 2024-12-04
*/
public class NewsQuery extends NewsEntity {
/** 开始 主键ID,主键,自增长 */
......@@ -138,6 +138,21 @@ public class NewsQuery extends NewsEntity {
/** 结束 更新时间 */
private String updateTimeEnd;
/** 开始 点赞次数 */
private Integer upNumsStart;
/** 结束 点赞次数 */
private Integer upNumsEnd;
/** 增加 点赞次数 */
private Integer upNumsIncrement;
/** 点赞次数列表 */
private List <Integer> upNumsList;
/** 点赞次数排除列表 */
private List <Integer> upNumsNotList;
/** 责任编辑 */
private List<String> editorList;
......@@ -911,6 +926,87 @@ public class NewsQuery extends NewsEntity {
this.updateTimeEnd = updateTimeEnd;
}
/**
* 获取 开始 点赞次数
* @return upNumsStart
*/
public Integer getUpNumsStart(){
return this.upNumsStart;
}
/**
* 设置 开始 点赞次数
* @param upNumsStart
*/
public void setUpNumsStart(Integer upNumsStart){
this.upNumsStart = upNumsStart;
}
/**
* 获取 结束 点赞次数
* @return $upNumsEnd
*/
public Integer getUpNumsEnd(){
return this.upNumsEnd;
}
/**
* 设置 结束 点赞次数
* @param upNumsEnd
*/
public void setUpNumsEnd(Integer upNumsEnd){
this.upNumsEnd = upNumsEnd;
}
/**
* 获取 增加 点赞次数
* @return upNumsIncrement
*/
public Integer getUpNumsIncrement(){
return this.upNumsIncrement;
}
/**
* 设置 增加 点赞次数
* @param upNumsIncrement
*/
public void setUpNumsIncrement(Integer upNumsIncrement){
this.upNumsIncrement = upNumsIncrement;
}
/**
* 获取 点赞次数
* @return upNumsList
*/
public List<Integer> getUpNumsList(){
return this.upNumsList;
}
/**
* 设置 点赞次数
* @param upNumsList
*/
public void setUpNumsList(List<Integer> upNumsList){
this.upNumsList = upNumsList;
}
/**
* 获取 点赞次数
* @return upNumsNotList
*/
public List<Integer> getUpNumsNotList(){
return this.upNumsNotList;
}
/**
* 设置 点赞次数
* @param upNumsNotList
*/
public void setUpNumsNotList(List<Integer> upNumsNotList){
this.upNumsNotList = upNumsNotList;
}
/**
* 获取 责任编辑
* @return editorList
......@@ -1636,6 +1732,60 @@ public class NewsQuery extends NewsEntity {
}
/**
* 设置 点赞次数
* @param upNums
*/
public NewsQuery upNums(Integer upNums){
setUpNums(upNums);
return this;
}
/**
* 设置 开始 点赞次数
* @param upNumsStart
*/
public NewsQuery upNumsStart(Integer upNumsStart){
this.upNumsStart = upNumsStart;
return this;
}
/**
* 设置 结束 点赞次数
* @param upNumsEnd
*/
public NewsQuery upNumsEnd(Integer upNumsEnd){
this.upNumsEnd = upNumsEnd;
return this;
}
/**
* 设置 增加 点赞次数
* @param upNumsIncrement
*/
public NewsQuery upNumsIncrement(Integer upNumsIncrement){
this.upNumsIncrement = upNumsIncrement;
return this;
}
/**
* 设置 点赞次数
* @param upNumsList
*/
public NewsQuery upNumsList(List<Integer> upNumsList){
this.upNumsList = upNumsList;
return this;
}
/**
* 设置 点赞次数
* @param upNumsNotList
*/
public NewsQuery upNumsNotList(List<Integer> upNumsNotList){
this.upNumsNotList = upNumsNotList;
return this;
}
/**
* 设置 责任编辑
......
package com.mortals.xhx.module.news.model;
import java.util.Date;
import java.util.List;
import java.util.ArrayList;
import java.math.BigDecimal;
import cn.hutool.core.date.DateUtil;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mortals.framework.annotation.Excel;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.news.model.vo.NewsUpVo;
import lombok.Data;
/**
* 新闻点赞记录信息实体对象
*
* @author zxfei
* @date 2024-12-04
*/
@Data
public class NewsUpEntity extends NewsUpVo {
private static final long serialVersionUID = 1L;
/**
* 新闻ID
*/
private Long newsId;
/**
* 点赞人ID
*/
private Long upId;
/**
* 点赞人名称
*/
private String upName;
/**
* 累计分享次数
*/
private Integer sumUp;
/**
* 备注
*/
private String remark;
/**
* 点赞时间
*/
private Date upTime;
@Override
public int hashCode() {
return this.getId().hashCode();
}
@Override
public boolean equals(Object obj) {
if (obj == null) return false;
if (obj instanceof NewsUpEntity) {
NewsUpEntity tmp = (NewsUpEntity) obj;
if (this.getId() == tmp.getId()) {
return true;
}
}
return false;
}
public void initAttrValue(){
this.newsId = null;
this.upId = null;
this.upName = "";
this.sumUp = 0;
this.remark = "";
this.upTime = null;
}
}
\ No newline at end of file
package com.mortals.xhx.module.news.model.vo;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.news.model.NewsUpEntity;
import java.util.ArrayList;
import java.util.List;
import lombok.Data;
import com.mortals.framework.annotation.Excel;
import java.math.BigDecimal;
import java.util.Date;
/**
* 新闻点赞记录信息视图对象
*
* @author zxfei
* @date 2024-12-04
*/
@Data
public class NewsUpVo extends BaseEntityLong {
/** 序号,主键,自增长列表 */
private List <Long> idList;
}
\ No newline at end of file
......@@ -23,6 +23,12 @@ public class NewsVo extends BaseEntityLong {
* 分享次数
*/
private Integer shareNums;
/**点赞状态**/
private Integer upStatus;
/**分享状态**/
private Integer shareStatus;
/**
* 头像地址
*/
private String photoPath;
}
\ No newline at end of file
package com.mortals.xhx.module.news.service;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.news.model.NewsEntity;
import com.mortals.xhx.module.news.dao.NewsDao;
......@@ -13,4 +15,31 @@ import com.mortals.xhx.module.news.dao.NewsDao;
public interface NewsService extends ICRUDService<NewsEntity,Long>{
NewsDao getDao();
/**
* 点赞
* @param id
* @param context
* @param increment 点赞次数增减值
* @return
*/
NewsEntity upNews(Long id, Context context, int increment) throws AppException;
/**
* 浏览新闻
* @param id
* @param context
* @return
* @throws AppException
*/
NewsEntity viewNews(Long id, Context context) throws AppException;
/**
* 分享新闻
* @param id
* @param context
* @return
* @throws AppException
*/
NewsEntity shareNews(Long id, Context context) throws AppException;
}
\ No newline at end of file
package com.mortals.xhx.module.news.service;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.news.model.NewsUpEntity;
import com.mortals.xhx.module.news.dao.NewsUpDao;
/**
* NewsUpService
*
* 新闻点赞记录信息 service接口
*
* @author zxfei
* @date 2024-12-04
*/
public interface NewsUpService extends ICRUDService<NewsUpEntity,Long>{
NewsUpDao getDao();
}
\ No newline at end of file
package com.mortals.xhx.module.news.service.impl;
import com.mortals.framework.model.PageInfo;
import com.mortals.xhx.base.system.user.model.UserEntity;
import com.mortals.xhx.base.system.user.model.UserQuery;
import com.mortals.xhx.base.system.user.service.UserService;
import com.mortals.xhx.module.news.model.*;
import com.mortals.xhx.module.news.service.NewsRecordService;
import com.mortals.xhx.module.news.service.NewsShareService;
import com.mortals.xhx.module.news.service.NewsUpService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.xhx.module.news.dao.NewsDao;
import com.mortals.xhx.module.news.model.NewsEntity;
import com.mortals.xhx.module.news.service.NewsService;
import lombok.extern.slf4j.Slf4j;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* NewsService
* 新闻 service实现
......@@ -18,4 +34,157 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
public class NewsServiceImpl extends AbstractCRUDServiceImpl<NewsDao, NewsEntity, Long> implements NewsService {
@Autowired
private NewsShareService newsShareService;
@Autowired
private NewsRecordService newsRecordService;
@Autowired
private NewsUpService newsUpService;
@Autowired
private UserService userService;
@Override
protected void findAfter(NewsEntity params, PageInfo pageInfo, Context context, List<NewsEntity> list) throws AppException {
if(CollectionUtils.isNotEmpty(list)){
List<Long> userIdList = list.stream().map(NewsEntity::getCreateUserId).collect(Collectors.toList());
List<UserEntity> userList = userService.find(new UserQuery().idList(userIdList));
Map<Long,UserEntity> userMap = userList.parallelStream().collect(Collectors.toMap(x -> x.getId(), z -> z, (o, n) -> n));
if(context!=null && context.getUser()!=null){
List<Long> newsIdList = list.stream().map(NewsEntity::getId).collect(Collectors.toList());
List<NewsUpEntity> upList = newsUpService.find(new NewsUpQuery().newsIdList(newsIdList).upId(context.getUser().getId()));
Map<Long,NewsUpEntity> upMap = new HashMap<>();
if(CollectionUtils.isNotEmpty(upList)){
upMap = upList.parallelStream().collect(Collectors.toMap(x -> x.getId(), z -> z, (o, n) -> n));
}
List<NewsShareEntity> shareList = newsShareService.find(new NewsShareQuery().newsIdList(newsIdList).createUserId(context.getUser().getId()));
Map<Long,NewsShareEntity> shareMap = new HashMap<>();
if(CollectionUtils.isNotEmpty(shareList)) {
shareMap = shareList.parallelStream().collect(Collectors.toMap(x -> x.getId(), z -> z, (o, n) -> n));
}
for(NewsEntity item:list){
if(upMap.containsKey(item.getId())){
item.setUpStatus(1);
}else {
item.setUpStatus(0);
}
if(shareMap.containsKey(item.getId())){
item.setShareStatus(1);
}else {
item.setShareStatus(0);
}
UserEntity userEntity = userMap.get(item.getCreateUserId());
if(userEntity!=null) {
item.setPhotoPath(userEntity.getPhotoPath());
}
}
}
}
}
@Override
public NewsEntity upNews(Long id, Context context, int increment) throws AppException {
NewsEntity news = this.get(id);
if(news==null){
throw new AppException("新闻不存在");
}
if(context!=null && context.getUser()!=null) {
NewsUpEntity newsUpEntity = newsUpService.selectOne(new NewsUpQuery().newsId(id).upId(context.getUser().getId()));
if(newsUpEntity!=null){
if(increment < 0){
newsUpService.remove(newsUpEntity.getId(),context);
}else {
NewsUpQuery updateUp = new NewsUpQuery();
updateUp.setId(newsUpEntity.getId());
updateUp.setSumUpIncrement(increment);
updateUp.setUpTime(new Date());
updateUp.setUpdateTime(new Date());
updateUp.setUpdateUserId(context.getUser().getId());
newsUpService.update(updateUp);
}
}else {
if(increment > 0) {
newsUpEntity = new NewsUpEntity();
newsUpEntity.initAttrValue();
newsUpEntity.setNewsId(id);
newsUpEntity.setUpId(context.getUser().getId());
newsUpEntity.setUpName(context.getUser().getRealName());
newsUpEntity.setUpTime(new Date());
newsUpEntity.setCreateTime(new Date());
newsUpEntity.setCreateUserId(context.getUser().getId());
newsUpEntity.setSumUp(increment);
newsUpService.save(newsUpEntity);
}
}
}
NewsQuery update = new NewsQuery();
update.setId(id);
update.setUpNumsIncrement(increment);
return this.update(update);
}
@Override
public NewsEntity viewNews(Long id, Context context) throws AppException {
NewsEntity news = this.get(id);
if(news==null){
throw new AppException("新闻不存在");
}
if(context!=null && context.getUser()!=null) {
NewsRecordEntity newsRecordEntity = newsRecordService.selectOne(new NewsRecordQuery().newsId(id).viewId(context.getUser().getId()));
if(newsRecordEntity!=null){
NewsRecordQuery updateRecord = new NewsRecordQuery();
updateRecord.setId(newsRecordEntity.getId());
updateRecord.setSumViewsIncrement(1);
updateRecord.setViewTime(new Date());
updateRecord.setUpdateTime(new Date());
updateRecord.setUpdateUserId(context.getUser().getId());
newsRecordService.update(updateRecord);
}else {
newsRecordEntity = new NewsRecordEntity();
newsRecordEntity.initAttrValue();
newsRecordEntity.setNewsId(id);
newsRecordEntity.setViewId(context.getUser().getId());
newsRecordEntity.setViewName(context.getUser().getRealName());
newsRecordEntity.setCreateTime(new Date());
newsRecordEntity.setCreateUserId(context.getUser().getId());
newsRecordEntity.setSumViews(1);
newsRecordService.save(newsRecordEntity);
}
}
NewsQuery update = new NewsQuery();
update.setId(id);
update.setViewNumsIncrement(1);
return this.update(update);
}
@Override
public NewsEntity shareNews(Long id, Context context) throws AppException {
NewsEntity news = this.get(id);
if(news==null){
throw new AppException("新闻不存在");
}
if(context!=null && context.getUser()!=null) {
NewsShareEntity newsShareEntity = newsShareService.selectOne(new NewsShareQuery().newsId(id).createUserId(context.getUser().getId()));
if(newsShareEntity!=null){
NewsShareQuery updateShare = new NewsShareQuery();
updateShare.setId(id);
updateShare.setSumSharesIncrement(1);
updateShare.setUpdateTime(new Date());
updateShare.setUpdateUserId(context.getUser().getId());
newsShareService.update(updateShare);
}else {
newsShareEntity = new NewsShareEntity();
newsShareEntity.initAttrValue();
newsShareEntity.setNewsId(id);
newsShareEntity.setSumShares(1);
newsShareEntity.setShareName(context.getUser().getRealName());
newsShareEntity.setCreateTime(new Date());
newsShareEntity.setCreateUserId(context.getUser().getId());
newsShareService.save(newsShareEntity);
}
}
NewsQuery update = new NewsQuery();
update.setId(id);
update.setShareNumsIncrement(1);
return this.update(update);
}
}
\ No newline at end of file
package com.mortals.xhx.module.news.service.impl;
import org.springframework.beans.BeanUtils;
import java.util.function.Function;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.xhx.module.news.dao.NewsUpDao;
import com.mortals.xhx.module.news.model.NewsUpEntity;
import com.mortals.xhx.module.news.service.NewsUpService;
import lombok.extern.slf4j.Slf4j;
/**
* NewsUpService
* 新闻点赞记录信息 service实现
*
* @author zxfei
* @date 2024-12-04
*/
@Service("newsUpService")
@Slf4j
public class NewsUpServiceImpl extends AbstractCRUDServiceImpl<NewsUpDao, NewsUpEntity, Long> implements NewsUpService {
}
\ No newline at end of file
package com.mortals.xhx.module.news.web;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.base.system.user.model.UserQuery;
import com.mortals.xhx.base.system.user.service.UserService;
import com.mortals.xhx.busiz.applets.req.NewsReq;
import com.mortals.xhx.module.dept.model.DeptEntity;
import com.mortals.xhx.module.dept.model.DeptQuery;
import com.mortals.xhx.module.dept.service.DeptService;
......@@ -93,4 +95,54 @@ public class NewsController extends BaseCRUDJsonBodyMappingController<NewsServic
}
}
/**
* 新闻浏览
*/
@PostMapping(value = "view")
public Rest<NewsEntity> viewNews(@RequestBody NewsReq newsReq) {
String busiDesc = "新闻浏览";
Rest<NewsEntity> rest = Rest.ok(busiDesc + " 【成功】");
Context context = this.getContext();
Map<String, Object> model = new HashMap<>();
try {
if (org.springframework.util.ObjectUtils.isEmpty(newsReq.getId())) {
throw new AppException("新闻id不能为空!");
}
NewsEntity newsEntity =service.viewNews(newsReq.getId(),context);
rest.setData(newsEntity);
this.init(model, context);
rest.setDict(model.get("dict"));
recordSysLog(request, busiDesc + " 【成功】");
} catch (Exception e) {
log.error(busiDesc, e);
rest = Rest.fail(super.convertException(e));
}
return rest;
}
/**
* 新闻分享
*/
@PostMapping(value = "share")
public Rest<NewsEntity> shareNews(@RequestBody NewsReq newsReq) {
String busiDesc = "新闻分享";
Rest<NewsEntity> rest = Rest.ok(busiDesc + " 【成功】");
Context context = this.getContext();
Map<String, Object> model = new HashMap<>();
try {
if (org.springframework.util.ObjectUtils.isEmpty(newsReq.getId())) {
throw new AppException("新闻id不能为空!");
}
NewsEntity newsEntity = service.shareNews(newsReq.getId(),context);
rest.setData(newsEntity);
this.init(model, context);
rest.setDict(model.get("dict"));
recordSysLog(request, busiDesc + " 【成功】");
} catch (Exception e) {
log.error(busiDesc, e);
rest = Rest.fail(super.convertException(e));
}
return rest;
}
}
\ No newline at end of file
package com.mortals.xhx.module.news.web;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.mortals.framework.model.Context;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.module.news.model.NewsUpEntity;
import com.mortals.xhx.module.news.service.NewsUpService;
import org.apache.commons.lang3.ArrayUtils;
import com.mortals.framework.util.StringUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject;
import java.util.Arrays;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import static com.mortals.framework.ap.SysConstains.*;
import com.mortals.xhx.common.code.*;
/**
*
* 新闻点赞记录信息
*
* @author zxfei
* @date 2024-12-04
*/
@RestController
@RequestMapping("news/up")
public class NewsUpController extends BaseCRUDJsonBodyMappingController<NewsUpService,NewsUpEntity,Long> {
@Autowired
private ParamService paramService;
public NewsUpController(){
super.setModuleDesc( "新闻点赞记录信息");
}
@Override
protected void init(Map<String, Object> model, Context context) {
super.init(model, context);
}
}
\ No newline at end of file
......@@ -30,6 +30,7 @@
<result property="openId" column="openId" />
<result property="photoPath" column="photoPath" />
<result property="companyAdress" column="companyAdress" />
<result property="nickName" column="nickName" />
</resultMap>
<!-- 表所有列 -->
......@@ -110,23 +111,26 @@
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('companyAdress') or colPickMode == 1 and data.containsKey('companyAdress')))">
a.companyAdress,
</if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('nickName') or colPickMode == 1 and data.containsKey('nickName')))">
a.nickName,
</if>
</trim>
</sql>
<!-- 新增 区分主键自增加还是业务插入 -->
<insert id="insert" parameterType="UserEntity" useGeneratedKeys="true" keyProperty="id">
insert into mortals_xhx_user
(loginName,loginPwd,loginLimitAddress,realName,mobile,phone,email,qq,userType,status,customerId,createTime,createUserId,createUserName,lastLoginTime,lastLoginAddress,deptId,deptName,siteIds,areaCodes,staffId,openId,photoPath,companyAdress)
(loginName,loginPwd,loginLimitAddress,realName,mobile,phone,email,qq,userType,status,customerId,createTime,createUserId,createUserName,lastLoginTime,lastLoginAddress,deptId,deptName,siteIds,areaCodes,staffId,openId,photoPath,companyAdress,nickName)
VALUES
(#{loginName},#{loginPwd},#{loginLimitAddress},#{realName},#{mobile},#{phone},#{email},#{qq},#{userType},#{status},#{customerId},#{createTime},#{createUserId},#{createUserName},#{lastLoginTime},#{lastLoginAddress},#{deptId},#{deptName},#{siteIds},#{areaCodes},#{staffId},#{openId},#{photoPath},#{companyAdress})
(#{loginName},#{loginPwd},#{loginLimitAddress},#{realName},#{mobile},#{phone},#{email},#{qq},#{userType},#{status},#{customerId},#{createTime},#{createUserId},#{createUserName},#{lastLoginTime},#{lastLoginAddress},#{deptId},#{deptName},#{siteIds},#{areaCodes},#{staffId},#{openId},#{photoPath},#{companyAdress},#{nickName})
</insert>
<!-- 批量新增 -->
<insert id="insertBatch" parameterType="paramDto">
insert into mortals_xhx_user
(loginName,loginPwd,loginLimitAddress,realName,mobile,phone,email,qq,userType,status,customerId,createTime,createUserId,createUserName,lastLoginTime,lastLoginAddress,deptId,deptName,siteIds,areaCodes,staffId,openId,photoPath,companyAdress)
(loginName,loginPwd,loginLimitAddress,realName,mobile,phone,email,qq,userType,status,customerId,createTime,createUserId,createUserName,lastLoginTime,lastLoginAddress,deptId,deptName,siteIds,areaCodes,staffId,openId,photoPath,companyAdress,nickName)
VALUES
<foreach collection="data.dataList" item="item" index="index" separator="," >
(#{item.loginName},#{item.loginPwd},#{item.loginLimitAddress},#{item.realName},#{item.mobile},#{item.phone},#{item.email},#{item.qq},#{item.userType},#{item.status},#{item.customerId},#{item.createTime},#{item.createUserId},#{item.createUserName},#{item.lastLoginTime},#{item.lastLoginAddress},#{item.deptId},#{item.deptName},#{item.siteIds},#{item.areaCodes},#{item.staffId},#{item.openId},#{item.photoPath},#{item.companyAdress})
(#{item.loginName},#{item.loginPwd},#{item.loginLimitAddress},#{item.realName},#{item.mobile},#{item.phone},#{item.email},#{item.qq},#{item.userType},#{item.status},#{item.customerId},#{item.createTime},#{item.createUserId},#{item.createUserName},#{item.lastLoginTime},#{item.lastLoginAddress},#{item.deptId},#{item.deptName},#{item.siteIds},#{item.areaCodes},#{item.staffId},#{item.openId},#{item.photoPath},#{item.companyAdress},#{item.nickName})
</foreach>
</insert>
......@@ -226,6 +230,9 @@
<if test="(colPickMode==0 and data.containsKey('companyAdress')) or (colPickMode==1 and !data.containsKey('companyAdress'))">
a.companyAdress=#{data.companyAdress},
</if>
<if test="(colPickMode==0 and data.containsKey('nickName')) or (colPickMode==1 and !data.containsKey('nickName'))">
a.nickName=#{data.nickName},
</if>
</trim>
<trim suffixOverrides="where" suffix="">
where
......@@ -436,6 +443,13 @@
</if>
</foreach>
</trim>
<trim prefix="nickName=(case" suffix="ELSE nickName end),">
<foreach collection="data.dataList" item="item" index="index" separator="" >
<if test="(colPickMode==0 and item.containsKey('nickName')) or (colPickMode==1 and !item.containsKey('nickName'))">
when a.id=#{item.id} then #{item.nickName}
</if>
</foreach>
</trim>
</trim>
where id in
<foreach collection="data.dataList" item="item" index="index" open="(" separator="," close=")">
......@@ -1111,6 +1125,27 @@
#{item}
</foreach>
</if>
<if test="conditionParamRef.containsKey('nickName')">
<if test="conditionParamRef.nickName != null and conditionParamRef.nickName != ''">
${_conditionType_} a.nickName like #{${_conditionParam_}.nickName}
</if>
<if test="conditionParamRef.nickName == null">
${_conditionType_} a.nickName is null
</if>
</if>
<if test="conditionParamRef.containsKey('nickNameList') and conditionParamRef.nickNameList.size() > 0">
${_conditionType_} a.nickName in
<foreach collection="conditionParamRef.nickNameList" open="(" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
</if>
<if test="conditionParamRef.containsKey('nickNameNotList') and conditionParamRef.nickNameNotList.size() > 0">
${_conditionType_} a.nickName not in
<foreach collection="conditionParamRef.nickNameNotList" open="(" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
</if>
</sql>
<sql id="_orderCols_">
<if test="orderColList != null and !orderColList.isEmpty()">
......@@ -1347,6 +1382,11 @@
<if test='orderCol.companyAdress != null and "DESC".equalsIgnoreCase(orderCol.companyAdress)'>DESC</if>
,
</if>
<if test="orderCol.containsKey('nickName')">
a.nickName
<if test='orderCol.nickName != null and "DESC".equalsIgnoreCase(orderCol.nickName)'>DESC</if>
,
</if>
</trim>
</if>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment