动态管理

This commit is contained in:
pserimal
2023-06-08 16:49:28 +08:00
parent e86f563d44
commit e87d2948f4
10 changed files with 415 additions and 55 deletions

View File

@@ -0,0 +1,46 @@
package com.cool.store.dao;
import cn.hutool.core.bean.BeanUtil;
import com.cool.store.dto.content.ContentAddDto;
import com.cool.store.dto.content.ContentQueryListDto;
import com.cool.store.dto.content.ContentUpdateDto;
import com.cool.store.entity.HyContentInfoDO;
import com.cool.store.mapper.HyContentInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
@Deprecated
public class ContentDAO {
@Autowired
private HyContentInfoMapper contentInfoMapper;
public String addContentInfo(ContentAddDto dto) {
HyContentInfoDO hyContentInfoDO = new HyContentInfoDO();
BeanUtil.copyProperties(dto, hyContentInfoDO);
hyContentInfoDO.setUpdateUserId(dto.getCreateUserId());
return Integer.toString(contentInfoMapper.insertSelective(hyContentInfoDO));
}
public void deleteContent(String contentId) {
contentInfoMapper.deleteSelective(contentId);
}
public void updateContent(ContentUpdateDto dto) {
HyContentInfoDO hyContentInfoDO = new HyContentInfoDO();
BeanUtil.copyProperties(dto, hyContentInfoDO);
hyContentInfoDO.setId(Long.parseLong(dto.getContentId()));
contentInfoMapper.updateByPrimaryKeySelective(hyContentInfoDO);
}
public List<HyContentInfoDO> queryContentList(ContentQueryListDto dto) {
return contentInfoMapper.queryContentList(dto);
}
public HyContentInfoDO queryContentInfo(String contentId) {
return contentInfoMapper.queryContentInfo(contentId);
}
}

View File

@@ -1,8 +1,11 @@
package com.cool.store.mapper;
import com.cool.store.dto.content.ContentQueryListDto;
import com.cool.store.entity.HyContentInfoDO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author zhangchenbiao
* @date 2023-05-29 03:50
@@ -22,4 +25,22 @@ public interface HyContentInfoMapper {
* dateTime:2023-05-29 03:50
*/
int updateByPrimaryKeySelective(@Param("record") HyContentInfoDO record);
/**
* 删除方法
* @param contentId
*/
void deleteSelective(@Param("contentId") String contentId);
/**
* 分页查询动态列表
* 根据传入参数匹配
*/
List<HyContentInfoDO> queryContentList(ContentQueryListDto dto);
/**
* 根据contentId查询动态详情
*/
HyContentInfoDO queryContentInfo(@Param("contentId") String contentId);
}

View File

@@ -100,40 +100,69 @@
<update id="updateByPrimaryKeySelective">
update hy_content_info
<set>
<if test="record.contentTitle != null">
<if test="record.contentTitle != null and record.contentTitle != ''">
content_title = #{record.contentTitle},
</if>
<if test="record.subject != null">
<if test="record.subject != null and record.subject != ''">
subject = #{record.subject},
</if>
<if test="record.contentType != null">
<if test="record.contentType != null and record.contentType != ''">
content_type = #{record.contentType},
</if>
<if test="record.cover != null">
<if test="record.cover != null and record.cover != ''">
cover = #{record.cover},
</if>
<if test="record.status != null">
<if test="record.status != null and record.status != null">
status = #{record.status},
</if>
<if test="record.deleted != null">
<if test="record.deleted != null and record.deleted != ''">
deleted = #{record.deleted},
</if>
<if test="record.createTime != null">
<if test="record.createTime != null and record.createTime != ''">
create_time = #{record.createTime},
</if>
<if test="record.updateTime != null">
<if test="record.updateTime != null and record.updateTime != ''">
update_time = #{record.updateTime},
</if>
<if test="record.createUserId != null">
<if test="record.createUserId != null and record.createUserId != ''">
create_user_id = #{record.createUserId},
</if>
<if test="record.updateUserId != null">
<if test="record.updateUserId != null and record.updateUserId != ''">
update_user_id = #{record.updateUserId},
</if>
<if test="record.content != null">
<if test="record.content != null and record.content != ''">
content = #{record.content},
</if>
</set>
where id = #{record.id}
</update>
<update id="deleteSelective">
update hy_content_info
<set>
deleted = 1
</set>
where id = #{contentId}
</update>
<select id="queryContentList" resultType="com.cool.store.entity.HyContentInfoDO">
select <include refid="Base_Column_List"></include>
from hy_content_info
where deleted = 0
<if test="contentTitle != null and contentTitle != ''">
and content_title like concat('%', #{contentTitle}, '%')
</if>
<if test="subject != null and subject != ''">
and subject = #{subject}
</if>
<if test="contentType != null and contentType != ''">
and content_type = #{contentType}
</if>
</select>
<!-- 查询动态详情 -->
<select id="queryContentInfo" resultType="com.cool.store.entity.HyContentInfoDO">
select <include refid="Base_Column_List"></include>
from hy_content_info
where deleted = 0
and id = #{contentId}
</select>
</mapper>