浏览代码

fixe 代码生成功能

fushengqian 1 年之前
父节点
当前提交
8ac45e1307

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

@@ -145,7 +145,7 @@ public class GenCodeServiceImpl implements GenCodeService {
         // 获取模板列表
         List<String> templates = VelocityUtils.getTemplateList();
         for (String template : templates) {
-            if (!StringUtils.containsAny(template, "sql.vm", "api.js.vm", "index.vue.vm", "index-tree.vue.vm")) {
+            if (!StringUtils.containsAny(template, "sql.vm", "api.js.vm", "index.vue.vm")) {
                 // 渲染模板
                 StringWriter sw = new StringWriter();
                 Template tpl = Velocity.getTemplate(template, "UTF-8");

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

@@ -106,8 +106,7 @@ public class SettingServiceImpl extends ServiceImpl<MtSettingMapper, MtSetting>
      */
     @Override
     public List<MtSetting> getSettingList(Integer merchantId, String type) {
-        List<MtSetting> dataList = mtSettingMapper.querySettingByType(merchantId, type);
-        return dataList;
+        return mtSettingMapper.querySettingByType(merchantId, type);
     }
 
     /**

+ 5 - 8
fuint-application/src/main/java/com/fuint/common/util/VelocityUtils.java

@@ -51,9 +51,10 @@ public class VelocityUtils {
         velocityContext.put("pkColumn", genTable.getPkName());
         velocityContext.put("author", genTable.getAuthor());
         velocityContext.put("table", genTable);
-        String tableName = CommonUtil.firstLetterToUpperCase(genTable.getTableName());
+        String tableClass = CommonUtil.firstLetterToUpperCase(genTable.getTableName());
         String tablePrefix = CommonUtil.firstLetterToUpperCase(genTable.getTablePrefix()).replaceAll("_", "");
-        velocityContext.put("className", tablePrefix + tableName);
+        velocityContext.put("className", tablePrefix + tableClass);
+        velocityContext.put("tableClass", tableClass);
 
         if (columns != null && columns.size() > 0) {
             for (ColumnBean columnBean : columns) {
@@ -83,7 +84,7 @@ public class VelocityUtils {
         templates.add("vm/java/mapper.java.vm");
         templates.add("vm/java/service.java.vm");
         templates.add("vm/java/serviceImpl.java.vm");
-        templates.add("vm/java/controller.java.vm");
+        templates.add("vm/java/BackendController.java.vm");
         templates.add("vm/xml/mapper.xml.vm");
         templates.add("vm/sql/sql.vm");
         templates.add("vm/js/api.js.vm");
@@ -112,18 +113,14 @@ public class VelocityUtils {
             fileName = StringUtil.format("{}/{}Service.java", SERVICE_PATH, tableName);
         } else if (template.contains("serviceImpl.java.vm")) {
             fileName = StringUtil.format("{}/impl/{}ServiceImpl.java", SERVICE_PATH, tableName);
-        } else if (template.contains("controller.java.vm")) {
+        } else if (template.contains("BackendController.java.vm")) {
             fileName = StringUtil.format("{}/{}Controller.java", CONTROLLER_PATH, "Backend" + tableName);
         } else if (template.contains("mapper.xml.vm")) {
             fileName = StringUtil.format("{}/{}Mapper.xml", REPOSITORY_PATH + MAPPER_XML_PATH, tablePrefix + tableName);
-        } else if (template.contains("sql.vm")) {
-            fileName = tablePrefix + tableName + "Menu.sql";
         } else if (template.contains("api.js.vm")) {
             fileName = StringUtil.format("{}/api/{}/{}.js", vuePath, moduleName, tablePrefix + tableName);
         } else if (template.contains("index.vue.vm")) {
             fileName = StringUtil.format("{}/views/{}/{}/index.vue", vuePath, moduleName, tablePrefix + tableName);
-        } else if (template.contains("index-tree.vue.vm")) {
-            fileName = StringUtil.format("{}/views/{}/{}/index.vue", vuePath, moduleName, tablePrefix + tableName);
         }
 
         return fileName;

+ 19 - 196
fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendBannerController.java

@@ -1,231 +1,54 @@
 package com.fuint.module.backendApi.controller;
 
 import com.fuint.common.dto.AccountInfo;
-import com.fuint.common.service.StoreService;
 import com.fuint.common.util.TokenUtil;
+import com.fuint.framework.exception.BusinessCheckException;
 import com.fuint.framework.web.BaseController;
 import com.fuint.framework.web.ResponseObject;
-import com.fuint.common.Constants;
-import com.fuint.common.dto.BannerDto;
-import com.fuint.common.enums.StatusEnum;
-import com.fuint.common.service.SettingService;
-import com.fuint.framework.pagination.PaginationRequest;
-import com.fuint.framework.pagination.PaginationResponse;
-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.utils.StringUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
 import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
 import javax.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 
 /**
- * 焦点图管理类controller
+ * 抽奖活动管理类Controller
  *
- * Created by FSQ
- * CopyRight https://www.fuint.cn
+ * @Created by FSQ
+ * @CopyRight https://www.fuint.cn
  */
-@Api(tags="管理端-焦点图相关接口")
+@Api(tags="管理端-抽奖活动管理相关接口")
 @RestController
 @AllArgsConstructor
 @RequestMapping(value = "/backendApi/banner")
 public class BackendBannerController extends BaseController {
 
-    /**
-     * 焦点图服务接口
-     */
-    private BannerService bannerService;
-
-    /**
-     * 系统设置服务接口
-     * */
-    private SettingService settingService;
-
-    /**
-     * 店铺服务接口
-     */
-    private StoreService storeService;
-
-    /**
-     * 焦点图列表查询
-     *
-     * @param  request HttpServletRequest对象
-     * @return banner列表
-     */
-    @ApiOperation(value = "焦点图列表查询")
+  /**
+   * 抽奖活动列表查询
+   *
+   * @param request HttpServletRequest对象
+   * @return 抽奖活动列表
+   */
+    @ApiOperation(value = "抽奖活动列表查询")
     @RequestMapping(value = "/list", method = RequestMethod.GET)
     @CrossOrigin
-    @PreAuthorize("@pms.hasPermission('content:banner:list')")
+    @PreAuthorize("@pms.hasPermission('content:article:index')")
     public ResponseObject list(HttpServletRequest request) throws BusinessCheckException {
-        String token = request.getHeader("Access-Token");
-        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"));
-        String title = request.getParameter("title");
-        String status = request.getParameter("status");
-        String searchStoreId = request.getParameter("storeId");
-
-        AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
-        Integer storeId;
-        if (accountInfo == null) {
-            return getFailureResult(1001, "请先登录");
-        } else {
-            storeId = accountInfo.getStoreId();
-        }
-
-        PaginationRequest paginationRequest = new PaginationRequest();
-        paginationRequest.setCurrentPage(page);
-        paginationRequest.setPageSize(pageSize);
-
-        Map<String, Object> params = new HashMap<>();
-        if (accountInfo.getMerchantId() != null && accountInfo.getMerchantId() > 0) {
-            params.put("merchantId", accountInfo.getMerchantId());
-        }
-        if (StringUtil.isNotEmpty(title)) {
-            params.put("title", title);
-        }
-        if (StringUtil.isNotEmpty(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);
-        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();
-
-        Map<String, Object> result = new HashMap<>();
-        result.put("dataList", paginationResponse);
-        result.put("imagePath", imagePath);
-        result.put("storeList", storeList);
-
-        return getSuccessResult(result);
-    }
-
-    /**
-     * 更新焦点图状态
-     *
-     * @return
-     */
-    @ApiOperation(value = "更新焦点图状态")
-    @RequestMapping(value = "/updateStatus", method = RequestMethod.POST)
-    @CrossOrigin
-    @PreAuthorize("@pms.hasPermission('content:banner:edit')")
-    public ResponseObject updateStatus(HttpServletRequest request, @RequestBody Map<String, Object> params) throws BusinessCheckException {
-        String token = request.getHeader("Access-Token");
-        String status = params.get("status") != null ? params.get("status").toString() : StatusEnum.ENABLED.getKey();
-        Integer id = params.get("id") == null ? 0 : Integer.parseInt(params.get("id").toString());
-
-        AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
-        if (accountInfo == null) {
-            return getFailureResult(1001, "请先登录");
-        }
-
-        MtBanner mtBanner = bannerService.queryBannerById(id);
-        if (mtBanner == null) {
-            return getFailureResult(201);
-        }
-
-        String operator = accountInfo.getAccountName();
-
-        BannerDto bannerDto = new BannerDto();
-        bannerDto.setOperator(operator);
-        bannerDto.setId(id);
-        bannerDto.setStatus(status);
-        bannerService.updateBanner(bannerDto);
-
-        return getSuccessResult(true);
-    }
-
-    /**
-     * 保存焦点图
-     *
-     * @param request HttpServletRequest对象
-     * @return
-     */
-    @ApiOperation(value = "保存焦点图")
-    @RequestMapping(value = "/save", method = RequestMethod.POST)
-    @CrossOrigin
-    @PreAuthorize("@pms.hasPermission('content:banner:add')")
-    public ResponseObject saveHandler(HttpServletRequest request, @RequestBody Map<String, Object> params) throws BusinessCheckException {
-        String token = request.getHeader("Access-Token");
-        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 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);
-        if (accountInfo == null) {
-            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());
-        if (StringUtil.isNotEmpty(id)) {
-            info.setId(Integer.parseInt(id));
-            bannerService.updateBanner(info);
-        } else {
-            bannerService.addBanner(info);
-        }
-
-        return getSuccessResult(true);
-    }
-
-    /**
-     * 获取焦点图详情
-     *
-     * @param id
-     * @return
-     */
-    @ApiOperation(value = "获取焦点图详情")
-    @RequestMapping(value = "/info/{id}", method = RequestMethod.GET)
-    @CrossOrigin
-    @PreAuthorize("@pms.hasPermission('content:banner:list')")
-    public ResponseObject info(HttpServletRequest request, @PathVariable("id") Integer id) throws BusinessCheckException {
         String token = request.getHeader("Access-Token");
         AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
         if (accountInfo == null) {
             return getFailureResult(1001, "请先登录");
         }
 
-        MtBanner bannerInfo = bannerService.queryBannerById(id);
-        String imagePath = settingService.getUploadBasePath();
-
         Map<String, Object> result = new HashMap<>();
-        result.put("bannerInfo", bannerInfo);
-        result.put("imagePath", imagePath);
+        result.put("dataList", new ArrayList<>());
 
         return getSuccessResult(result);
     }

+ 55 - 0
fuint-application/src/main/resources/vm/java/BackendController.java.vm

@@ -0,0 +1,55 @@
+package com.fuint.module.backendApi.controller;
+
+import com.fuint.common.dto.AccountInfo;
+import com.fuint.common.util.TokenUtil;
+import com.fuint.framework.exception.BusinessCheckException;
+import com.fuint.framework.web.BaseController;
+import com.fuint.framework.web.ResponseObject;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+import javax.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * ${moduleName}管理类Controller
+ *
+ * @Created by ${author}
+ * @CopyRight https://www.fuint.cn
+ */
+@Api(tags="管理端-${moduleName}管理相关接口")
+@RestController
+@AllArgsConstructor
+@RequestMapping(value = "/backendApi/${tableName}")
+public class Backend${tableClass}Controller extends BaseController {
+
+  /**
+   * ${moduleName}列表查询
+   *
+   * @param request HttpServletRequest对象
+   * @return ${moduleName}列表
+   */
+    @ApiOperation(value = "${moduleName}列表查询")
+    @RequestMapping(value = "/list", method = RequestMethod.GET)
+    @CrossOrigin
+    @PreAuthorize("@pms.hasPermission('content:article:index')")
+    public ResponseObject list(HttpServletRequest request) throws BusinessCheckException {
+        String token = request.getHeader("Access-Token");
+        AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
+        if (accountInfo == null) {
+            return getFailureResult(1001, "请先登录");
+        }
+
+        Map<String, Object> result = new HashMap<>();
+        result.put("dataList", new ArrayList<>());
+
+        return getSuccessResult(result);
+    }
+}

+ 0 - 107
fuint-application/src/main/resources/vm/java/controller.java.vm

@@ -1,107 +0,0 @@
-package ${packageName}.controller;
-
-import java.util.List;
-import javax.servlet.http.HttpServletResponse;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-import com.fuint.common.annotation.Log;
-import com.fuint.common.core.controller.BaseController;
-import com.fuint.common.core.domain.AjaxResult;
-import com.fuint.common.enums.BusinessType;
-import ${packageName}.domain.${ClassName};
-import ${packageName}.service.I${ClassName}Service;
-import com.fuint.common.utils.poi.ExcelUtil;
-#if($table.crud || $table.sub)
-import com.fuint.common.core.page.TableDataInfo;
-#elseif($table.tree)
-#end
-
-/**
- * ${functionName}Controller
- * 
- * @author ${author}
- * @date ${datetime}
- */
-@RestController
-@RequestMapping("/${moduleName}/${businessName}")
-public class ${ClassName}Controller extends BaseController {
-    @Autowired
-    private I${ClassName}Service ${className}Service;
-
-    /**
-     * 查询${functionName}列表
-     */
-    @PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')")
-    @GetMapping("/list")
-#if($table.crud || $table.sub)
-    public TableDataInfo list(${ClassName} ${className}) {
-        startPage();
-        List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
-        return getDataTable(list);
-    }
-#elseif($table.tree)
-    public AjaxResult list(${ClassName} ${className}) {
-        List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
-        return success(list);
-    }
-#end
-
-    /**
-     * 导出${functionName}列表
-     */
-    @PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')")
-    @Log(title = "${functionName}", businessType = BusinessType.EXPORT)
-    @PostMapping("/export")
-    public void export(HttpServletResponse response, ${ClassName} ${className}) {
-        List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
-        ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}.class);
-        util.exportExcel(response, list, "${functionName}数据");
-    }
-
-    /**
-     * 获取${functionName}详细信息
-     */
-    @PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')")
-    @GetMapping(value = "/{${pkColumn.javaField}}")
-    public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField}) {
-        return success(${className}Service.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField}));
-    }
-
-    /**
-     * 新增${functionName}
-     */
-    @PreAuthorize("@ss.hasPermi('${permissionPrefix}:add')")
-    @Log(title = "${functionName}", businessType = BusinessType.INSERT)
-    @PostMapping
-    public AjaxResult add(@RequestBody ${ClassName} ${className}) {
-        return toAjax(${className}Service.insert${ClassName}(${className}));
-    }
-
-    /**
-     * 修改${functionName}
-     */
-    @PreAuthorize("@ss.hasPermi('${permissionPrefix}:edit')")
-    @Log(title = "${functionName}", businessType = BusinessType.UPDATE)
-    @PutMapping
-    public AjaxResult edit(@RequestBody ${ClassName} ${className}) {
-        return toAjax(${className}Service.update${ClassName}(${className}));
-    }
-
-    /**
-     * 删除${functionName}
-     */
-    @PreAuthorize("@ss.hasPermi('${permissionPrefix}:remove')")
-    @Log(title = "${functionName}", businessType = BusinessType.DELETE)
-	@DeleteMapping("/{${pkColumn.javaField}s}")
-    public AjaxResult remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s) {
-        return toAjax(${className}Service.delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaField}s));
-    }
-}