From ca10cf5abcf5b37d5aa41e6c230a581c7180dc3a Mon Sep 17 00:00:00 2001 From: little-cat-sweet <2116400472@qq.com> Date: Mon, 2 Aug 2021 17:31:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=B8=AE=E5=8A=A9=E7=AE=A1?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/XhpcDictBizController.java | 3 +- .../controller/XhpcHelpController.java | 55 +++++++++++ .../com/xhpc/general/domain/HelpEntity.java | 66 +++++++++++++ .../{domain => dto}/XhpcDictionaryChild.java | 5 +- .../XhpcDictBizQuantityCheckMapper.java | 1 + .../xhpc/general/mapper/XhpcHelpMapper.java | 35 +++++++ .../general/service/IXhpcHelpService.java | 37 ++++++++ .../general/service/XhpcHelpServiceImpl.java | 93 +++++++++++++++++++ .../HelpEntityLengthCheckUtil.java | 28 ++++++ .../main/resources/mapper/XhpcHelpMapper.xml | 61 ++++++++++++ 10 files changed, 382 insertions(+), 2 deletions(-) create mode 100644 xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/controller/XhpcHelpController.java create mode 100644 xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/domain/HelpEntity.java rename xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/{domain => dto}/XhpcDictionaryChild.java (69%) create mode 100644 xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/mapper/XhpcHelpMapper.java create mode 100644 xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/service/IXhpcHelpService.java create mode 100644 xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/service/XhpcHelpServiceImpl.java create mode 100644 xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/util/lengthCheckUtil/HelpEntityLengthCheckUtil.java create mode 100644 xhpc-modules/xhpc-general/src/main/resources/mapper/XhpcHelpMapper.xml diff --git a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/controller/XhpcDictBizController.java b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/controller/XhpcDictBizController.java index cc1ff8b9..183d42f7 100644 --- a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/controller/XhpcDictBizController.java +++ b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/controller/XhpcDictBizController.java @@ -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.page.TableDataInfo; 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 org.apache.ibatis.annotations.Param; import org.springframework.beans.factory.annotation.Autowired; @@ -104,6 +104,7 @@ public class XhpcDictBizController extends BaseController { */ @GetMapping("/getParentItems") public TableDataInfo getSearchParentResult(String code, String name ){ + startPage(); List list = xhpcDictBizService.getMainItems(code,name); return getDataTable(list); diff --git a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/controller/XhpcHelpController.java b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/controller/XhpcHelpController.java new file mode 100644 index 00000000..e0d9c79e --- /dev/null +++ b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/controller/XhpcHelpController.java @@ -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 list=iXhpcHelpService.selectHelpItems(title, createBy, type); + return getDataTable(list); + } + + @GetMapping("/selectItem") + public AjaxResult selectHelpItem(@RequestParam Long helpId){ + + return iXhpcHelpService.selectHelpItem(helpId); + } +} diff --git a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/domain/HelpEntity.java b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/domain/HelpEntity.java new file mode 100644 index 00000000..b8dda218 --- /dev/null +++ b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/domain/HelpEntity.java @@ -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; + } +} diff --git a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/domain/XhpcDictionaryChild.java b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/dto/XhpcDictionaryChild.java similarity index 69% rename from xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/domain/XhpcDictionaryChild.java rename to xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/dto/XhpcDictionaryChild.java index 82e651c1..9b757719 100644 --- a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/domain/XhpcDictionaryChild.java +++ b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/dto/XhpcDictionaryChild.java @@ -1,6 +1,9 @@ -package com.xhpc.general.domain; +package com.xhpc.general.dto; + +import com.xhpc.general.domain.XhpcDictionary; /** + * 业务字典批量参数json参数类 * program: ruoyi * User: HongYun * Date:2021-08-02 10 diff --git a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/mapper/XhpcDictBizQuantityCheckMapper.java b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/mapper/XhpcDictBizQuantityCheckMapper.java index 2f076325..84b9f1fe 100644 --- a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/mapper/XhpcDictBizQuantityCheckMapper.java +++ b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/mapper/XhpcDictBizQuantityCheckMapper.java @@ -3,6 +3,7 @@ package com.xhpc.general.mapper; import org.apache.ibatis.annotations.Param; /** + * 业务字典数条数mapper * program: Getting the quantity of one column's rows. * User: HongYun * Date:2021-07-28 15 diff --git a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/mapper/XhpcHelpMapper.java b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/mapper/XhpcHelpMapper.java new file mode 100644 index 00000000..fef4f8a4 --- /dev/null +++ b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/mapper/XhpcHelpMapper.java @@ -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 selectHelpItems(@Param("title") String title, @Param("createBy") String createBy, @Param("type") Integer type); + + HelpEntity selectHelpItem(@Param("helpId") Long helpId); + + + +} diff --git a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/service/IXhpcHelpService.java b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/service/IXhpcHelpService.java new file mode 100644 index 00000000..c8539498 --- /dev/null +++ b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/service/IXhpcHelpService.java @@ -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 selectHelpItems(String title, String createBy, Integer type); + + AjaxResult selectHelpItem(Long helpId); +} diff --git a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/service/XhpcHelpServiceImpl.java b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/service/XhpcHelpServiceImpl.java new file mode 100644 index 00000000..f54747e5 --- /dev/null +++ b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/service/XhpcHelpServiceImpl.java @@ -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 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)); + } +} diff --git a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/util/lengthCheckUtil/HelpEntityLengthCheckUtil.java b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/util/lengthCheckUtil/HelpEntityLengthCheckUtil.java new file mode 100644 index 00000000..7065037f --- /dev/null +++ b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/util/lengthCheckUtil/HelpEntityLengthCheckUtil.java @@ -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(); + } +} diff --git a/xhpc-modules/xhpc-general/src/main/resources/mapper/XhpcHelpMapper.xml b/xhpc-modules/xhpc-general/src/main/resources/mapper/XhpcHelpMapper.xml new file mode 100644 index 00000000..27e2def0 --- /dev/null +++ b/xhpc-modules/xhpc-general/src/main/resources/mapper/XhpcHelpMapper.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + update xhpc_help set del_flag=1 where help_id=#{helpId}; + + + + + + + insert xhpc_help (title,content,type) values (#{title},#{content},#{type}); + + + + update xhpc_help set title=#{title},content=#{content},type=#{type} where help_id=#{helpId}; + + + + + + + + \ No newline at end of file