diff --git a/src/main/java/com/huoran/iasf/controller/UserGroupController.java b/src/main/java/com/huoran/iasf/controller/UserGroupController.java new file mode 100644 index 0000000..ea7fefa --- /dev/null +++ b/src/main/java/com/huoran/iasf/controller/UserGroupController.java @@ -0,0 +1,103 @@ +package com.huoran.iasf.controller; + +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.huoran.iasf.common.aop.annotation.LogAnnotation; +import com.huoran.iasf.common.utils.R; +import com.huoran.iasf.entity.SysFilesEntity; +import com.huoran.iasf.entity.UserGroup; +import com.huoran.iasf.service.UserGroupService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import java.util.List; + +/** + *

+ * 用户组 前端控制器 + *

+ * + * @author cheney + * @since 2022-08-10 + */ +@RestController +@RequestMapping("/sys/userGroup") +@Api(tags = "用户组管理") +public class UserGroupController { + + @Autowired + private UserGroupService userGroupService; + + @PostMapping("/add") + @ApiOperation(value = "新增用户组") + @LogAnnotation(title = "用户组管理", action = "新增用户组") + @RequiresPermissions("sys:userGroup:add") + public R addUserGroup(@RequestBody @Valid UserGroup userGroup) { + UserGroup one = userGroupService.getOne(new QueryWrapper(). + eq("group_name", userGroup.getGroupName())); + if (ObjectUtil.isNotNull(one)){ + R.fail("用户组已存在"); + } + userGroupService.save(userGroup); + return R.success(); + } + + @DeleteMapping("/delete/{id}") + @ApiOperation(value = "删除用户组") + @LogAnnotation(title = "用户组管理", action = "删除用户组") + @RequiresPermissions("sys:userGroup:deleted") + public R deleted(@PathVariable("id") Integer id) { + userGroupService.removeById(id); + return R.success(); + } + + @PutMapping("/update") + @ApiOperation(value = "更新用户组信息") + @LogAnnotation(title = "用户组管理", action = "更新用户组信息") + @RequiresPermissions("sys:userGroup:update") + public R updateUserGroup(@RequestBody UserGroup userGroup) { + if (StringUtils.isEmpty(userGroup.getId())) { + return R.fail("id不能为空"); + } + List groups = userGroupService.list(new QueryWrapper(). + eq("group_name", userGroup.getGroupName())); + if (ObjectUtil.isNotNull(groups) && groups.size()>1){ + R.fail("用户组已存在"); + } + userGroupService.updateById(userGroup); + return R.success(); + } + +/* @GetMapping("/detail/{id}") + @ApiOperation(value = "查询用户组详情接口") + @LogAnnotation(title = "用户组管理", action = "查询用户组详情") + @RequiresPermissions("sys:userGroup:detail") + public R detailInfo(@PathVariable("id") Integer id) { + return R.success(userGroupService.getById(id)); + }*/ + + + @GetMapping("/list") + @ApiOperation(value = "用户组列表") + @LogAnnotation(title = "用户组管理", action = "获取所有用户组机构") + @RequiresPermissions("sys:userGroup:list") + public R getUserGroupAll(@RequestBody UserGroup userGroup) { + LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(); + if (!StringUtils.isEmpty(userGroup.getGroupName())) { + queryWrapper.like(UserGroup::getGroupName, userGroup.getGroupName()); + } + queryWrapper.orderByDesc(UserGroup::getCreateTime); + IPage iPage = userGroupService.page(userGroup.getQueryPage(),queryWrapper); + return R.success(iPage); + } + +} + diff --git a/src/main/java/com/huoran/iasf/entity/UserGroup.java b/src/main/java/com/huoran/iasf/entity/UserGroup.java new file mode 100644 index 0000000..d04e2c0 --- /dev/null +++ b/src/main/java/com/huoran/iasf/entity/UserGroup.java @@ -0,0 +1,52 @@ +package com.huoran.iasf.entity; + +import com.baomidou.mybatisplus.annotation.*; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.Date; + +/** + *

+ * 用户组 + *

+ * + * @author cheney + * @since 2022-08-10 + */ + +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("sys_user_group") +@ApiModel(value="UserGroup对象", description="用户组") +public class UserGroup extends BaseEntity implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "主键") + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + @ApiModelProperty(value = "名称") + @NotNull(message = "用户组名称不能为空!") + private String groupName; + + @ApiModelProperty(value = "描述") + private String description; + + @TableField(fill = FieldFill.INSERT) + @ApiModelProperty(value = "创建时间") + private Date createTime; + + @TableField(fill = FieldFill.INSERT_UPDATE) + @ApiModelProperty(value = "更新时间") + private Date updateTime; + + @ApiModelProperty(value = "是否删除(1未删除;0已删除)") + private Integer deleted; + +} diff --git a/src/main/java/com/huoran/iasf/mapper/UserGroupMapper.java b/src/main/java/com/huoran/iasf/mapper/UserGroupMapper.java new file mode 100644 index 0000000..f9e5ad8 --- /dev/null +++ b/src/main/java/com/huoran/iasf/mapper/UserGroupMapper.java @@ -0,0 +1,16 @@ +package com.huoran.iasf.mapper; + +import com.huoran.iasf.entity.UserGroup; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 用户组 Mapper 接口 + *

+ * + * @author cheney + * @since 2022-08-10 + */ +public interface UserGroupMapper extends BaseMapper { + +} diff --git a/src/main/java/com/huoran/iasf/mapper/xml/UserGroupMapper.xml b/src/main/java/com/huoran/iasf/mapper/xml/UserGroupMapper.xml new file mode 100644 index 0000000..6a9d356 --- /dev/null +++ b/src/main/java/com/huoran/iasf/mapper/xml/UserGroupMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/main/java/com/huoran/iasf/service/UserGroupService.java b/src/main/java/com/huoran/iasf/service/UserGroupService.java new file mode 100644 index 0000000..e8cbd21 --- /dev/null +++ b/src/main/java/com/huoran/iasf/service/UserGroupService.java @@ -0,0 +1,16 @@ +package com.huoran.iasf.service; + +import com.huoran.iasf.entity.UserGroup; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 用户组 服务类 + *

+ * + * @author cheney + * @since 2022-08-10 + */ +public interface UserGroupService extends IService { + +} diff --git a/src/main/java/com/huoran/iasf/service/impl/UserGroupServiceImpl.java b/src/main/java/com/huoran/iasf/service/impl/UserGroupServiceImpl.java new file mode 100644 index 0000000..493289d --- /dev/null +++ b/src/main/java/com/huoran/iasf/service/impl/UserGroupServiceImpl.java @@ -0,0 +1,20 @@ +package com.huoran.iasf.service.impl; + +import com.huoran.iasf.entity.UserGroup; +import com.huoran.iasf.mapper.UserGroupMapper; +import com.huoran.iasf.service.UserGroupService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 用户组 服务实现类 + *

+ * + * @author cheney + * @since 2022-08-10 + */ +@Service +public class UserGroupServiceImpl extends ServiceImpl implements UserGroupService { + +}