parent
f1aac4d77c
commit
dbf9b77a12
6 changed files with 212 additions and 0 deletions
@ -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; |
||||
|
||||
/** |
||||
* <p> |
||||
* 用户组 前端控制器 |
||||
* </p> |
||||
* |
||||
* @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<UserGroup>(). |
||||
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<UserGroup> groups = userGroupService.list(new QueryWrapper<UserGroup>(). |
||||
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<UserGroup> queryWrapper = Wrappers.lambdaQuery(); |
||||
if (!StringUtils.isEmpty(userGroup.getGroupName())) { |
||||
queryWrapper.like(UserGroup::getGroupName, userGroup.getGroupName()); |
||||
} |
||||
queryWrapper.orderByDesc(UserGroup::getCreateTime); |
||||
IPage<SysFilesEntity> iPage = userGroupService.page(userGroup.getQueryPage(),queryWrapper); |
||||
return R.success(iPage); |
||||
} |
||||
|
||||
} |
||||
|
@ -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; |
||||
|
||||
/** |
||||
* <p> |
||||
* 用户组 |
||||
* </p> |
||||
* |
||||
* @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; |
||||
|
||||
} |
@ -0,0 +1,16 @@ |
||||
package com.huoran.iasf.mapper; |
||||
|
||||
import com.huoran.iasf.entity.UserGroup; |
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
||||
/** |
||||
* <p> |
||||
* 用户组 Mapper 接口 |
||||
* </p> |
||||
* |
||||
* @author cheney |
||||
* @since 2022-08-10 |
||||
*/ |
||||
public interface UserGroupMapper extends BaseMapper<UserGroup> { |
||||
|
||||
} |
@ -0,0 +1,5 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="com.huoran.iasf.mapper.UserGroupMapper"> |
||||
|
||||
</mapper> |
@ -0,0 +1,16 @@ |
||||
package com.huoran.iasf.service; |
||||
|
||||
import com.huoran.iasf.entity.UserGroup; |
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
|
||||
/** |
||||
* <p> |
||||
* 用户组 服务类 |
||||
* </p> |
||||
* |
||||
* @author cheney |
||||
* @since 2022-08-10 |
||||
*/ |
||||
public interface UserGroupService extends IService<UserGroup> { |
||||
|
||||
} |
@ -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; |
||||
|
||||
/** |
||||
* <p> |
||||
* 用户组 服务实现类 |
||||
* </p> |
||||
* |
||||
* @author cheney |
||||
* @since 2022-08-10 |
||||
*/ |
||||
@Service |
||||
public class UserGroupServiceImpl extends ServiceImpl<UserGroupMapper, UserGroup> implements UserGroupService { |
||||
|
||||
} |
Loading…
Reference in new issue