From a73a8d2db29c8f5810f0143dbaebe03478a5e9a4 Mon Sep 17 00:00:00 2001 From: jishenghua <752718920@qq.com> Date: Sat, 22 Feb 2025 22:04:06 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=99=E7=BB=8F=E6=89=8B=E4=BA=BA=E5=92=8C?= =?UTF-8?q?=E4=BB=93=E5=BA=93=E4=BC=98=E5=8C=96=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../erp/controller/FunctionController.java | 84 +++++++++++++++++-- .../datasource/mappers/FunctionMapperEx.java | 6 -- .../service/functions/FunctionComponent.java | 73 ---------------- .../service/functions/FunctionResource.java | 15 ---- .../service/functions/FunctionService.java | 16 +--- .../resources/mapper_xml/FunctionMapperEx.xml | 19 +---- 6 files changed, 79 insertions(+), 134 deletions(-) delete mode 100644 jshERP-boot/src/main/java/com/jsh/erp/service/functions/FunctionComponent.java delete mode 100644 jshERP-boot/src/main/java/com/jsh/erp/service/functions/FunctionResource.java diff --git a/jshERP-boot/src/main/java/com/jsh/erp/controller/FunctionController.java b/jshERP-boot/src/main/java/com/jsh/erp/controller/FunctionController.java index 30fcdc7b5..d71be18c8 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/controller/FunctionController.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/controller/FunctionController.java @@ -2,19 +2,16 @@ package com.jsh.erp.controller; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; -import com.jsh.erp.constants.ExceptionConstants; +import com.jsh.erp.base.BaseController; +import com.jsh.erp.base.TableDataInfo; import com.jsh.erp.datasource.entities.Function; +import com.jsh.erp.datasource.entities.FunctionEx; import com.jsh.erp.datasource.entities.SystemConfig; -import com.jsh.erp.datasource.entities.User; import com.jsh.erp.datasource.entities.UserBusiness; -import com.jsh.erp.exception.BusinessRunTimeException; import com.jsh.erp.service.functions.FunctionService; import com.jsh.erp.service.systemConfig.SystemConfigService; import com.jsh.erp.service.userBusiness.UserBusinessService; -import com.jsh.erp.utils.BaseResponseInfo; -import com.jsh.erp.utils.ErpInfo; -import com.jsh.erp.utils.StringUtil; -import com.jsh.erp.utils.Tools; +import com.jsh.erp.utils.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; @@ -30,6 +27,7 @@ import java.util.List; import java.util.Map; import static com.jsh.erp.utils.ResponseJsonUtil.returnJson; +import static com.jsh.erp.utils.ResponseJsonUtil.returnStr; /** * @author ji-sheng-hua jshERP @@ -37,7 +35,7 @@ import static com.jsh.erp.utils.ResponseJsonUtil.returnJson; @RestController @RequestMapping(value = "/function") @Api(tags = {"功能管理"}) -public class FunctionController { +public class FunctionController extends BaseController { private Logger logger = LoggerFactory.getLogger(FunctionController.class); @Resource @@ -49,6 +47,76 @@ public class FunctionController { @Resource private SystemConfigService systemConfigService; + @GetMapping(value = "/info") + @ApiOperation(value = "根据id获取信息") + public String getList(@RequestParam("id") Long id, + HttpServletRequest request) throws Exception { + Function function = functionService.getFunction(id); + Map objectMap = new HashMap<>(); + if(function != null) { + objectMap.put("info", function); + return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); + } else { + return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); + } + } + + @GetMapping(value = "/list") + @ApiOperation(value = "获取信息列表") + public TableDataInfo getList(@RequestParam(value = Constants.SEARCH, required = false) String search, + HttpServletRequest request)throws Exception { + String name = StringUtil.getInfo(search, "name"); + String type = StringUtil.getInfo(search, "type"); + List list = functionService.select(name, type); + return getDataTable(list); + } + + @PostMapping(value = "/add") + @ApiOperation(value = "新增") + public String addResource(@RequestBody JSONObject obj, HttpServletRequest request)throws Exception { + Map objectMap = new HashMap<>(); + int insert = functionService.insertFunction(obj, request); + return returnStr(objectMap, insert); + } + + @PutMapping(value = "/update") + @ApiOperation(value = "修改") + public String updateResource(@RequestBody JSONObject obj, HttpServletRequest request)throws Exception { + Map objectMap = new HashMap<>(); + int update = functionService.updateFunction(obj, request); + return returnStr(objectMap, update); + } + + @DeleteMapping(value = "/delete") + @ApiOperation(value = "删除") + public String deleteResource(@RequestParam("id") Long id, HttpServletRequest request)throws Exception { + Map objectMap = new HashMap<>(); + int delete = functionService.deleteFunction(id, request); + return returnStr(objectMap, delete); + } + + @DeleteMapping(value = "/deleteBatch") + @ApiOperation(value = "批量删除") + public String batchDeleteResource(@RequestParam("ids") String ids, HttpServletRequest request)throws Exception { + Map objectMap = new HashMap<>(); + int delete = functionService.batchDeleteFunction(ids, request); + return returnStr(objectMap, delete); + } + + @GetMapping(value = "/checkIsNameExist") + @ApiOperation(value = "检查名称是否存在") + public String checkIsNameExist(@RequestParam Long id, @RequestParam(value ="name", required = false) String name, + HttpServletRequest request)throws Exception { + Map objectMap = new HashMap<>(); + int exist = functionService.checkIsNameExist(id, name); + if(exist > 0) { + objectMap.put("status", true); + } else { + objectMap.put("status", false); + } + return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); + } + @GetMapping(value = "/checkIsNumberExist") @ApiOperation(value = "检查编号是否存在") public String checkIsNumberExist(@RequestParam Long id, diff --git a/jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/FunctionMapperEx.java b/jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/FunctionMapperEx.java index 961ce2fc5..6d237fa1d 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/FunctionMapperEx.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/FunctionMapperEx.java @@ -9,12 +9,6 @@ import java.util.List; public interface FunctionMapperEx { List selectByConditionFunction( - @Param("name") String name, - @Param("type") String type, - @Param("offset") Integer offset, - @Param("rows") Integer rows); - - Long countsByFunction( @Param("name") String name, @Param("type") String type); diff --git a/jshERP-boot/src/main/java/com/jsh/erp/service/functions/FunctionComponent.java b/jshERP-boot/src/main/java/com/jsh/erp/service/functions/FunctionComponent.java deleted file mode 100644 index 8dafacffb..000000000 --- a/jshERP-boot/src/main/java/com/jsh/erp/service/functions/FunctionComponent.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.jsh.erp.service.functions; - -import com.alibaba.fastjson.JSONObject; -import com.jsh.erp.service.ICommonQuery; -import com.jsh.erp.utils.Constants; -import com.jsh.erp.utils.QueryUtils; -import com.jsh.erp.utils.StringUtil; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletRequest; -import java.util.List; -import java.util.Map; - -@Service(value = "function_component") -@FunctionResource -public class FunctionComponent implements ICommonQuery { - - @Resource - private FunctionService functionService; - - @Override - public Object selectOne(Long id) throws Exception { - return functionService.getFunction(id); - } - - @Override - public List select(Map map)throws Exception { - return getFunctionsList(map); - } - - private List getFunctionsList(Map map) throws Exception{ - String search = map.get(Constants.SEARCH); - String name = StringUtil.getInfo(search, "name"); - String type = StringUtil.getInfo(search, "type"); - String order = QueryUtils.order(map); - return functionService.select(name, type, QueryUtils.offset(map), QueryUtils.rows(map)); - } - - @Override - public Long counts(Map map) throws Exception{ - String search = map.get(Constants.SEARCH); - String name = StringUtil.getInfo(search, "name"); - String type = StringUtil.getInfo(search, "type"); - return functionService.countFunction(name, type); - } - - @Override - public int insert(JSONObject obj, HttpServletRequest request)throws Exception { - return functionService.insertFunction(obj, request); - } - - @Override - public int update(JSONObject obj, HttpServletRequest request)throws Exception { - return functionService.updateFunction(obj, request); - } - - @Override - public int delete(Long id, HttpServletRequest request)throws Exception { - return functionService.deleteFunction(id, request); - } - - @Override - public int deleteBatch(String ids, HttpServletRequest request)throws Exception { - return functionService.batchDeleteFunction(ids, request); - } - - @Override - public int checkIsNameExist(Long id, String name)throws Exception { - return functionService.checkIsNameExist(id, name); - } - -} diff --git a/jshERP-boot/src/main/java/com/jsh/erp/service/functions/FunctionResource.java b/jshERP-boot/src/main/java/com/jsh/erp/service/functions/FunctionResource.java deleted file mode 100644 index 703448430..000000000 --- a/jshERP-boot/src/main/java/com/jsh/erp/service/functions/FunctionResource.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.jsh.erp.service.functions; - -import com.jsh.erp.service.ResourceInfo; - -import java.lang.annotation.*; - -/** - * @author jishenghua qq752718920 2018-10-7 15:26:27 - */ -@ResourceInfo(value = "function") -@Inherited -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.RUNTIME) -public @interface FunctionResource { -} diff --git a/jshERP-boot/src/main/java/com/jsh/erp/service/functions/FunctionService.java b/jshERP-boot/src/main/java/com/jsh/erp/service/functions/FunctionService.java index 08153d3ea..dc59f3f24 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/service/functions/FunctionService.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/service/functions/FunctionService.java @@ -77,11 +77,11 @@ public class FunctionService { return list; } - public List select(String name, String type, int offset, int rows)throws Exception { + public List select(String name, String type)throws Exception { List list=null; try{ if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) { - list = functionMapperEx.selectByConditionFunction(name, type, offset, rows); + list = functionMapperEx.selectByConditionFunction(name, type); } }catch(Exception e){ JshException.readFail(logger, e); @@ -89,18 +89,6 @@ public class FunctionService { return list; } - public Long countFunction(String name, String type)throws Exception { - Long result=null; - try{ - if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) { - result = functionMapperEx.countsByFunction(name, type); - } - }catch(Exception e){ - JshException.readFail(logger, e); - } - return result; - } - @Transactional(value = "transactionManager", rollbackFor = Exception.class) public int insertFunction(JSONObject obj, HttpServletRequest request)throws Exception { Function functions = JSONObject.parseObject(obj.toJSONString(), Function.class); diff --git a/jshERP-boot/src/main/resources/mapper_xml/FunctionMapperEx.xml b/jshERP-boot/src/main/resources/mapper_xml/FunctionMapperEx.xml index 11fb1b47a..4f8e72390 100644 --- a/jshERP-boot/src/main/resources/mapper_xml/FunctionMapperEx.xml +++ b/jshERP-boot/src/main/resources/mapper_xml/FunctionMapperEx.xml @@ -19,25 +19,8 @@ and ifnull(fa.delete_flag,'0') !='1' order by fa.sort asc - - limit #{offset},#{rows} - - - + update jsh_function set delete_flag='1'