用户基础功能
This commit is contained in:
parent
69f5dec219
commit
b3004cffc5
@ -3,14 +3,18 @@ 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.model.vo.UserVo;
|
||||
import com.cdzy.activity.service.UserService;
|
||||
import com.cdzy.activity.uitls.VerifyUtil;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.core.util.StringUtil;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.cdzy.activity.model.table.ActivityTableDef.ACTIVITY;
|
||||
|
||||
/**
|
||||
* 微信用户控制层。
|
||||
@ -56,7 +60,19 @@ public class UserController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户微信无感登录。
|
||||
* 用户详情。
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 登陆结果
|
||||
*/
|
||||
@PostMapping("fill")
|
||||
public JsonResult<?> fill(@Validated @RequestBody UserVo user) {
|
||||
userService.saveUser(user);
|
||||
return JsonResult.success(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户详情。
|
||||
*
|
||||
* @param openId 微信登陆openId
|
||||
* @return 登陆结果
|
||||
@ -69,4 +85,19 @@ public class UserController {
|
||||
return JsonResult.success(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户查询活动分页数据。
|
||||
*
|
||||
* @param activityName 活动名称
|
||||
* @param activityType 活动类型
|
||||
* @return 登陆结果
|
||||
*/
|
||||
@GetMapping("activity/page")
|
||||
public JsonResult<?> activityPage(String activityName,Integer activityType) {
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.where(ACTIVITY.ACTIVITY_NAME.like(activityName, StringUtil.hasText(activityName)))
|
||||
.where(ACTIVITY.ACTIVITY_TYPE.eq(activityType, Objects.nonNull(activityType)));
|
||||
User user = userService.getOne(queryWrapper);
|
||||
return JsonResult.success(user);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.cdzy.activity.model;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
@ -77,6 +78,7 @@ public class User implements Serializable {
|
||||
/**
|
||||
*是否已填写资料:1-未填写 2-已填
|
||||
*/
|
||||
@Column(onInsertValue = "1")
|
||||
private Integer isFilled;
|
||||
|
||||
}
|
||||
|
||||
78
src/main/java/com/cdzy/activity/model/vo/UserVo.java
Normal file
78
src/main/java/com/cdzy/activity/model/vo/UserVo.java
Normal file
@ -0,0 +1,78 @@
|
||||
package com.cdzy.activity.model.vo;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 实体类。
|
||||
*
|
||||
* @author attiya
|
||||
* @since 2025-09-19
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class UserVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@NotBlank(message = "微信openId不能为空")
|
||||
private String wxOpenId;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
@NotBlank(message = "姓名不能为空")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
@NotBlank(message = "手机号不能为空")
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
@NotBlank(message = "性别不能为空")
|
||||
private String gender;
|
||||
|
||||
/**
|
||||
* 地址
|
||||
*/
|
||||
@NotBlank(message = "地址不能为空")
|
||||
private String address;
|
||||
|
||||
/**
|
||||
* 年龄
|
||||
*/
|
||||
@NotNull(message = "年龄不能为空")
|
||||
private Integer age;
|
||||
|
||||
/**
|
||||
* 慢性病史:1-有 2-无
|
||||
*/
|
||||
@NotNull(message = "有无慢性病史不能为空")
|
||||
private Integer chronicDiseasesHistory;
|
||||
|
||||
/**
|
||||
* 所患慢性病
|
||||
*/
|
||||
private String chronicDisease;
|
||||
|
||||
/**
|
||||
* 健康:1-健康 2-不健康
|
||||
*/
|
||||
@NotNull(message = "健康状况不能为空")
|
||||
private Integer heath;
|
||||
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
package com.cdzy.activity.service;
|
||||
|
||||
import com.cdzy.activity.model.vo.UserVo;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.cdzy.activity.model.User;
|
||||
|
||||
@ -11,4 +12,5 @@ import com.cdzy.activity.model.User;
|
||||
*/
|
||||
public interface UserService extends IService<User> {
|
||||
|
||||
void saveUser(UserVo user);
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.cdzy.activity.service.impl;
|
||||
|
||||
import com.cdzy.activity.model.vo.UserVo;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.cdzy.activity.model.User;
|
||||
import com.cdzy.activity.mapper.UserMapper;
|
||||
@ -15,4 +16,8 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService{
|
||||
|
||||
@Override
|
||||
public void saveUser(UserVo user) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -3,36 +3,87 @@ package com.cdzy.activity.model.table;
|
||||
import com.mybatisflex.core.query.QueryColumn;
|
||||
import com.mybatisflex.core.table.TableDef;
|
||||
|
||||
public class UserTableDef extends TableDef{
|
||||
// Auto generate by mybatis-flex, do not modify it.
|
||||
public class UserTableDef extends TableDef {
|
||||
|
||||
public static final UserTableDef USER=new UserTableDef();
|
||||
/**
|
||||
* 实体类。
|
||||
|
||||
@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");
|
||||
|
||||
/**
|
||||
* 是否已填写资料:1-未填写 2-已填
|
||||
*/
|
||||
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 IS_FILLED =new QueryColumn(this,"isFilled");
|
||||
public final QueryColumn CHRONIC_DISEASES_HISTORY =new QueryColumn(this,"chronicDiseasesHistory");
|
||||
public final QueryColumn ADDRESS =new QueryColumn(this,"address");
|
||||
public final QueryColumn PHONE =new QueryColumn(this,"phone");
|
||||
public final QueryColumn CHRONIC_DISEASE =new QueryColumn(this,"chronicDisease");
|
||||
public final QueryColumn GENDER =new QueryColumn(this,"gender");
|
||||
public final QueryColumn USER_ID =new QueryColumn(this,"userId");
|
||||
public final QueryColumn HEATH =new QueryColumn(this,"heath");
|
||||
public final QueryColumn WX_OPEN_ID =new QueryColumn(this,"wxOpenId");
|
||||
public final QueryColumn AGE =new QueryColumn(this,"age");
|
||||
public final QueryColumn NAME =new QueryColumn(this,"name");
|
||||
/**
|
||||
* 所有字段。
|
||||
*/
|
||||
public final QueryColumn ALL_COLUMNS=new QueryColumn(this,"*");
|
||||
public final QueryColumn ALL_COLUMNS = new QueryColumn(this, "*");
|
||||
|
||||
/**
|
||||
* 默认字段,不包含逻辑删除或者 large 等字段。
|
||||
*/
|
||||
public final QueryColumn[]DEFAULT_COLUMNS=new QueryColumn[]{ IS_FILLED , CHRONIC_DISEASES_HISTORY , ADDRESS , PHONE , CHRONIC_DISEASE , GENDER , USER_ID , HEATH , WX_OPEN_ID , AGE , NAME };
|
||||
public UserTableDef(){super("","user");}
|
||||
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));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,37 @@
|
||||
package com.cdzy.activity.model.vo.table;
|
||||
|
||||
import com.mybatisflex.core.query.QueryColumn;
|
||||
import com.mybatisflex.core.table.TableDef;
|
||||
|
||||
public class UserVoTableDef extends TableDef{
|
||||
|
||||
public static final UserVoTableDef USER_VO=new UserVoTableDef();
|
||||
|
||||
public final QueryColumn IS_FILLED =new QueryColumn(this,"");
|
||||
public final QueryColumn CHRONIC_DISEASES_HISTORY =new QueryColumn(this,"chronicDiseasesHistory");
|
||||
public final QueryColumn ADDRESS =new QueryColumn(this,"address");
|
||||
public final QueryColumn PHONE =new QueryColumn(this,"phone");
|
||||
public final QueryColumn CHRONIC_DISEASE =new QueryColumn(this,"chronicDisease");
|
||||
public final QueryColumn GENDER =new QueryColumn(this,"gender");
|
||||
public final QueryColumn HEATH =new QueryColumn(this,"heath");
|
||||
public final QueryColumn WX_OPEN_ID =new QueryColumn(this,"wxOpenId");
|
||||
public final QueryColumn AGE =new QueryColumn(this,"age");
|
||||
public final QueryColumn NAME =new QueryColumn(this,"name");
|
||||
/**
|
||||
* 所有字段。
|
||||
*/
|
||||
public final QueryColumn ALL_COLUMNS=new QueryColumn(this,"*");
|
||||
|
||||
/**
|
||||
* 默认字段,不包含逻辑删除或者 large 等字段。
|
||||
*/
|
||||
public final QueryColumn[]DEFAULT_COLUMNS=new QueryColumn[]{ IS_FILLED , CHRONIC_DISEASES_HISTORY , ADDRESS , PHONE , CHRONIC_DISEASE , GENDER , HEATH , WX_OPEN_ID , AGE , NAME };
|
||||
public UserVoTableDef(){super("","user");}
|
||||
private UserVoTableDef(String schema, String name, String alisa) {
|
||||
super(schema, name, alisa);
|
||||
}
|
||||
public UserVoTableDef as(String alias) {
|
||||
String key = getNameWithSchema() + "." + alias;
|
||||
return getCache(key, k -> new UserVoTableDef("", "user", alias));
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user