补充基础表
This commit is contained in:
@@ -0,0 +1,132 @@
|
||||
package com.gxwebsoft.common.system.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.common.system.service.UserRefereeService;
|
||||
import com.gxwebsoft.common.system.entity.UserReferee;
|
||||
import com.gxwebsoft.common.system.param.UserRefereeParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户推荐关系表控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-10-07 22:56:36
|
||||
*/
|
||||
@Api(tags = "用户推荐关系表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/common.system/user-referee")
|
||||
public class UserRefereeController extends BaseController {
|
||||
@Resource
|
||||
private UserRefereeService userRefereeService;
|
||||
|
||||
@PreAuthorize("hasAuthority('common.system:userReferee:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询用户推荐关系表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<UserReferee>> page(UserRefereeParam param) {
|
||||
// 使用关联查询
|
||||
return success(userRefereeService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('common.system:userReferee:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部用户推荐关系表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<UserReferee>> list(UserRefereeParam param) {
|
||||
// 使用关联查询
|
||||
return success(userRefereeService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('common.system:userReferee:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询用户推荐关系表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<UserReferee> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(userRefereeService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('common.system:userReferee:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加用户推荐关系表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody UserReferee userReferee) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
userReferee.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (userRefereeService.save(userReferee)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('common.system:userReferee:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改用户推荐关系表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody UserReferee userReferee) {
|
||||
if (userRefereeService.updateById(userReferee)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('common.system:userReferee:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除用户推荐关系表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (userRefereeService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('common.system:userReferee:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加用户推荐关系表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<UserReferee> list) {
|
||||
if (userRefereeService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('common.system:userReferee:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改用户推荐关系表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<UserReferee> batchParam) {
|
||||
if (batchParam.update(userRefereeService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('common.system:userReferee:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除用户推荐关系表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (userRefereeService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.gxwebsoft.common.system.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 用户推荐关系表
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-10-07 22:56:36
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value = "UserReferee对象", description = "用户推荐关系表")
|
||||
@TableName("sys_user_referee")
|
||||
public class UserReferee implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "主键ID")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "推荐人ID")
|
||||
private Integer dealerId;
|
||||
|
||||
@ApiModelProperty(value = "用户id(被推荐人)")
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty(value = "推荐关系层级(1,2,3)")
|
||||
private Integer level;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String comments;
|
||||
|
||||
@ApiModelProperty(value = "是否删除, 0否, 1是")
|
||||
@TableLogic
|
||||
private Integer deleted;
|
||||
|
||||
@ApiModelProperty(value = "租户id")
|
||||
private Integer tenantId;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty(value = "修改时间")
|
||||
private Date updateTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.gxwebsoft.common.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.gxwebsoft.common.system.entity.UserReferee;
|
||||
import com.gxwebsoft.common.system.param.UserRefereeParam;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户推荐关系表Mapper
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-10-07 22:56:36
|
||||
*/
|
||||
public interface UserRefereeMapper extends BaseMapper<UserReferee> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param param 查询参数
|
||||
* @return List<UserReferee>
|
||||
*/
|
||||
List<UserReferee> selectPageRel(@Param("page") IPage<UserReferee> page,
|
||||
@Param("param") UserRefereeParam param);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<User>
|
||||
*/
|
||||
List<UserReferee> selectListRel(@Param("param") UserRefereeParam param);
|
||||
|
||||
}
|
||||
@@ -39,8 +39,8 @@
|
||||
<include refid="selectUserRoleSql"/>
|
||||
) d ON a.user_id = d.user_id
|
||||
LEFT JOIN sys_tenant e ON a.tenant_id = e.tenant_id
|
||||
LEFT JOIN shop_user_grade g ON a.grade_id = g.grade_id
|
||||
LEFT JOIN shop_user_referee h ON a.user_id = h.user_id and h.deleted = 0
|
||||
LEFT JOIN sys_user_grade g ON a.grade_id = g.grade_id
|
||||
LEFT JOIN sys_user_referee h ON a.user_id = h.user_id and h.deleted = 0
|
||||
<where>
|
||||
<if test="param.userId != null">
|
||||
AND a.user_id = #{param.userId}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
<?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.gxwebsoft.common.system.mapper.UserRefereeMapper">
|
||||
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*
|
||||
FROM sys_user_referee a
|
||||
<where>
|
||||
<if test="param.id != null">
|
||||
AND a.id = #{param.id}
|
||||
</if>
|
||||
<if test="param.dealerId != null">
|
||||
AND a.dealer_id = #{param.dealerId}
|
||||
</if>
|
||||
<if test="param.userId != null">
|
||||
AND a.user_id = #{param.userId}
|
||||
</if>
|
||||
<if test="param.level != null">
|
||||
AND a.level = #{param.level}
|
||||
</if>
|
||||
<if test="param.comments != null">
|
||||
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
|
||||
</if>
|
||||
<if test="param.deleted != null">
|
||||
AND a.deleted = #{param.deleted}
|
||||
</if>
|
||||
<if test="param.deleted == null">
|
||||
AND a.deleted = 0
|
||||
</if>
|
||||
<if test="param.createTimeStart != null">
|
||||
AND a.create_time >= #{param.createTimeStart}
|
||||
</if>
|
||||
<if test="param.createTimeEnd != null">
|
||||
AND a.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="selectPageRel" resultType="com.gxwebsoft.common.system.entity.UserReferee">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="selectListRel" resultType="com.gxwebsoft.common.system.entity.UserReferee">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.gxwebsoft.common.system.param;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.gxwebsoft.common.core.annotation.QueryField;
|
||||
import com.gxwebsoft.common.core.annotation.QueryType;
|
||||
import com.gxwebsoft.common.core.web.BaseParam;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 用户推荐关系表查询参数
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-10-07 22:56:36
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@ApiModel(value = "UserRefereeParam对象", description = "用户推荐关系表查询参数")
|
||||
public class UserRefereeParam extends BaseParam {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "主键ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "推荐人ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer dealerId;
|
||||
|
||||
@ApiModelProperty(value = "用户id(被推荐人)")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty(value = "推荐关系层级(1,2,3)")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer level;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String comments;
|
||||
|
||||
@ApiModelProperty(value = "是否删除, 0否, 1是")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer deleted;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.gxwebsoft.common.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.system.entity.UserReferee;
|
||||
import com.gxwebsoft.common.system.param.UserRefereeParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户推荐关系表Service
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-10-07 22:56:36
|
||||
*/
|
||||
public interface UserRefereeService extends IService<UserReferee> {
|
||||
|
||||
/**
|
||||
* 分页关联查询
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return PageResult<UserReferee>
|
||||
*/
|
||||
PageResult<UserReferee> pageRel(UserRefereeParam param);
|
||||
|
||||
/**
|
||||
* 关联查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<UserReferee>
|
||||
*/
|
||||
List<UserReferee> listRel(UserRefereeParam param);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*
|
||||
* @param id 主键ID
|
||||
* @return UserReferee
|
||||
*/
|
||||
UserReferee getByIdRel(Integer id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.gxwebsoft.common.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.common.system.mapper.UserRefereeMapper;
|
||||
import com.gxwebsoft.common.system.service.UserRefereeService;
|
||||
import com.gxwebsoft.common.system.entity.UserReferee;
|
||||
import com.gxwebsoft.common.system.param.UserRefereeParam;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户推荐关系表Service实现
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-10-07 22:56:36
|
||||
*/
|
||||
@Service
|
||||
public class UserRefereeServiceImpl extends ServiceImpl<UserRefereeMapper, UserReferee> implements UserRefereeService {
|
||||
|
||||
@Override
|
||||
public PageResult<UserReferee> pageRel(UserRefereeParam param) {
|
||||
PageParam<UserReferee, UserRefereeParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
List<UserReferee> list = baseMapper.selectPageRel(page, param);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserReferee> listRel(UserRefereeParam param) {
|
||||
List<UserReferee> list = baseMapper.selectListRel(param);
|
||||
// 排序
|
||||
PageParam<UserReferee, UserRefereeParam> page = new PageParam<>();
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return page.sortRecords(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserReferee getByIdRel(Integer id) {
|
||||
UserRefereeParam param = new UserRefereeParam();
|
||||
param.setId(id);
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -51,7 +51,8 @@ public class SysGenerator {
|
||||
// "sys_plug",
|
||||
// "sys_company"
|
||||
// "sys_user_oauth"
|
||||
"sys_user_grade"
|
||||
// "sys_user_grade"
|
||||
"sys_user_referee"
|
||||
|
||||
};
|
||||
// 需要去除的表前缀
|
||||
|
||||
Reference in New Issue
Block a user