first commit
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package com.sqx.modules.sdk.controller;
|
||||
|
||||
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.annotation.Login;
|
||||
import com.sqx.modules.sdk.service.SdkInfoService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author wucahng
|
||||
* @since 2023-02-20
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/app/sdkInfo/")
|
||||
public class AppSdkInfoController {
|
||||
@Autowired
|
||||
private SdkInfoService infoService;
|
||||
|
||||
/**
|
||||
* 卡密兑换
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Login
|
||||
@PostMapping("sdkExchange")
|
||||
public Result sdkExchange(@RequestAttribute("userId") Long userId, String sdkContent) {
|
||||
return infoService.sdkExchange(userId, sdkContent);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.sqx.modules.sdk.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.sdk.entity.SdkInfo;
|
||||
import com.sqx.modules.sdk.service.SdkInfoService;
|
||||
import com.sqx.modules.utils.excel.ExcelData;
|
||||
import com.sqx.modules.utils.excel.ExportExcelUtils;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author wucahng
|
||||
* @since 2023-02-20
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/admin/sdkInfo/")
|
||||
public class SdkInfoController {
|
||||
@Autowired
|
||||
private SdkInfoService infoService;
|
||||
|
||||
/**
|
||||
* 生成卡密
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("saveSdkInfo")
|
||||
public Result saveSdkInfo(Long typeId, Integer num,Long sysUserId) {
|
||||
return infoService.saveSdkInfo(typeId, num,sysUserId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取卡密列表
|
||||
*/
|
||||
@GetMapping("getSdkList")
|
||||
public Result getSdkList(Integer page, Integer limit, SdkInfo sdkInfo) {
|
||||
return Result.success().put("data", infoService.getSdkList(page, limit, sdkInfo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除卡密
|
||||
*/
|
||||
@GetMapping("deleteSdk")
|
||||
public Result deleteSdk(String sdkIds) {
|
||||
return infoService.removeByIds(Arrays.asList(sdkIds.split(","))) ? Result.success() : Result.error();
|
||||
}
|
||||
|
||||
@GetMapping("excelCouponCardList")
|
||||
@ApiOperation("导出卡密列表")
|
||||
public void excelCouponCardList(SdkInfo sdkInfo, HttpServletResponse response) throws Exception{
|
||||
ExcelData excelData = infoService.excelSdkList(sdkInfo);
|
||||
ExportExcelUtils.exportExcel(response,"卡密列表.xlsx",excelData);
|
||||
}
|
||||
|
||||
@GetMapping("/selectSdkCount")
|
||||
@ApiOperation("卡密数据统计")
|
||||
public Result selectSdkCount(Integer type,String date){
|
||||
if(type==3){
|
||||
date = date.substring(0,4);
|
||||
}else if(type==2){
|
||||
date = date.substring(0,7);
|
||||
}
|
||||
int sdkCount = infoService.count(new QueryWrapper<SdkInfo>().like("create_time", date));
|
||||
int wsySdkCount = infoService.count(new QueryWrapper<SdkInfo>().like("create_time", date).eq("status",0));
|
||||
int ysySdkCount = infoService.count(new QueryWrapper<SdkInfo>().like("create_time", date).eq("status",1));
|
||||
int ygqSdkCount = infoService.count(new QueryWrapper<SdkInfo>().like("create_time", date).eq("status",2));
|
||||
Map<String,Integer> result=new HashMap<>();
|
||||
result.put("sdkCount",sdkCount);
|
||||
result.put("wsySdkCount",wsySdkCount);
|
||||
result.put("ysySdkCount",ysySdkCount);
|
||||
result.put("ygqSdkCount",ygqSdkCount);
|
||||
return Result.success().put("data",result);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.sqx.modules.sdk.controller;
|
||||
|
||||
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.sdk.entity.SdkType;
|
||||
import com.sqx.modules.sdk.service.SdkTypeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 卡密类型
|
||||
* </p>
|
||||
*
|
||||
* @author wuchang
|
||||
* @since 2023-02-20
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/admin/sdkType/")
|
||||
public class SdkTypeController {
|
||||
@Autowired
|
||||
private SdkTypeService sdkTypeService;
|
||||
|
||||
/**
|
||||
* 添加或修改卡密类型
|
||||
*/
|
||||
@PostMapping("saveSdkType")
|
||||
public Result saveSdkType(SdkType sdkType) {
|
||||
return sdkTypeService.saveSdkType(sdkType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取卡密类型列表
|
||||
*/
|
||||
@GetMapping("getSdkTypeList")
|
||||
public Result getSdkTypeList(Integer page, Integer limit, SdkType sdkType) {
|
||||
return Result.success().put("data", sdkTypeService.getSdkTypeList(page, limit, sdkType));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除卡密类型
|
||||
*/
|
||||
@GetMapping("deleteSdkType")
|
||||
public Result deleteSdkType(Long typeId) {
|
||||
return sdkTypeService.removeById(typeId) ? Result.success() : Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
28
src/main/java/com/sqx/modules/sdk/dao/SdkInfoDao.java
Normal file
28
src/main/java/com/sqx/modules/sdk/dao/SdkInfoDao.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package com.sqx.modules.sdk.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sqx.modules.sdk.entity.SdkInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author www.javacoder.top
|
||||
* @since 2023-02-20
|
||||
*/
|
||||
@Mapper
|
||||
public interface SdkInfoDao extends BaseMapper<SdkInfo> {
|
||||
|
||||
IPage<SdkInfo> getSdkPage(@Param("pages") Page<SdkInfo> pages, @Param("sdkInfo") SdkInfo sdkInfo);
|
||||
|
||||
|
||||
List<SdkInfo> getSdkList(@Param("sdkInfo") SdkInfo sdkInfo);
|
||||
|
||||
}
|
||||
18
src/main/java/com/sqx/modules/sdk/dao/SdkTypeDao.java
Normal file
18
src/main/java/com/sqx/modules/sdk/dao/SdkTypeDao.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package com.sqx.modules.sdk.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.sqx.modules.sdk.entity.SdkType;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author www.javacoder.top
|
||||
* @since 2023-02-20
|
||||
*/
|
||||
@Mapper
|
||||
public interface SdkTypeDao extends BaseMapper<SdkType> {
|
||||
|
||||
}
|
||||
92
src/main/java/com/sqx/modules/sdk/entity/SdkInfo.java
Normal file
92
src/main/java/com/sqx/modules/sdk/entity/SdkInfo.java
Normal file
@@ -0,0 +1,92 @@
|
||||
package com.sqx.modules.sdk.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.SqlCondition;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author www.javacoder.top
|
||||
* @since 2023-02-20
|
||||
*/
|
||||
@Data
|
||||
public class SdkInfo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 卡密id
|
||||
*/
|
||||
@TableId(value = "sdk_id", type = IdType.AUTO)
|
||||
private Long sdkId;
|
||||
|
||||
/**
|
||||
* 卡密内容
|
||||
*/
|
||||
private String sdkContent;
|
||||
|
||||
/**
|
||||
* 卡密类型id
|
||||
*/
|
||||
private Long typeId;
|
||||
|
||||
/**
|
||||
* 0未使用 1已使用 2已过期
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 天数
|
||||
*/
|
||||
private Integer giveNum;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private String createTime;
|
||||
|
||||
/**
|
||||
* 过期时间
|
||||
*/
|
||||
private String overdueTime;
|
||||
/**
|
||||
* 使用时间
|
||||
*/
|
||||
private String useTime;
|
||||
|
||||
/**
|
||||
* 渠道商
|
||||
*/
|
||||
private Long sysUserId;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String sysUserName;
|
||||
|
||||
/**
|
||||
* 类型备注
|
||||
*/
|
||||
@TableField(condition = SqlCondition.LIKE)
|
||||
private String sdkRemarks;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String nickName;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String startTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String endTime;
|
||||
|
||||
|
||||
}
|
||||
52
src/main/java/com/sqx/modules/sdk/entity/SdkType.java
Normal file
52
src/main/java/com/sqx/modules/sdk/entity/SdkType.java
Normal file
@@ -0,0 +1,52 @@
|
||||
package com.sqx.modules.sdk.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.SqlCondition;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author www.javacoder.top
|
||||
* @since 2023-02-20
|
||||
*/
|
||||
@Data
|
||||
public class SdkType implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* sdk类型
|
||||
*/
|
||||
@TableId(value = "type_id", type = IdType.AUTO)
|
||||
private Long typeId;
|
||||
|
||||
/**
|
||||
* 赠送天数
|
||||
*/
|
||||
private Integer giveNum;
|
||||
|
||||
|
||||
/**
|
||||
* 有效天数
|
||||
*/
|
||||
private Integer validDay;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private String createTime;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@TableField(condition = SqlCondition.LIKE)
|
||||
private String remarks;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.sqx.modules.sdk.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.sdk.entity.SdkInfo;
|
||||
import com.sqx.modules.utils.excel.ExcelData;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author www.javacoder.top
|
||||
* @since 2023-02-20
|
||||
*/
|
||||
public interface SdkInfoService extends IService<SdkInfo> {
|
||||
|
||||
Result saveSdkInfo(Long typeId, Integer num,Long sysUserId);
|
||||
|
||||
IPage<SdkInfo> getSdkList(Integer page, Integer limit, SdkInfo sdkInfo);
|
||||
|
||||
Result sdkExchange(Long userId, String sdkContent);
|
||||
|
||||
ExcelData excelSdkList(SdkInfo sdkInfo);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.sqx.modules.sdk.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.sdk.entity.SdkType;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author www.javacoder.top
|
||||
* @since 2023-02-20
|
||||
*/
|
||||
public interface SdkTypeService extends IService<SdkType> {
|
||||
|
||||
Result saveSdkType(SdkType sdkType);
|
||||
|
||||
IPage<SdkType> getSdkTypeList(Integer page, Integer limit, SdkType sdkType);
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
package com.sqx.modules.sdk.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.sqx.common.utils.DateUtils;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.entity.UserVip;
|
||||
import com.sqx.modules.app.service.UserService;
|
||||
import com.sqx.modules.app.service.UserVipService;
|
||||
import com.sqx.modules.sdk.dao.SdkInfoDao;
|
||||
import com.sqx.modules.sdk.entity.SdkInfo;
|
||||
import com.sqx.modules.sdk.entity.SdkType;
|
||||
import com.sqx.modules.sdk.service.SdkInfoService;
|
||||
import com.sqx.modules.sdk.service.SdkTypeService;
|
||||
import com.sqx.modules.utils.excel.ExcelData;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author www.javacoder.top
|
||||
* @since 2023-02-20
|
||||
*/
|
||||
@Service
|
||||
public class SdkInfoServiceImpl extends ServiceImpl<SdkInfoDao, SdkInfo> implements SdkInfoService {
|
||||
|
||||
@Autowired
|
||||
private SdkTypeService typeService;
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private UserVipService userVipService;
|
||||
|
||||
|
||||
@Override
|
||||
public Result saveSdkInfo(Long typeId, Integer num,Long sysUserId) {
|
||||
SdkType sdkType = typeService.getById(typeId);
|
||||
if (sdkType==null){
|
||||
return Result.error("卡密类型不存在");
|
||||
}
|
||||
SdkInfo sdkInfo = new SdkInfo();
|
||||
for (int i = 0; i < num; i++) {
|
||||
String replace = UUID.randomUUID().toString().replace("-", "");
|
||||
sdkInfo.setSdkContent(replace);
|
||||
sdkInfo.setStatus(0);
|
||||
sdkInfo.setCreateTime(DateUtils.format(new Date()));
|
||||
sdkInfo.setTypeId(typeId);
|
||||
Calendar calendar=Calendar.getInstance();
|
||||
calendar.add(Calendar.DAY_OF_MONTH,sdkType.getValidDay());
|
||||
sdkInfo.setOverdueTime(DateUtils.format(calendar.getTime()));
|
||||
sdkInfo.setSdkRemarks(sdkType.getRemarks());
|
||||
sdkInfo.setGiveNum(sdkType.getGiveNum());
|
||||
sdkInfo.setSysUserId(sysUserId);
|
||||
baseMapper.insert(sdkInfo);
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<SdkInfo> getSdkList(Integer page, Integer limit, SdkInfo sdkInfo) {
|
||||
Page<SdkInfo> pages;
|
||||
if (page != null && limit != null) {
|
||||
pages = new Page<>(page, limit);
|
||||
} else {
|
||||
pages = new Page<>();
|
||||
pages.setSize(-1);
|
||||
}
|
||||
return baseMapper.getSdkPage(pages, sdkInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExcelData excelSdkList(SdkInfo sdkInfo) {
|
||||
List<SdkInfo> sdkList = baseMapper.getSdkList(sdkInfo);
|
||||
ExcelData data = new ExcelData();
|
||||
data.setName("提现列表");
|
||||
List<String> titles = new ArrayList();
|
||||
titles.add("编号");titles.add("卡密名称");titles.add("卡密");titles.add("赠送会员天数");
|
||||
titles.add("到期时间"); titles.add("领取用户");titles.add("状态");titles.add("创建时间");
|
||||
data.setTitles(titles);
|
||||
List<List<Object>> rows = new ArrayList();
|
||||
DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
for(SdkInfo sdkInfo1:sdkList){
|
||||
List<Object> row = new ArrayList();
|
||||
row.add(sdkInfo1.getSdkId());
|
||||
row.add(sdkInfo1.getSdkRemarks());
|
||||
row.add(sdkInfo1.getSdkContent());
|
||||
row.add(sdkInfo1.getGiveNum());
|
||||
row.add(sdkInfo1.getOverdueTime());
|
||||
row.add(sdkInfo1.getNickName());
|
||||
//0未使用 1已使用 2已过期
|
||||
if(sdkInfo1.getStatus()==0){
|
||||
row.add("未使用");
|
||||
}else if(sdkInfo1.getStatus()==1){
|
||||
row.add("已使用");
|
||||
}else if(sdkInfo1.getStatus()==2){
|
||||
row.add("已过期");
|
||||
}else {
|
||||
row.add("未知");
|
||||
}
|
||||
row.add(sdkInfo1.getCreateTime());
|
||||
rows.add(row);
|
||||
}
|
||||
data.setRows(rows);
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Result sdkExchange(Long userId, String sdkContent) {
|
||||
SdkInfo content = baseMapper.selectOne(new QueryWrapper<SdkInfo>().eq("sdk_content", sdkContent));
|
||||
if(content==null){
|
||||
return Result.error("卡密不存在");
|
||||
}
|
||||
if(content.getStatus()==2){
|
||||
return Result.error("卡密已过期");
|
||||
}
|
||||
if(content.getStatus()==1){
|
||||
return Result.error("卡密已使用");
|
||||
}
|
||||
Integer day = content.getGiveNum();
|
||||
UserVip userVip = userVipService.selectUserVipByUserId(userId);
|
||||
Calendar calendar=Calendar.getInstance();
|
||||
if(userVip!=null){
|
||||
if(userVip.getIsVip()==2){
|
||||
Date date = DateUtils.stringToDate(userVip.getEndTime(), "yyyy-MM-dd HH:mm:ss");
|
||||
calendar.setTime(date);
|
||||
}
|
||||
}else{
|
||||
userVip=new UserVip();
|
||||
userVip.setUserId(userId);
|
||||
userVip.setCreateTime(DateUtils.format(new Date()));
|
||||
}
|
||||
userVip.setIsVip(2);
|
||||
userVip.setVipType(1);
|
||||
calendar.add(Calendar.DAY_OF_MONTH,day);
|
||||
userVip.setEndTime(DateUtils.format(calendar.getTime()));
|
||||
if(userVip.getVipId()!=null){
|
||||
userVipService.updateById(userVip);
|
||||
}else{
|
||||
userVipService.save(userVip);
|
||||
}
|
||||
content.setStatus(1);
|
||||
content.setUseTime(DateUtils.format(new Date()));
|
||||
content.setUserId(userId);
|
||||
baseMapper.updateById(content);
|
||||
return Result.success("兑换成功");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.sqx.modules.sdk.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.sqx.common.utils.DateUtils;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.sdk.dao.SdkTypeDao;
|
||||
import com.sqx.modules.sdk.entity.SdkType;
|
||||
import com.sqx.modules.sdk.service.SdkTypeService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @autho wuchang
|
||||
* @since 2023-02-20
|
||||
*/
|
||||
@Service
|
||||
public class SdkTypeServiceImpl extends ServiceImpl<SdkTypeDao, SdkType> implements SdkTypeService {
|
||||
|
||||
@Override
|
||||
public Result saveSdkType(SdkType sdkType) {
|
||||
if (sdkType.getTypeId() != null) {
|
||||
baseMapper.updateById(sdkType);
|
||||
return Result.success();
|
||||
} else {
|
||||
sdkType.setCreateTime(DateUtils.format(new Date()));
|
||||
baseMapper.insert(sdkType);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<SdkType> getSdkTypeList(Integer page, Integer limit, SdkType sdkType) {
|
||||
Page<SdkType> pages;
|
||||
if (page != null && limit != null) {
|
||||
pages = new Page<>(page, limit);
|
||||
} else {
|
||||
pages = new Page<>();
|
||||
pages.setSize(-1);
|
||||
}
|
||||
return baseMapper.selectPage(pages, new QueryWrapper<>(sdkType).orderByDesc("create_time"));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user