Commit 3cb41ff1 authored by gaoyingwei's avatar gaoyingwei

添加 会员相关代码

parent 975069f8
...@@ -47,8 +47,7 @@ ...@@ -47,8 +47,7 @@
<dependency> <dependency>
<groupId>org.91isoft</groupId> <groupId>org.91isoft</groupId>
<artifactId>91isoft_spbt</artifactId> <artifactId>91isoft_spbt</artifactId>
<version>3.3.0_core_alpha1</version> <version>3.3.0_core_alpha2</version>
<scope>compile</scope>
<!-- <version>3.0.0_nlt.25</version>--> <!-- <version>3.0.0_nlt.25</version>-->
<!-- 排除oracle12的驱动,此处代码不能提交,测试使用的是12,生产为11 --> <!-- 排除oracle12的驱动,此处代码不能提交,测试使用的是12,生产为11 -->
</dependency> </dependency>
......
package org.rcisoft.app.appMemInfo.controller;
/*固定导入*/
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.servlet.http.HttpServletResponse;
import org.rcisoft.business.memInfo.entity.MemInfo;
import org.rcisoft.business.memInfo.service.MemInfoService;
import org.rcisoft.core.anno.CyEncryptSm4Anno;
import org.rcisoft.core.anno.CyOpeLogAnno;
import org.rcisoft.core.constant.CyMessCons;
import org.rcisoft.core.controller.CyPaginationController;
import org.rcisoft.core.model.CyGridModel;
import org.rcisoft.core.model.CyPersistModel;
import org.rcisoft.core.operlog.enums.CyLogTypeEnum;
import org.rcisoft.core.result.CyResult;
import org.rcisoft.core.util.CyEpExcelUtil;
import org.rcisoft.core.util.CyResultGenUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
/**
* Created by cy on 2024年12月20日 下午3:35:34.
*/
@RestController
@RequestMapping("/app")
public class AppMemInfoController extends CyPaginationController<MemInfo> {
@Autowired
private MemInfoService memInfoServiceImpl;
// @PreAuthorize("@cyPerm.hasPerm('mem:info:add')")
@CyOpeLogAnno(title = "system-会员表管理-新增会员表", businessType = CyLogTypeEnum.INSERT)
@Operation(summary="添加会员表", description="添加会员表")
@PostMapping(value = "/open/memInfo/add")
@CyEncryptSm4Anno
public CyResult add( MemInfo memInfo) {
CyPersistModel data = memInfoServiceImpl.persist(memInfo);
return CyResultGenUtil.builder(data,
CyMessCons.MESSAGE_ALERT_SUCCESS,
CyMessCons.MESSAGE_ALERT_ERROR,
memInfo);
}
@CyOpeLogAnno(title = "system-会员表管理-校验手机号", businessType = CyLogTypeEnum.OTHER)
@Operation(summary="校验手机号", description="校验手机号")
@PostMapping(value = "/open/memInfo/checkInfo")
@CyEncryptSm4Anno
public CyResult checkInfo(@Valid MemInfo memInfo) {
return CyResultGenUtil.genSuccessResult(memInfoServiceImpl.checkInfo(memInfo));
}
@CyOpeLogAnno(title = "system-会员表管理-查询会员表", businessType = CyLogTypeEnum.QUERY)
@Operation(summary="查询单一会员表", description="查询单一会员表")
@Parameters({@Parameter(name = "businessId", description = "businessId", required = true, schema = @Schema(type = "string"))})
@GetMapping("/open/memInfo/detail/{businessId:\\w+}")
public CyResult detail(@PathVariable int businessId) {
return CyResultGenUtil.builder(new CyPersistModel(1),
CyMessCons.MESSAGE_ALERT_SUCCESS,
CyMessCons.MESSAGE_ALERT_ERROR,
memInfoServiceImpl.findById(businessId));
}
@CyOpeLogAnno(title = "system-会员表管理-查询会员表", businessType = CyLogTypeEnum.QUERY)
@Operation(summary="分页查询会员表集合", description="分页查询会员表集合")
@GetMapping(value = "/open/memInfo/list")
@CyEncryptSm4Anno
public CyGridModel listByPagination(MemInfo memInfo) {
memInfoServiceImpl.findAllByPagination(getPaginationUtility(), memInfo);
return getGridModelResponse();
}
}
package org.rcisoft.business.memInfo.controller;
/*固定导入*/
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.Operation;
import org.rcisoft.core.anno.CyEncryptSm4Anno;
import org.rcisoft.core.anno.CyOpeLogAnno;
import org.rcisoft.core.operlog.enums.CyLogTypeEnum;
import org.rcisoft.core.util.CyEpExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.BindingResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.rcisoft.core.result.CyResult;
import org.rcisoft.core.util.CyResultGenUtil;
import org.rcisoft.core.model.CyPersistModel;
import org.rcisoft.core.constant.CyMessCons;
import org.rcisoft.core.controller.CyPaginationController;
import org.rcisoft.core.util.CyUserUtil;
import org.rcisoft.core.model.CyGridModel;
import org.rcisoft.core.exception.CyServiceException;
import jakarta.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import org.rcisoft.business.memInfo.entity.MemInfo;
import org.rcisoft.business.memInfo.service.MemInfoService;
import java.util.List;
/**
* Created by cy on 2024年12月20日 下午3:35:34.
*/
@RestController
@RequestMapping("/memInfo")
public class MemInfoController extends CyPaginationController<MemInfo> {
@Autowired
private MemInfoService memInfoServiceImpl;
@PreAuthorize("@cyPerm.hasPerm('mem:info:add')")
@CyOpeLogAnno(title = "system-会员表管理-新增会员表", businessType = CyLogTypeEnum.INSERT)
@Operation(summary="添加会员表", description="添加会员表")
@PostMapping(value = "/add")
@CyEncryptSm4Anno
public CyResult add(@Valid MemInfo memInfo, BindingResult bindingResult) {
CyPersistModel data = memInfoServiceImpl.persist(memInfo);
return CyResultGenUtil.builder(data,
CyMessCons.MESSAGE_ALERT_SUCCESS,
CyMessCons.MESSAGE_ALERT_ERROR,
memInfo);
}
@PreAuthorize("@cyPerm.hasPerm('mem:info:delete')")
@CyOpeLogAnno(title = "system-会员表管理-删除会员表", businessType = CyLogTypeEnum.DELETE)
@Operation(summary="逻辑删除会员表", description="逻辑删除会员表")
@Parameters({@Parameter(name = "businessId", description = "businessId", required = true, schema = @Schema(type = "string"))})
@DeleteMapping("/deleteLogical/{businessId:\\w+}")
public CyResult deleteLogical(@PathVariable int businessId,MemInfo memInfo) {
memInfo.setBusinessId(businessId);
CyPersistModel data = memInfoServiceImpl.removeLogical(memInfo);
return CyResultGenUtil.builder(data,
CyMessCons.MESSAGE_ALERT_SUCCESS,
CyMessCons.MESSAGE_ALERT_ERROR,
businessId);
}
@PreAuthorize("@cyPerm.hasPerm('mem:info:delete')")
@CyOpeLogAnno(title = "system-会员表管理-删除会员表", businessType = CyLogTypeEnum.DELETE)
@Operation(summary="删除会员表", description="删除会员表")
@Parameters({@Parameter(name = "businessId", description = "businessId", required = true, schema = @Schema(type = "string"))})
@DeleteMapping("/delete/{businessId:\\w+}")
public CyResult delete(@PathVariable int businessId,MemInfo memInfo) {
memInfo.setBusinessId(businessId);
CyPersistModel data = memInfoServiceImpl.remove(memInfo);
return CyResultGenUtil.builder(data,
CyMessCons.MESSAGE_ALERT_SUCCESS,
CyMessCons.MESSAGE_ALERT_ERROR,
businessId);
}
@PreAuthorize("@cyPerm.hasPerm('mem:info:update')")
@CyOpeLogAnno(title = "system-会员表管理-修改会员表", businessType = CyLogTypeEnum.UPDATE)
@Operation(summary="修改会员表", description="修改会员表")
@Parameters({@Parameter(name = "businessId", description = "businessId", required = false, schema = @Schema(type = "string"))})
@PutMapping("/update/{businessId:\\w+}")
public CyResult update(@PathVariable int businessId, @Valid MemInfo memInfo, BindingResult bindingResult) {
memInfo.setBusinessId(businessId);
CyPersistModel data = memInfoServiceImpl.merge(memInfo);
return CyResultGenUtil.builder(data,
CyMessCons.MESSAGE_ALERT_SUCCESS,
CyMessCons.MESSAGE_ALERT_ERROR,
memInfo);
}
@PreAuthorize("@cyPerm.hasPerm('mem:info:query')")
@CyOpeLogAnno(title = "system-会员表管理-查询会员表", businessType = CyLogTypeEnum.QUERY)
@Operation(summary="查询单一会员表", description="查询单一会员表")
@Parameters({@Parameter(name = "businessId", description = "businessId", required = true, schema = @Schema(type = "string"))})
@GetMapping("/detail/{businessId:\\w+}")
public CyResult detail(@PathVariable int businessId) {
return CyResultGenUtil.builder(new CyPersistModel(1),
CyMessCons.MESSAGE_ALERT_SUCCESS,
CyMessCons.MESSAGE_ALERT_ERROR,
memInfoServiceImpl.findById(businessId));
}
@PreAuthorize("@cyPerm.hasPerm('mem:info:list')")
@CyOpeLogAnno(title = "system-会员表管理-查询会员表", businessType = CyLogTypeEnum.QUERY)
@Operation(summary="查询会员表集合", description="查询会员表集合")
@GetMapping(value = "/listAll")
public CyResult listAll(MemInfo memInfo) {
return CyResultGenUtil.builder(new CyPersistModel(1),
CyMessCons.MESSAGE_ALERT_SUCCESS,
CyMessCons.MESSAGE_ALERT_ERROR,
memInfoServiceImpl.findAll(memInfo));
}
@PreAuthorize("@cyPerm.hasPerm('mem:info:list')")
@CyOpeLogAnno(title = "system-会员表管理-查询会员表", businessType = CyLogTypeEnum.QUERY)
@Operation(summary="分页查询会员表集合", description="分页查询会员表集合")
@GetMapping(value = "/list")
public CyGridModel listByPagination(MemInfo memInfo) {
memInfoServiceImpl.findAllByPagination(getPaginationUtility(), memInfo);
return getGridModelResponse();
}
@PreAuthorize("@cyPerm.hasPerm('mem:info:export')")
@CyOpeLogAnno(title = "system-会员表管理-查询会员表", businessType = CyLogTypeEnum.EXPORT)
@Operation(summary = "导出会员表信息", description = "导出会员表信息")
@GetMapping(value = "/export")
public void outMemInfo(HttpServletResponse response,MemInfo memInfo,@PathVariable @RequestParam(defaultValue = "0") String excelId) {
String excelName="";
switch(excelId){
case "0": excelName="会员表信息.xls";break;
case "1": excelName="会员表信息.xlsx";break;
case "2": excelName="会员表信息.csv";break;
}
List<MemInfo> memInfoList = memInfoServiceImpl.export(memInfo);
CyEpExcelUtil.exportExcel(memInfoList, "会员表信息", "会员表信息", MemInfo.class, excelName, response);
}
@CyOpeLogAnno(title = "system-会员表管理-校验手机号", businessType = CyLogTypeEnum.INSERT)
@Operation(summary="校验手机号", description="校验手机号")
@PostMapping(value = "/checkInfo")
@CyEncryptSm4Anno
public CyResult checkInfo(@Valid MemInfo memInfo) {
return CyResultGenUtil.genSuccessResult(memInfoServiceImpl.checkInfo(memInfo));
}
}
package org.rcisoft.business.memInfo.dao;
import org.rcisoft.core.mapper.CyBaseMapper;
import org.rcisoft.business.memInfo.entity.MemInfo;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.rcisoft.sys.rbac.user.dto.SysUserRbacDTO;
import org.springframework.stereotype.Repository;
import org.rcisoft.core.model.CyPageInfo;
import org.apache.ibatis.annotations.Param;
import com.baomidou.mybatisplus.core.metadata.IPage;
import java.util.List;
/**
* Created with cy on 2024年12月20日 下午3:35:34.
*/
public interface MemInfoRepository extends CyBaseMapper<MemInfo> {
List<MemInfo> queryMemInfos(@Param("entity") MemInfo memInfo);
/**
* 分页查询 memInfo
*
*/
IPage<MemInfo> queryMemInfosPaged(CyPageInfo cyPageInfo,@Param("entity") MemInfo memInfo);
/**
* 根据roleKey查询角色
* @param roleKey
* @return
*/
List<Integer> selectRoleByKey(@Param("roleKey")String roleKey);
//校验手机号是否重复
SysUserRbacDTO checkPhoneRepeat(@Param("userId")Integer userId, @Param("phone")String phone);
//校验身份证是否重复
SysUserRbacDTO checkIdcardRepeat(@Param("userId")Integer userId, @Param("Idcard")String Idcard);
/**
* 查询详情
* @param id
* @return
*/
MemInfo selectDetailById(@Param("businessId")int businessId);
}
package org.rcisoft.business.memInfo.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.baomidou.mybatisplus.annotation.TableField;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
import org.rcisoft.core.entity.CyIdIncreEntity;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* Created with cy on 2024年12月20日 下午3:35:34.
*/
@Data
@TableName("mem_info")
public class MemInfo extends CyIdIncreEntity<MemInfo> {
/**
* @desc 用户id
* @column user_id
* @default
*/
@Excel(name = "用户id", orderNum = "0", width = 20)
private Integer userId;
/**
* @desc 会员号
* @column mem_code
* @default
*/
@Excel(name = "会员号", orderNum = "1", width = 20)
private String memCode;
/**
* @desc 用户性别(0男 1女 2未知)
* @column mem_sex
* @default
*/
@Excel(name = "用户性别(0男 1女 2未知)", orderNum = "2", width = 20)
private String memSex;
/**
* @desc 生日,格式:xxxx-01-01
* @column mem_birthday
* @default
*/
@Excel(name = "生日,格式:xxxx-01-01", orderNum = "3", width = 20)
private String memBirthday;
/**
* @desc 星座,1-12 水瓶-摩羯 ,根据birthday,自动带入
* @column mem_constellation
* @default
*/
@Excel(name = "星座,1-12 水瓶-摩羯 ,根据birthday,自动带入", orderNum = "4", width = 20)
private String memConstellation;
/**
* @desc 身高
* @column mem_height
* @default
*/
@Excel(name = "身高", orderNum = "5", width = 20)
private BigDecimal memHeight;
/**
* @desc 体重 kg
* @column mem_weight
* @default
*/
@Excel(name = "体重 kg", orderNum = "6", width = 20)
private BigDecimal memWeight;
/**
* @desc 大专以下 1,大专 2,本科 3,硕士,4,博士 5,博士后 6,其他 0
* @column mem_max_education
* @default
*/
@Excel(name = "大专以下 1,大专 2,本科 3,硕士,4,博士 5,博士后 6,其他 0", orderNum = "7", width = 20)
private String memMaxEducation;
/**
* @desc 毕业院校
* @column mem_college
* @default
*/
@Excel(name = "毕业院校", orderNum = "8", width = 20)
private String memCollege;
/**
* @desc 职业
* @column mem_career
* @default
*/
@Excel(name = "职业", orderNum = "9", width = 20)
private String memCareer;
/**
* @desc 年收入,单位 k
* @column mem_year_income
* @default
*/
@Excel(name = "年收入,单位 k", orderNum = "10", width = 20)
private BigDecimal memYearIncome;
/**
* @desc 工作单位
* @column mem_work_place
* @default
*/
@Excel(name = "工作单位", orderNum = "11", width = 20)
private String memWorkPlace;
/**
* @desc 居住地省份
* @column mem_residence_province
* @default
*/
@Excel(name = "居住地省份", orderNum = "12", width = 20)
private String memResidenceProvince;
/**
* @desc 居住地市
* @column mem_residence_city
* @default
*/
@Excel(name = "居住地市", orderNum = "13", width = 20)
private String memResidenceCity;
/**
* @desc 籍贯省份
* @column mem_native_province
* @default
*/
@Excel(name = "籍贯省份", orderNum = "14", width = 20)
private String memNativeProvince;
/**
* @desc 籍贯市
* @column mem_native_city
* @default
*/
@Excel(name = "籍贯市", orderNum = "15", width = 20)
private String memNativeCity;
/**
* @desc 自我介绍
* @column mem_introduce
* @default
*/
@Excel(name = "自我介绍", orderNum = "16", width = 20)
private String memIntroduce;
/**
* @desc 兴趣爱好
* @column mem_hobby
* @default
*/
@Excel(name = "兴趣爱好", orderNum = "17", width = 20)
private String memHobby;
/**
* @desc 未来规划
* @column mem_future_plan
* @default
*/
@Excel(name = "未来规划", orderNum = "18", width = 20)
private String memFuturePlan;
/**
* @desc 期待
* @column mem_half_desire
* @default
*/
@Excel(name = "期待", orderNum = "19", width = 20)
private String memHalfDesire;
/**
* @desc 婚姻状况:0 其他 ,1 未婚,2 已婚,3 离异
* @column mem_marriage
* @default
*/
@Excel(name = "婚姻状况:0 其他 ,1 未婚,2 已婚,3 离异", orderNum = "20", width = 20)
private String memMarriage;
/**
* @desc 婚姻状况备注
* @column mem_marriage_remarks
* @default
*/
@Excel(name = "婚姻状况备注", orderNum = "21", width = 20)
private String memMarriageRemarks;
/**
* @desc 16型人格
* @column mem_mbti
* @default
*/
@Excel(name = "16型人格", orderNum = "22", width = 20)
private String memMbti;
/**
* @desc wx 号
* @column mem_wx_code
* @default
*/
@Excel(name = "wx 号", orderNum = "23", width = 20)
private String memWxCode;
/**
* @desc 真实姓名
* @column mem_real_name
* @default
*/
@Excel(name = "真实姓名", orderNum = "24", width = 20)
private String memRealName;
/**
* @desc 电话
* @column mem_phone
* @default
*/
@Excel(name = "电话", orderNum = "25", width = 20)
private String memPhone;
/**
* @desc 证件号
* @column mem_idcard
* @default
*/
@Excel(name = "证件号", orderNum = "26", width = 20)
private String memIdcard;
/**
* @desc 1 已实名,0 未实名
* @column mem_real_authen
* @default
*/
@Excel(name = "1 已实名,0 未实名", orderNum = "27", width = 20)
private String memRealAuthen;
/**
* @desc 实名时间
* @column mem_real_authen_date
* @default
*/
@JsonFormat(
pattern = "yyyy-MM-dd"
)
@Excel(name = "实名时间", orderNum = "28", width = 20, format = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date memRealAuthenDate;
/**
* @desc 会员等级 0 无
* @column mem_level
* @default
*/
@Excel(name = "会员等级 0 无", orderNum = "29", width = 20)
private Integer memLevel;
/**
* @desc 会员开始时间
* @column mem_level_begin_date
* @default
*/
@JsonFormat(
pattern = "yyyy-MM-dd"
)
@Excel(name = "会员开始时间", orderNum = "30", width = 20, format = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date memLevelBeginDate;
/**
* @desc 会员结束时间
* @column mem_level_end_date
* @default
*/
@JsonFormat(
pattern = "yyyy-MM-dd"
)
@Excel(name = "会员结束时间", orderNum = "31", width = 20, format = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date memLevelEndDate;
/**
* @desc 昵称
* @column mem_nick_name
* @default
*/
@Excel(name = "昵称", orderNum = "32", width = 20)
private String memNickName;
/**
* @desc 昵称
* @column mem_code_level
* @default
*/
// @Excel(name = "昵称", orderNum = "32", width = 20)
private String memCodeLevel;
/**
* 开始时间
*/
@JsonIgnore
@TableField(exist = false)
private String beginTime;
/**
* 结束时间
*/
@JsonIgnore
@TableField(exist = false)
private String endTime;
/**
* 生日开始时间
*/
@JsonIgnore
@TableField(exist = false)
private String beginBirthday;
/**
* 生日结束时间
*/
@JsonIgnore
@TableField(exist = false)
private String endBirthday;
/**
* 最小身高
*/
@TableField(exist = false)
private BigDecimal minHeight;
/**
* 最大身高
*/
@TableField(exist = false)
private BigDecimal maxHeight;
/**
* 最小体重
*/
@TableField(exist = false)
private BigDecimal minWeight;
/**
* 最大体重
*/
@TableField(exist = false)
private BigDecimal maxWeight;
/**
* 学历
*/
@TableField(exist = false)
private String educations;
/**
* 最小年收入
*/
@TableField(exist = false)
private BigDecimal minYearIncome;
/**
* 最大年收入
*/
@TableField(exist = false)
private BigDecimal maxYearIncome;
/**
* 实名开始时间
*/
@JsonIgnore
@TableField(exist = false)
private String authenBeginTime;
/**
* 实名结束时间
*/
@JsonIgnore
@TableField(exist = false)
private String authenEndTime;
/**
* 开始时间
*/
@JsonIgnore
@TableField(exist = false)
private String memLevelBeginTime;
/**
* 结束时间
*/
@JsonIgnore
@TableField(exist = false)
private String memLevelEndTime;
}
package org.rcisoft.business.memInfo.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.rcisoft.business.memInfo.entity.MemInfo;
import org.rcisoft.core.model.CyPersistModel;
import org.rcisoft.core.aop.CyPageUtilAsp;
import org.rcisoft.core.model.CyPageInfo;
import java.util.List;
/**
* Created by cy on 2024年12月20日 下午3:35:34.
*/
public interface MemInfoService {
/**
* 保存 会员表
* @param memInfo
* @return
*/
CyPersistModel persist(MemInfo memInfo);
/**
* 删除 会员表
* @param memInfo
* @return
*/
CyPersistModel remove(MemInfo memInfo);
/**
* 逻辑删除 会员表
* @param memInfo
* @return
*/
CyPersistModel removeLogical(MemInfo memInfo);
/**
* 修改 会员表
* @param memInfo
* @return
*/
CyPersistModel merge(MemInfo memInfo);
/**
* 根据id查询 会员表
* @param id
* @return
*/
MemInfo findById(int id);
/**
* 分页查询 会员表
* @param memInfo
* @return
*/
IPage<MemInfo> findAllByPagination(CyPageInfo<MemInfo> paginationUtility,
MemInfo memInfo);
/**
* 查询list 会员表
* @param memInfo
* @return
*/
List<MemInfo> findAll(MemInfo memInfo);
/**
* 导出会员表
* @return
*/
List<MemInfo> export(MemInfo memInfo);
/**
* 校验会员信息
* @param memInfo
* @return
*/
Boolean checkInfo(MemInfo memInfo);
}
package org.rcisoft.business.memInfo.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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 org.apache.commons.lang3.StringUtils;
import org.rcisoft.core.constant.CyDelStaCons;
import org.rcisoft.core.constant.CyFlagStaCons;
import org.rcisoft.core.exception.CyServiceException;
import org.rcisoft.core.util.CyAESUtils;
import org.rcisoft.core.util.CyIdGenUtil;
import org.rcisoft.core.util.CyUserUtil;
import org.rcisoft.core.aop.CyPageUtilAsp;
import org.rcisoft.core.model.CyPersistModel;
import org.rcisoft.core.util.CyEpExcelUtil;
import org.rcisoft.business.memInfo.dao.MemInfoRepository;
import org.rcisoft.business.memInfo.entity.MemInfo;
import org.rcisoft.business.memInfo.service.MemInfoService;
import org.rcisoft.core.service.CyBaseService;
import org.rcisoft.sys.constant.CyUserCons;
import org.rcisoft.sys.rbac.user.dao.SysUserRbacRepository;
import org.rcisoft.sys.rbac.user.dto.SysUserRbacDTO;
import org.rcisoft.sys.rbac.user.entity.SysUserRbac;
import org.rcisoft.sys.rbac.user.enums.UserInfoExceptionEnums;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.rcisoft.core.model.CyPageInfo;
import java.util.HashSet;
import java.util.List;
import java.util.Random;
import java.util.Set;
import lombok.extern.slf4j.Slf4j;
/**
* Created by cy on 2024年12月20日 下午3:35:34.
*/
@Service
@Transactional(readOnly = true,propagation = Propagation.NOT_SUPPORTED)
@Slf4j
public class MemInfoServiceImpl extends ServiceImpl<MemInfoRepository,MemInfo> implements MemInfoService {
// 定义允许的字符集
private static final String CHAR_POOL = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";
private static final Random RANDOM = new Random();
private static final Set<String> generatedNicknames = new HashSet<>();
@Autowired
private SysUserRbacRepository sysUserRbacRepository;
@Autowired
private PasswordEncoder passwordEncoder;
@Autowired
CyIdGenUtil cyIdGenUtil;
@Value("${cy.init.password}")
private String password;
/**
* 保存 会员表
* @param memInfo
* @return
*/
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public CyPersistModel persist(MemInfo memInfo){
//手机号、身份证存储加密
if (StringUtils.isNotBlank(memInfo.getMemPhone()))
memInfo.setMemPhone(CyAESUtils.encrypt(memInfo.getMemPhone()));
if (StringUtils.isNotBlank(memInfo.getMemIdcard()))
memInfo.setMemIdcard(CyAESUtils.encrypt(memInfo.getMemIdcard()));
//身份证、手机号验重
SysUserRbacDTO sysUserRbacDTO = baseMapper.checkPhoneRepeat(null,memInfo.getMemPhone());
if (sysUserRbacDTO != null) {
throw new CyServiceException(UserInfoExceptionEnums.PHONE_EXISTS);
}
sysUserRbacDTO = baseMapper.checkIdcardRepeat(null,memInfo.getMemIdcard());
if (sysUserRbacDTO != null) {
throw new CyServiceException(UserInfoExceptionEnums.ID_NUMBER_EXISTS);
}
//添加sys_user
SysUserRbac userRbac = new SysUserRbac();
userRbac.setUsername(this.generateRandomName());
userRbac.setUserType(CyUserCons.USER_TYPE_COMMON);
userRbac.setPhone(memInfo.getMemPhone());
userRbac.setSex(memInfo.getMemSex());
userRbac.setPassword(passwordEncoder.encode(password));
userRbac.setIdNumber(memInfo.getMemIdcard());
userRbac.setUserIdentity("10");
userRbac.setFlag(CyFlagStaCons.NORMAL.getStatus());
userRbac.setDelFlag(CyDelStaCons.NORMAL.getStatus());
sysUserRbacRepository.insert(userRbac);
//查询会员角色
List<Integer> roleIds = baseMapper.selectRoleByKey("member");
//插入角色
if (!roleIds.isEmpty()) {
sysUserRbacRepository.insertUserRole(userRbac.getBusinessId(), roleIds);
}
//生成会员号
memInfo.setMemCode("11");
//增加操作
memInfo.setUserId(userRbac.getBusinessId());
int line = baseMapper.insert(memInfo);
log.debug(CyUserUtil.getAuthenUsername()+"新增了ID为"+
memInfo.getBusinessId()+"的会员表信息");
return new CyPersistModel(line);
}
/**
* 删除 会员表
* @param memInfo
* @return
*/
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public CyPersistModel remove(MemInfo memInfo){
int line = baseMapper.realDelete(memInfo);
log.debug(CyUserUtil.getAuthenUsername()+"删除了ID为"+
memInfo.getBusinessId()+"的会员表信息");
return new CyPersistModel(line);
}
/**
* 逻辑删除 会员表
* @param memInfo
* @return
*/
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public CyPersistModel removeLogical(MemInfo memInfo){
memInfo.setDeleted();
int line = baseMapper.deleteById(memInfo);
log.debug(CyUserUtil.getAuthenUsername()+"逻辑删除了ID为"+
memInfo.getBusinessId()+"的会员表信息");
return new CyPersistModel(line);
}
/**
* 修改 会员表
* @param memInfo
* @return
*/
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public CyPersistModel merge(MemInfo memInfo){
int line = baseMapper.updateById(memInfo);
log.debug(CyUserUtil.getAuthenUsername()+"修改了ID为"+ memInfo.getBusinessId()+"的会员表信息");
return new CyPersistModel(line);
}
/**
* 根据id查询 会员表
* @param id
* @return
*/
@Override
public MemInfo findById(int id){
return baseMapper.selectDetailById(id);
}
/**
* 分页查询 会员表
* @param memInfo
* @return
*/
@Override
public IPage<MemInfo> findAllByPagination(CyPageInfo<MemInfo> paginationUtility,
MemInfo memInfo){
return baseMapper.queryMemInfosPaged(paginationUtility,memInfo);
}
/**
* 查询list 会员表
* @param memInfo
* @return
*/
@Override
public List<MemInfo> findAll(MemInfo memInfo){
return baseMapper.queryMemInfos(memInfo);
}
/**
* 导出会员表
* @return
*/
@Override
public List<MemInfo> export(MemInfo memInfo) {
List<MemInfo> memInfoList = baseMapper.queryMemInfos(memInfo);
return memInfoList;
}
private String generateRandomName() {
StringBuilder nickname;
int length = 10;
do {
nickname = new StringBuilder(length);
for (int i = 0; i < length; i++) {
int index = RANDOM.nextInt(CHAR_POOL.length());
nickname.append(CHAR_POOL.charAt(index));
}
} while (generatedNicknames.contains(nickname.toString()));
// 存储生成的昵称
generatedNicknames.add(nickname.toString());
return "wx_" + nickname.toString();
}
/**
* 校验会员信息
* @param memInfo
* @return
*/
@Override
public Boolean checkInfo(MemInfo memInfo) {
//手机号、身份证存储加密
if (StringUtils.isNotBlank(memInfo.getMemPhone()))
memInfo.setMemPhone(CyAESUtils.encrypt(memInfo.getMemPhone()));
if (StringUtils.isNotBlank(memInfo.getMemIdcard()))
memInfo.setMemIdcard(CyAESUtils.encrypt(memInfo.getMemIdcard()));
//身份证、手机号验重
SysUserRbacDTO sysUserRbacDTO = baseMapper.checkPhoneRepeat(memInfo.getUserId(),memInfo.getMemPhone());
if (sysUserRbacDTO != null) {
throw new CyServiceException(UserInfoExceptionEnums.PHONE_EXISTS);
}
sysUserRbacDTO = baseMapper.checkIdcardRepeat(null,memInfo.getMemIdcard());
if (sysUserRbacDTO != null) {
throw new CyServiceException(UserInfoExceptionEnums.ID_NUMBER_EXISTS);
}
return true;
}
}
...@@ -47,7 +47,7 @@ cy: ...@@ -47,7 +47,7 @@ cy:
decryptParam: false decryptParam: false
decryptKey: cyKey decryptKey: cyKey
# sm4 # sm4
decryptSm4Param: false decryptSm4Param: true
decryptSm4Secret: 'FFFAAA333777EEEB' decryptSm4Secret: 'FFFAAA333777EEEB'
# 文件存储 # 文件存储
fileStorage: fileStorage:
...@@ -69,8 +69,8 @@ cy: ...@@ -69,8 +69,8 @@ cy:
code: code:
enable: true enable: true
author: cy author: cy
dbType: sqlserver dbType: mysql
database: rcisoft database: cy
basePackage: org.rcisoft.sys basePackage: org.rcisoft.sys
rejectRepeatSubmit: rejectRepeatSubmit:
enable: false enable: false
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment