用户基础功能
This commit is contained in:
parent
3727198264
commit
1cbcf12ad7
BIN
.idea/.cache/.Apifox_Helper/.toolWindow.db
generated
BIN
.idea/.cache/.Apifox_Helper/.toolWindow.db
generated
Binary file not shown.
@ -2,7 +2,10 @@ package com.cdzy.activity.controller;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.cdzy.activity.model.JsonResult;
|
||||
import com.cdzy.activity.model.User;
|
||||
import com.cdzy.activity.service.UserService;
|
||||
import com.cdzy.activity.uitls.VerifyUtil;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
@ -21,6 +24,9 @@ public class UserController {
|
||||
@Resource
|
||||
private VerifyUtil verifyUtil;
|
||||
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
/**
|
||||
* 用户微信无感登录。
|
||||
*
|
||||
@ -36,7 +42,16 @@ public class UserController {
|
||||
if (result.containsKey("errcode")) {
|
||||
return JsonResult.failed(String.format("微信登录失败 %s", result.getString("errmsg")));
|
||||
}
|
||||
return JsonResult.success("微信登录成功", result.getString("openid"));
|
||||
String openid = result.getString("openid");
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.eq(User::getWxOpenId, openid);
|
||||
User user = userService.getOne(queryWrapper);
|
||||
if (user == null) {
|
||||
user = new User();
|
||||
user.setWxOpenId(openid);
|
||||
userService.save(user);
|
||||
}
|
||||
return JsonResult.success("微信登录成功", openid);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
14
src/main/java/com/cdzy/activity/mapper/UserMapper.java
Normal file
14
src/main/java/com/cdzy/activity/mapper/UserMapper.java
Normal file
@ -0,0 +1,14 @@
|
||||
package com.cdzy.activity.mapper;
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.cdzy.activity.model.User;
|
||||
|
||||
/**
|
||||
* 映射层。
|
||||
*
|
||||
* @author attiya
|
||||
* @since 2025-09-19
|
||||
*/
|
||||
public interface UserMapper extends BaseMapper<User> {
|
||||
|
||||
}
|
||||
@ -1,6 +1,5 @@
|
||||
package com.cdzy.activity.model;
|
||||
|
||||
import com.cdzy.activity.enums.ActivityStatus;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
@ -87,6 +86,11 @@ public class Activity implements Serializable {
|
||||
*/
|
||||
private Integer limitRegister;
|
||||
|
||||
/**
|
||||
* 活动类型:1-体育 2-文娱
|
||||
*/
|
||||
private Integer activityType;
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
82
src/main/java/com/cdzy/activity/model/User.java
Normal file
82
src/main/java/com/cdzy/activity/model/User.java
Normal file
@ -0,0 +1,82 @@
|
||||
package com.cdzy.activity.model;
|
||||
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import com.mybatisflex.core.keygen.KeyGenerators;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 实体类。
|
||||
*
|
||||
* @author attiya
|
||||
* @since 2025-09-19
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("user")
|
||||
public class User implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id(keyType = KeyType.Generator, value = KeyGenerators.snowFlakeId)
|
||||
private Long userId;
|
||||
|
||||
private String wxOpenId;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
private String gender;
|
||||
|
||||
/**
|
||||
* 地址
|
||||
*/
|
||||
private String address;
|
||||
|
||||
/**
|
||||
* 年龄
|
||||
*/
|
||||
private Integer age;
|
||||
|
||||
/**
|
||||
* 慢性病史:1-有 2-无
|
||||
*/
|
||||
private Integer chronicDiseasesHistory;
|
||||
|
||||
/**
|
||||
* 所患慢性病
|
||||
*/
|
||||
private String chronicDisease;
|
||||
|
||||
/**
|
||||
* 健康:1-健康 2-不健康
|
||||
*/
|
||||
private Integer heath;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Integer isFilled;
|
||||
|
||||
}
|
||||
@ -86,4 +86,9 @@ public class ActivityVo implements Serializable {
|
||||
*/
|
||||
private Integer limitRegister;
|
||||
|
||||
/**
|
||||
* 活动类型:1-体育 2-文娱
|
||||
*/
|
||||
private Integer activityType;
|
||||
|
||||
}
|
||||
@ -1,9 +1,5 @@
|
||||
package com.cdzy.activity.model.vo;
|
||||
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import com.mybatisflex.core.keygen.KeyGenerators;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
14
src/main/java/com/cdzy/activity/service/UserService.java
Normal file
14
src/main/java/com/cdzy/activity/service/UserService.java
Normal file
@ -0,0 +1,14 @@
|
||||
package com.cdzy.activity.service;
|
||||
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.cdzy.activity.model.User;
|
||||
|
||||
/**
|
||||
* 服务层。
|
||||
*
|
||||
* @author attiya
|
||||
* @since 2025-09-19
|
||||
*/
|
||||
public interface UserService extends IService<User> {
|
||||
|
||||
}
|
||||
@ -63,6 +63,7 @@ public class ActivityServiceImpl extends ServiceImpl<ActivityMapper, Activity>
|
||||
.limitPeople(activity.getLimitPeople())
|
||||
.limitRegister(activity.getLimitRegister())
|
||||
.status(ActivityStatus.UN_START_REGISTERING)
|
||||
.activityType(activity.getActivityType())
|
||||
.build();
|
||||
activityMapper.insert(entity);
|
||||
}
|
||||
@ -93,6 +94,7 @@ public class ActivityServiceImpl extends ServiceImpl<ActivityMapper, Activity>
|
||||
entity.setMaxNum(activity.getMaxNum());
|
||||
entity.setLimitPeople(activity.getLimitPeople());
|
||||
entity.setLimitRegister(activity.getLimitRegister());
|
||||
entity.setActivityType(activity.getActivityType());
|
||||
activityMapper.update(entity);
|
||||
}else {
|
||||
throw new RuntimeException("该活动不存在");
|
||||
|
||||
@ -0,0 +1,18 @@
|
||||
package com.cdzy.activity.service.impl;
|
||||
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.cdzy.activity.model.User;
|
||||
import com.cdzy.activity.mapper.UserMapper;
|
||||
import com.cdzy.activity.service.UserService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 服务层实现。
|
||||
*
|
||||
* @author attiya
|
||||
* @since 2025-09-19
|
||||
*/
|
||||
@Service
|
||||
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService{
|
||||
|
||||
}
|
||||
@ -34,6 +34,8 @@ public class VerifyUtil {
|
||||
|
||||
@Resource
|
||||
private WechatConfig wechatConfig;
|
||||
|
||||
|
||||
/**
|
||||
* 微信工具类构造函数。
|
||||
*/
|
||||
|
||||
@ -5,6 +5,7 @@ import com.cdzy.activity.model.Staff;
|
||||
import com.cdzy.activity.service.StaffService;
|
||||
import com.mybatisflex.codegen.Generator;
|
||||
import com.mybatisflex.codegen.config.GlobalConfig;
|
||||
import com.mybatisflex.core.keygen.impl.SnowFlakeIDKeyGenerator;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@ -20,16 +21,15 @@ class ActivityRegistrationApplicationTests {
|
||||
private static final String mapperPath="D:/ActivityRegistration/resources/mapper";
|
||||
private static final String packageName ="com.cdzy.activity";
|
||||
private static final String[] tables= new String[]{
|
||||
"bulletin"
|
||||
"user"
|
||||
};
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
Staff entity = Staff.builder()
|
||||
.username("admin")
|
||||
.password("123456")
|
||||
.build();
|
||||
staffService.save(entity );
|
||||
for (int i = 0; i < 3; i++) {
|
||||
SnowFlakeIDKeyGenerator idKeyGenerator = new SnowFlakeIDKeyGenerator();
|
||||
System.out.println(idKeyGenerator.nextId());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Binary file not shown.
BIN
target/classes/com/cdzy/activity/mapper/UserMapper.class
Normal file
BIN
target/classes/com/cdzy/activity/mapper/UserMapper.class
Normal file
Binary file not shown.
BIN
target/classes/com/cdzy/activity/model/User$UserBuilder.class
Normal file
BIN
target/classes/com/cdzy/activity/model/User$UserBuilder.class
Normal file
Binary file not shown.
BIN
target/classes/com/cdzy/activity/model/User.class
Normal file
BIN
target/classes/com/cdzy/activity/model/User.class
Normal file
Binary file not shown.
BIN
target/classes/com/cdzy/activity/model/table/UserTableDef.class
Normal file
BIN
target/classes/com/cdzy/activity/model/table/UserTableDef.class
Normal file
Binary file not shown.
Binary file not shown.
BIN
target/classes/com/cdzy/activity/model/vo/BulletinVo.class
Normal file
BIN
target/classes/com/cdzy/activity/model/vo/BulletinVo.class
Normal file
Binary file not shown.
BIN
target/classes/com/cdzy/activity/service/UserService.class
Normal file
BIN
target/classes/com/cdzy/activity/service/UserService.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -37,6 +37,11 @@ public class ActivityTableDef extends TableDef {
|
||||
*/
|
||||
public final QueryColumn ACTIVITY_NAME = new QueryColumn(this, "activity_name");
|
||||
|
||||
/**
|
||||
* 活动类型:1-体育 2-文娱
|
||||
*/
|
||||
public final QueryColumn ACTIVITY_TYPE = new QueryColumn(this, "activity_type");
|
||||
|
||||
/**
|
||||
* 封面
|
||||
*/
|
||||
@ -80,7 +85,7 @@ public class ActivityTableDef extends TableDef {
|
||||
/**
|
||||
* 默认字段,不包含逻辑删除或者 large 等字段。
|
||||
*/
|
||||
public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{MAX_NUM, STATUS, END_TIME, START_TIME, ACTIVITY_ID, LIMIT_PEOPLE, ACTIVITY_NAME, ACTIVITY_COVER, LIMIT_REGISTER, ACTIVITY_SPONSOR, ACTIVITY_LOCATION, ACTIVITY_DESCRIPTION, REGISTRATION_END_TIME, REGISTRATION_START_TIME};
|
||||
public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{MAX_NUM, STATUS, END_TIME, START_TIME, ACTIVITY_ID, LIMIT_PEOPLE, ACTIVITY_NAME, ACTIVITY_TYPE, ACTIVITY_COVER, LIMIT_REGISTER, ACTIVITY_SPONSOR, ACTIVITY_LOCATION, ACTIVITY_DESCRIPTION, REGISTRATION_END_TIME, REGISTRATION_START_TIME};
|
||||
|
||||
public ActivityTableDef() {
|
||||
super("", "activity");
|
||||
|
||||
@ -0,0 +1,86 @@
|
||||
package com.cdzy.activity.model.table;
|
||||
|
||||
import com.mybatisflex.core.query.QueryColumn;
|
||||
import com.mybatisflex.core.table.TableDef;
|
||||
|
||||
// Auto generate by mybatis-flex, do not modify it.
|
||||
public class UserTableDef extends TableDef {
|
||||
|
||||
/**
|
||||
* 实体类。
|
||||
|
||||
@author attiya
|
||||
@since 2025-09-19
|
||||
*/
|
||||
public static final UserTableDef USER = new UserTableDef();
|
||||
|
||||
/**
|
||||
* 年龄
|
||||
*/
|
||||
public final QueryColumn AGE = new QueryColumn(this, "age");
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
public final QueryColumn NAME = new QueryColumn(this, "name");
|
||||
|
||||
/**
|
||||
* 健康:1-健康 2-不健康
|
||||
*/
|
||||
public final QueryColumn HEATH = new QueryColumn(this, "heath");
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
public final QueryColumn PHONE = new QueryColumn(this, "phone");
|
||||
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
public final QueryColumn GENDER = new QueryColumn(this, "gender");
|
||||
|
||||
public final QueryColumn USER_ID = new QueryColumn(this, "user_id");
|
||||
|
||||
/**
|
||||
* 地址
|
||||
*/
|
||||
public final QueryColumn ADDRESS = new QueryColumn(this, "address");
|
||||
|
||||
public final QueryColumn IS_FILLED = new QueryColumn(this, "is_filled");
|
||||
|
||||
public final QueryColumn WX_OPEN_ID = new QueryColumn(this, "wx_open_id");
|
||||
|
||||
/**
|
||||
* 所患慢性病
|
||||
*/
|
||||
public final QueryColumn CHRONIC_DISEASE = new QueryColumn(this, "chronic_disease");
|
||||
|
||||
/**
|
||||
* 慢性病史:1-有 2-无
|
||||
*/
|
||||
public final QueryColumn CHRONIC_DISEASES_HISTORY = new QueryColumn(this, "chronic_diseases_history");
|
||||
|
||||
/**
|
||||
* 所有字段。
|
||||
*/
|
||||
public final QueryColumn ALL_COLUMNS = new QueryColumn(this, "*");
|
||||
|
||||
/**
|
||||
* 默认字段,不包含逻辑删除或者 large 等字段。
|
||||
*/
|
||||
public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{AGE, NAME, HEATH, PHONE, GENDER, USER_ID, ADDRESS, IS_FILLED, WX_OPEN_ID, CHRONIC_DISEASE, CHRONIC_DISEASES_HISTORY};
|
||||
|
||||
public UserTableDef() {
|
||||
super("", "user");
|
||||
}
|
||||
|
||||
private UserTableDef(String schema, String name, String alisa) {
|
||||
super(schema, name, alisa);
|
||||
}
|
||||
|
||||
public UserTableDef as(String alias) {
|
||||
String key = getNameWithSchema() + "." + alias;
|
||||
return getCache(key, k -> new UserTableDef("", "user", alias));
|
||||
}
|
||||
|
||||
}
|
||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user