Browse Source

更新生成代码管理功能

fushengqian 1 year ago
parent
commit
7a04450684

+ 40 - 1
fuint-application/src/main/java/com/fuint/common/service/GenCodeService.java

@@ -1,5 +1,10 @@
 package com.fuint.common.service;
 package com.fuint.common.service;
 
 
+import com.fuint.framework.exception.BusinessCheckException;
+import com.fuint.framework.pagination.PaginationRequest;
+import com.fuint.framework.pagination.PaginationResponse;
+import com.fuint.repository.model.TGenCode;
+
 /**
 /**
  * 代码生成服务接口
  * 代码生成服务接口
  *
  *
@@ -8,11 +13,45 @@ package com.fuint.common.service;
  */
  */
 public interface GenCodeService {
 public interface GenCodeService {
 
 
+    /**
+     * 分页查询列表
+     *
+     * @param paginationRequest
+     * @return
+     */
+    PaginationResponse<TGenCode> queryGenCodeListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException;
+
+    /**
+     * 添加生成代码
+     *
+     * @param  tGenCode 代码参数
+     * @throws BusinessCheckException
+     * @return
+     */
+    TGenCode addGenCode(TGenCode tGenCode) throws BusinessCheckException;
+
+    /**
+     * 根据ID获取信息
+     *
+     * @param  id
+     * @throws BusinessCheckException
+     * @return
+     */
+    TGenCode queryGenCodeById(Integer id) throws BusinessCheckException;
+
+    /**
+     * 更新生成代码
+     * @param  tGenCode
+     * @throws BusinessCheckException
+     * @return
+     * */
+    TGenCode updateGenCode(TGenCode tGenCode) throws BusinessCheckException;
+
     /**
     /**
      * 生成代码(自定义路径)
      * 生成代码(自定义路径)
      * 
      * 
      * @param tableName 表名称
      * @param tableName 表名称
-     * @return 数据
+     * @return
      */
      */
     void generatorCode(String tableName);
     void generatorCode(String tableName);
 
 

+ 2 - 2
fuint-application/src/main/java/com/fuint/common/service/impl/ArticleServiceImpl.java

@@ -182,7 +182,7 @@ public class ArticleServiceImpl extends ServiceImpl<MtArticleMapper, MtArticle>
     /**
     /**
      * 编辑文章
      * 编辑文章
      *
      *
-     * @param  articleDto
+     * @param  articleDto 文章参数
      * @throws BusinessCheckException
      * @throws BusinessCheckException
      */
      */
     @Override
     @Override
@@ -235,7 +235,7 @@ public class ArticleServiceImpl extends ServiceImpl<MtArticleMapper, MtArticle>
     /**
     /**
      * 根据条件搜索文章
      * 根据条件搜索文章
      *
      *
-     * @param params
+     * @param params 搜索条件
      * @return
      * @return
      * */
      * */
     @Override
     @Override

+ 89 - 1
fuint-application/src/main/java/com/fuint/common/service/impl/GenCodeServiceImpl.java

@@ -1,11 +1,20 @@
 package com.fuint.common.service.impl;
 package com.fuint.common.service.impl;
 
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.fuint.common.enums.StatusEnum;
 import com.fuint.common.service.GenCodeService;
 import com.fuint.common.service.GenCodeService;
 import com.fuint.common.util.VelocityInitializer;
 import com.fuint.common.util.VelocityInitializer;
 import com.fuint.common.util.VelocityUtils;
 import com.fuint.common.util.VelocityUtils;
+import com.fuint.framework.annoation.OperationServiceLog;
+import com.fuint.framework.exception.BusinessCheckException;
 import com.fuint.framework.exception.BusinessRuntimeException;
 import com.fuint.framework.exception.BusinessRuntimeException;
+import com.fuint.framework.pagination.PaginationRequest;
+import com.fuint.framework.pagination.PaginationResponse;
 import com.fuint.repository.mapper.TGenCodeMapper;
 import com.fuint.repository.mapper.TGenCodeMapper;
 import com.fuint.repository.model.TGenCode;
 import com.fuint.repository.model.TGenCode;
+import com.github.pagehelper.Page;
+import com.github.pagehelper.PageHelper;
 import lombok.AllArgsConstructor;
 import lombok.AllArgsConstructor;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.FileUtils;
@@ -14,8 +23,10 @@ import org.apache.velocity.VelocityContext;
 import org.apache.velocity.app.Velocity;
 import org.apache.velocity.app.Velocity;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
+import org.springframework.data.domain.PageImpl;
+import org.springframework.data.domain.PageRequest;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
-
+import org.springframework.transaction.annotation.Transactional;
 import java.io.File;
 import java.io.File;
 import java.io.IOException;
 import java.io.IOException;
 import java.io.StringWriter;
 import java.io.StringWriter;
@@ -35,6 +46,83 @@ public class GenCodeServiceImpl implements GenCodeService {
 
 
     private TGenCodeMapper tGenCodeMapper;
     private TGenCodeMapper tGenCodeMapper;
 
 
+    /**
+     * 分页查询生成代码列表
+     *
+     * @param paginationRequest
+     * @return
+     */
+    @Override
+    public PaginationResponse<TGenCode> queryGenCodeListByPagination(PaginationRequest paginationRequest) {
+        Page<TGenCode> pageHelper = PageHelper.startPage(paginationRequest.getCurrentPage(), paginationRequest.getPageSize());
+        LambdaQueryWrapper<TGenCode> lambdaQueryWrapper = Wrappers.lambdaQuery();
+        lambdaQueryWrapper.ne(TGenCode::getStatus, StatusEnum.DISABLE.getKey());
+
+        String title = paginationRequest.getSearchParams().get("title") == null ? "" : paginationRequest.getSearchParams().get("title").toString();
+        if (org.apache.commons.lang.StringUtils.isNotBlank(title)) {
+            lambdaQueryWrapper.like(TGenCode::getTableName, title);
+        }
+        String status = paginationRequest.getSearchParams().get("status") == null ? "" : paginationRequest.getSearchParams().get("status").toString();
+        if (org.apache.commons.lang.StringUtils.isNotBlank(status)) {
+            lambdaQueryWrapper.eq(TGenCode::getStatus, status);
+        }
+
+        lambdaQueryWrapper.orderByAsc(TGenCode::getId);
+        List<TGenCode> dataList = tGenCodeMapper.selectList(lambdaQueryWrapper);
+
+        PageRequest pageRequest = PageRequest.of(paginationRequest.getCurrentPage(), paginationRequest.getPageSize());
+        PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal());
+        PaginationResponse<TGenCode> paginationResponse = new PaginationResponse(pageImpl, TGenCode.class);
+        paginationResponse.setTotalPages(pageHelper.getPages());
+        paginationResponse.setTotalElements(pageHelper.getTotal());
+        paginationResponse.setContent(dataList);
+
+        return paginationResponse;
+    }
+
+    /**
+     * 添加生成代码
+     *
+     * @param tGenCode 生成代码
+     * @return
+     */
+    @Override
+    @OperationServiceLog(description = "新增生成代码")
+    public TGenCode addGenCode(TGenCode tGenCode) throws BusinessCheckException {
+        tGenCode.setStatus(StatusEnum.ENABLED.getKey());
+        Integer id = tGenCodeMapper.insert(tGenCode);
+        if (id > 0) {
+            return tGenCode;
+        } else {
+            logger.error("新增生成代码失败.");
+            throw new BusinessCheckException("新增生成代码失败.");
+        }
+    }
+
+    /**
+     * 根据ID获取生成代码
+     *
+     * @param id 生成代码ID
+     */
+    @Override
+    public TGenCode queryGenCodeById(Integer id) {
+        return tGenCodeMapper.selectById(id);
+    }
+
+    /**
+     * 修改生成代码
+     *
+     * @param tGenCode
+     * @throws BusinessCheckException
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    @OperationServiceLog(description = "修改生成代码")
+    public TGenCode updateGenCode(TGenCode tGenCode) {
+        tGenCodeMapper.updateById(tGenCode);
+        return tGenCode;
+    }
+
     /**
     /**
      * 生成代码(自定义路径)
      * 生成代码(自定义路径)
      * 
      * 

+ 21 - 88
fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendGenCodeController.java

@@ -2,21 +2,16 @@ package com.fuint.module.backendApi.controller;
 
 
 import com.fuint.common.dto.AccountInfo;
 import com.fuint.common.dto.AccountInfo;
 import com.fuint.common.service.GenCodeService;
 import com.fuint.common.service.GenCodeService;
-import com.fuint.common.service.StoreService;
 import com.fuint.common.util.TokenUtil;
 import com.fuint.common.util.TokenUtil;
 import com.fuint.framework.exception.BusinessRuntimeException;
 import com.fuint.framework.exception.BusinessRuntimeException;
 import com.fuint.framework.web.BaseController;
 import com.fuint.framework.web.BaseController;
 import com.fuint.framework.web.ResponseObject;
 import com.fuint.framework.web.ResponseObject;
 import com.fuint.common.Constants;
 import com.fuint.common.Constants;
-import com.fuint.common.dto.BannerDto;
 import com.fuint.common.enums.StatusEnum;
 import com.fuint.common.enums.StatusEnum;
-import com.fuint.common.service.SettingService;
 import com.fuint.framework.pagination.PaginationRequest;
 import com.fuint.framework.pagination.PaginationRequest;
 import com.fuint.framework.pagination.PaginationResponse;
 import com.fuint.framework.pagination.PaginationResponse;
 import com.fuint.framework.exception.BusinessCheckException;
 import com.fuint.framework.exception.BusinessCheckException;
-import com.fuint.common.service.BannerService;
-import com.fuint.repository.model.MtBanner;
-import com.fuint.repository.model.MtStore;
+import com.fuint.repository.model.TGenCode;
 import com.fuint.utils.StringUtil;
 import com.fuint.utils.StringUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiOperation;
@@ -25,7 +20,6 @@ import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
 import java.util.HashMap;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 import java.util.Map;
 
 
 /**
 /**
@@ -40,21 +34,6 @@ import java.util.Map;
 @RequestMapping(value = "/backendApi/genCode")
 @RequestMapping(value = "/backendApi/genCode")
 public class BackendGenCodeController extends BaseController {
 public class BackendGenCodeController extends BaseController {
 
 
-    /**
-     * 焦点图服务接口
-     */
-    private BannerService bannerService;
-
-    /**
-     * 系统设置服务接口
-     * */
-    private SettingService settingService;
-
-    /**
-     * 店铺服务接口
-     */
-    private StoreService storeService;
-
     /**
     /**
      * 生成代码服务接口
      * 生成代码服务接口
      */
      */
@@ -69,21 +48,17 @@ public class BackendGenCodeController extends BaseController {
     @ApiOperation(value = "代码生成列表查询")
     @ApiOperation(value = "代码生成列表查询")
     @RequestMapping(value = "/list", method = RequestMethod.GET)
     @RequestMapping(value = "/list", method = RequestMethod.GET)
     @CrossOrigin
     @CrossOrigin
-    @PreAuthorize("@pms.hasPermission('content:banner:list')")
+    @PreAuthorize("@pms.hasPermission('system:genCode:list')")
     public ResponseObject list(HttpServletRequest request) throws BusinessCheckException {
     public ResponseObject list(HttpServletRequest request) throws BusinessCheckException {
         String token = request.getHeader("Access-Token");
         String token = request.getHeader("Access-Token");
         Integer page = request.getParameter("page") == null ? Constants.PAGE_NUMBER : Integer.parseInt(request.getParameter("page"));
         Integer page = request.getParameter("page") == null ? Constants.PAGE_NUMBER : Integer.parseInt(request.getParameter("page"));
         Integer pageSize = request.getParameter("pageSize") == null ? Constants.PAGE_SIZE : Integer.parseInt(request.getParameter("pageSize"));
         Integer pageSize = request.getParameter("pageSize") == null ? Constants.PAGE_SIZE : Integer.parseInt(request.getParameter("pageSize"));
         String title = request.getParameter("title");
         String title = request.getParameter("title");
         String status = request.getParameter("status");
         String status = request.getParameter("status");
-        String searchStoreId = request.getParameter("storeId");
 
 
         AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
         AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
-        Integer storeId;
         if (accountInfo == null) {
         if (accountInfo == null) {
             return getFailureResult(1001, "请先登录");
             return getFailureResult(1001, "请先登录");
-        } else {
-            storeId = accountInfo.getStoreId();
         }
         }
 
 
         PaginationRequest paginationRequest = new PaginationRequest();
         PaginationRequest paginationRequest = new PaginationRequest();
@@ -91,40 +66,17 @@ public class BackendGenCodeController extends BaseController {
         paginationRequest.setPageSize(pageSize);
         paginationRequest.setPageSize(pageSize);
 
 
         Map<String, Object> params = new HashMap<>();
         Map<String, Object> params = new HashMap<>();
-        if (accountInfo.getMerchantId() != null && accountInfo.getMerchantId() > 0) {
-            params.put("merchantId", accountInfo.getMerchantId());
-        }
         if (StringUtil.isNotEmpty(title)) {
         if (StringUtil.isNotEmpty(title)) {
             params.put("title", title);
             params.put("title", title);
         }
         }
         if (StringUtil.isNotEmpty(status)) {
         if (StringUtil.isNotEmpty(status)) {
             params.put("status", status);
             params.put("status", status);
         }
         }
-        if (StringUtil.isNotEmpty(searchStoreId)) {
-            params.put("storeId", searchStoreId);
-        }
-        if (storeId != null && storeId > 0) {
-            params.put("storeId", storeId);
-        }
         paginationRequest.setSearchParams(params);
         paginationRequest.setSearchParams(params);
-        PaginationResponse<MtBanner> paginationResponse = bannerService.queryBannerListByPagination(paginationRequest);
-
-        Map<String, Object> paramsStore = new HashMap<>();
-        paramsStore.put("status", StatusEnum.ENABLED.getKey());
-        if (accountInfo.getStoreId() != null && accountInfo.getStoreId() > 0) {
-            paramsStore.put("storeId", accountInfo.getStoreId().toString());
-        }
-        if (accountInfo.getMerchantId() != null && accountInfo.getMerchantId() > 0) {
-            paramsStore.put("merchantId", accountInfo.getMerchantId());
-        }
-
-        List<MtStore> storeList = storeService.queryStoresByParams(paramsStore);
-        String imagePath = settingService.getUploadBasePath();
+        PaginationResponse<TGenCode> paginationResponse = genCodeService.queryGenCodeListByPagination(paginationRequest);
 
 
         Map<String, Object> result = new HashMap<>();
         Map<String, Object> result = new HashMap<>();
         result.put("dataList", paginationResponse);
         result.put("dataList", paginationResponse);
-        result.put("imagePath", imagePath);
-        result.put("storeList", storeList);
 
 
         return getSuccessResult(result);
         return getSuccessResult(result);
     }
     }
@@ -134,10 +86,10 @@ public class BackendGenCodeController extends BaseController {
      *
      *
      * @return
      * @return
      */
      */
-    @ApiOperation(value = "更新更新代码状态")
+    @ApiOperation(value = "更新代码状态")
     @RequestMapping(value = "/updateStatus", method = RequestMethod.POST)
     @RequestMapping(value = "/updateStatus", method = RequestMethod.POST)
     @CrossOrigin
     @CrossOrigin
-    @PreAuthorize("@pms.hasPermission('content:banner:edit')")
+    @PreAuthorize("@pms.hasPermission('system:genCode:edit')")
     public ResponseObject updateStatus(HttpServletRequest request, @RequestBody Map<String, Object> params) throws BusinessCheckException {
     public ResponseObject updateStatus(HttpServletRequest request, @RequestBody Map<String, Object> params) throws BusinessCheckException {
         String token = request.getHeader("Access-Token");
         String token = request.getHeader("Access-Token");
         String status = params.get("status") != null ? params.get("status").toString() : StatusEnum.ENABLED.getKey();
         String status = params.get("status") != null ? params.get("status").toString() : StatusEnum.ENABLED.getKey();
@@ -148,18 +100,15 @@ public class BackendGenCodeController extends BaseController {
             return getFailureResult(1001, "请先登录");
             return getFailureResult(1001, "请先登录");
         }
         }
 
 
-        MtBanner mtBanner = bannerService.queryBannerById(id);
-        if (mtBanner == null) {
+        TGenCode tGenCode = genCodeService.queryGenCodeById(id);
+        if (tGenCode == null) {
             return getFailureResult(201);
             return getFailureResult(201);
         }
         }
 
 
-        String operator = accountInfo.getAccountName();
-
-        BannerDto bannerDto = new BannerDto();
-        bannerDto.setOperator(operator);
-        bannerDto.setId(id);
-        bannerDto.setStatus(status);
-        bannerService.updateBanner(bannerDto);
+        tGenCode.setOperator(accountInfo.getAccountName());
+        tGenCode.setId(id);
+        tGenCode.setStatus(status);
+        genCodeService.updateGenCode(tGenCode);
 
 
         return getSuccessResult(true);
         return getSuccessResult(true);
     }
     }
@@ -173,38 +122,25 @@ public class BackendGenCodeController extends BaseController {
     @ApiOperation(value = "保存代码生成")
     @ApiOperation(value = "保存代码生成")
     @RequestMapping(value = "/save", method = RequestMethod.POST)
     @RequestMapping(value = "/save", method = RequestMethod.POST)
     @CrossOrigin
     @CrossOrigin
-    @PreAuthorize("@pms.hasPermission('content:banner:add')")
+    @PreAuthorize("@pms.hasPermission('system:genCode:add')")
     public ResponseObject saveHandler(HttpServletRequest request, @RequestBody Map<String, Object> params) throws BusinessCheckException {
     public ResponseObject saveHandler(HttpServletRequest request, @RequestBody Map<String, Object> params) throws BusinessCheckException {
         String token = request.getHeader("Access-Token");
         String token = request.getHeader("Access-Token");
         String id = params.get("id") == null ? "" : params.get("id").toString();
         String id = params.get("id") == null ? "" : params.get("id").toString();
-        String title = params.get("title") == null ? "" : params.get("title").toString();
-        String description = params.get("description") == null ? "" : params.get("description").toString();
-        String image = params.get("image") == null ? "" : params.get("image").toString();
-        String url = params.get("url") == null ? "" : params.get("url").toString();
         String status = params.get("status") == null ? "" : params.get("status").toString();
         String status = params.get("status") == null ? "" : params.get("status").toString();
-        String storeId = params.get("storeId") == null ? "0" : params.get("storeId").toString();
-        String sort = params.get("sort") == null ? "0" : params.get("sort").toString();
 
 
         AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
         AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
         if (accountInfo == null) {
         if (accountInfo == null) {
             return getFailureResult(1001, "请先登录");
             return getFailureResult(1001, "请先登录");
         }
         }
 
 
-        BannerDto info = new BannerDto();
-        info.setTitle(title);
-        info.setDescription(description);
-        info.setImage(image);
-        info.setUrl(url);
-        info.setOperator(accountInfo.getAccountName());
-        info.setStatus(status);
-        info.setStoreId(Integer.parseInt(storeId));
-        info.setSort(Integer.parseInt(sort));
-        info.setMerchantId(accountInfo.getMerchantId());
+        TGenCode tGenCode = new TGenCode();
+        tGenCode.setOperator(accountInfo.getAccountName());
+        tGenCode.setStatus(status);
         if (StringUtil.isNotEmpty(id)) {
         if (StringUtil.isNotEmpty(id)) {
-            info.setId(Integer.parseInt(id));
-            bannerService.updateBanner(info);
+            tGenCode.setId(Integer.parseInt(id));
+            genCodeService.updateGenCode(tGenCode);
         } else {
         } else {
-            bannerService.addBanner(info);
+            genCodeService.addGenCode(tGenCode);
         }
         }
 
 
         return getSuccessResult(true);
         return getSuccessResult(true);
@@ -219,7 +155,7 @@ public class BackendGenCodeController extends BaseController {
     @ApiOperation(value = "获取代码生成详情")
     @ApiOperation(value = "获取代码生成详情")
     @RequestMapping(value = "/info/{id}", method = RequestMethod.GET)
     @RequestMapping(value = "/info/{id}", method = RequestMethod.GET)
     @CrossOrigin
     @CrossOrigin
-    @PreAuthorize("@pms.hasPermission('content:banner:list')")
+    @PreAuthorize("@pms.hasPermission('system:genCode:list')")
     public ResponseObject info(HttpServletRequest request, @PathVariable("id") Integer id) throws BusinessCheckException {
     public ResponseObject info(HttpServletRequest request, @PathVariable("id") Integer id) throws BusinessCheckException {
         String token = request.getHeader("Access-Token");
         String token = request.getHeader("Access-Token");
         AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
         AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
@@ -227,12 +163,10 @@ public class BackendGenCodeController extends BaseController {
             return getFailureResult(1001, "请先登录");
             return getFailureResult(1001, "请先登录");
         }
         }
 
 
-        MtBanner bannerInfo = bannerService.queryBannerById(id);
-        String imagePath = settingService.getUploadBasePath();
+        TGenCode tGenCode = genCodeService.queryGenCodeById(id);
 
 
         Map<String, Object> result = new HashMap<>();
         Map<String, Object> result = new HashMap<>();
-        result.put("bannerInfo", bannerInfo);
-        result.put("imagePath", imagePath);
+        result.put("tGenCode", tGenCode);
 
 
         return getSuccessResult(result);
         return getSuccessResult(result);
     }
     }
@@ -254,7 +188,6 @@ public class BackendGenCodeController extends BaseController {
         }
         }
 
 
         genCodeService.generatorCode("mt_luck");
         genCodeService.generatorCode("mt_luck");
-
         return getSuccessResult(true);
         return getSuccessResult(true);
     }
     }
 }
 }

+ 10 - 0
fuint-repository/src/main/java/com/fuint/repository/model/TGenCode.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.annotation.TableName;
 import java.io.Serializable;
 import java.io.Serializable;
+import java.util.Date;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Getter;
 import lombok.Getter;
@@ -51,6 +52,15 @@ public class TGenCode implements Serializable {
     @ApiModelProperty("前端路径")
     @ApiModelProperty("前端路径")
     private String frontPath;
     private String frontPath;
 
 
+    @ApiModelProperty("创建时间")
+    private Date createTime;
+
+    @ApiModelProperty("更新时间")
+    private Date updateTime;
+
+    @ApiModelProperty("最后操作人")
+    private String operator;
+
     @ApiModelProperty("状态 0 无效 1 有效")
     @ApiModelProperty("状态 0 无效 1 有效")
     private String status;
     private String status;