完成帮助管理
This commit is contained in:
parent
659583526e
commit
ca10cf5abc
@ -4,7 +4,7 @@ import com.xhpc.common.core.web.controller.BaseController;
|
|||||||
import com.xhpc.common.core.web.domain.AjaxResult;
|
import com.xhpc.common.core.web.domain.AjaxResult;
|
||||||
import com.xhpc.common.core.web.page.TableDataInfo;
|
import com.xhpc.common.core.web.page.TableDataInfo;
|
||||||
import com.xhpc.general.domain.XhpcDictionary;
|
import com.xhpc.general.domain.XhpcDictionary;
|
||||||
import com.xhpc.general.domain.XhpcDictionaryChild;
|
import com.xhpc.general.dto.XhpcDictionaryChild;
|
||||||
import com.xhpc.general.service.IXhpcDictBizService;
|
import com.xhpc.general.service.IXhpcDictBizService;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -104,6 +104,7 @@ public class XhpcDictBizController extends BaseController {
|
|||||||
*/
|
*/
|
||||||
@GetMapping("/getParentItems")
|
@GetMapping("/getParentItems")
|
||||||
public TableDataInfo getSearchParentResult(String code, String name ){
|
public TableDataInfo getSearchParentResult(String code, String name ){
|
||||||
|
|
||||||
startPage();
|
startPage();
|
||||||
List<XhpcDictionary> list = xhpcDictBizService.getMainItems(code,name);
|
List<XhpcDictionary> list = xhpcDictBizService.getMainItems(code,name);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
|
|||||||
@ -0,0 +1,55 @@
|
|||||||
|
package com.xhpc.general.controller;
|
||||||
|
|
||||||
|
import com.xhpc.common.core.web.controller.BaseController;
|
||||||
|
import com.xhpc.common.core.web.domain.AjaxResult;
|
||||||
|
import com.xhpc.common.core.web.page.TableDataInfo;
|
||||||
|
import com.xhpc.general.domain.HelpEntity;
|
||||||
|
import com.xhpc.general.service.IXhpcHelpService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 帮助管理controller
|
||||||
|
* program: ruoyi
|
||||||
|
* User: HongYun
|
||||||
|
* Date:2021-08-02 11
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/help")
|
||||||
|
public class XhpcHelpController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
IXhpcHelpService iXhpcHelpService;
|
||||||
|
@PostMapping("/delete")
|
||||||
|
public AjaxResult deleteHelpItem(@RequestBody HelpEntity helpEntity){
|
||||||
|
|
||||||
|
return iXhpcHelpService.deleteHelpItem(helpEntity.getHelpId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/add")
|
||||||
|
public AjaxResult insertHelpItem(@RequestBody HelpEntity helpEntity){
|
||||||
|
|
||||||
|
return iXhpcHelpService.insertHelpItem(helpEntity.getTitle(),helpEntity.getContent(),helpEntity.getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/update")
|
||||||
|
public AjaxResult updateHelpItem(@RequestBody HelpEntity helpEntity){
|
||||||
|
|
||||||
|
return iXhpcHelpService.updateHelpItem(helpEntity.getHelpId(),helpEntity.getTitle(),helpEntity.getContent(),helpEntity.getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/selectItems")
|
||||||
|
public TableDataInfo selectHelpItems(String title, String createBy, Integer type){
|
||||||
|
|
||||||
|
startPage();
|
||||||
|
List<HelpEntity> list=iXhpcHelpService.selectHelpItems(title, createBy, type);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/selectItem")
|
||||||
|
public AjaxResult selectHelpItem(@RequestParam Long helpId){
|
||||||
|
|
||||||
|
return iXhpcHelpService.selectHelpItem(helpId);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,66 @@
|
|||||||
|
package com.xhpc.general.domain;
|
||||||
|
|
||||||
|
import com.xhpc.common.core.web.domain.BaseEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 帮助实体类
|
||||||
|
* program: ruoyi
|
||||||
|
* User: HongYun
|
||||||
|
* Date:2021-08-02 11
|
||||||
|
*/
|
||||||
|
public class HelpEntity extends BaseEntity {
|
||||||
|
private Long helpId;
|
||||||
|
private String title;
|
||||||
|
private String content;
|
||||||
|
private Integer type;
|
||||||
|
private Integer status;
|
||||||
|
private Integer delFlag;
|
||||||
|
|
||||||
|
public Long getHelpId() {
|
||||||
|
return helpId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHelpId(Long helpId) {
|
||||||
|
this.helpId = helpId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getContent() {
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContent(String content) {
|
||||||
|
this.content = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(Integer type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(Integer status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getDelFlag() {
|
||||||
|
return delFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDelFlag(Integer delFlag) {
|
||||||
|
this.delFlag = delFlag;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,6 +1,9 @@
|
|||||||
package com.xhpc.general.domain;
|
package com.xhpc.general.dto;
|
||||||
|
|
||||||
|
import com.xhpc.general.domain.XhpcDictionary;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 业务字典批量参数json参数类
|
||||||
* program: ruoyi
|
* program: ruoyi
|
||||||
* User: HongYun
|
* User: HongYun
|
||||||
* Date:2021-08-02 10
|
* Date:2021-08-02 10
|
||||||
@ -3,6 +3,7 @@ package com.xhpc.general.mapper;
|
|||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 业务字典数条数mapper
|
||||||
* program: Getting the quantity of one column's rows.
|
* program: Getting the quantity of one column's rows.
|
||||||
* User: HongYun
|
* User: HongYun
|
||||||
* Date:2021-07-28 15
|
* Date:2021-07-28 15
|
||||||
|
|||||||
@ -0,0 +1,35 @@
|
|||||||
|
package com.xhpc.general.mapper;
|
||||||
|
|
||||||
|
import com.xhpc.general.domain.HelpEntity;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 帮助Mapper接口
|
||||||
|
* program: ruoyi
|
||||||
|
* User: HongYun
|
||||||
|
* Date:2021-08-02 11
|
||||||
|
*/
|
||||||
|
public interface XhpcHelpMapper {
|
||||||
|
|
||||||
|
int deleteHelpItem(@Param("helpId") Long helpId);
|
||||||
|
/**
|
||||||
|
* Counting the quantity by the type,title.
|
||||||
|
* @param type
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int countSameTypeTitle(@Param("type") Integer type,@Param("title") String title);
|
||||||
|
|
||||||
|
|
||||||
|
int insertHelpItem(@Param("title") String title,@Param("content") String content,@Param("type") Integer type);
|
||||||
|
|
||||||
|
int updateHelpItem(@Param("helpId") Long helpId,@Param("title") String title,@Param("type")Integer type,@Param("content") String content);
|
||||||
|
|
||||||
|
List<HelpEntity> selectHelpItems(@Param("title") String title, @Param("createBy") String createBy, @Param("type") Integer type);
|
||||||
|
|
||||||
|
HelpEntity selectHelpItem(@Param("helpId") Long helpId);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,37 @@
|
|||||||
|
package com.xhpc.general.service;
|
||||||
|
|
||||||
|
import com.xhpc.common.core.web.domain.AjaxResult;
|
||||||
|
import com.xhpc.general.domain.HelpEntity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**帮助service接口
|
||||||
|
* program: ruoyi
|
||||||
|
* User: HongYun
|
||||||
|
* Date:2021-08-02 11
|
||||||
|
*/
|
||||||
|
public interface IXhpcHelpService {
|
||||||
|
/**
|
||||||
|
* Deleting a helpItem by help_id.
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
AjaxResult deleteHelpItem(Long helpId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inserting a helpItem by ....
|
||||||
|
* @param title
|
||||||
|
* @param content
|
||||||
|
* @param type
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
AjaxResult insertHelpItem(String title,String content,Integer type);
|
||||||
|
|
||||||
|
|
||||||
|
AjaxResult updateHelpItem(Long helpId,String title,String content,Integer type);
|
||||||
|
|
||||||
|
|
||||||
|
List<HelpEntity> selectHelpItems(String title, String createBy, Integer type);
|
||||||
|
|
||||||
|
AjaxResult selectHelpItem(Long helpId);
|
||||||
|
}
|
||||||
@ -0,0 +1,93 @@
|
|||||||
|
package com.xhpc.general.service;
|
||||||
|
|
||||||
|
import com.xhpc.common.core.web.domain.AjaxResult;
|
||||||
|
import com.xhpc.general.domain.HelpEntity;
|
||||||
|
import com.xhpc.general.mapper.XhpcHelpMapper;
|
||||||
|
import com.xhpc.general.util.lengthCheckUtil.HelpEntityLengthCheckUtil;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 帮助Service业务层处理
|
||||||
|
* program: ruoyi
|
||||||
|
* User: HongYun
|
||||||
|
* Date:2021-08-02 11
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class XhpcHelpServiceImpl implements IXhpcHelpService{
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
XhpcHelpMapper xhpcHelpMapper;
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public AjaxResult deleteHelpItem(Long helpId) {
|
||||||
|
|
||||||
|
int res=xhpcHelpMapper.deleteHelpItem(helpId);
|
||||||
|
if(res==0){
|
||||||
|
return AjaxResult.error("删除失败");
|
||||||
|
}else {
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public AjaxResult insertHelpItem(String title, String content, Integer type) {
|
||||||
|
|
||||||
|
//Checking title's length.
|
||||||
|
if(!HelpEntityLengthCheckUtil.checkTitleL(title.length())){
|
||||||
|
return AjaxResult.error("标题的长度不能大于"+HelpEntityLengthCheckUtil.getTitleLL());
|
||||||
|
}
|
||||||
|
//Ensuring the title is unique.
|
||||||
|
int res1=xhpcHelpMapper.countSameTypeTitle(type,title);
|
||||||
|
if(res1!=0){
|
||||||
|
return AjaxResult.error("此类型已有此标题");
|
||||||
|
}
|
||||||
|
int res2=xhpcHelpMapper.insertHelpItem(title, content, type);
|
||||||
|
if(res2==0){
|
||||||
|
return AjaxResult.error("插入失败");
|
||||||
|
}
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public AjaxResult updateHelpItem(Long helpId, String title, String content, Integer type) {
|
||||||
|
|
||||||
|
//Checking the title's length.
|
||||||
|
if(!HelpEntityLengthCheckUtil.checkTitleL(title.length())){
|
||||||
|
return AjaxResult.error("标题的长度不能大于"+HelpEntityLengthCheckUtil.getTitleLL());
|
||||||
|
}
|
||||||
|
HelpEntity helpEntity=xhpcHelpMapper.selectHelpItem(helpId);
|
||||||
|
if(!helpEntity.getTitle().equals(title)) {
|
||||||
|
int res1 = xhpcHelpMapper.countSameTypeTitle(type, title);
|
||||||
|
if (res1 != 0) {
|
||||||
|
return AjaxResult.error("此类型已有此标题");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int res2=xhpcHelpMapper.updateHelpItem(helpId, title, type, content);
|
||||||
|
if(res2==0){
|
||||||
|
return AjaxResult.error("修改失败");
|
||||||
|
}
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public List<HelpEntity> selectHelpItems(String title, String createBy, Integer type) {
|
||||||
|
|
||||||
|
return xhpcHelpMapper.selectHelpItems(title, createBy, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AjaxResult selectHelpItem(Long helpId) {
|
||||||
|
|
||||||
|
return AjaxResult.success(xhpcHelpMapper.selectHelpItem(helpId));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
package com.xhpc.general.util.lengthCheckUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*帮助字段长度检查
|
||||||
|
* program: ruoyi
|
||||||
|
* User: HongYun
|
||||||
|
* Date:2021-08-02 11
|
||||||
|
*/
|
||||||
|
public class HelpEntityLengthCheckUtil {
|
||||||
|
private final static Integer titleLL=50;
|
||||||
|
private final static Integer createByL=30;
|
||||||
|
|
||||||
|
public static Integer getTitleLL() {
|
||||||
|
return titleLL;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean checkTitleL(int length){
|
||||||
|
return length<=HelpEntityLengthCheckUtil.getTitleLL();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Integer getCreateByL() {
|
||||||
|
return createByL;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean checkCreateByL(int length){
|
||||||
|
return length<=HelpEntityLengthCheckUtil.getCreateByL();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,61 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.xhpc.general.mapper.XhpcHelpMapper">
|
||||||
|
|
||||||
|
<resultMap id="BaseResultMap" type="com.xhpc.general.domain.HelpEntity">
|
||||||
|
<result property="helpId" column="help_id"/>
|
||||||
|
<result property="title" column="title"/>
|
||||||
|
<result property="content" column="content"/>
|
||||||
|
<result property="type" column="type"/>
|
||||||
|
<result property="status" column="status"/>
|
||||||
|
<result property="delFlag" column="del_flag"/>
|
||||||
|
<result property="createTime" column="create_time"/>
|
||||||
|
<result property="createBy" column="create_by"/>
|
||||||
|
<result property="updateTime" column="update_time"/>
|
||||||
|
<result property="updateBy" column="update_by"/>
|
||||||
|
<result property="remark" column="remark"/>
|
||||||
|
</resultMap>
|
||||||
|
<!-- 通用查询映射结果 -->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<update id="deleteHelpItem">
|
||||||
|
|
||||||
|
update xhpc_help set del_flag=1 where help_id=#{helpId};
|
||||||
|
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<select id="countSameTypeTitle" resultType="java.lang.Integer">
|
||||||
|
select count(title) from xhpc_help where type=#{type} and title=#{title} and del_flag=0;
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertHelpItem">
|
||||||
|
insert xhpc_help (title,content,type) values (#{title},#{content},#{type});
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateHelpItem">
|
||||||
|
update xhpc_help set title=#{title},content=#{content},type=#{type} where help_id=#{helpId};
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<select id="selectHelpItems" resultMap="BaseResultMap">
|
||||||
|
select * from xhpc_help
|
||||||
|
where del_flag=0
|
||||||
|
<if test="title!=null and title!=''">
|
||||||
|
and title=#{title}
|
||||||
|
</if>
|
||||||
|
<if test="createBy!=null and createBy!=''">
|
||||||
|
and create_by=#{createBy}
|
||||||
|
</if>
|
||||||
|
<if test="type!=null">
|
||||||
|
and type=#{type}
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectHelpItem" resultMap="BaseResultMap">
|
||||||
|
select * from xhpc_help
|
||||||
|
where help_id=#{helpId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
||||||
Loading…
x
Reference in New Issue
Block a user