用户模块
This commit is contained in:
parent
6e0576df5b
commit
9fb9d51ed1
|
@ -0,0 +1,148 @@
|
|||
package com.greenorange.promotion.controller.promoCode;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.greenorange.promotion.annotation.RequiresPermission;
|
||||
import com.greenorange.promotion.annotation.SysLog;
|
||||
import com.greenorange.promotion.common.BaseResponse;
|
||||
import com.greenorange.promotion.common.ErrorCode;
|
||||
import com.greenorange.promotion.common.ResultUtils;
|
||||
import com.greenorange.promotion.constant.UserConstant;
|
||||
import com.greenorange.promotion.exception.ThrowUtils;
|
||||
import com.greenorange.promotion.model.dto.CommonBatchRequest;
|
||||
import com.greenorange.promotion.model.dto.promoCode.PromoCodeAddRequest;
|
||||
import com.greenorange.promotion.model.dto.promoCode.PromoCodeQueryRequest;
|
||||
import com.greenorange.promotion.model.dto.promoCode.PromoCodeUpdateRequest;
|
||||
import com.greenorange.promotion.model.entity.PromoCode;
|
||||
import com.greenorange.promotion.model.vo.promoCode.PromoCodeVO;
|
||||
import com.greenorange.promotion.service.common.CommonService;
|
||||
import com.greenorange.promotion.service.project.PromoCodeService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.greenorange.promotion.model.dto.CommonRequest;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 推广码 控制器
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("promoCode")
|
||||
@Slf4j
|
||||
@Tag(name = "推广码管理")
|
||||
public class PromoCodeController {
|
||||
|
||||
@Resource
|
||||
private PromoCodeService promoCodeService;
|
||||
|
||||
@Resource
|
||||
private CommonService commonService;
|
||||
|
||||
/**
|
||||
* web端管理员添加推广码
|
||||
* @param promoCodeAddRequest 推广码添加请求体
|
||||
* @return 是否添加成功
|
||||
*/
|
||||
@PostMapping("add")
|
||||
@Operation(summary = "web端管理员添加推广码", description = "参数:推广码添加请求体,权限:管理员,方法名:addPromoCode")
|
||||
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
|
||||
@SysLog(title = "推广码管理", content = "web端管理员添加推广码")
|
||||
public BaseResponse<Boolean> addPromoCode(@Valid @RequestBody PromoCodeAddRequest promoCodeAddRequest) {
|
||||
PromoCode promoCode = commonService.copyProperties(promoCodeAddRequest, PromoCode.class);
|
||||
promoCodeService.save(promoCode);
|
||||
return ResultUtils.success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* web端管理员根据id修改推广码信息
|
||||
* @param promoCodeUpdateRequest 推广码更新请求体
|
||||
* @return 是否更新成功
|
||||
*/
|
||||
@PostMapping("update")
|
||||
@Operation(summary = "web端管理员更新推广码", description = "参数:推广码更新请求体,权限:管理员,方法名:updatePromoCode")
|
||||
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
|
||||
@SysLog(title = "推广码管理", content = "web端管理员根据id修改推广码信息")
|
||||
public BaseResponse<Boolean> updatePromoCode(@Valid @RequestBody PromoCodeUpdateRequest promoCodeUpdateRequest) {
|
||||
PromoCode promoCode = commonService.copyProperties(promoCodeUpdateRequest, PromoCode.class);
|
||||
promoCodeService.updateById(promoCode);
|
||||
return ResultUtils.success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* web端管理员根据id删除推广码
|
||||
* @param commonRequest 推广码删除请求体
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@PostMapping("delete")
|
||||
@Operation(summary = "web端管理员根据id删除推广码", description = "参数:推广码删除请求体,权限:管理员,方法名:delPromoCode")
|
||||
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
|
||||
@SysLog(title = "推广码管理", content = "web端管理员根据id删除推广码")
|
||||
public BaseResponse<Boolean> delPromoCode(@Valid @RequestBody CommonRequest commonRequest) {
|
||||
Long id = commonRequest.getId();
|
||||
promoCodeService.removeById(id);
|
||||
return ResultUtils.success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* web端管理员批量删除推广码
|
||||
* @param commonBatchRequest 推广码批量删除请求体
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@PostMapping("delBatch")
|
||||
@Operation(summary = "web端管理员批量删除推广码", description = "参数:推广码批量删除请求体,权限:管理员,方法名:delBatchPromoCode")
|
||||
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
|
||||
@SysLog(title = "推广码管理", content = "web端管理员批量删除推广码")
|
||||
public BaseResponse<Boolean> delBatchPromoCode(@Valid @RequestBody CommonBatchRequest commonBatchRequest) {
|
||||
List<Long> ids = commonBatchRequest.getIds();
|
||||
promoCodeService.removeByIds(ids);
|
||||
return ResultUtils.success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* web端管理员根据id查询推广码
|
||||
* @param commonRequest 推广码查询请求体
|
||||
* @return 推广码信息
|
||||
*/
|
||||
@PostMapping("queryById")
|
||||
@Operation(summary = "web端管理员根据id查询推广码", description = "参数:推广码查询请求体,权限:管理员,方法名:queryPromoCodeById")
|
||||
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
|
||||
@SysLog(title = "推广码管理", content = "web端管理员根据id查询推广码")
|
||||
public BaseResponse<PromoCodeVO> queryPromoCodeById(@Valid @RequestBody CommonRequest commonRequest) {
|
||||
Long id = commonRequest.getId();
|
||||
PromoCode promoCode = promoCodeService.getById(id);
|
||||
ThrowUtils.throwIf(promoCode == null, ErrorCode.OPERATION_ERROR, "当前推广码不存在");
|
||||
PromoCodeVO promoCodeVO = commonService.copyProperties(promoCode, PromoCodeVO.class);
|
||||
return ResultUtils.success(promoCodeVO);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Web端管理员分页查询推广码
|
||||
// * @param promoCodeQueryRequest 推广码查询请求体
|
||||
// * @return 推广码列表
|
||||
// */
|
||||
// @PostMapping("page")
|
||||
// @Operation(summary = "Web端管理员分页查询推广码", description = "参数:推广码查询请求体,权限:管理员,方法名:listPromoCodeByPage")
|
||||
// @RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
|
||||
// @SysLog(title = "推广码管理", content = "Web端管理员分页查询推广码")
|
||||
// public BaseResponse<Page<PromoCodeVO>> listPromoCodeByPage(@Valid @RequestBody PromoCodeQueryRequest promoCodeQueryRequest) {
|
||||
// long current = promoCodeQueryRequest.getCurrent();
|
||||
// long pageSize = promoCodeQueryRequest.getPageSize();
|
||||
// QueryWrapper<PromoCode> queryWrapper = promoCodeService.getQueryWrapper(promoCodeQueryRequest);
|
||||
// Page<PromoCode> page = promoCodeService.page(new Page<>(current, pageSize), queryWrapper);
|
||||
// List<PromoCode> promoCodeList = page.getRecords();
|
||||
// List<PromoCodeVO> promoCodeVOList = commonService.convertList(promoCodeList, PromoCodeVO.class);
|
||||
// Page<PromoCodeVO> voPage = new Page<>(current, pageSize);
|
||||
// voPage.setRecords(promoCodeVOList);
|
||||
// voPage.setPages(page.getPages());
|
||||
// voPage.setTotal(page.getTotal());
|
||||
// return ResultUtils.success(voPage);
|
||||
// }
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.greenorange.promotion.mapper;
|
||||
|
||||
import com.greenorange.promotion.model.entity.PromoCode;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @author 35880
|
||||
* @description 针对表【promo_code(推广码信息表)】的数据库操作Mapper
|
||||
* @createDate 2025-05-07 04:02:32
|
||||
* @Entity com.greenorange.promotion.model.entity.PromoCode
|
||||
*/
|
||||
public interface PromoCodeMapper extends BaseMapper<PromoCode> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
package com.greenorange.promotion.model.dto.promoCode;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 推广码添加请求体
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "推广码添加请求体", requiredProperties = {
|
||||
"promoCodeInfoKey",
|
||||
"promoCodeLink",
|
||||
"projectId",
|
||||
"promoCodeStatus",
|
||||
})
|
||||
public class PromoCodeAddRequest implements Serializable {
|
||||
|
||||
/**
|
||||
* 推广码信息key
|
||||
*/
|
||||
@NotBlank(message = "推广码信息key不能为空")
|
||||
@Schema(description = "推广码信息key", example = "")
|
||||
private String promoCodeInfoKey;
|
||||
|
||||
/**
|
||||
* 推广码链接
|
||||
*/
|
||||
@NotBlank(message = "推广码链接不能为空")
|
||||
@Schema(description = "推广码链接", example = "")
|
||||
private String promoCodeLink;
|
||||
|
||||
/**
|
||||
* 项目ID
|
||||
*/
|
||||
@Min(value = 1L, message = "项目ID ID不能小于1")
|
||||
@Schema(description = "项目ID", example = "")
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 推广码状态
|
||||
*/
|
||||
@NotBlank(message = "推广码状态不能为空")
|
||||
@Schema(description = "推广码状态", example = "")
|
||||
private String promoCodeStatus;
|
||||
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
package com.greenorange.promotion.model.dto.promoCode;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import com.greenorange.promotion.common.PageRequest;
|
||||
|
||||
/**
|
||||
* 推广码查询请求体,继承自分页请求 PageRequest
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "推广码查询请求体", requiredProperties = {"current", "pageSize"})
|
||||
public class PromoCodeQueryRequest extends PageRequest implements Serializable {
|
||||
|
||||
/**
|
||||
* 推广码ID
|
||||
*/
|
||||
@Min(value = 1L, message = "推广码ID ID不能小于1")
|
||||
@Schema(description = "推广码ID", example = "")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 推广码信息key
|
||||
*/
|
||||
@NotBlank(message = "推广码信息key不能为空")
|
||||
@Schema(description = "推广码信息key", example = "")
|
||||
private String promoCodeInfoKey;
|
||||
|
||||
/**
|
||||
* 推广码链接
|
||||
*/
|
||||
@NotBlank(message = "推广码链接不能为空")
|
||||
@Schema(description = "推广码链接", example = "")
|
||||
private String promoCodeLink;
|
||||
|
||||
/**
|
||||
* 项目ID
|
||||
*/
|
||||
@Min(value = 1L, message = "项目ID ID不能小于1")
|
||||
@Schema(description = "项目ID", example = "")
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 推广码状态
|
||||
*/
|
||||
@NotBlank(message = "推广码状态不能为空")
|
||||
@Schema(description = "推广码状态", example = "")
|
||||
private String promoCodeStatus;
|
||||
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
package com.greenorange.promotion.model.dto.promoCode;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 推广码更新请求体
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "推广码更新请求体", requiredProperties = {
|
||||
"id",
|
||||
"promoCodeInfoKey",
|
||||
"promoCodeLink",
|
||||
"projectId",
|
||||
"promoCodeStatus",
|
||||
})
|
||||
public class PromoCodeUpdateRequest implements Serializable {
|
||||
|
||||
/**
|
||||
* 推广码ID
|
||||
*/
|
||||
@Min(value = 1L, message = "推广码ID ID不能小于1")
|
||||
@Schema(description = "推广码ID", example = "")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 推广码信息key
|
||||
*/
|
||||
@NotBlank(message = "推广码信息key不能为空")
|
||||
@Schema(description = "推广码信息key", example = "")
|
||||
private String promoCodeInfoKey;
|
||||
|
||||
/**
|
||||
* 推广码链接
|
||||
*/
|
||||
@NotBlank(message = "推广码链接不能为空")
|
||||
@Schema(description = "推广码链接", example = "")
|
||||
private String promoCodeLink;
|
||||
|
||||
/**
|
||||
* 项目ID
|
||||
*/
|
||||
@Min(value = 1L, message = "项目ID ID不能小于1")
|
||||
@Schema(description = "项目ID", example = "")
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 推广码状态
|
||||
*/
|
||||
@NotBlank(message = "推广码状态不能为空")
|
||||
@Schema(description = "推广码状态", example = "")
|
||||
private String promoCodeStatus;
|
||||
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package com.greenorange.promotion.model.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 推广码信息表
|
||||
* @TableName promo_code
|
||||
*/
|
||||
@TableName(value ="promo_code")
|
||||
@Data
|
||||
public class PromoCode implements Serializable {
|
||||
/**
|
||||
* 推广码ID
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 推广码信息key
|
||||
*/
|
||||
private String promoCodeInfoKey;
|
||||
|
||||
/**
|
||||
* 推广码链接
|
||||
*/
|
||||
private String promoCodeLink;
|
||||
|
||||
/**
|
||||
* 项目ID
|
||||
*/
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 推广码状态
|
||||
*/
|
||||
private Object promoCodeStatus;
|
||||
|
||||
/**
|
||||
* 是否删除
|
||||
*/
|
||||
private Integer isDelete;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package com.greenorange.promotion.model.vo.promoCode;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 推广码 视图对象
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "推广码 视图对象")
|
||||
public class PromoCodeVO implements Serializable {
|
||||
|
||||
/**
|
||||
* 推广码ID
|
||||
*/
|
||||
@Schema(description = "推广码ID", example = "1")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 推广码信息key
|
||||
*/
|
||||
@Schema(description = "推广码信息key", example = "${field.example}")
|
||||
private String promoCodeInfoKey;
|
||||
|
||||
/**
|
||||
* 推广码链接
|
||||
*/
|
||||
@Schema(description = "推广码链接", example = "${field.example}")
|
||||
private String promoCodeLink;
|
||||
|
||||
/**
|
||||
* 项目ID
|
||||
*/
|
||||
@Schema(description = "项目ID", example = "${field.example}")
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 推广码状态
|
||||
*/
|
||||
@Schema(description = "推广码状态", example = "${field.example}")
|
||||
private String promoCodeStatus;
|
||||
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.greenorange.promotion.service.project;
|
||||
|
||||
import com.greenorange.promotion.model.entity.PromoCode;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @author 35880
|
||||
* @description 针对表【promo_code(推广码信息表)】的数据库操作Service
|
||||
* @createDate 2025-05-07 04:02:32
|
||||
*/
|
||||
public interface PromoCodeService extends IService<PromoCode> {
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.greenorange.promotion.service.project.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.greenorange.promotion.model.entity.PromoCode;
|
||||
import com.greenorange.promotion.service.project.PromoCodeService;
|
||||
import com.greenorange.promotion.mapper.PromoCodeMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author 35880
|
||||
* @description 针对表【promo_code(推广码信息表)】的数据库操作Service实现
|
||||
* @createDate 2025-05-07 04:02:32
|
||||
*/
|
||||
@Service
|
||||
public class PromoCodeServiceImpl extends ServiceImpl<PromoCodeMapper, PromoCode>
|
||||
implements PromoCodeService{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
23
src/main/resources/mapper/PromoCodeMapper.xml
Normal file
23
src/main/resources/mapper/PromoCodeMapper.xml
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?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.greenorange.promotion.mapper.PromoCodeMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.greenorange.promotion.model.entity.PromoCode">
|
||||
<id property="id" column="id" jdbcType="BIGINT"/>
|
||||
<result property="promoCodeInfoKey" column="promoCodeInfoKey" jdbcType="VARCHAR"/>
|
||||
<result property="promoCodeLink" column="promoCodeLink" jdbcType="VARCHAR"/>
|
||||
<result property="projectId" column="projectId" jdbcType="BIGINT"/>
|
||||
<result property="promoCodeStatus" column="promoCodeStatus" jdbcType="OTHER"/>
|
||||
<result property="isDelete" column="isDelete" jdbcType="TINYINT"/>
|
||||
<result property="createTime" column="createTime" jdbcType="TIMESTAMP"/>
|
||||
<result property="updateTime" column="updateTime" jdbcType="TIMESTAMP"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id,promoCodeInfoKey,promoCodeLink,
|
||||
projectId,promoCodeStatus,isDelete,
|
||||
createTime,updateTime
|
||||
</sql>
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user