update
This commit is contained in:
parent
11226f53ea
commit
158b6a5163
@ -3,14 +3,18 @@ package me.xiaoyan.point.api.controller.admin;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.xiaoyan.point.api.error.BizException;
|
||||
import me.xiaoyan.point.api.pojo.UserInfo;
|
||||
import me.xiaoyan.point.api.pojo.vo.GoodsQueryParam;
|
||||
import me.xiaoyan.point.api.pojo.vo.PageDataResult;
|
||||
import me.xiaoyan.point.api.pojo.vo.UserAdminInfo;
|
||||
import me.xiaoyan.point.api.pojo.vo.UserQueryParam;
|
||||
import me.xiaoyan.point.api.service.UserInfoService;
|
||||
import me.xiaoyan.point.api.util.DataStatus;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
|
||||
@RestController
|
||||
@ -19,6 +23,9 @@ import java.util.HashMap;
|
||||
public class UserAdminController {
|
||||
private HashMap<String, UserAdminInfo> userStoreMap = new HashMap<>();
|
||||
|
||||
@Resource
|
||||
private UserInfoService userInfoService;
|
||||
|
||||
@PostConstruct
|
||||
public void initUserStore() {
|
||||
log.info("初始化用户数据");
|
||||
@ -57,4 +64,13 @@ public class UserAdminController {
|
||||
return "ok";
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
public PageDataResult list(@RequestBody UserQueryParam param) {
|
||||
return PageDataResult.convert(userInfoService.queryByPage(param));
|
||||
}
|
||||
|
||||
@GetMapping("/remove")
|
||||
public boolean remove(int id) {
|
||||
return userInfoService.updateById(UserInfo.builder().id(id).status(DataStatus.DELETE).build());
|
||||
}
|
||||
}
|
||||
|
@ -64,4 +64,6 @@ public class UserInfo implements Serializable {
|
||||
private Integer status;
|
||||
@TableField(exist = false)
|
||||
private Point pointInfo;
|
||||
@TableField(exist = false)
|
||||
private UserInfo parent;
|
||||
}
|
||||
|
@ -0,0 +1,9 @@
|
||||
package me.xiaoyan.point.api.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UserQueryParam extends PageParam {
|
||||
private String nickname;
|
||||
private String openId;
|
||||
}
|
@ -1,8 +1,10 @@
|
||||
package me.xiaoyan.point.api.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import me.xiaoyan.point.api.pojo.UserInfo;
|
||||
import me.xiaoyan.point.api.pojo.vo.UserLoginData;
|
||||
import me.xiaoyan.point.api.pojo.vo.UserQueryParam;
|
||||
|
||||
public interface UserInfoService extends IService<UserInfo> {
|
||||
|
||||
@ -16,4 +18,6 @@ public interface UserInfoService extends IService<UserInfo> {
|
||||
UserInfo getInfoById(Integer uid);
|
||||
|
||||
UserInfo getInfoByCode(String code);
|
||||
|
||||
Page<UserInfo> queryByPage(UserQueryParam param);
|
||||
}
|
||||
|
@ -1,10 +1,15 @@
|
||||
package me.xiaoyan.point.api.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.google.gson.Gson;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.xiaoyan.point.api.pojo.vo.UserQueryParam;
|
||||
import me.xiaoyan.point.api.util.DataStatus;
|
||||
import me.xiaoyan.point.api.util.QueryWrapperUtil;
|
||||
import me.xiaoyan.point.api.util.WechatDecryptDataUtil;
|
||||
import me.xiaoyan.point.api.error.BizException;
|
||||
import me.xiaoyan.point.api.mapper.UserInfoMapper;
|
||||
@ -28,6 +33,7 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@ -157,4 +163,31 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo>
|
||||
// 使用openid查询用户信息
|
||||
return this.getBaseMapper().selectOneByOpenId(sessionData.getOpenid());
|
||||
}
|
||||
|
||||
|
||||
private UserInfo getParent(int parentUid) {
|
||||
if (parentUid < 1) return null;
|
||||
return getBaseMapper().selectById(parentUid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<UserInfo> queryByPage(UserQueryParam param) {
|
||||
QueryWrapper q = QueryWrapperUtil
|
||||
.builder()
|
||||
// 查询标题
|
||||
.eq("nickname", param.getNickname())
|
||||
.eq("open_id", param.getOpenId())
|
||||
.ne("status", DataStatus.DELETE)
|
||||
.build();
|
||||
Page<UserInfo> page = getBaseMapper().selectPage(param.getPage(), q);
|
||||
List<UserInfo> records = page.getRecords();
|
||||
if (records != null && records.size() > 0) {
|
||||
records.forEach(u -> {
|
||||
u.setPointInfo(pointService.getById(u.getId()));
|
||||
u.setParent(getParent(u.getParentId()));
|
||||
});
|
||||
|
||||
}
|
||||
return page;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,7 @@
|
||||
package me.xiaoyan.point.api.util;
|
||||
|
||||
public class DataStatus {
|
||||
public static final int NORMAL = 1;
|
||||
public static final int DELETE = 0;
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package me.xiaoyan.point.api.util;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
public class QueryWrapperUtil {
|
||||
private QueryWrapper q;
|
||||
|
||||
private QueryWrapperUtil(QueryWrapper queryWrapper) {
|
||||
this.q = queryWrapper;
|
||||
}
|
||||
|
||||
public static QueryWrapperUtil builder() {
|
||||
return new QueryWrapperUtil(new QueryWrapper());
|
||||
}
|
||||
|
||||
public static QueryWrapperUtil builder(QueryWrapper queryWrapper) {
|
||||
return new QueryWrapperUtil(queryWrapper);
|
||||
}
|
||||
|
||||
public QueryWrapperUtil eq(String column, String value) {
|
||||
if (StringUtils.hasText(value)) {
|
||||
q.eq(column, value);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryWrapperUtil ne(String column, Object value) {
|
||||
q.ne(column, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryWrapper build() {
|
||||
return this.q;
|
||||
}
|
||||
}
|
@ -14,7 +14,8 @@ create table userinfo
|
||||
first_login_time datetime default current_timestamp,
|
||||
update_time datetime null on update current_timestamp,
|
||||
status tinyint(2) default 1
|
||||
) engine = innodb collate = 'utf8mb4_general_ci' comment '用户表';
|
||||
) engine = innodb
|
||||
collate = 'utf8mb4_general_ci' comment '用户表';
|
||||
|
||||
create table point
|
||||
(
|
||||
@ -24,7 +25,8 @@ create table point
|
||||
expire_point int(10) null default 0,
|
||||
expire_time datetime null,
|
||||
update_time datetime null on update current_timestamp
|
||||
) engine = innodb collate = 'utf8mb4_general_ci' comment '积分表';
|
||||
) engine = innodb
|
||||
collate = 'utf8mb4_general_ci' comment '积分表';
|
||||
create table point_record
|
||||
(
|
||||
id bigint(15) primary key auto_increment,
|
||||
@ -34,7 +36,8 @@ create table point_record
|
||||
reason varchar(100) not null,
|
||||
valid_time datetime null,
|
||||
expire_time datetime null
|
||||
) engine = innodb collate = 'utf8mb4_general_ci' comment '积分记录表';
|
||||
) engine = innodb
|
||||
collate = 'utf8mb4_general_ci' comment '积分记录表';
|
||||
|
||||
create table sign_record
|
||||
(
|
||||
@ -42,29 +45,31 @@ create table sign_record
|
||||
uid int(10) not null,
|
||||
point int(10) not null,
|
||||
ip varchar(50) not null,
|
||||
create_time datetime default current_timestamp
|
||||
) engine = innodb collate = 'utf8mb4_general_ci' comment '打卡记录表';
|
||||
|
||||
create_time datetime default current_timestamp
|
||||
) engine = innodb
|
||||
collate = 'utf8mb4_general_ci' comment '打卡记录表';
|
||||
drop table if exists goods;
|
||||
create table goods
|
||||
(
|
||||
id bigint(15) primary key auto_increment,
|
||||
category tinyint(2) null default 1 comment '商品类别(1:普通 2:精选 3:秒杀 4:抽奖)',
|
||||
type tinyint(2) null default 1 comment '商品类型(1:实物 2:虚拟)',
|
||||
category tinyint(2) null default 1 comment '商品类别(1:普通 2:精选 3:秒杀 4:抽奖)',
|
||||
type tinyint(2) null default 1 comment '商品类型(1:实物 2:虚拟)',
|
||||
title varchar(50) not null,
|
||||
origin_price int(10) unsigned comment '原价' default 0,
|
||||
price int(10) unsigned not null comment '价格',
|
||||
stock int(10) unsigned not null comment '库存数量',
|
||||
limit_count int(10) unsigned null default 1 comment '购买最大数量(0表示不限制)',
|
||||
limit_count int(10) unsigned null default 1 comment '购买最大数量(0表示不限制)',
|
||||
cover varchar(200) not null comment '商品图',
|
||||
description text not null comment '描述',
|
||||
notice varchar(500) null comment '提示',
|
||||
online_time datetime not null comment '上架时间',
|
||||
offline_time datetime not null comment '下架时间',
|
||||
create_time datetime default current_timestamp,
|
||||
create_time datetime default current_timestamp,
|
||||
update_time datetime null on update current_timestamp,
|
||||
status tinyint(2) default 1,
|
||||
status tinyint(2) default 1,
|
||||
index ix_title (title)
|
||||
) engine = innodb comment '商品表';
|
||||
) engine = innodb
|
||||
collate = 'utf8mb4_general_ci' comment '商品表';
|
||||
|
||||
create table order_info
|
||||
(
|
||||
@ -72,8 +77,8 @@ create table order_info
|
||||
gid bigint(15) not null comment '商品编号',
|
||||
price int(10) not null comment '价格',
|
||||
uid int(10) not null comment '用户编号',
|
||||
data json null comment '订单数据',
|
||||
data json null comment '订单数据',
|
||||
create_time datetime default current_timestamp,
|
||||
update_time datetime null on update current_timestamp,
|
||||
status tinyint(2) default 1 comment '订单状态(0:已删除 1:待确认 2:已取消 3:已完成)'
|
||||
) comment '订单表';
|
||||
) collate = 'utf8mb4_general_ci' comment '订单表';
|
Loading…
x
Reference in New Issue
Block a user