mirror of https://gitee.com/stylefeng/roses
【7.0.4】更新C端用户
parent
d5cd8bb072
commit
0a88f66f16
|
@ -0,0 +1 @@
|
|||
C端用户,适用于BBS等to c 业务的用户管理
|
|
@ -0,0 +1 @@
|
|||
C端用户api
|
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>kernel-s-customer</artifactId>
|
||||
<version>7.0.4</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>customer-api</artifactId>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [https://www.stylefeng.cn]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Guns源码头部的版权声明。
|
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.customer.api;
|
||||
|
||||
/**
|
||||
* C端用户api
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/6/7 11:31
|
||||
*/
|
||||
public interface CustomerApi {
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [https://www.stylefeng.cn]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Guns源码头部的版权声明。
|
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.customer.api.constants;
|
||||
|
||||
/**
|
||||
* C端业务的常量
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/6/7 11:28
|
||||
*/
|
||||
public interface CustomerConstants {
|
||||
|
||||
/**
|
||||
* C端模块的名称
|
||||
*/
|
||||
String CUSTOMER_MODULE_NAME = "kernel-s-customer";
|
||||
|
||||
/**
|
||||
* 异常枚举的步进值
|
||||
*/
|
||||
String CUSTOMER_EXCEPTION_STEP_CODE = "31";
|
||||
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [https://www.stylefeng.cn]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Guns源码头部的版权声明。
|
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.customer.api.exception;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.stylefeng.roses.kernel.customer.api.constants.CustomerConstants;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.AbstractExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
||||
|
||||
/**
|
||||
* C端用户的异常
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/6/7 11:29
|
||||
*/
|
||||
public class CustomerException extends ServiceException {
|
||||
|
||||
public CustomerException(AbstractExceptionEnum exception, Object... params) {
|
||||
super(CustomerConstants.CUSTOMER_MODULE_NAME, exception.getErrorCode(), StrUtil.format(exception.getUserTip(), params));
|
||||
}
|
||||
|
||||
public CustomerException(AbstractExceptionEnum exception) {
|
||||
super(CustomerConstants.CUSTOMER_MODULE_NAME, exception);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [https://www.stylefeng.cn]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Guns源码头部的版权声明。
|
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.customer.api.exception.enums;
|
||||
|
||||
import cn.stylefeng.roses.kernel.customer.api.constants.CustomerConstants;
|
||||
import cn.stylefeng.roses.kernel.rule.constants.RuleConstants;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.AbstractExceptionEnum;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* C端用户异常枚举
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/6/7 11:30
|
||||
*/
|
||||
@Getter
|
||||
public enum CustomerExceptionEnum implements AbstractExceptionEnum {
|
||||
|
||||
/**
|
||||
* 查询不到对应用户
|
||||
*/
|
||||
CANT_FIND_CUSTOMER(RuleConstants.BUSINESS_ERROR_TYPE_CODE + CustomerConstants.CUSTOMER_EXCEPTION_STEP_CODE + "01", "查询不到对应用户,用户id是:{}");
|
||||
|
||||
/**
|
||||
* 错误编码
|
||||
*/
|
||||
private final String errorCode;
|
||||
|
||||
/**
|
||||
* 提示用户信息
|
||||
*/
|
||||
private final String userTip;
|
||||
|
||||
CustomerExceptionEnum(String errorCode, String userTip) {
|
||||
this.errorCode = errorCode;
|
||||
this.userTip = userTip;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
C端用户管理业务模块
|
|
@ -0,0 +1,67 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>kernel-s-customer</artifactId>
|
||||
<version>7.0.4</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>customer-business</artifactId>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!--c端用户api-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>customer-api</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--资源api模块-->
|
||||
<!--用在资源控制器,资源扫描上-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>scanner-api</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--参数校验模块-->
|
||||
<!--用在控制器,参数校验-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>validator-api</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--数据库sdk-->
|
||||
<!--数据库初始化-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>db-sdk-init</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--数据库sdk-->
|
||||
<!--数据库dao框架-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>db-sdk-mp</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--web模块-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,98 @@
|
|||
package cn.stylefeng.roses.kernel.customer.modular.controller;
|
||||
|
||||
import cn.stylefeng.roses.kernel.customer.modular.request.CustomerRequest;
|
||||
import cn.stylefeng.roses.kernel.customer.modular.service.CustomerService;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
|
||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
|
||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
|
||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* C端用户表控制器
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/06/07 11:40
|
||||
*/
|
||||
@RestController
|
||||
@ApiResource(name = "C端用户表")
|
||||
public class CustomerController {
|
||||
|
||||
@Resource
|
||||
private CustomerService customerService;
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/06/07 11:40
|
||||
*/
|
||||
@PostResource(name = "添加", path = "/customer/add")
|
||||
public ResponseData add(@RequestBody @Validated(CustomerRequest.add.class) CustomerRequest customerRequest) {
|
||||
customerService.add(customerRequest);
|
||||
return new SuccessResponseData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/06/07 11:40
|
||||
*/
|
||||
@PostResource(name = "删除", path = "/customer/delete")
|
||||
public ResponseData delete(@RequestBody @Validated(CustomerRequest.delete.class) CustomerRequest customerRequest) {
|
||||
customerService.del(customerRequest);
|
||||
return new SuccessResponseData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/06/07 11:40
|
||||
*/
|
||||
@PostResource(name = "编辑", path = "/customer/edit")
|
||||
public ResponseData edit(@RequestBody @Validated(CustomerRequest.edit.class) CustomerRequest customerRequest) {
|
||||
customerService.edit(customerRequest);
|
||||
return new SuccessResponseData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看详情
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/06/07 11:40
|
||||
*/
|
||||
@GetResource(name = "查看详情", path = "/customer/detail")
|
||||
public ResponseData detail(@Validated(CustomerRequest.detail.class) CustomerRequest customerRequest) {
|
||||
return new SuccessResponseData(customerService.detail(customerRequest));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取列表
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/06/07 11:40
|
||||
*/
|
||||
@GetResource(name = "获取列表", path = "/customer/list")
|
||||
public ResponseData list(CustomerRequest customerRequest) {
|
||||
return new SuccessResponseData(customerService.findList(customerRequest));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取列表(带分页)
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/06/07 11:40
|
||||
*/
|
||||
@GetResource(name = "分页查询", path = "/customer/page")
|
||||
public ResponseData page(CustomerRequest customerRequest) {
|
||||
return new SuccessResponseData(customerService.findPage(customerRequest));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
package cn.stylefeng.roses.kernel.customer.modular.entity;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseEntity;
|
||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.field.ChineseDescription;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* C端用户表实例类
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/06/07 11:40
|
||||
*/
|
||||
@TableName("toc_customer")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class Customer extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId(value = "customer_id", type = IdType.ASSIGN_ID)
|
||||
@ChineseDescription("主键id")
|
||||
private Long customerId;
|
||||
|
||||
/**
|
||||
* 账号
|
||||
*/
|
||||
@TableField("account")
|
||||
@ChineseDescription("账号")
|
||||
private String account;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
@TableField("password")
|
||||
@ChineseDescription("密码")
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 昵称(显示名称)
|
||||
*/
|
||||
@TableField("nick_name")
|
||||
@ChineseDescription("昵称(显示名称)")
|
||||
private String nickName;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
@TableField("email")
|
||||
@ChineseDescription("邮箱")
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 手机
|
||||
*/
|
||||
@TableField("telephone")
|
||||
@ChineseDescription("手机")
|
||||
private String telephone;
|
||||
|
||||
/**
|
||||
* 用户头像(文件表id)
|
||||
*/
|
||||
@TableField("avatar")
|
||||
@ChineseDescription("用户头像(文件表id)")
|
||||
private Long avatar;
|
||||
|
||||
/**
|
||||
* 用户头像的文件全名
|
||||
*/
|
||||
@TableField("avatar_object_name")
|
||||
@ChineseDescription("用户头像的文件全名")
|
||||
private String avatarObjectName;
|
||||
|
||||
/**
|
||||
* 用户积分
|
||||
*/
|
||||
@TableField("score")
|
||||
@ChineseDescription("用户积分")
|
||||
private Integer score;
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package cn.stylefeng.roses.kernel.customer.modular.mapper;
|
||||
|
||||
import cn.stylefeng.roses.kernel.customer.modular.entity.Customer;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* C端用户表 Mapper 接口
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/06/07 11:40
|
||||
*/
|
||||
public interface CustomerMapper extends BaseMapper<Customer> {
|
||||
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.stylefeng.roses.kernel.customer.modular.mapper.CustomerMapper">
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,79 @@
|
|||
package cn.stylefeng.roses.kernel.customer.modular.request;
|
||||
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
|
||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.field.ChineseDescription;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* C端用户表封装类
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/06/07 11:40
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class CustomerRequest extends BaseRequest {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@NotNull(message = "主键id不能为空", groups = {edit.class, delete.class})
|
||||
@ChineseDescription("主键id")
|
||||
private Long customerId;
|
||||
|
||||
/**
|
||||
* 账号
|
||||
*/
|
||||
@NotBlank(message = "账号不能为空", groups = {add.class, edit.class})
|
||||
@ChineseDescription("账号")
|
||||
private String account;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
@NotBlank(message = "密码不能为空", groups = {add.class, edit.class})
|
||||
@ChineseDescription("密码")
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 昵称(显示名称)
|
||||
*/
|
||||
@NotBlank(message = "昵称(显示名称)不能为空", groups = {add.class, edit.class})
|
||||
@ChineseDescription("昵称(显示名称)")
|
||||
private String nickName;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
@ChineseDescription("邮箱")
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 手机
|
||||
*/
|
||||
@ChineseDescription("手机")
|
||||
private String telephone;
|
||||
|
||||
/**
|
||||
* 用户头像(文件表id)
|
||||
*/
|
||||
@ChineseDescription("用户头像(文件表id)")
|
||||
private Long avatar;
|
||||
|
||||
/**
|
||||
* 用户头像的文件全名
|
||||
*/
|
||||
@ChineseDescription("用户头像的文件全名")
|
||||
private String avatarObjectName;
|
||||
|
||||
/**
|
||||
* 用户积分
|
||||
*/
|
||||
@ChineseDescription("用户积分")
|
||||
private Integer score;
|
||||
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
package cn.stylefeng.roses.kernel.customer.modular.service;
|
||||
|
||||
import cn.stylefeng.roses.kernel.customer.modular.entity.Customer;
|
||||
import cn.stylefeng.roses.kernel.customer.modular.request.CustomerRequest;
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* C端用户表 服务类
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/06/07 11:40
|
||||
*/
|
||||
public interface CustomerService extends IService<Customer> {
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/06/07 11:40
|
||||
*/
|
||||
void add(CustomerRequest customerRequest);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/06/07 11:40
|
||||
*/
|
||||
void del(CustomerRequest customerRequest);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/06/07 11:40
|
||||
*/
|
||||
void edit(CustomerRequest customerRequest);
|
||||
|
||||
/**
|
||||
* 查询详情
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/06/07 11:40
|
||||
*/
|
||||
Customer detail(CustomerRequest customerRequest);
|
||||
|
||||
/**
|
||||
* 获取列表
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/06/07 11:40
|
||||
*/
|
||||
List<Customer> findList(CustomerRequest customerRequest);
|
||||
|
||||
/**
|
||||
* 获取列表(带分页)
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/06/07 11:40
|
||||
*/
|
||||
PageResult<Customer> findPage(CustomerRequest customerRequest);
|
||||
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
package cn.stylefeng.roses.kernel.customer.modular.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.stylefeng.roses.kernel.customer.modular.entity.Customer;
|
||||
import cn.stylefeng.roses.kernel.customer.modular.mapper.CustomerMapper;
|
||||
import cn.stylefeng.roses.kernel.customer.modular.request.CustomerRequest;
|
||||
import cn.stylefeng.roses.kernel.customer.modular.service.CustomerService;
|
||||
import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;
|
||||
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.enums.defaults.DefaultBusinessExceptionEnum;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* C端用户表业务实现层
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/06/07 11:40
|
||||
*/
|
||||
@Service
|
||||
public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> implements CustomerService {
|
||||
|
||||
@Override
|
||||
public void add(CustomerRequest customerRequest) {
|
||||
Customer customer = new Customer();
|
||||
BeanUtil.copyProperties(customerRequest, customer);
|
||||
this.save(customer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void del(CustomerRequest customerRequest) {
|
||||
Customer customer = this.queryCustomer(customerRequest);
|
||||
this.removeById(customer.getCustomerId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void edit(CustomerRequest customerRequest) {
|
||||
Customer customer = this.queryCustomer(customerRequest);
|
||||
BeanUtil.copyProperties(customerRequest, customer);
|
||||
this.updateById(customer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Customer detail(CustomerRequest customerRequest) {
|
||||
return this.queryCustomer(customerRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<Customer> findPage(CustomerRequest customerRequest) {
|
||||
LambdaQueryWrapper<Customer> wrapper = createWrapper(customerRequest);
|
||||
Page<Customer> sysRolePage = this.page(PageFactory.defaultPage(), wrapper);
|
||||
return PageResultFactory.createPageResult(sysRolePage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Customer> findList(CustomerRequest customerRequest) {
|
||||
LambdaQueryWrapper<Customer> wrapper = this.createWrapper(customerRequest);
|
||||
return this.list(wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取信息
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/06/07 11:40
|
||||
*/
|
||||
private Customer queryCustomer(CustomerRequest customerRequest) {
|
||||
Customer customer = this.getById(customerRequest.getCustomerId());
|
||||
if (ObjectUtil.isEmpty(customer)) {
|
||||
throw new ServiceException(DefaultBusinessExceptionEnum.SYSTEM_RUNTIME_ERROR);
|
||||
}
|
||||
return customer;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建查询wrapper
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/06/07 11:40
|
||||
*/
|
||||
private LambdaQueryWrapper<Customer> createWrapper(CustomerRequest customerRequest) {
|
||||
LambdaQueryWrapper<Customer> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
Long customerId = customerRequest.getCustomerId();
|
||||
String account = customerRequest.getAccount();
|
||||
String password = customerRequest.getPassword();
|
||||
String nickName = customerRequest.getNickName();
|
||||
String email = customerRequest.getEmail();
|
||||
String telephone = customerRequest.getTelephone();
|
||||
Long avatar = customerRequest.getAvatar();
|
||||
String avatarObjectName = customerRequest.getAvatarObjectName();
|
||||
Integer score = customerRequest.getScore();
|
||||
|
||||
queryWrapper.eq(ObjectUtil.isNotNull(customerId), Customer::getCustomerId, customerId);
|
||||
queryWrapper.like(ObjectUtil.isNotEmpty(account), Customer::getAccount, account);
|
||||
queryWrapper.like(ObjectUtil.isNotEmpty(password), Customer::getPassword, password);
|
||||
queryWrapper.like(ObjectUtil.isNotEmpty(nickName), Customer::getNickName, nickName);
|
||||
queryWrapper.like(ObjectUtil.isNotEmpty(email), Customer::getEmail, email);
|
||||
queryWrapper.like(ObjectUtil.isNotEmpty(telephone), Customer::getTelephone, telephone);
|
||||
queryWrapper.eq(ObjectUtil.isNotNull(avatar), Customer::getAvatar, avatar);
|
||||
queryWrapper.like(ObjectUtil.isNotEmpty(avatarObjectName), Customer::getAvatarObjectName, avatarObjectName);
|
||||
queryWrapper.eq(ObjectUtil.isNotNull(score), Customer::getScore, score);
|
||||
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
spring boot自动装配
|
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>kernel-s-customer</artifactId>
|
||||
<version>7.0.4</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>customer-spring-boot-starter</artifactId>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!--字典的业务-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>customer-business</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [https://www.stylefeng.cn]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Guns源码头部的版权声明。
|
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.customer.starter;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* C端自动装配
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/6/7 11:32
|
||||
*/
|
||||
@Configuration
|
||||
public class GunsCustomerAutoConfiguration {
|
||||
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
cn.stylefeng.roses.kernel.customer.starter.GunsCustomerAutoConfiguration
|
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>roses-kernel</artifactId>
|
||||
<version>7.0.4</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>kernel-s-customer</artifactId>
|
||||
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
<module>customer-api</module>
|
||||
<module>customer-business</module>
|
||||
<module>customer-spring-boot-starter</module>
|
||||
</modules>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- 开发规则 -->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>kernel-a-rule</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
Loading…
Reference in New Issue