skill模块联调
This commit is contained in:
parent
de4dcf33e9
commit
63eefa2207
|
|
@ -43,4 +43,8 @@ public class Skill {
|
|||
private String mdContent;
|
||||
|
||||
private Integer praisesCount;
|
||||
|
||||
private String praiseUserIds;
|
||||
|
||||
private Boolean praised;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -179,6 +179,7 @@ public class ApprovalServiceImpl implements ApprovalService {
|
|||
break;
|
||||
case "SKILL":
|
||||
Skill skill = JSONUtil.toBean(content, Skill.class);
|
||||
skill.setIsPublic(true);
|
||||
skillDao.edit(skill);
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import cn.hutool.core.io.FileUtil;
|
|||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
|
|
@ -99,7 +100,11 @@ public class SkillServiceImpl implements SkillService {
|
|||
|
||||
@Override
|
||||
public Skill queryById(Long id) {
|
||||
return skillDao.getSkillById(id);
|
||||
Long userid = SecurityUtils.getLoginUser().getUserid();
|
||||
Skill skill = skillDao.getSkillById(id);
|
||||
JSONArray userIds = StrUtil.isBlank(skill.getPraiseUserIds()) ? JSONUtil.createArray() : JSONUtil.parseArray(skill.getPraiseUserIds());
|
||||
skill.setPraised(userIds.contains(userid.intValue()));
|
||||
return skill;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -121,9 +126,9 @@ public class SkillServiceImpl implements SkillService {
|
|||
public Skill publish(Long id, LoginUser loginUser, HttpServletRequest request) {
|
||||
Set<String> roles = loginUser.getRoles();
|
||||
Skill skill = skillDao.getSkillById(id);
|
||||
skill.setIsPublic(true);
|
||||
if (roles.contains("admin")) {
|
||||
//无需审批,直接通过
|
||||
skill.setIsPublic(true);
|
||||
skillDao.edit(skill);
|
||||
}
|
||||
|
||||
|
|
@ -137,7 +142,7 @@ public class SkillServiceImpl implements SkillService {
|
|||
approvalRequest.setStatus(ApprovalStatus.PENDING.getCode());
|
||||
|
||||
String titleTemplate = "{}发布的Skill<b>\"{}\"</b>需要审核,请查看";
|
||||
String urlTemplate = "/dataset/skill/info/{}";
|
||||
String urlTemplate = "/dataset/skills/info/{}";
|
||||
|
||||
String titleFormat = StrUtil.format(titleTemplate, username, skill.getName());
|
||||
String urlFormat = StrUtil.format(urlTemplate, skill.getId());
|
||||
|
|
@ -155,6 +160,16 @@ public class SkillServiceImpl implements SkillService {
|
|||
Skill skill = skillDao.getSkillById(id);
|
||||
int praiseCount = skill.getPraisesCount() == null ? 1 : skill.getPraisesCount() + 1;
|
||||
skill.setPraisesCount(praiseCount);
|
||||
|
||||
Long userid = SecurityUtils.getLoginUser().getUserid();
|
||||
JSONArray userIds = StrUtil.isBlank(skill.getPraiseUserIds()) ? JSONUtil.createArray() : JSONUtil.parseArray(skill.getPraiseUserIds());
|
||||
if (userIds.contains(userid)) {
|
||||
return skill;
|
||||
}
|
||||
userIds.add(userid);
|
||||
skill.setPraiseUserIds(JSONUtil.toJsonStr(userIds));
|
||||
skill.setPraised(true);
|
||||
|
||||
skillDao.edit(skill);
|
||||
return skill;
|
||||
}
|
||||
|
|
@ -164,6 +179,16 @@ public class SkillServiceImpl implements SkillService {
|
|||
Skill skill = skillDao.getSkillById(id);
|
||||
int praiseCount = skill.getPraisesCount() == null ? 0 : skill.getPraisesCount() - 1;
|
||||
skill.setPraisesCount(praiseCount);
|
||||
|
||||
Long userid = SecurityUtils.getLoginUser().getUserid();
|
||||
JSONArray userIds = StrUtil.isBlank(skill.getPraiseUserIds()) ? JSONUtil.createArray() : JSONUtil.parseArray(skill.getPraiseUserIds());
|
||||
if (!userIds.contains(userid.intValue())) {
|
||||
return skill;
|
||||
}
|
||||
userIds.remove(userIds.indexOf(userid.intValue()));
|
||||
skill.setPraiseUserIds(JSONUtil.toJsonStr(userIds));
|
||||
skill.setPraised(false);
|
||||
|
||||
skillDao.edit(skill);
|
||||
return skill;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@
|
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.platform.mapper.SkillDao">
|
||||
<insert id="save" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into skill(name, description, type, preview_pic, create_by, update_by,file_path,file_tree_json,md_content)
|
||||
insert into skill(name, description, type, preview_pic, create_by, update_by,file_path,file_tree_json,md_content,praises_count)
|
||||
values (#{skill.name}, #{skill.description}, #{skill.type},
|
||||
#{skill.previewPic}, #{skill.createBy}, #{skill.updateBy},#{skill.filePath},#{skill.fileTreeJson},#{skill.mdContent})
|
||||
#{skill.previewPic}, #{skill.createBy}, #{skill.updateBy},#{skill.filePath},#{skill.fileTreeJson},#{skill.mdContent},#{skill.praisesCount})
|
||||
</insert>
|
||||
|
||||
<update id="edit">
|
||||
|
|
@ -22,9 +22,12 @@
|
|||
<if test="skill.previewPic != null and skill.previewPic !=''">
|
||||
preview_pic = #{skill.previewPic},
|
||||
</if>
|
||||
<if test="skill.praisesCount != null and skill.praisesCount !=''">
|
||||
<if test="skill.praisesCount != null ">
|
||||
praises_count = #{skill.praisesCount},
|
||||
</if>
|
||||
<if test="skill.praiseUserIds != null and skill.praiseUserIds !=''">
|
||||
praise_user_ids = #{skill.praiseUserIds},
|
||||
</if>
|
||||
<if test="skill.filePath != null and skill.filePath !=''">
|
||||
file_path = #{skill.filePath},
|
||||
</if>
|
||||
|
|
|
|||
Loading…
Reference in New Issue