Commit 4c4b2d16 authored by liwei's avatar liwei

新增了黑明单的新增和分页查询

parent a894b60b
package org.rcisoft.app.appOpmBlackList.controller;
/*固定导入*/
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.servlet.http.HttpServletResponse;
import org.rcisoft.business.opmBlacklist.entity.OpmBlackList;
import org.rcisoft.business.opmBlacklist.service.OpmBlackListService;
import org.rcisoft.core.anno.CyOpeLogAnno;
import org.rcisoft.core.constant.CyMessCons;
import org.rcisoft.core.controller.CyPaginationController;
import org.rcisoft.core.model.CyGridModel;
import org.rcisoft.core.model.CyPersistModel;
import org.rcisoft.core.operlog.enums.CyLogTypeEnum;
import org.rcisoft.core.result.CyResult;
import org.rcisoft.core.util.CyEpExcelUtil;
import org.rcisoft.core.util.CyResultGenUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
/**
* Created by cy on 2025年2月10日 上午9:46:37.
*/
@RestController
@RequestMapping("/app")
public class AppOpmBlackListController extends CyPaginationController<OpmBlackList> {
@Autowired
private OpmBlackListService opmBlackListServiceImpl;
@PreAuthorize("@cyPerm.hasPerm('app:blackList:add')")
@CyOpeLogAnno(title = "system-黑名单表管理-新增黑名单表", businessType = CyLogTypeEnum.INSERT)
@Operation(summary="添加黑名单表", description="添加黑名单表")
@PostMapping(value = "/opmBlackList/add")
public CyResult add(@Valid @RequestBody OpmBlackList opmBlackList, BindingResult bindingResult) {
CyPersistModel data = opmBlackListServiceImpl.persist(opmBlackList);
return CyResultGenUtil.builder(data,
CyMessCons.MESSAGE_ALERT_SUCCESS,
CyMessCons.MESSAGE_ALERT_ERROR,
opmBlackList);
}
@PreAuthorize("@cyPerm.hasPerm('app:blackList:list')")
@CyOpeLogAnno(title = "system-黑名单表管理-查询黑名单表", businessType = CyLogTypeEnum.QUERY)
@Operation(summary="分页查询黑名单表集合", description="分页查询黑名单表集合")
@GetMapping(value = "/opmBlackList/list")
public CyGridModel listByPagination(OpmBlackList opmBlackList) {
opmBlackListServiceImpl.findAllByPagination(getPaginationUtility(), opmBlackList);
return getGridModelResponse();
}
@PreAuthorize("@cyPerm.hasPerm('app:blackList:delete')")
@CyOpeLogAnno(title = "system-黑名单表管理-删除黑名单表", businessType = CyLogTypeEnum.DELETE)
@Operation(summary="删除黑名单表", description="删除黑名单表")
@Parameters({@Parameter(name = "businessId", description = "businessId", required = true, schema = @Schema(type = "string"))})
@DeleteMapping("/opmBlackList/delete/{businessId:\\w+}")
public CyResult delete(@PathVariable int businessId,OpmBlackList opmBlackList) {
opmBlackList.setBusinessId(businessId);
CyPersistModel data = opmBlackListServiceImpl.remove(opmBlackList);
return CyResultGenUtil.builder(data,
CyMessCons.MESSAGE_ALERT_SUCCESS,
CyMessCons.MESSAGE_ALERT_ERROR,
businessId);
}
}
......@@ -9,6 +9,7 @@ import io.swagger.v3.oas.annotations.Operation;
import org.rcisoft.core.anno.CyOpeLogAnno;
import org.rcisoft.core.operlog.enums.CyLogTypeEnum;
import org.rcisoft.core.util.CyEpExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.BindingResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
......@@ -34,14 +35,14 @@ import java.util.List;
* Created by cy on 2025年2月10日 上午9:46:37.
*/
@RestController
@RequestMapping("/opmblacklist")
@RequestMapping("/opmBlackList")
public class OpmBlackListController extends CyPaginationController<OpmBlackList> {
@Autowired
private OpmBlackListService opmBlackListServiceImpl;
//@PreAuthorize("@cyPerm.hasPerm('sys:blackList:add')")
@PreAuthorize("@cyPerm.hasPerm('sys:blackList:add')")
@CyOpeLogAnno(title = "system-黑名单表管理-新增黑名单表", businessType = CyLogTypeEnum.INSERT)
@Operation(summary="添加黑名单表", description="添加黑名单表")
@PostMapping(value = "/add")
......@@ -52,13 +53,14 @@ public class OpmBlackListController extends CyPaginationController<OpmBlackList>
CyMessCons.MESSAGE_ALERT_ERROR,
opmBlackList);
}
//@PreAuthorize("@cyPerm.hasPerm('sys:blackList:delete')")
@PreAuthorize("@cyPerm.hasPerm('sys:blackList:delete')")
@CyOpeLogAnno(title = "system-黑名单表管理-删除黑名单表", businessType = CyLogTypeEnum.DELETE)
@Operation(summary="删除黑名单表", description="删除黑名单表")
@Parameters({@Parameter(name = "businessId", description = "businessId", required = true, schema = @Schema(type = "string"))})
@DeleteMapping("/delete/{businessId:\\w+}")
public CyResult delete(@PathVariable int businessId,OpmBlackList opmBlackList) {
opmBlackList.setBusinessId(String.valueOf(businessId));
opmBlackList.setBusinessId(businessId);
CyPersistModel data = opmBlackListServiceImpl.remove(opmBlackList);
return CyResultGenUtil.builder(data,
CyMessCons.MESSAGE_ALERT_SUCCESS,
......@@ -66,13 +68,13 @@ public class OpmBlackListController extends CyPaginationController<OpmBlackList>
businessId);
}
//@PreAuthorize("@cyPerm.hasPerm('sys:blackList:update')")
@PreAuthorize("@cyPerm.hasPerm('sys:blackList:update')")
@CyOpeLogAnno(title = "system-黑名单表管理-修改黑名单表", businessType = CyLogTypeEnum.UPDATE)
@Operation(summary="修改黑名单表", description="修改黑名单表")
@Parameters({@Parameter(name = "businessId", description = "businessId", required = false, schema = @Schema(type = "string"))})
@PutMapping("/update/{businessId:\\w+}")
public CyResult update(@PathVariable int businessId, @Valid OpmBlackList opmBlackList, BindingResult bindingResult) {
opmBlackList.setBusinessId(String.valueOf(businessId));
opmBlackList.setBusinessId(businessId);
CyPersistModel data = opmBlackListServiceImpl.merge(opmBlackList);
return CyResultGenUtil.builder(data,
CyMessCons.MESSAGE_ALERT_SUCCESS,
......@@ -80,7 +82,7 @@ public class OpmBlackListController extends CyPaginationController<OpmBlackList>
opmBlackList);
}
//@PreAuthorize("@cyPerm.hasPerm('sys:blackList:query')")
@PreAuthorize("@cyPerm.hasPerm('sys:blackList:query')")
@CyOpeLogAnno(title = "system-黑名单表管理-查询黑名单表", businessType = CyLogTypeEnum.QUERY)
@Operation(summary="查询单一黑名单表", description="查询单一黑名单表")
@Parameters({@Parameter(name = "businessId", description = "businessId", required = true, schema = @Schema(type = "string"))})
......@@ -92,7 +94,7 @@ public class OpmBlackListController extends CyPaginationController<OpmBlackList>
opmBlackListServiceImpl.findById(businessId));
}
//@PreAuthorize("@cyPerm.hasPerm('sys:blackList:list')")
@PreAuthorize("@cyPerm.hasPerm('sys:blackList:list')")
@CyOpeLogAnno(title = "system-黑名单表管理-查询黑名单表", businessType = CyLogTypeEnum.QUERY)
@Operation(summary="查询黑名单表集合", description="查询黑名单表集合")
@GetMapping(value = "/listAll")
......@@ -103,7 +105,7 @@ public class OpmBlackListController extends CyPaginationController<OpmBlackList>
opmBlackListServiceImpl.findAll(opmBlackList));
}
//@PreAuthorize("@cyPerm.hasPerm('sys:blackList:list')")
@PreAuthorize("@cyPerm.hasPerm('sys:blackList:list')")
@CyOpeLogAnno(title = "system-黑名单表管理-查询黑名单表", businessType = CyLogTypeEnum.QUERY)
@Operation(summary="分页查询黑名单表集合", description="分页查询黑名单表集合")
@GetMapping(value = "/list")
......
......@@ -6,6 +6,8 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.*;
import org.rcisoft.core.entity.CyIdIncreEntity;
import org.rcisoft.core.entity.CyIdIncreNotDataEntity;
import org.rcisoft.core.entity.CyIdNotDataEntity;
import org.springframework.format.annotation.DateTimeFormat;
......@@ -20,13 +22,13 @@ import java.util.List;
*/
@Data
@TableName("opm_black_list")
public class OpmBlackList extends CyIdNotDataEntity<OpmBlackList> {
public class OpmBlackList extends CyIdIncreNotDataEntity<OpmBlackList> {
/**
* @desc 创建时间
* @column create_date
* @default
* @default
*/
@JsonFormat(
pattern = "yyyy-MM-dd"
......@@ -38,7 +40,7 @@ public class OpmBlackList extends CyIdNotDataEntity<OpmBlackList> {
/**
* @desc 用户id
* @column user_id
* @default
* @default
*/
@Excel(name = "用户id", orderNum = "1", width = 20)
private BigInteger userId;
......@@ -46,7 +48,7 @@ public class OpmBlackList extends CyIdNotDataEntity<OpmBlackList> {
/**
* @desc 目标id
* @column target_id
* @default
* @default
*/
@Excel(name = "目标id", orderNum = "2", width = 20)
private BigInteger targetId;
......@@ -65,5 +67,23 @@ public class OpmBlackList extends CyIdNotDataEntity<OpmBlackList> {
@TableField(exist = false)
private String endTime;
/**
* 会员ID
*/
@TableField(exist = false)
private Integer memberId;
/**
* 头像ID
*/
@TableField(exist = false)
private Integer avatar;
/**
* 会员昵称
*/
@TableField(exist = false)
private String memNickName;
}
......@@ -21,6 +21,8 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.rcisoft.core.model.CyPageInfo;
import java.math.BigInteger;
import java.util.Date;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
......@@ -42,6 +44,9 @@ public class OpmBlackListServiceImpl extends ServiceImpl<OpmBlackListRepository,
@Override
public CyPersistModel persist(OpmBlackList opmBlackList){
//增加操作
Integer userId = Integer.valueOf(CyUserUtil.getAuthenBusinessId());
opmBlackList.setUserId(BigInteger.valueOf(userId));
opmBlackList.setCreateDate(new Date());
int line = baseMapper.insert(opmBlackList);
log.debug(CyUserUtil.getAuthenUsername()+"新增了ID为"+
opmBlackList.getBusinessId()+"的黑名单表信息");
......@@ -93,6 +98,8 @@ public class OpmBlackListServiceImpl extends ServiceImpl<OpmBlackListRepository,
@Override
public IPage<OpmBlackList> findAllByPagination(CyPageInfo<OpmBlackList> paginationUtility,
OpmBlackList opmBlackList){
String userId = CyUserUtil.getAuthenBusinessId();
opmBlackList.setUserId(BigInteger.valueOf(Integer.valueOf(userId)));
return baseMapper.queryOpmBlackListsPaged(paginationUtility,opmBlackList);
}
......
<?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="org.rcisoft.business.opmBlacklist.dao.OpmBlackListRepository">
<resultMap id="BaseResultMap" type="org.rcisoft.business.opmBlacklist.entity.OpmBlackList">
<id column="business_id" jdbcType="BIGINT" property="businessId"/>
<result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
<result column="user_id" jdbcType="BIGINT" property="userId"/>
<result column="target_id" jdbcType="BIGINT" property="targetId"/>
</resultMap>
<!--<cache type="${corePackag!}.util.RedisCache"/>-->
<select id="queryOpmBlackLists" resultMap="BaseResultMap">
select * from opm_black_list
where 1=1
<if test="entity.userId !=null and entity.userId != '' ">
and user_id = #{entity.userId}
</if>
<if test="entity.targetId !=null and entity.targetId != '' ">
and target_id = #{entity.targetId}
</if>
ORDER BY business_id DESC
<select id="queryOpmBlackLists" resultType="org.rcisoft.business.opmBlacklist.entity.OpmBlackList">
SELECT
obl.*,
mi.business_id as memberId,
mi.avatar,
mi.mem_nick_name
FROM
opm_black_list obl
LEFT JOIN mem_info mi ON mi.user_id = obl.user_id
WHERE 1=1
AND obl.user_id = #{entity.userId}
ORDER BY
business_id DESC
</select>
<select id="queryOpmBlackListsPaged" resultMap="BaseResultMap">
select * from opm_black_list
where 1=1
<if test="entity.userId !=null and entity.userId != '' ">
and user_id = #{entity.userId}
</if>
<if test="entity.targetId !=null and entity.targetId != '' ">
and target_id = #{entity.targetId}
</if>
ORDER BY business_id DESC
<select id="queryOpmBlackListsPaged" resultType="org.rcisoft.business.opmBlacklist.entity.OpmBlackList">
SELECT
obl.*,
mi.business_id as memberId,
mi.mem_nick_name,
mi.avatar
FROM
opm_black_list obl
LEFT JOIN mem_info mi ON mi.user_id = obl.target_id
WHERE 1=1
AND obl.user_id = #{entity.userId}
ORDER BY
business_id DESC
</select>
</mapper>
\ No newline at end of file
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment