| | |
| | | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.im.config.CreateTeamRequest; |
| | | import com.ruoyi.system.domain.GroupWelcomeConfig; |
| | | import com.ruoyi.system.domain.IpBlacklist; |
| | | import com.ruoyi.system.domain.NeteaseTeam; |
| | | import com.ruoyi.system.service.GroupWelcomeConfigService; |
| | | import com.ruoyi.system.service.IpBlacklistService; |
| | | import org.aspectj.weaver.loadtime.Aj; |
| | |
| | | **/ |
| | | @RestController |
| | | @RequestMapping("/system/basic") |
| | | public class BasicSetupController { |
| | | public class BasicSetupController extends BaseController { |
| | | |
| | | @Autowired |
| | | GroupWelcomeConfigService groupWelcomeConfigService; |
| | |
| | | |
| | | |
| | | /** |
| | | * 创建群组 |
| | | * 修改基础信息 |
| | | */ |
| | | @PostMapping("/update") |
| | | public AjaxResult createGroup(@Validated @RequestBody GroupWelcomeConfig vo) { |
| | | public AjaxResult update(GroupWelcomeConfig vo) { |
| | | GroupWelcomeConfig configServiceById = groupWelcomeConfigService.getById(vo.getId()); |
| | | if(ObjectUtil.isEmpty(configServiceById)){ |
| | | return AjaxResult.error("请联系管理员初始化配置"); |
| | |
| | | configServiceById.setWelcomeMessage(vo.getWelcomeMessage()); |
| | | configServiceById.setLegalInstitution(vo.getLegalInstitution()); |
| | | configServiceById.setCopyrightInfo(vo.getCopyrightInfo()); |
| | | configServiceById.setCodeUrl(vo.getCodeUrl()); |
| | | configServiceById.setCustomerServiceUrl(vo.getCustomerServiceUrl()); |
| | | configServiceById.setAboutUs(vo.getAboutUs()); |
| | | groupWelcomeConfigService.updateById(configServiceById); |
| | | return AjaxResult.success("保存成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 查询基础信息 |
| | | */ |
| | | @GetMapping("/get") |
| | | public AjaxResult get() { |
| | | GroupWelcomeConfig groupWelcomeConfig = groupWelcomeConfigService.getOne(new LambdaQueryWrapper<>(GroupWelcomeConfig.class) |
| | | .eq(GroupWelcomeConfig::getConfigurationName, "IM-BASICS").last(" limit 1")); |
| | | return AjaxResult.success(groupWelcomeConfig); |
| | | } |
| | | |
| | | /** |
| | | * ip黑名单列表 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('im:group:list')") |
| | | @GetMapping("/list") |
| | | public TableDataInfo list(@RequestParam(value = "keywords", required = false) String keywords) |
| | | { |
| | | // 创建查询条件包装器 |
| | | LambdaQueryWrapper<IpBlacklist> queryWrapper = new LambdaQueryWrapper<>(); |
| | | |
| | | // 只有当 keyword 不为空时才添加 OR 条件 |
| | | if (ObjectUtil.isNotEmpty(keywords)) { |
| | | queryWrapper.and(wrapper -> wrapper.eq(IpBlacklist::getIpAddress,keywords) |
| | | ); |
| | | } |
| | | |
| | | // 默认按创建时间倒序 |
| | | queryWrapper.orderByDesc(IpBlacklist::getCreateTime); |
| | | startPage(); |
| | | List<IpBlacklist> list = ipBlacklistService.list(queryWrapper); |
| | | return getDataTable(list); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 新增ip黑名单 |
| | | */ |
| | | @PostMapping("/addIp") |
| | | public AjaxResult addIp(@PathVariable("ip") String ip) { |
| | | public AjaxResult addIp(@RequestParam("ip") String ip) { |
| | | |
| | | long count = ipBlacklistService.count(new LambdaQueryWrapper<>(IpBlacklist.class).eq(IpBlacklist::getIpAddress, ip)); |
| | | if(count > 0){ |
| | |
| | | } |
| | | |
| | | /** |
| | | * 新增ip黑名单 |
| | | * 删除ip黑名单 |
| | | */ |
| | | @PostMapping("/deleteIp") |
| | | public AjaxResult addIp(@PathVariable("id") Integer id) { |
| | | public AjaxResult addIp(@RequestParam("id") Integer id) { |
| | | |
| | | IpBlacklist ipBlacklist = ipBlacklistService.getById(id); |
| | | if(ObjectUtil.isEmpty(ipBlacklist)){ |
| | | return AjaxResult.error("ip地址不存在!"); |
| | | } |
| | | ipBlacklistService.removeById(id); |
| | | return AjaxResult.success("添加成功"); |
| | | return AjaxResult.success("删除成功"); |
| | | } |
| | | |
| | | } |