소스 검색

Merge remote-tracking branch 'origin/saas' into saas

zouxuan 3 년 전
부모
커밋
87b9a21ed7

+ 1 - 0
.gitignore

@@ -10,3 +10,4 @@ bin
 .gitignore
 .idea
 *.iml
+/lib/

+ 20 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SysManualDao.java

@@ -0,0 +1,20 @@
+package com.ym.mec.biz.dal.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ym.mec.biz.dal.entity.SysManual;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * (SysManual)表数据库访问层
+ *
+ * @author makejava
+ * @since 2021-12-20 17:22:42
+ */
+public interface SysManualDao extends BaseMapper<SysManual> {
+
+    int insertBatch(@Param("entities") List<SysManual> entities);
+
+}
+

+ 134 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/SysManual.java

@@ -0,0 +1,134 @@
+package com.ym.mec.biz.dal.entity;
+
+
+import java.util.Date;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import com.baomidou.mybatisplus.annotation.TableId;
+
+import java.io.Serializable;
+
+/**
+ * (SysManual)表实体类
+ *
+ * @author makejava
+ * @since 2021-12-20 13:46:08
+ */
+@ApiModel(value = "sys_manual-${tableInfo.comment}")
+public class SysManual implements Serializable {
+    @TableId(value = "id_", type = IdType.AUTO)
+    @ApiModelProperty(value = "${column.comment}")
+    private Integer id;
+
+    @TableField("menu_id_")
+    @ApiModelProperty(value = "菜单Id")
+    private Integer menuId;
+
+    @TableField("name_")
+    @ApiModelProperty(value = "手册名称")
+    private String name;
+
+    @TableField("op_flow_")
+    @ApiModelProperty(value = "操作流程")
+    private String opFlow;
+
+    @TableField("fun_rule_")
+    @ApiModelProperty(value = "功能规则")
+    private String funRule;
+
+    @TableField("video_url_")
+    @ApiModelProperty(value = "操作视频")
+    private String videoUrl;
+
+    @TableField("create_time_")
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+
+    @TableField("update_time_")
+    @ApiModelProperty(value = "更新时间")
+    private Date updateTime;
+
+    @TableField("operator_id_")
+    @ApiModelProperty(value = "操作人")
+    private Integer operatorId;
+
+    private static final long serialVersionUID = 1L;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getMenuId() {
+        return menuId;
+    }
+
+    public void setMenuId(Integer menuId) {
+        this.menuId = menuId;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getOpFlow() {
+        return opFlow;
+    }
+
+    public void setOpFlow(String opFlow) {
+        this.opFlow = opFlow;
+    }
+
+    public String getFunRule() {
+        return funRule;
+    }
+
+    public void setFunRule(String funRule) {
+        this.funRule = funRule;
+    }
+
+    public String getVideoUrl() {
+        return videoUrl;
+    }
+
+    public void setVideoUrl(String videoUrl) {
+        this.videoUrl = videoUrl;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public Integer getOperatorId() {
+        return operatorId;
+    }
+
+    public void setOperatorId(Integer operatorId) {
+        this.operatorId = operatorId;
+    }
+
+
+}
+

+ 34 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/SysManualQueryInfo.java

@@ -0,0 +1,34 @@
+package com.ym.mec.biz.dal.page;
+
+import com.ym.mec.common.page.QueryInfo;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * Description
+ *
+ * @author: feng-ji
+ * @date: 2021-12-20
+ */
+public class SysManualQueryInfo  extends QueryInfo {
+
+    private Integer id;
+
+    @ApiModelProperty(value = "按菜单查询")
+    private Integer menuId;
+
+    public Integer getMenuId() {
+        return menuId;
+    }
+
+    public void setMenuId(Integer menuId) {
+        this.menuId = menuId;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+}

+ 14 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/SysManualService.java

@@ -0,0 +1,14 @@
+package com.ym.mec.biz.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ym.mec.biz.dal.entity.SysManual;
+
+/**
+ * (SysManual)表服务接口
+ *
+ * @author makejava
+ * @since 2021-12-20 13:46:08
+ */
+public interface SysManualService extends IService<SysManual> {
+}
+

+ 23 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysManualServiceImpl.java

@@ -0,0 +1,23 @@
+package com.ym.mec.biz.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ym.mec.biz.dal.dao.SysManualDao;
+import com.ym.mec.biz.dal.entity.SysManual;
+import com.ym.mec.biz.service.SysManualService;
+import org.springframework.stereotype.Service;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * (SysManual)表服务实现类
+ *
+ * @author makejava
+ * @since 2021-12-20 17:19:38
+ */
+@Service("sysManualService")
+public class SysManualServiceImpl extends ServiceImpl<SysManualDao, SysManual> implements SysManualService {
+
+    private final static Logger logger = LoggerFactory.getLogger(SysManualServiceImpl.class);
+}
+

+ 4 - 0
mec-common/common-core/src/main/java/com/ym/mec/common/controller/BaseController.java

@@ -7,6 +7,7 @@ import com.ym.mec.common.exception.BizException;
 import com.ym.mec.thirdparty.exception.ThirdpartyException;
 import com.ym.mec.util.http.HttpUtil;
 import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.exception.ExceptionUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -120,6 +121,9 @@ public class BaseController {
 		}catch (Exception exception){
 			logger.error("System Error", exception);
 		}
+        if (StringUtils.isNotBlank(ex.getMessage())) {
+            return failed(ex.getMessage());
+        }
 		return failed("系统繁忙");
 	}
 

+ 72 - 0
mec-util/src/main/java/com/ym/mec/util/validator/ValidationKit.java

@@ -0,0 +1,72 @@
+package com.ym.mec.util.validator;
+
+import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.validation.BindingResult;
+import org.springframework.validation.FieldError;
+
+import java.util.Objects;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+/**
+ * 个别功能在传参时只需要部分成员变量赋值,但是接收类加入了@Valid的验证,
+ * 从而不得已要在传参时把接收类所有的成员变量都赋值。
+ * 该功能可以让加入了@Valid的验证的接收类中分成员变量没有赋值的时不报出异
+ * 常,只针对你需要的值进行验证再报出异常。
+ *
+ * @author hgw
+ * Created by 2021-12-20
+ */
+public class ValidationKit {
+
+    /**
+     * 校验
+     *
+     * @param result BindingResult
+     * @param fields 只校验的字段
+     */
+    public static void validFields(BindingResult result, String... fields) {
+        if (!result.hasFieldErrors()) {
+            return;
+        }
+        Stream<String> stringStream = result.getFieldErrors().stream()
+                .map(FieldError::getField)
+                .filter(field -> ArrayUtils.contains(fields, field));
+
+        String errorCollect = concat(result, stringStream);
+        if (StringUtils.isNotBlank(errorCollect)) {
+            throw new RuntimeException(errorCollect);
+        }
+    }
+
+    /**
+     * 忽略校验部分字段
+     *
+     * @param result       BindingResult
+     * @param ignoreFields 忽略验证的字段
+     */
+    public static void ignoreFields(BindingResult result, String... ignoreFields) {
+        if (!result.hasFieldErrors()) {
+            return;
+        }
+        Stream<String> stringStream = result.getFieldErrors().stream()
+                .map(FieldError::getField)
+                .filter(field -> !ArrayUtils.contains(ignoreFields, field));
+
+        String errorCollect = concat(result, stringStream);
+        if (StringUtils.isNotBlank(errorCollect)) {
+            throw new RuntimeException(errorCollect);
+        }
+    }
+
+    private static String concat(BindingResult result, Stream<String> stringStream) {
+        return stringStream.filter(f -> Objects.nonNull(result.getFieldError(f)))
+                .map(result::getFieldError)
+                .filter(Objects::nonNull)
+                .map(FieldError::getDefaultMessage)
+                .filter(StringUtils::isNotBlank)
+                .collect(Collectors.joining());
+    }
+
+}

+ 62 - 0
mec-web/src/main/java/com/ym/mec/web/controller/SysManualController.java

@@ -0,0 +1,62 @@
+package com.ym.mec.web.controller;
+
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.ym.mec.biz.dal.entity.SysManual;
+import com.ym.mec.biz.dal.page.SysManualQueryInfo;
+import com.ym.mec.biz.service.SysManualService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import com.ym.mec.common.controller.BaseController;
+
+/**
+ * (SysManual)表控制层
+ *
+ * @author makejava
+ * @since 2021-12-20 14:23:36
+ */
+@RestController
+@Api(tags = "帮助手册")
+@RequestMapping("/sysManual")
+public class SysManualController extends BaseController {
+    /**
+     * 服务对象
+     */
+    @Autowired
+    private SysManualService sysManualService;
+
+
+    @ApiOperation(value = "查询操作手册")
+    @GetMapping("/list")
+    public Object list(SysManualQueryInfo queryInfo) {
+        if (queryInfo.getMenuId() != 0) {
+            return succeed(sysManualService.list(new QueryWrapper<SysManual>().eq("menu_id_", queryInfo.getMenuId())));
+        } else {
+            return succeed(sysManualService.list(new QueryWrapper<SysManual>()));
+        }
+    }
+
+    @ApiOperation(value = "新增帮助手册")
+    @PostMapping("/add")
+    public Object add(@RequestBody SysManual sysManual) throws Exception{
+        sysManualService.save(sysManual);
+        return succeed();
+    }
+
+    @ApiOperation(value = "修改帮助手册")
+    @PostMapping("/update")
+    public Object update(@RequestBody SysManual sysManual) throws Exception{
+        sysManualService.updateById(sysManual);
+        return succeed();
+    }
+
+    @ApiOperation(value = "删除帮助手册")
+    @PostMapping("/remove")
+    public Object remove(@RequestBody SysManual sysManual) throws Exception{
+        sysManualService.removeById(sysManual.getId());
+        return succeed();
+    }
+
+}

+ 7 - 6
mec-web/src/main/java/com/ym/mec/web/controller/TenantInfoController.java

@@ -3,9 +3,11 @@ package com.ym.mec.web.controller;
 import com.ym.mec.biz.dal.dto.TenantInfoDto;
 import com.ym.mec.biz.service.TenantInfoService;
 import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.util.validator.ValidationKit;
 import io.swagger.annotations.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.BindingResult;
 import org.springframework.web.bind.annotation.*;
 
 import javax.validation.Valid;
@@ -25,7 +27,7 @@ public class TenantInfoController extends BaseController {
 
     @ApiOperation("添加机构信息")
     @PostMapping(value = "/add")
-//    @PreAuthorize("@pcs.hasPermissions('tenantInfo/add')")
+    @PreAuthorize("@pcs.hasPermissions('tenantInfo/add')")
     public Object addTenantInfo(@Valid @RequestBody TenantInfoDto dto) {
         tenantInfoService.addTenantInfo(dto);
         return succeed();
@@ -33,8 +35,9 @@ public class TenantInfoController extends BaseController {
 
     @ApiOperation("修改机构信息")
     @PostMapping(value = "/update")
-//    @PreAuthorize("@pcs.hasPermissions('tenantInfo/update')")
-    public Object updateTenantInfo(@Valid @RequestBody TenantInfoDto dto) {
+    @PreAuthorize("@pcs.hasPermissions('tenantInfo/update')")
+    public Object updateTenantInfo(@Valid @RequestBody TenantInfoDto dto, BindingResult bindingResult) {
+        ValidationKit.ignoreFields(bindingResult,"productInfo","config");
         tenantInfoService.updateTenantInfo(dto);
         return succeed();
     }
@@ -49,12 +52,10 @@ public class TenantInfoController extends BaseController {
 
     @ApiOperation("查询单个机构详情")
     @GetMapping(value = "/info/{id}")
-//    @PreAuthorize("@pcs.hasPermissions('tenantInfo/info')")
     public Object queryTenantInfo(@ApiParam(value = "机构ID", required = true) @PathVariable("id") Integer id) {
         return succeed(tenantInfoService.queryTenantInfo(id));
     }
 
-
     @ApiImplicitParams({
             @ApiImplicitParam(name = "search", dataType = "String", value = "关键字"),
             @ApiImplicitParam(name = "createdName", dataType = "String", value = "创建人"),
@@ -67,7 +68,7 @@ public class TenantInfoController extends BaseController {
     })
     @ApiOperation("分页查询")
     @PostMapping(value = "/queryPage")
-//    @PreAuthorize("@pcs.hasPermissions('tenantInfo/queryPage')")
+    @PreAuthorize("@pcs.hasPermissions('tenantInfo/queryPage')")
     public Object queryPage(@RequestBody Map<String, Object> param) {
         return succeed(tenantInfoService.queryPage(param));
     }