init
This commit is contained in:
@@ -8,4 +8,6 @@ public class RedisConstant {
|
||||
public static final String DYNAMIC_TOTAL_CACHE_REDIS = REDIS_P + "synamicTotal:%s:%s";
|
||||
public static final String CODE_REDIS = REDIS_P + "code:%s:%s";
|
||||
public static final String USER_GREET_TOTAL_REDIS = REDIS_P + "userGreetTotal:%s:%s";
|
||||
|
||||
public static final String BLACK_REDIS = REDIS_P + "black:%s";
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ import java.util.Arrays;
|
||||
@RequestMapping("/cai/black")
|
||||
public class BlackController extends BaseController {
|
||||
|
||||
private final BlackService iBlackService;
|
||||
private final BlackService blackService;
|
||||
|
||||
/**
|
||||
* 查询黑名单列表
|
||||
@@ -42,7 +42,7 @@ public class BlackController extends BaseController {
|
||||
@SaCheckPermission("cai:black:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<Black> list(Black bo, PageQuery pageQuery) {
|
||||
Page<Black> page = iBlackService.page(pageQuery.build(), Wrappers.lambdaQuery(bo).orderByDesc(Black::getCreateTime));
|
||||
Page<Black> page = blackService.page(pageQuery.build(), Wrappers.lambdaQuery(bo).orderByDesc(Black::getCreateTime));
|
||||
return TableDataInfo.build(page);
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ public class BlackController extends BaseController {
|
||||
@GetMapping("/{id}")
|
||||
public R<Black> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long id) {
|
||||
return R.ok(iBlackService.getById(id));
|
||||
return R.ok(blackService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,7 +66,7 @@ public class BlackController extends BaseController {
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody Black bo) {
|
||||
return toAjax(iBlackService.save(bo));
|
||||
return toAjax(blackService.addBlack(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,19 +77,17 @@ public class BlackController extends BaseController {
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody Black bo) {
|
||||
return toAjax(iBlackService.updateById(bo));
|
||||
return toAjax(blackService.updateBlackStatus(bo.getId(),bo.getEnableStatus()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除黑名单
|
||||
*
|
||||
* @param ids 主键串
|
||||
*/
|
||||
@SaCheckPermission("cai:black:remove")
|
||||
@Log(title = "黑名单", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] ids) {
|
||||
return toAjax(iBlackService.removeBatchByIds(Arrays.asList(ids)));
|
||||
@DeleteMapping("/{id}")
|
||||
public R<Void> remove(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long id) {
|
||||
return toAjax(blackService.deleteBlack(id));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.ruoyi.cai.controller.admin;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.cai.domain.UserInfo;
|
||||
import com.ruoyi.cai.dto.admin.vo.UserInfoAdminVo;
|
||||
import com.ruoyi.cai.service.UserInfoService;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.annotation.RepeatSubmit;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.validate.EditGroup;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 用户好友提成
|
||||
*
|
||||
* @author 77
|
||||
* @date 2024-01-04
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/cai/userInfo")
|
||||
public class UserInfoController extends BaseController {
|
||||
|
||||
private final UserInfoService userInfoService;
|
||||
|
||||
@SaCheckPermission("cai:userInfo:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<UserInfoAdminVo> list(UserInfoAdminVo bo, PageQuery pageQuery) {
|
||||
Page<UserInfoAdminVo> page = userInfoService.pageAdmin(pageQuery,bo);
|
||||
return TableDataInfo.build(page);
|
||||
}
|
||||
|
||||
@SaCheckPermission("cai:userInfo:query")
|
||||
@GetMapping("/{id}")
|
||||
public R<UserInfo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long id) {
|
||||
return R.ok(userInfoService.getById(id));
|
||||
}
|
||||
|
||||
@SaCheckPermission("cai:userInfo:edit")
|
||||
@Log(title = "用户好友提成", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody UserInfo bo) {
|
||||
return toAjax(userInfoService.updateById(bo));
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,9 @@ public class UserInfo {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableId(value = "user_id",type = IdType.INPUT)
|
||||
@TableId(value = "id",type = IdType.INPUT)
|
||||
private Long id;
|
||||
|
||||
private Long userId;
|
||||
/**
|
||||
* 奖励好友收入视频提成比率
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.ruoyi.cai.dto.admin.vo;
|
||||
|
||||
import com.ruoyi.cai.domain.UserInfo;
|
||||
import com.ruoyi.common.annotation.Sensitive;
|
||||
import com.ruoyi.common.enums.SensitiveStrategy;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UserInfoAdminVo extends UserInfo {
|
||||
|
||||
/**
|
||||
* 用户号/ID号
|
||||
*/
|
||||
private String usercode;
|
||||
/**
|
||||
* 昵称
|
||||
*/
|
||||
private String nickname;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
@Sensitive(strategy = SensitiveStrategy.PHONE)
|
||||
private String mobile;
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private String avatar;
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
private Integer gender;
|
||||
private Integer age;
|
||||
|
||||
private Integer isAnchor;
|
||||
}
|
||||
@@ -1,7 +1,11 @@
|
||||
package com.ruoyi.cai.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.cai.domain.UserInfo;
|
||||
import com.ruoyi.cai.dto.admin.vo.UserInfoAdminVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface UserInfoMapper extends BaseMapper<UserInfo> {
|
||||
Page<UserInfoAdminVo> pageAdmin(@Param("build") Page<Object> build, @Param("bo") UserInfoAdminVo bo);
|
||||
}
|
||||
|
||||
@@ -11,4 +11,13 @@ import com.ruoyi.cai.domain.Black;
|
||||
*/
|
||||
public interface BlackService extends IService<Black> {
|
||||
|
||||
boolean addBlack(Black black);
|
||||
|
||||
boolean updateBlackStatus(Long id, Integer enableStatus);
|
||||
|
||||
boolean deleteBlack(Long id);
|
||||
|
||||
boolean checkBlackIp(String ip);
|
||||
|
||||
boolean checkBlackMic(String ip);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
package com.ruoyi.cai.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.cai.domain.UserInfo;
|
||||
import com.ruoyi.cai.dto.admin.vo.UserInfoAdminVo;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
|
||||
public interface UserInfoService extends IService<UserInfo> {
|
||||
|
||||
UserInfo getByUserId(Long userId);
|
||||
|
||||
Page<UserInfoAdminVo> pageAdmin(PageQuery pageQuery, UserInfoAdminVo bo);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
package com.ruoyi.cai.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.cai.constant.RedisConstant;
|
||||
import com.ruoyi.cai.domain.Black;
|
||||
import com.ruoyi.cai.mapper.BlackMapper;
|
||||
import com.ruoyi.cai.service.BlackService;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.helper.LoginHelper;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
@@ -14,4 +21,60 @@ import org.springframework.stereotype.Service;
|
||||
*/
|
||||
@Service
|
||||
public class BlackServiceImpl extends ServiceImpl<BlackMapper,Black> implements BlackService {
|
||||
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
|
||||
private String getKey(Integer type){
|
||||
return String.format(RedisConstant.BLACK_REDIS,type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addBlack(Black black){
|
||||
black.setCreateById(LoginHelper.getUserId());
|
||||
black.setCreateByName(LoginHelper.getUsername());
|
||||
this.save(black);
|
||||
redisTemplate.opsForSet().add(getKey(black.getType()),black.getIpAddress());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateBlackStatus(Long id,Integer enableStatus){
|
||||
Black black = this.getById(id);
|
||||
if(black == null){
|
||||
throw new ServiceException("数据不存在");
|
||||
}
|
||||
this.update(Wrappers.lambdaUpdate(Black.class).set(Black::getEnableStatus,enableStatus).eq(Black::getId,id));
|
||||
if(enableStatus == 1){
|
||||
redisTemplate.opsForSet().add(getKey(black.getType()),black.getIpAddress());
|
||||
}else {
|
||||
redisTemplate.opsForSet().remove(getKey(black.getType()),black.getIpAddress());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteBlack(Long id){
|
||||
Black black = this.getById(id);
|
||||
if(black == null){
|
||||
throw new ServiceException("数据不存在");
|
||||
}
|
||||
this.removeById(id);
|
||||
redisTemplate.opsForSet().remove(getKey(black.getType()),black.getIpAddress());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkBlackIp(String ip){
|
||||
Boolean member = redisTemplate.opsForSet().isMember(getKey(1), ip);
|
||||
return BooleanUtils.isTrue(member);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkBlackMic(String ip){
|
||||
Boolean member = redisTemplate.opsForSet().isMember(getKey(2), ip);
|
||||
return BooleanUtils.isTrue(member);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class CitysServiceImpl extends ServiceImpl<CitysMapper, Citys> implements
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
|
||||
@PostConstruct
|
||||
// @PostConstruct
|
||||
public void init() {
|
||||
this.resetRedis();
|
||||
}
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
package com.ruoyi.cai.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.cai.domain.UserInfo;
|
||||
import com.ruoyi.cai.dto.admin.vo.UserInfoAdminVo;
|
||||
import com.ruoyi.cai.mapper.UserInfoMapper;
|
||||
import com.ruoyi.cai.service.UserInfoService;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@@ -15,4 +18,9 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo> i
|
||||
return this.getOne(Wrappers.lambdaQuery(UserInfo.class).eq(UserInfo::getUserId,userId)
|
||||
.last("limit 1"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<UserInfoAdminVo> pageAdmin(PageQuery pageQuery, UserInfoAdminVo bo) {
|
||||
return baseMapper.pageAdmin(pageQuery.build(),bo);
|
||||
}
|
||||
}
|
||||
|
||||
24
ruoyi-cai/src/main/resources/mapper/cai/UserInfoMapper.xml
Normal file
24
ruoyi-cai/src/main/resources/mapper/cai/UserInfoMapper.xml
Normal file
@@ -0,0 +1,24 @@
|
||||
<?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.ruoyi.cai.mapper.UserInfoMapper">
|
||||
<select id="pageAdmin" resultType="com.ruoyi.cai.dto.admin.vo.UserInfoAdminVo">
|
||||
select t1.*,t2.usercode,t2.nickname,t2.mobile,t2.avatar,t2.gender,t2.is_anchor,t2.age
|
||||
from cai_user_info t1
|
||||
left join cai_user t2 on t1.user_id = t2.id
|
||||
<where>
|
||||
<if test="bo.mobile != null and bo.mobile != ''">
|
||||
and t2.mobile = #{bo.mobile}
|
||||
</if>
|
||||
<if test="bo.usercode != null and bo.usercode != ''">
|
||||
and t2.usercode = #{bo.usercode}
|
||||
</if>
|
||||
<if test="bo.gender != null">
|
||||
and t2.gender = #{bo.gender}
|
||||
</if>
|
||||
<if test="bo.isAnchor != null">
|
||||
and t2.is_anchor = #{bo.isAnchor}
|
||||
</if>
|
||||
</where>
|
||||
order by t2.create_time desc
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import com.ruoyi.common.core.service.SensitiveService;
|
||||
import com.ruoyi.common.helper.LoginHelper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
@@ -26,9 +27,9 @@ public class SysSensitiveServiceImpl implements SensitiveService {
|
||||
*/
|
||||
@Override
|
||||
public boolean isSensitive() {
|
||||
/*if(LoginHelper.isAdmin()){
|
||||
if(LoginHelper.isAdmin()){
|
||||
return false;
|
||||
}*/
|
||||
}
|
||||
return SENSITIVE;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user