提交 c4c2e15f authored 作者: 吴德鹏's avatar 吴德鹏

完成帖子管理

上级 3a4487c3
......@@ -119,5 +119,11 @@ public class HashtagController {
return R.ok().put("list", list);
}
@RequestMapping("/getTagsByIds")
@ResponseBody
public R getTagsByIds(@RequestBody String[] ids) {
return R.ok();
}
}
......@@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.io.UnsupportedEncodingException;
import java.util.List;
import java.util.Map;
......@@ -66,7 +67,7 @@ public class PostController {
@RequestMapping("/save")
@RequiresPermissions("post:save")
@ResponseBody
public R save(@RequestBody PostEntity post) {
public R save(@RequestBody PostEntity post) throws UnsupportedEncodingException {
postService.save(post);
return R.ok();
......
......@@ -53,7 +53,7 @@ public class PostHashtagController {
@RequestMapping("/info/{id}")
@RequiresPermissions("posthashtag:info")
@ResponseBody
public R info(@PathVariable("id") Long id) {
public R info(@PathVariable("id") String id) {
PostHashtagEntity postHashtag = postHashtagService.queryObject(id);
return R.ok().put("postHashtag", postHashtag);
......@@ -89,7 +89,7 @@ public class PostHashtagController {
@RequestMapping("/delete")
@RequiresPermissions("posthashtag:delete")
@ResponseBody
public R delete(@RequestBody Long[] ids) {
public R delete(@RequestBody String[] ids) {
postHashtagService.deleteBatch(ids);
return R.ok();
......
......@@ -13,4 +13,6 @@ import java.util.List;
public interface HashtagDao extends BaseDao<HashtagEntity> {
List<HashtagEntity> getTagsByName(String name);
List<HashtagEntity> getTagsByIds(String[] ids);
}
......@@ -24,4 +24,6 @@ public interface TbCfStationItemDao extends BaseDao<TbCfStationItemEntity> {
TbCfStationItemEntity queryByCode(String code);
List<TbCfStationItemEntity> queryByCodeList(String code);
List<TbCfStationItemEntity> getItemByIds(String[] ids);
}
......@@ -8,7 +8,7 @@ import java.util.Date;
* 表名 post
*
* @author lipengjun
* @date 2020-06-28 15:28:31
* @date 2020-07-03 11:16:53
*/
public class PostEntity implements Serializable {
private static final long serialVersionUID = 1L;
......@@ -73,6 +73,18 @@ public class PostEntity implements Serializable {
* 是否置顶 0: 不置顶 1:置顶
*/
private Integer isTop;
/**
* 商品ID集合
*/
private String itemIds;
/**
* 标签ID集合
*/
private String tagIds;
/**
*
*/
private String title;
/**
* 设置:帖子ID
......@@ -269,4 +281,43 @@ public class PostEntity implements Serializable {
public Integer getIsTop() {
return isTop;
}
/**
* 设置:商品ID集合
*/
public void setItemIds(String itemIds) {
this.itemIds = itemIds;
}
/**
* 获取:商品ID集合
*/
public String getItemIds() {
return itemIds;
}
/**
* 设置:标签ID集合
*/
public void setTagIds(String tagIds) {
this.tagIds = tagIds;
}
/**
* 获取:标签ID集合
*/
public String getTagIds() {
return tagIds;
}
/**
* 设置:
*/
public void setTitle(String title) {
this.title = title;
}
/**
* 获取:
*/
public String getTitle() {
return title;
}
}
package com.platform.service;
import com.platform.entity.HashtagEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
......@@ -78,4 +79,12 @@ public interface HashtagService {
*/
List<HashtagEntity> getTagsByName(String name);
/**
* 根据ID集合查找标签
*
* @param ids
* @return list
*/
List<HashtagEntity> getTagsByIds(String[] ids);
}
......@@ -19,7 +19,7 @@ public interface PostHashtagService {
* @param id 主键
* @return 实体
*/
PostHashtagEntity queryObject(Long id);
PostHashtagEntity queryObject(String id);
/**
* 分页查询
......@@ -59,7 +59,7 @@ public interface PostHashtagService {
* @param id
* @return 删除条数
*/
int delete(Long id);
int delete(String id);
/**
* 根据主键批量删除
......@@ -67,5 +67,5 @@ public interface PostHashtagService {
* @param ids
* @return 删除条数
*/
int deleteBatch(Long[] ids);
int deleteBatch(String[] ids);
}
......@@ -4,6 +4,7 @@ import com.platform.entity.PostEntity;
import com.platform.vo.PostVo;
import org.springframework.web.bind.annotation.PathVariable;
import java.io.UnsupportedEncodingException;
import java.util.List;
import java.util.Map;
......@@ -21,7 +22,7 @@ public interface PostService {
* @param id 主键
* @return 实体
*/
PostEntity queryObject(String id);
PostVo queryObject(String id);
/**
* 分页查询
......@@ -45,7 +46,7 @@ public interface PostService {
* @param post 实体
* @return 保存条数
*/
int save(PostEntity post);
int save(PostEntity post) throws UnsupportedEncodingException;
/**
* 根据主键更新实体
......
......@@ -98,4 +98,9 @@ public class HashtagServiceImpl implements HashtagService {
public List<HashtagEntity> getTagsByName(String name) {
return hashtagDao.getTagsByName(name);
}
@Override
public List<HashtagEntity> getTagsByIds(String[] ids) {
return hashtagDao.getTagsByIds(ids);
}
}
......@@ -22,7 +22,7 @@ public class PostHashtagServiceImpl implements PostHashtagService {
private PostHashtagDao postHashtagDao;
@Override
public PostHashtagEntity queryObject(Long id) {
public PostHashtagEntity queryObject(String id) {
return postHashtagDao.queryObject(id);
}
......@@ -48,12 +48,12 @@ public class PostHashtagServiceImpl implements PostHashtagService {
}
@Override
public int delete(Long id) {
public int delete(String id) {
return postHashtagDao.delete(id);
}
@Override
public int deleteBatch(Long[] ids) {
public int deleteBatch(String[] ids) {
return postHashtagDao.deleteBatch(ids);
}
}
package com.platform.service.impl;
import com.platform.dao.PostDao;
import com.platform.dao.SysUserDao;
import com.platform.dao.TbCfUserInfoDao;
import com.platform.entity.PostEntity;
import com.platform.entity.SysUserEntity;
import com.platform.entity.TbCfUserInfoEntity;
import com.platform.dao.*;
import com.platform.entity.*;
import com.platform.service.PostService;
import com.platform.utils.IdUtil;
import com.platform.utils.ShiroUtils;
......@@ -14,6 +10,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Date;
......@@ -40,9 +37,34 @@ public class PostServiceImpl implements PostService {
@Autowired
private SysUserDao sysUserDao;
@Autowired
private TbCfStationItemDao tbCfStationItemDao;
@Autowired
private HashtagDao hashtagDao;
@Override
public PostEntity queryObject(String id) {
return postDao.queryObject(id);
public PostVo queryObject(String id) {
//帖子主题信息
PostEntity post = postDao.queryObject(id);
PostVo postVo = new PostVo();
BeanUtils.copyProperties(post, postVo);
if (post.getItemIds() != null && post.getItemIds().length() > 0) {
//帖子关联的商品
List<TbCfStationItemEntity> itemList = tbCfStationItemDao.getItemByIds(post.getItemIds().split(","));
postVo.setItemList(itemList);//设置帖子商品
}
if (post.getTagIds() != null && post.getTagIds().length() > 0) {
//帖子关联的标签
List<HashtagEntity> tagList = hashtagDao.getTagsByIds(post.getTagIds().split(","));
postVo.setTagList(tagList);//设置帖子标签
}
return postVo;
}
@Override
......@@ -75,26 +97,22 @@ public class PostServiceImpl implements PostService {
}
@Override
public int save(PostEntity post) {
public int save(PostEntity post) throws UnsupportedEncodingException {
int res = 0;
try {
post.setId(IdUtil.createIdbyUUID());
post.setCreateDate(new Date());
post.setUpdateDate(new Date());
post.setVersion(1);
post.setIsTop(0);
String type = String.valueOf(post.getUserType());
if ("0".equals(type)) {
post.setUserId(getUserId());
} else if ("1".equals(type)) {
String userId = tbCfUserInfoDao.queryById(post.getCreatedBy());
post.setUserId(userId);
}
post.setCategory(URLDecoder.decode(post.getCategory(), "utf-8"));
res = postDao.save(post);
} catch (Exception e) {
post.setId(IdUtil.createIdbyUUID());
post.setCreateDate(new Date());
post.setUpdateDate(new Date());
post.setVersion(1);
post.setIsTop(0);
String type = String.valueOf(post.getUserType());
if ("0".equals(type)) {
post.setUserId(getUserId());
} else if ("1".equals(type)) {
String userId = tbCfUserInfoDao.queryById(post.getCreatedBy());
post.setUserId(userId);
}
post.setCategory(URLDecoder.decode(post.getCategory(), "utf-8"));
res = postDao.save(post);
return res;
}
......@@ -131,7 +149,6 @@ public class PostServiceImpl implements PostService {
*/
@Override
public int changeStatus(Integer archived, String[] ids) {
System.err.println("======>>>>>" + archived);
//下线帖子
if ("2".equals(archived.toString())) {
for (int i = 0; i < ids.length; i++) {
......
......@@ -2,6 +2,8 @@ package com.platform.vo;
import com.platform.entity.PostEntity;
import java.util.List;
/**
* @Auther: wudepeng
......@@ -10,8 +12,14 @@ import com.platform.entity.PostEntity;
*/
public class PostVo extends PostEntity {
//评论数
private Integer count;
//点赞数
private Integer likes;
//帖子商品
private List<?> itemList;
//帖子标签
private List<?> tagList;
public Integer getCount() {
return count;
......@@ -28,4 +36,20 @@ public class PostVo extends PostEntity {
public void setLikes(Integer likes) {
this.likes = likes;
}
public List<?> getItemList() {
return itemList;
}
public void setItemList(List<?> itemList) {
this.itemList = itemList;
}
public List<?> getTagList() {
return tagList;
}
public void setTagList(List<?> tagList) {
this.tagList = tagList;
}
}
......@@ -76,6 +76,26 @@
from hashtag
where name LIKE concat('%',#{name},'%')
</select>
<select id="getTagsByIds" resultType="com.platform.entity.HashtagEntity">
select
`id`,
`archived`,
`archived_by`,
`archived_date`,
`create_date`,
`created_by`,
`update_date`,
`updated_by`,
`version`,
`name`,
`user_id`
from hashtag
where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<select id="queryTotal" resultType="int">
select count(*) from hashtag
WHERE 1=1
......
......@@ -19,6 +19,9 @@
<result property="category" column="category"/>
<result property="userId" column="user_id"/>
<result property="isTop" column="is_top"/>
<result property="itemIds" column="item_ids"/>
<result property="tagIds" column="tag_ids"/>
<result property="title" column="title"/>
</resultMap>
<select id="queryObject" resultType="com.platform.entity.PostEntity">
......@@ -37,7 +40,10 @@
`caption`,
`category`,
`user_id`,
`is_top`
`is_top`,
`item_ids`,
`tag_ids`,
`title`
from post
where id = #{id}
</select>
......@@ -117,7 +123,10 @@
`caption`,
`category`,
`user_id`,
`is_top`)
`is_top`,
`item_ids`,
`tag_ids`,
`title`)
values(
#{id},
#{archived},
......@@ -133,26 +142,32 @@
#{caption},
#{category},
#{userId},
#{isTop})
#{isTop},
#{itemIds},
#{tagIds},
#{title})
</insert>
<update id="update" parameterType="com.platform.entity.PostEntity">
update post
<set>
<if test="archived != null">`archived` = #{archived},</if>
<if test="archivedBy != null">`archived_by` = #{archivedBy},</if>
<if test="archivedDate != null">`archived_date` = #{archivedDate},</if>
<if test="userType != null">`user_type` = #{userType},</if>
<if test="createDate != null">`create_date` = #{createDate},</if>
<if test="createdBy != null">`created_by` = #{createdBy},</if>
<if test="updateDate != null">`update_date` = #{updateDate},</if>
<if test="updatedBy != null">`updated_by` = #{updatedBy},</if>
<if test="version != null">`version` = #{version},</if>
<if test="picture != null">`picture` = #{picture},</if>
<if test="caption != null">`caption` = #{caption},</if>
<if test="category != null">`category` = #{category},</if>
<if test="userId != null">`user_id` = #{userId},</if>
<if test="isTop != null">`is_top` = #{isTop}</if>
<if test="archived != null">`archived` = #{archived}, </if>
<if test="archivedBy != null">`archived_by` = #{archivedBy}, </if>
<if test="archivedDate != null">`archived_date` = #{archivedDate}, </if>
<if test="userType != null">`user_type` = #{userType}, </if>
<if test="createDate != null">`create_date` = #{createDate}, </if>
<if test="createdBy != null">`created_by` = #{createdBy}, </if>
<if test="updateDate != null">`update_date` = #{updateDate}, </if>
<if test="updatedBy != null">`updated_by` = #{updatedBy}, </if>
<if test="version != null">`version` = #{version}, </if>
<if test="picture != null">`picture` = #{picture}, </if>
<if test="caption != null">`caption` = #{caption}, </if>
<if test="category != null">`category` = #{category}, </if>
<if test="userId != null">`user_id` = #{userId}, </if>
<if test="isTop != null">`is_top` = #{isTop}, </if>
<if test="itemIds != null">`item_ids` = #{itemIds}, </if>
<if test="tagIds != null">`tag_ids` = #{tagIds}, </if>
<if test="title != null">`title` = #{title}</if>
</set>
where id = #{id}
</update>
......
......@@ -331,4 +331,11 @@
#{itemId}
</foreach>
</update>
<select id="getItemByIds" resultType="com.platform.entity.TbCfStationItemEntity">
select i.item_Id,i.item_img from tb_cf_station_item i where i.item_id in
<foreach item="itemId" collection="array" open="(" separator="," close=")">
#{itemId}
</foreach>
</select>
</mapper>
\ No newline at end of file
......@@ -99,23 +99,23 @@ let vm = new Vue({
],
commoditycategoryListsActive3: null,
postProductArr:[],
postProductArr: [],
},
methods: {
deleteProduct(index){
this.$delete(this.postProductArr,index);
deleteProduct(index) {
this.$delete(this.postProductArr, index);
},
selectProduct(){
if(this.postProductArr.length<9){
selectProduct() {
if (this.postProductArr.length < 9) {
let reg = /\"(.*?)\"/g;
let id = getSelectedRow("#searchjqGrid");
let rowData = jQuery("#searchjqGrid").jqGrid("getRowData",id);
let rowData = jQuery("#searchjqGrid").jqGrid("getRowData", id);
this.postProductArr.push({
itemImg:reg.exec(rowData.itemImg)[1],
itemId:rowData.itemId
itemImg: reg.exec(rowData.itemImg)[1],
itemId: rowData.itemId
})
this.isShownProductMadal = false;
}else{
} else {
alert('超出限制');
}
},
......@@ -167,7 +167,13 @@ let vm = new Vue({
{label: '商品一级分类', name: 'goodtype', index: 'goodtype', width: 80},
{label: '商品二级分类', name: 'title', index: 'title', width: 80},
{label: '商品品名', name: 'dname', index: 'itemDescritionId', width: 120},
{label: '状态', name: 'enableFlag', index: 'enable_flag', width: 120, formatter: itemStatusFormat},
{
label: '状态',
name: 'enableFlag',
index: 'enable_flag',
width: 120,
formatter: itemStatusFormat
},
{label: '创建日期', name: 'createTime', index: 'create_time', width: 160}
],
multiselect: true,
......@@ -322,6 +328,9 @@ let vm = new Vue({
vm.reload();
},
add: function () {
vm.uploadList = [];
vm.tagList = [];
vm.postProductArr = [];
vm.account = true;
vm.isShow = false;
vm.disabled = false;
......@@ -341,8 +350,18 @@ let vm = new Vue({
vm.getInfo(id);
},
saveOrUpdate: function (event) {
//帖子关联的商品
vm.post.itemIds = vm.postProductArr.map(res => res.itemId).join(',')
console.log('itemIds', vm.post.itemIds)
//帖子关联的标签
let tagIds = '';
vm.tagList.map(res => {
if (res.isSelected)
tagIds += res.value + ","
})
vm.post.tagIds = tagIds.substr(0, tagIds.length - 1).trim()
let flag = vm.flag;
console.log(121323, vm.post.userType)
console.log('tagIds', vm.post.tagIds)
if (vm.post.userType === 1 && vm.post.id == null) {
flag = this.queryAccount();
}
......@@ -393,6 +412,8 @@ let vm = new Vue({
}
,
getInfo: function (id) {
vm.tagList = [];
vm.postProductArr = [];
console.log(id);
Ajax.request({
url: "../post/info/" + id,
......@@ -402,6 +423,19 @@ let vm = new Vue({
vm.post = r.post;
vm.isShow = false;
vm.uploadList = [];
if (vm.post.itemList != null && vm.post.itemList.length > 0) {
vm.postProductArr = vm.post.itemList;
}
if (vm.post.tagList != null && vm.post.tagList.length > 0) {
vm.post.tagList.forEach(res => {
vm.tagList.push({
value: res.id,
label: res.name,
isSelected: true
})
})
}
console.log('tagList', vm.tagList)
let status = vm.post.archived;
//正常
if (status === 1) {
......@@ -420,6 +454,7 @@ let vm = new Vue({
} else {
UE.getEditor('content').setContent('');
}
}
});
}
......@@ -481,7 +516,7 @@ let vm = new Vue({
this.tagList.push({
label: item.name,
value: item.id,
isSelected :false,
isSelected: false,
});
})
})
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论