he2802 пре 4 година
родитељ
комит
ce40aec58c
18 измењених фајлова са 173 додато и 44 уклоњено
  1. 13 1
      zhongzheng-admin/src/main/java/com/zhongzheng/controller/common/CaptchaController.java
  2. 4 2
      zhongzheng-admin/src/main/java/com/zhongzheng/controller/course/MajorCategoryController.java
  3. 9 0
      zhongzheng-admin/src/main/java/com/zhongzheng/controller/system/SysLoginController.java
  4. 17 0
      zhongzheng-admin/src/main/java/com/zhongzheng/controller/system/SysMenuController.java
  5. 12 0
      zhongzheng-admin/src/main/java/com/zhongzheng/controller/system/SysRoleController.java
  6. 16 1
      zhongzheng-admin/src/main/java/com/zhongzheng/controller/system/SysUserController.java
  7. 6 10
      zhongzheng-admin/src/main/java/com/zhongzheng/controller/tool/TestController.java
  8. 4 3
      zhongzheng-admin/src/main/java/com/zhongzheng/core/config/SwaggerConfig.java
  9. 3 2
      zhongzheng-admin/src/main/resources/application.yml
  10. 1 1
      zhongzheng-api/src/main/resources/application.yml
  11. 6 2
      zhongzheng-common/pom.xml
  12. 18 3
      zhongzheng-common/src/main/java/com/zhongzheng/common/core/domain/entity/SysMenu.java
  13. 15 3
      zhongzheng-common/src/main/java/com/zhongzheng/common/core/domain/entity/SysRole.java
  14. 8 2
      zhongzheng-common/src/main/java/com/zhongzheng/common/core/domain/model/LoginBody.java
  15. 4 2
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/MajorCategoryAddBo.java
  16. 4 2
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/MajorCategoryEditBo.java
  17. 2 10
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/IMajorCategoryService.java
  18. 31 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/MajorCategoryServiceImpl.java

+ 13 - 1
zhongzheng-admin/src/main/java/com/zhongzheng/controller/common/CaptchaController.java

@@ -10,9 +10,14 @@ import cn.hutool.captcha.generator.RandomGenerator;
 import cn.hutool.core.convert.Convert;
 import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.StrUtil;
+import com.github.xiaoymin.knife4j.annotations.ApiSupport;
+import com.github.xiaoymin.knife4j.annotations.DynamicParameter;
+import com.github.xiaoymin.knife4j.annotations.DynamicResponseParameters;
 import com.zhongzheng.common.constant.Constants;
 import com.zhongzheng.common.core.domain.AjaxResult;
 import com.zhongzheng.common.core.redis.RedisCache;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -24,8 +29,10 @@ import java.util.concurrent.TimeUnit;
 /**
  * 验证码操作处理
  *
- * @author Lion Li
+ * @author hjl
  */
+@Api(tags ="系统操作管理")
+@ApiSupport(order = 1)
 @RestController
 public class CaptchaController {
 
@@ -58,6 +65,11 @@ public class CaptchaController {
 	/**
 	 * 生成验证码
 	 */
+	@ApiOperation("获取验证码")
+	@DynamicResponseParameters(name = "CodeMapModel",properties = {
+			@DynamicParameter(name = "uuid",value = "验证码uuid"),
+			@DynamicParameter(name = "img",value = "验证码图片base64"),
+	})
 	@GetMapping("/captchaImage")
 	public AjaxResult getCode() {
 		// 保存验证码信息

+ 4 - 2
zhongzheng-admin/src/main/java/com/zhongzheng/controller/course/MajorCategoryController.java

@@ -3,6 +3,7 @@ package com.zhongzheng.controller.course;
 import java.util.List;
 import java.util.Arrays;
 
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import com.zhongzheng.modules.course.bo.MajorCategoryAddBo;
 import com.zhongzheng.modules.course.bo.MajorCategoryEditBo;
 import com.zhongzheng.modules.course.bo.MajorCategoryQueryBo;
@@ -82,6 +83,7 @@ public class MajorCategoryController extends BaseController {
      * 新增【专业分类】
      */
     @ApiOperation("新增【专业分类】")
+    @ApiOperationSupport(ignoreParameters = {"updateTime","createTime"})
     @PreAuthorize("@ss.hasPermi('course:category:add')")
     @Log(title = "【专业分类】", businessType = BusinessType.INSERT)
     @PostMapping()
@@ -103,11 +105,11 @@ public class MajorCategoryController extends BaseController {
     /**
      * 删除【专业分类】
      */
-    @ApiOperation("删除【专业分类】")
+  /*  @ApiOperation("删除【专业分类】")
     @PreAuthorize("@ss.hasPermi('course:category:remove')")
     @Log(title = "【专业分类】" , businessType = BusinessType.DELETE)
     @DeleteMapping("/{categoryIds}")
     public AjaxResult<Void> remove(@PathVariable Long[] categoryIds) {
         return toAjax(iMajorCategoryService.deleteWithValidByIds(Arrays.asList(categoryIds), true) ? 1 : 0);
-    }
+    }*/
 }

+ 9 - 0
zhongzheng-admin/src/main/java/com/zhongzheng/controller/system/SysLoginController.java

@@ -1,5 +1,7 @@
 package com.zhongzheng.controller.system;
 
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import com.github.xiaoymin.knife4j.annotations.ApiSupport;
 import com.zhongzheng.common.constant.Constants;
 import com.zhongzheng.common.core.domain.AjaxResult;
 import com.zhongzheng.common.core.domain.entity.SysMenu;
@@ -11,6 +13,8 @@ import com.zhongzheng.framework.web.service.SysLoginService;
 import com.zhongzheng.framework.web.service.SysPermissionService;
 import com.zhongzheng.framework.web.service.TokenService;
 import com.zhongzheng.modules.system.service.ISysMenuService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -25,6 +29,8 @@ import java.util.Set;
  *
  * @author zhongzheng
  */
+@Api(tags ="登录用户操作管理")
+@ApiSupport(order = 2)
 @RestController
 public class SysLoginController
 {
@@ -46,6 +52,7 @@ public class SysLoginController
      * @param loginBody 登录信息
      * @return 结果
      */
+    @ApiOperation("登录")
     @PostMapping("/login")
     public AjaxResult login(@RequestBody LoginBody loginBody)
     {
@@ -62,6 +69,7 @@ public class SysLoginController
      *
      * @return 用户信息
      */
+    @ApiOperation("登录用户信息")
     @GetMapping("getInfo")
     public AjaxResult getInfo()
     {
@@ -83,6 +91,7 @@ public class SysLoginController
      *
      * @return 路由信息
      */
+    @ApiOperation("路由菜单信息")
     @GetMapping("getRouters")
     public AjaxResult getRouters()
     {

+ 17 - 0
zhongzheng-admin/src/main/java/com/zhongzheng/controller/system/SysMenuController.java

@@ -1,6 +1,7 @@
 package com.zhongzheng.controller.system;
 
 import cn.hutool.core.util.StrUtil;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import com.zhongzheng.common.annotation.Log;
 import com.zhongzheng.common.constant.Constants;
 import com.zhongzheng.common.constant.UserConstants;
@@ -13,6 +14,8 @@ import com.zhongzheng.common.utils.SecurityUtils;
 import com.zhongzheng.common.utils.ServletUtils;
 import com.zhongzheng.framework.web.service.TokenService;
 import com.zhongzheng.modules.system.service.ISysMenuService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.validation.annotation.Validated;
@@ -25,6 +28,7 @@ import java.util.List;
  *
  * @author zhongzheng
  */
+@Api(tags ="菜单管理")
 @RestController
 @RequestMapping("/system/menu")
 public class SysMenuController extends BaseController
@@ -38,6 +42,8 @@ public class SysMenuController extends BaseController
     /**
      * 获取菜单列表
      */
+    @ApiOperation("获取菜单列表")
+    @ApiOperationSupport(includeParameters = {"ignore_all"})
     @PreAuthorize("@ss.hasPermi('system:menu:list')")
     @GetMapping("/list")
     public AjaxResult list(SysMenu menu)
@@ -51,6 +57,7 @@ public class SysMenuController extends BaseController
     /**
      * 根据菜单编号获取详细信息
      */
+    @ApiOperation("根据菜单编号获取详细信息")
     @PreAuthorize("@ss.hasPermi('system:menu:query')")
     @GetMapping(value = "/{menuId}")
     public AjaxResult getInfo(@PathVariable Long menuId)
@@ -61,6 +68,8 @@ public class SysMenuController extends BaseController
     /**
      * 获取菜单下拉树列表
      */
+    @ApiOperation("获取菜单下拉树列表")
+    @ApiOperationSupport(includeParameters = {})
     @GetMapping("/treeselect")
     public AjaxResult treeselect(SysMenu menu)
     {
@@ -73,6 +82,7 @@ public class SysMenuController extends BaseController
     /**
      * 加载对应角色菜单列表树
      */
+    @ApiOperation("加载对应角色菜单列表树")
     @GetMapping(value = "/roleMenuTreeselect/{roleId}")
     public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId)
     {
@@ -87,6 +97,9 @@ public class SysMenuController extends BaseController
     /**
      * 新增菜单
      */
+    @ApiOperation("新增菜单")
+    @ApiOperationSupport(ignoreParameters = {"children","createBy","createTime","menuId","params"
+            ,"parentName","remark","updateBy","updateTime"})
     @PreAuthorize("@ss.hasPermi('system:menu:add')")
     @Log(title = "菜单管理", businessType = BusinessType.INSERT)
     @PostMapping
@@ -108,6 +121,9 @@ public class SysMenuController extends BaseController
     /**
      * 修改菜单
      */
+    @ApiOperation("修改菜单")
+    @ApiOperationSupport(ignoreParameters = {"children","createBy","createTime","params"
+            ,"parentName","remark","updateBy","updateTime"})
     @PreAuthorize("@ss.hasPermi('system:menu:edit')")
     @Log(title = "菜单管理", businessType = BusinessType.UPDATE)
     @PutMapping
@@ -133,6 +149,7 @@ public class SysMenuController extends BaseController
     /**
      * 删除菜单
      */
+    @ApiOperation("删除菜单")
     @PreAuthorize("@ss.hasPermi('system:menu:remove')")
     @Log(title = "菜单管理", businessType = BusinessType.DELETE)
     @DeleteMapping("/{menuId}")

+ 12 - 0
zhongzheng-admin/src/main/java/com/zhongzheng/controller/system/SysRoleController.java

@@ -1,6 +1,7 @@
 package com.zhongzheng.controller.system;
 
 import cn.hutool.core.lang.Validator;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import com.zhongzheng.common.annotation.Log;
 import com.zhongzheng.common.constant.UserConstants;
 import com.zhongzheng.common.core.controller.BaseController;
@@ -16,6 +17,8 @@ import com.zhongzheng.framework.web.service.SysPermissionService;
 import com.zhongzheng.framework.web.service.TokenService;
 import com.zhongzheng.modules.system.service.ISysRoleService;
 import com.zhongzheng.modules.system.service.ISysUserService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.validation.annotation.Validated;
@@ -28,6 +31,7 @@ import java.util.List;
  *
  * @author zhongzheng
  */
+@Api(tags ="角色信息管理")
 @RestController
 @RequestMapping("/system/role")
 public class SysRoleController extends BaseController
@@ -66,6 +70,7 @@ public class SysRoleController extends BaseController
     /**
      * 根据角色编号获取详细信息
      */
+    @ApiOperation("根据角色编号获取详细信息")
     @PreAuthorize("@ss.hasPermi('system:role:query')")
     @GetMapping(value = "/{roleId}")
     public AjaxResult getInfo(@PathVariable Long roleId)
@@ -76,6 +81,9 @@ public class SysRoleController extends BaseController
     /**
      * 新增角色
      */
+    @ApiOperation("新增角色")
+    @ApiOperationSupport(ignoreParameters = {"createBy","createTime","dataScope","delFlag","updateTime"
+    ,"flag","params","roleId","updateBy","deptIds","deptCheckStrictly","menuCheckStrictly"})
     @PreAuthorize("@ss.hasPermi('system:role:add')")
     @Log(title = "角色管理", businessType = BusinessType.INSERT)
     @PostMapping
@@ -97,6 +105,7 @@ public class SysRoleController extends BaseController
     /**
      * 修改保存角色
      */
+    @ApiOperation("修改保存角色")
     @PreAuthorize("@ss.hasPermi('system:role:edit')")
     @Log(title = "角色管理", businessType = BusinessType.UPDATE)
     @PutMapping
@@ -131,6 +140,7 @@ public class SysRoleController extends BaseController
     /**
      * 修改保存数据权限
      */
+    @ApiOperation("修改保存数据权限")
     @PreAuthorize("@ss.hasPermi('system:role:edit')")
     @Log(title = "角色管理", businessType = BusinessType.UPDATE)
     @PutMapping("/dataScope")
@@ -143,6 +153,7 @@ public class SysRoleController extends BaseController
     /**
      * 状态修改
      */
+    @ApiOperation("状态修改")
     @PreAuthorize("@ss.hasPermi('system:role:edit')")
     @Log(title = "角色管理", businessType = BusinessType.UPDATE)
     @PutMapping("/changeStatus")
@@ -167,6 +178,7 @@ public class SysRoleController extends BaseController
     /**
      * 获取角色选择框列表
      */
+    @ApiOperation("获取角色选择框列表")
     @PreAuthorize("@ss.hasPermi('system:role:query')")
     @GetMapping("/optionselect")
     public AjaxResult optionselect()

+ 16 - 1
zhongzheng-admin/src/main/java/com/zhongzheng/controller/system/SysUserController.java

@@ -1,6 +1,9 @@
 package com.zhongzheng.controller.system;
 
 import cn.hutool.core.lang.Validator;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import com.github.xiaoymin.knife4j.annotations.DynamicParameter;
+import com.github.xiaoymin.knife4j.annotations.DynamicParameters;
 import com.zhongzheng.common.annotation.Log;
 import com.zhongzheng.common.constant.UserConstants;
 import com.zhongzheng.common.core.controller.BaseController;
@@ -17,6 +20,9 @@ import com.zhongzheng.framework.web.service.TokenService;
 import com.zhongzheng.modules.system.service.ISysPostService;
 import com.zhongzheng.modules.system.service.ISysRoleService;
 import com.zhongzheng.modules.system.service.ISysUserService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.validation.annotation.Validated;
@@ -31,6 +37,7 @@ import java.util.stream.Collectors;
  *
  * @author zhongzheng
  */
+@Api(tags ="用户信息管理")
 @RestController
 @RequestMapping("/system/user")
 public class SysUserController extends BaseController
@@ -50,6 +57,7 @@ public class SysUserController extends BaseController
     /**
      * 获取用户列表
      */
+    @ApiOperation("获取用户列表")
     @PreAuthorize("@ss.hasPermi('system:user:list')")
     @GetMapping("/list")
     public TableDataInfo list(SysUser user)
@@ -92,6 +100,8 @@ public class SysUserController extends BaseController
     /**
      * 根据用户编号获取详细信息
      */
+    @ApiOperation("获取用户详细")
+    @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path")
     @PreAuthorize("@ss.hasPermi('system:user:query')")
     @GetMapping(value = { "/", "/{userId}" })
     public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId)
@@ -112,6 +122,8 @@ public class SysUserController extends BaseController
     /**
      * 新增用户
      */
+    @ApiOperation("新增用户")
+    @ApiOperationSupport(ignoreParameters = {"id","orderDate.id"})
     @PreAuthorize("@ss.hasPermi('system:user:add')")
     @Log(title = "用户管理", businessType = BusinessType.INSERT)
     @PostMapping
@@ -139,6 +151,7 @@ public class SysUserController extends BaseController
     /**
      * 修改用户
      */
+    @ApiOperation("更新用户")
     @PreAuthorize("@ss.hasPermi('system:user:edit')")
     @Log(title = "用户管理", businessType = BusinessType.UPDATE)
     @PutMapping
@@ -162,13 +175,15 @@ public class SysUserController extends BaseController
     /**
      * 删除用户
      */
+  /*  @ApiOperation("删除用户信息")
+    @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path")
     @PreAuthorize("@ss.hasPermi('system:user:remove')")
     @Log(title = "用户管理", businessType = BusinessType.DELETE)
     @DeleteMapping("/{userIds}")
     public AjaxResult remove(@PathVariable Long[] userIds)
     {
         return toAjax(userService.deleteUserByIds(userIds));
-    }
+    }*/
 
     /**
      * 重置密码

+ 6 - 10
zhongzheng-admin/src/main/java/com/zhongzheng/controller/tool/TestController.java

@@ -16,7 +16,7 @@ import java.util.Map;
  *
  * @author zhongzheng
  */
-@Api(tags ="用户信息管理")
+
 @RestController
 @RequestMapping("/test/user")
 public class TestController extends BaseController
@@ -27,7 +27,7 @@ public class TestController extends BaseController
         users.put(2, new UserEntity(2, "ry", "admin123", "15666666666"));
     }
 
-    @ApiOperation("获取用户列表")
+
     @GetMapping("/list")
     public AjaxResult userList()
     {
@@ -35,8 +35,7 @@ public class TestController extends BaseController
         return AjaxResult.success(userList);
     }
 
-    @ApiOperation("获取用户详细")
-    @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path")
+
     @GetMapping("/{userId}")
     public AjaxResult getUser(@PathVariable Integer userId)
     {
@@ -50,8 +49,7 @@ public class TestController extends BaseController
         }
     }
 
-    @ApiOperation("新增用户")
-    @ApiImplicitParam(name = "userEntity", value = "新增用户信息", dataType = "UserEntity")
+
     @PostMapping("/save")
     public AjaxResult save(UserEntity user)
     {
@@ -62,8 +60,7 @@ public class TestController extends BaseController
         return AjaxResult.success(users.put(user.getUserId(), user));
     }
 
-    @ApiOperation("更新用户")
-    @ApiImplicitParam(name = "userEntity", value = "新增用户信息", dataType = "UserEntity")
+
     @PutMapping("/update")
     public AjaxResult update(UserEntity user)
     {
@@ -79,8 +76,7 @@ public class TestController extends BaseController
         return AjaxResult.success(users.put(user.getUserId(), user));
     }
 
-    @ApiOperation("删除用户信息")
-    @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path")
+
     @DeleteMapping("/{userId}")
     public AjaxResult delete(@PathVariable Integer userId)
     {

+ 4 - 3
zhongzheng-admin/src/main/java/com/zhongzheng/core/config/SwaggerConfig.java

@@ -112,13 +112,14 @@ public class SwaggerConfig
         // 用ApiInfoBuilder进行定制
         return new ApiInfoBuilder()
                 // 设置标题
-                .title("标题:中正云学堂后台_接口文档")
+                .title("标题:中正云学堂管理系统_接口文档")
                 // 描述
-                .description("描述:用于中正云学堂后台_接口文档")
+                .description("描述:用于中正云学堂管理系统_接口文档")
                 // 作者信息
                 .contact(new Contact(ruoyiConfig.getName(), null, null))
                 // 版本
-                .version("版本号:" + ruoyiConfig.getVersion())
+                .version("版本号:0.0.1")
+
                 .build();
     }
 }

+ 3 - 2
zhongzheng-admin/src/main/resources/application.yml

@@ -112,7 +112,7 @@ token:
     # 令牌密钥
     secret: abcdefghijklmnopqrstuvwxyz
     # 令牌有效期(默认30分钟)
-    expireTime: 30
+    expireTime: 120
 
 # MyBatis配置
 # https://baomidou.com/config/
@@ -215,7 +215,8 @@ swagger:
   enabled: true
   # 请求前缀
   pathMapping:
-
+knife4j:
+  enable: true
 # 防止XSS攻击
 xss:
   # 过滤开关

+ 1 - 1
zhongzheng-api/src/main/resources/application.yml

@@ -112,7 +112,7 @@ token:
     # 令牌密钥
     secret: abcdefghijklmnopqrstuvwxyz
     # 令牌有效期(默认30分钟)
-    expireTime: 30
+    expireTime: 120
 
 # MyBatis配置
 # https://baomidou.com/config/

+ 6 - 2
zhongzheng-common/pom.xml

@@ -52,7 +52,7 @@
             <groupId>org.apache.commons</groupId>
             <artifactId>commons-lang3</artifactId>
         </dependency>
-  
+
         <!-- JSON工具类 -->
         <dependency>
             <groupId>com.fasterxml.jackson.core</groupId>
@@ -137,6 +137,10 @@
             <artifactId>spring-boot-admin-starter-client</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>com.github.xiaoymin</groupId>
+            <artifactId>knife4j-spring-boot-starter</artifactId>
+        </dependency>
     </dependencies>
 
-</project>
+</project>

+ 18 - 3
zhongzheng-common/src/main/java/com/zhongzheng/common/core/domain/entity/SysMenu.java

@@ -2,6 +2,8 @@ package com.zhongzheng.common.core.domain.entity;
 
 import com.baomidou.mybatisplus.annotation.*;
 import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 import lombok.experimental.Accessors;
@@ -13,10 +15,10 @@ import java.util.*;
 
 /**
  * 菜单权限表 sys_menu
- * 
+ *
  * @author zhongzheng
  */
-
+@ApiModel("菜单")
 @Data
 @NoArgsConstructor
 @Accessors(chain = true)
@@ -25,10 +27,12 @@ public class SysMenu implements Serializable
     private static final long serialVersionUID = 1L;
 
     /** 菜单ID */
+    @ApiModelProperty(value ="菜单ID",required = true)
     @TableId(value = "menu_id",type = IdType.AUTO)
     private Long menuId;
 
     /** 菜单名称 */
+    @ApiModelProperty(value ="菜单名称",required = true)
     @NotBlank(message = "菜单名称不能为空")
     @Size(min = 0, max = 50, message = "菜单名称长度不能超过50个字符")
     private String menuName;
@@ -38,41 +42,52 @@ public class SysMenu implements Serializable
     private String parentName;
 
     /** 父菜单ID */
+    @ApiModelProperty(value ="父菜单ID",required = true)
     private Long parentId;
 
     /** 显示顺序 */
+    @ApiModelProperty(value ="显示顺序",required = true)
     @NotBlank(message = "显示顺序不能为空")
     private String orderNum;
 
     /** 路由地址 */
+    @ApiModelProperty(value ="路由地址",required = true)
     @Size(min = 0, max = 200, message = "路由地址不能超过200个字符")
     private String path;
 
     /** 组件路径 */
+    @ApiModelProperty(value ="组件路径")
     @Size(min = 0, max = 200, message = "组件路径不能超过255个字符")
     private String component;
 
     /** 是否为外链(0是 1否) */
+    @ApiModelProperty(value ="是否为外链(0是 1否)")
     private String isFrame;
 
     /** 是否缓存(0缓存 1不缓存) */
+    @ApiModelProperty(value ="是否缓存(0缓存 1不缓存)")
     private String isCache;
 
     /** 类型(M目录 C菜单 F按钮) */
+    @ApiModelProperty(value ="类型(M目录 C菜单 F按钮)",required = true)
     @NotBlank(message = "菜单类型不能为空")
     private String menuType;
 
     /** 显示状态(0显示 1隐藏) */
+    @ApiModelProperty(value ="显示状态(0显示 1隐藏)")
     private String visible;
-    
+
     /** 菜单状态(0显示 1隐藏) */
+    @ApiModelProperty(value ="菜单状态(0显示 1隐藏)")
     private String status;
 
     /** 权限字符串 */
+    @ApiModelProperty(value ="权限标识")
     @Size(min = 0, max = 100, message = "权限标识长度不能超过100个字符")
     private String perms;
 
     /** 菜单图标 */
+    @ApiModelProperty(value ="菜单图标")
     private String icon;
 
     /** 创建者 */

+ 15 - 3
zhongzheng-common/src/main/java/com/zhongzheng/common/core/domain/entity/SysRole.java

@@ -4,9 +4,12 @@ import com.baomidou.mybatisplus.annotation.*;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.zhongzheng.common.annotation.Excel;
 import com.zhongzheng.common.annotation.Excel.ColumnType;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 import lombok.experimental.Accessors;
+import org.springframework.beans.factory.annotation.Value;
 
 import javax.validation.constraints.NotBlank;
 import javax.validation.constraints.Size;
@@ -17,10 +20,10 @@ import java.util.Map;
 
 /**
  * 角色表 sys_role
- * 
+ *
  * @author zhongzheng
  */
-
+@ApiModel("角色")
 @Data
 @NoArgsConstructor
 @Accessors(chain = true)
@@ -34,18 +37,21 @@ public class SysRole implements Serializable
     private Long roleId;
 
     /** 角色名称 */
+    @ApiModelProperty(value ="角色名称",required = true)
     @Excel(name = "角色名称")
     @NotBlank(message = "角色名称不能为空")
     @Size(min = 0, max = 30, message = "角色名称长度不能超过30个字符")
     private String roleName;
 
     /** 角色权限 */
+    @ApiModelProperty(value ="权限字符",required = true)
     @Excel(name = "角色权限")
     @NotBlank(message = "权限字符不能为空")
     @Size(min = 0, max = 100, message = "权限字符长度不能超过100个字符")
     private String roleKey;
 
     /** 角色排序 */
+    @ApiModelProperty(value ="角色排序",required = true)
     @Excel(name = "角色排序")
     @NotBlank(message = "显示顺序不能为空")
     private String roleSort;
@@ -54,14 +60,18 @@ public class SysRole implements Serializable
     @Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限")
     private String dataScope;
 
+    @Value("true")
     /** 菜单树选择项是否关联显示( 0:父子不互相关联显示 1:父子互相关联显示) */
     private boolean menuCheckStrictly;
 
+    @Value("true")
     /** 部门树选择项是否关联显示(0:父子不互相关联显示 1:父子互相关联显示 ) */
     private boolean deptCheckStrictly;
 
     /** 角色状态(0正常 1停用) */
-    @Excel(name = "角色状态", readConverterExp = "0=正常,1=停用")
+    @ApiModelProperty(value ="状态 0=正常,1=停用")
+    @Value("1")
+    @Excel(name = "角色状态", readConverterExp = "1=正常,0=停用")
     private String status;
 
     /** 删除标志(0代表存在 2代表删除) */
@@ -87,6 +97,7 @@ public class SysRole implements Serializable
     private Date updateTime;
 
     /** 备注 */
+    @ApiModelProperty(value ="备注")
     private String remark;
 
     /**
@@ -100,6 +111,7 @@ public class SysRole implements Serializable
     private boolean flag = false;
 
     /** 菜单组 */
+    @ApiModelProperty(value ="菜单数组")
     @TableField(exist = false)
     private Long[] menuIds;
 

+ 8 - 2
zhongzheng-common/src/main/java/com/zhongzheng/common/core/domain/model/LoginBody.java

@@ -1,14 +1,16 @@
 package com.zhongzheng.common.core.domain.model;
 
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.*;
 import lombok.experimental.Accessors;
 
 /**
  * 用户登录对象
- * 
+ *
  * @author zhongzheng
  */
-
+@ApiModel("登录用户")
 @Data
 @NoArgsConstructor
 @Accessors(chain = true)
@@ -17,21 +19,25 @@ public class LoginBody
     /**
      * 用户名
      */
+    @ApiModelProperty(value ="用户名",required = true)
     private String username;
 
     /**
      * 用户密码
      */
+    @ApiModelProperty(value ="用户密码",required = true)
     private String password;
 
     /**
      * 验证码
      */
+    @ApiModelProperty(value ="验证码",required = true)
     private String code;
 
     /**
      * 唯一标识
      */
+    @ApiModelProperty(value ="验证码uuid",required = true)
     private String uuid = "";
 
 }

+ 4 - 2
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/MajorCategoryAddBo.java

@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 
+import javax.validation.constraints.Min;
 import javax.validation.constraints.NotBlank;
 import java.util.Date;
 
@@ -21,7 +22,8 @@ import java.util.Date;
 public class MajorCategoryAddBo {
 
     /** 父ID */
-    @ApiModelProperty("父ID")
+    @ApiModelProperty(value ="父ID",required = true)
+    @Min(value = 0, message = "pId必须为正整数")
     private Long pId;
     /** 排序 */
     @ApiModelProperty("排序")
@@ -39,7 +41,7 @@ public class MajorCategoryAddBo {
     @ApiModelProperty("更新时间")
     private Long updateTime;
     /** 分类名称 */
-    @ApiModelProperty("分类名称")
+    @ApiModelProperty(value ="分类名称",required = true)
     @NotBlank(message = "分类名称不能为空")
     private String categoryName;
 }

+ 4 - 2
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/MajorCategoryEditBo.java

@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 
+import javax.validation.constraints.Min;
 import javax.validation.constraints.NotBlank;
 import java.util.Date;
 
@@ -21,7 +22,8 @@ public class MajorCategoryEditBo {
 
 
     /** 类目ID */
-    @ApiModelProperty("类目ID")
+    @ApiModelProperty(value ="类目ID",required = true)
+    @Min(value = 0, message = "pId必须为正整数")
     private Long categoryId;
 
     /** 父ID */
@@ -33,7 +35,7 @@ public class MajorCategoryEditBo {
     private Integer sort;
 
     /** 1正常 0关闭 */
-    @ApiModelProperty("1正常 0关闭")
+    @ApiModelProperty(value = "1正常 0关闭")
     private Integer status;
 
     /** 备注 */

+ 2 - 10
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/IMajorCategoryService.java

@@ -2,6 +2,7 @@ package com.zhongzheng.modules.course.service;
 
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.zhongzheng.common.core.domain.entity.SysMenu;
 import com.zhongzheng.modules.course.bo.MajorCategoryAddBo;
 import com.zhongzheng.modules.course.bo.MajorCategoryEditBo;
 import com.zhongzheng.modules.course.bo.MajorCategoryQueryBo;
@@ -29,18 +30,8 @@ public interface IMajorCategoryService extends IService<MajorCategory> {
 	 */
 	List<MajorCategoryVo> queryList(MajorCategoryQueryBo bo);
 
-	/**
-	 * 根据新增业务对象插入【请填写功能名称】
-	 * @param bo 【请填写功能名称】新增业务对象
-	 * @return
-	 */
 	Boolean insertByAddBo(MajorCategoryAddBo bo);
 
-	/**
-	 * 根据编辑业务对象修改【请填写功能名称】
-	 * @param bo 【请填写功能名称】编辑业务对象
-	 * @return
-	 */
 	Boolean updateByEditBo(MajorCategoryEditBo bo);
 
 	/**
@@ -50,4 +41,5 @@ public interface IMajorCategoryService extends IService<MajorCategory> {
 	 * @return
 	 */
 	Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
+
 }

+ 31 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/MajorCategoryServiceImpl.java

@@ -1,7 +1,11 @@
 package com.zhongzheng.modules.course.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.lang.Validator;
 import cn.hutool.core.util.StrUtil;
+import com.zhongzheng.common.constant.UserConstants;
+import com.zhongzheng.common.core.domain.entity.SysMenu;
+import com.zhongzheng.common.exception.CustomException;
 import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.modules.course.bo.MajorCategoryAddBo;
 import com.zhongzheng.modules.course.bo.MajorCategoryEditBo;
@@ -90,6 +94,12 @@ public class MajorCategoryServiceImpl extends ServiceImpl<MajorCategoryMapper, M
      */
     private void validEntityBeforeSave(MajorCategory entity){
         //TODO 做一些数据校验,如唯一约束
+        if(checkMajorCategoryNameUnique(entity)){
+            throw new CustomException("分类名已存在");
+        }
+        if(entity.getPId()>0&&!checkMajorCategoryPid(entity)){
+            throw new CustomException("父ID不存在");
+        }
     }
 
     @Override
@@ -99,4 +109,25 @@ public class MajorCategoryServiceImpl extends ServiceImpl<MajorCategoryMapper, M
         }
         return this.removeByIds(ids);
     }
+
+
+    private boolean checkMajorCategoryNameUnique(MajorCategory entity) {
+        MajorCategory info = getOne(new LambdaQueryWrapper<MajorCategory>()
+                .eq(MajorCategory::getCategoryName,entity.getCategoryName())
+                .last("limit 1"));
+        if (Validator.isNotNull(info)) {
+            return true;
+        }
+        return false;
+    }
+
+    private boolean checkMajorCategoryPid(MajorCategory entity) {
+        MajorCategory info = getOne(new LambdaQueryWrapper<MajorCategory>()
+                .eq(MajorCategory::getCategoryId,entity.getPId())
+                .last("limit 1"));
+        if (Validator.isNotNull(info)) {
+            return true;
+        }
+        return false;
+    }
 }