diff --git a/kernel-s-customer/README.md b/kernel-s-customer/README.md new file mode 100644 index 000000000..753f37735 --- /dev/null +++ b/kernel-s-customer/README.md @@ -0,0 +1 @@ +C端用户,适用于BBS等to c 业务的用户管理 \ No newline at end of file diff --git a/kernel-s-customer/customer-api/README.md b/kernel-s-customer/customer-api/README.md new file mode 100644 index 000000000..b1b2ad543 --- /dev/null +++ b/kernel-s-customer/customer-api/README.md @@ -0,0 +1 @@ +C端用户api \ No newline at end of file diff --git a/kernel-s-customer/customer-api/pom.xml b/kernel-s-customer/customer-api/pom.xml new file mode 100644 index 000000000..b948f1ca2 --- /dev/null +++ b/kernel-s-customer/customer-api/pom.xml @@ -0,0 +1,21 @@ + + + 4.0.0 + + + cn.stylefeng.roses + kernel-s-customer + 7.0.4 + ../pom.xml + + + customer-api + + jar + + + + + diff --git a/kernel-s-customer/customer-api/src/main/java/cn/stylefeng/roses/kernel/customer/api/CustomerApi.java b/kernel-s-customer/customer-api/src/main/java/cn/stylefeng/roses/kernel/customer/api/CustomerApi.java new file mode 100644 index 000000000..a1c238504 --- /dev/null +++ b/kernel-s-customer/customer-api/src/main/java/cn/stylefeng/roses/kernel/customer/api/CustomerApi.java @@ -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 { + + +} diff --git a/kernel-s-customer/customer-api/src/main/java/cn/stylefeng/roses/kernel/customer/api/constants/CustomerConstants.java b/kernel-s-customer/customer-api/src/main/java/cn/stylefeng/roses/kernel/customer/api/constants/CustomerConstants.java new file mode 100644 index 000000000..87ed304ec --- /dev/null +++ b/kernel-s-customer/customer-api/src/main/java/cn/stylefeng/roses/kernel/customer/api/constants/CustomerConstants.java @@ -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"; + +} diff --git a/kernel-s-customer/customer-api/src/main/java/cn/stylefeng/roses/kernel/customer/api/exception/CustomerException.java b/kernel-s-customer/customer-api/src/main/java/cn/stylefeng/roses/kernel/customer/api/exception/CustomerException.java new file mode 100644 index 000000000..298e69536 --- /dev/null +++ b/kernel-s-customer/customer-api/src/main/java/cn/stylefeng/roses/kernel/customer/api/exception/CustomerException.java @@ -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); + } + +} diff --git a/kernel-s-customer/customer-api/src/main/java/cn/stylefeng/roses/kernel/customer/api/exception/enums/CustomerExceptionEnum.java b/kernel-s-customer/customer-api/src/main/java/cn/stylefeng/roses/kernel/customer/api/exception/enums/CustomerExceptionEnum.java new file mode 100644 index 000000000..ea457bc38 --- /dev/null +++ b/kernel-s-customer/customer-api/src/main/java/cn/stylefeng/roses/kernel/customer/api/exception/enums/CustomerExceptionEnum.java @@ -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; + } + +} diff --git a/kernel-s-customer/customer-business/README.md b/kernel-s-customer/customer-business/README.md new file mode 100644 index 000000000..941c90187 --- /dev/null +++ b/kernel-s-customer/customer-business/README.md @@ -0,0 +1 @@ +C端用户管理业务模块 \ No newline at end of file diff --git a/kernel-s-customer/customer-business/pom.xml b/kernel-s-customer/customer-business/pom.xml new file mode 100644 index 000000000..2be305f15 --- /dev/null +++ b/kernel-s-customer/customer-business/pom.xml @@ -0,0 +1,67 @@ + + + 4.0.0 + + + cn.stylefeng.roses + kernel-s-customer + 7.0.4 + ../pom.xml + + + customer-business + + jar + + + + + + cn.stylefeng.roses + customer-api + ${roses.version} + + + + + + cn.stylefeng.roses + scanner-api + ${roses.version} + + + + + + cn.stylefeng.roses + validator-api + ${roses.version} + + + + + + cn.stylefeng.roses + db-sdk-init + ${roses.version} + + + + + + cn.stylefeng.roses + db-sdk-mp + ${roses.version} + + + + + org.springframework.boot + spring-boot-starter-web + + + + + diff --git a/kernel-s-customer/customer-business/src/main/java/cn/stylefeng/roses/kernel/customer/modular/controller/CustomerController.java b/kernel-s-customer/customer-business/src/main/java/cn/stylefeng/roses/kernel/customer/modular/controller/CustomerController.java new file mode 100644 index 000000000..86b7afaf3 --- /dev/null +++ b/kernel-s-customer/customer-business/src/main/java/cn/stylefeng/roses/kernel/customer/modular/controller/CustomerController.java @@ -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)); + } + +} \ No newline at end of file diff --git a/kernel-s-customer/customer-business/src/main/java/cn/stylefeng/roses/kernel/customer/modular/entity/Customer.java b/kernel-s-customer/customer-business/src/main/java/cn/stylefeng/roses/kernel/customer/modular/entity/Customer.java new file mode 100644 index 000000000..9af0a60a0 --- /dev/null +++ b/kernel-s-customer/customer-business/src/main/java/cn/stylefeng/roses/kernel/customer/modular/entity/Customer.java @@ -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; + +} \ No newline at end of file diff --git a/kernel-s-customer/customer-business/src/main/java/cn/stylefeng/roses/kernel/customer/modular/mapper/CustomerMapper.java b/kernel-s-customer/customer-business/src/main/java/cn/stylefeng/roses/kernel/customer/modular/mapper/CustomerMapper.java new file mode 100644 index 000000000..eb18901d5 --- /dev/null +++ b/kernel-s-customer/customer-business/src/main/java/cn/stylefeng/roses/kernel/customer/modular/mapper/CustomerMapper.java @@ -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 { + +} \ No newline at end of file diff --git a/kernel-s-customer/customer-business/src/main/java/cn/stylefeng/roses/kernel/customer/modular/mapper/mapping/CustomerMapper.xml b/kernel-s-customer/customer-business/src/main/java/cn/stylefeng/roses/kernel/customer/modular/mapper/mapping/CustomerMapper.xml new file mode 100644 index 000000000..690df5806 --- /dev/null +++ b/kernel-s-customer/customer-business/src/main/java/cn/stylefeng/roses/kernel/customer/modular/mapper/mapping/CustomerMapper.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/kernel-s-customer/customer-business/src/main/java/cn/stylefeng/roses/kernel/customer/modular/request/CustomerRequest.java b/kernel-s-customer/customer-business/src/main/java/cn/stylefeng/roses/kernel/customer/modular/request/CustomerRequest.java new file mode 100644 index 000000000..c82028c49 --- /dev/null +++ b/kernel-s-customer/customer-business/src/main/java/cn/stylefeng/roses/kernel/customer/modular/request/CustomerRequest.java @@ -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; + +} \ No newline at end of file diff --git a/kernel-s-customer/customer-business/src/main/java/cn/stylefeng/roses/kernel/customer/modular/service/CustomerService.java b/kernel-s-customer/customer-business/src/main/java/cn/stylefeng/roses/kernel/customer/modular/service/CustomerService.java new file mode 100644 index 000000000..257b2aff7 --- /dev/null +++ b/kernel-s-customer/customer-business/src/main/java/cn/stylefeng/roses/kernel/customer/modular/service/CustomerService.java @@ -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 { + + /** + * 新增 + * + * @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 findList(CustomerRequest customerRequest); + + /** + * 获取列表(带分页) + * + * @author fengshuonan + * @date 2021/06/07 11:40 + */ + PageResult findPage(CustomerRequest customerRequest); + +} \ No newline at end of file diff --git a/kernel-s-customer/customer-business/src/main/java/cn/stylefeng/roses/kernel/customer/modular/service/impl/CustomerServiceImpl.java b/kernel-s-customer/customer-business/src/main/java/cn/stylefeng/roses/kernel/customer/modular/service/impl/CustomerServiceImpl.java new file mode 100644 index 000000000..4e69eb62c --- /dev/null +++ b/kernel-s-customer/customer-business/src/main/java/cn/stylefeng/roses/kernel/customer/modular/service/impl/CustomerServiceImpl.java @@ -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 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 findPage(CustomerRequest customerRequest) { + LambdaQueryWrapper wrapper = createWrapper(customerRequest); + Page sysRolePage = this.page(PageFactory.defaultPage(), wrapper); + return PageResultFactory.createPageResult(sysRolePage); + } + + @Override + public List findList(CustomerRequest customerRequest) { + LambdaQueryWrapper 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 createWrapper(CustomerRequest customerRequest) { + LambdaQueryWrapper 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; + } + +} \ No newline at end of file diff --git a/kernel-s-customer/customer-spring-boot-starter/README.md b/kernel-s-customer/customer-spring-boot-starter/README.md new file mode 100644 index 000000000..6c48c0828 --- /dev/null +++ b/kernel-s-customer/customer-spring-boot-starter/README.md @@ -0,0 +1 @@ +spring boot自动装配 \ No newline at end of file diff --git a/kernel-s-customer/customer-spring-boot-starter/pom.xml b/kernel-s-customer/customer-spring-boot-starter/pom.xml new file mode 100644 index 000000000..5566a10fb --- /dev/null +++ b/kernel-s-customer/customer-spring-boot-starter/pom.xml @@ -0,0 +1,29 @@ + + + 4.0.0 + + + cn.stylefeng.roses + kernel-s-customer + 7.0.4 + ../pom.xml + + + customer-spring-boot-starter + + jar + + + + + + cn.stylefeng.roses + customer-business + ${roses.version} + + + + + diff --git a/kernel-s-customer/customer-spring-boot-starter/src/main/java/cn/stylefeng/roses/kernel/customer/starter/GunsCustomerAutoConfiguration.java b/kernel-s-customer/customer-spring-boot-starter/src/main/java/cn/stylefeng/roses/kernel/customer/starter/GunsCustomerAutoConfiguration.java new file mode 100644 index 000000000..72ffda56e --- /dev/null +++ b/kernel-s-customer/customer-spring-boot-starter/src/main/java/cn/stylefeng/roses/kernel/customer/starter/GunsCustomerAutoConfiguration.java @@ -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 { + +} diff --git a/kernel-s-customer/customer-spring-boot-starter/src/main/resources/META-INF/spring.factories b/kernel-s-customer/customer-spring-boot-starter/src/main/resources/META-INF/spring.factories new file mode 100644 index 000000000..de1289629 --- /dev/null +++ b/kernel-s-customer/customer-spring-boot-starter/src/main/resources/META-INF/spring.factories @@ -0,0 +1,2 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ + cn.stylefeng.roses.kernel.customer.starter.GunsCustomerAutoConfiguration \ No newline at end of file diff --git a/kernel-s-customer/pom.xml b/kernel-s-customer/pom.xml new file mode 100644 index 000000000..f706230e9 --- /dev/null +++ b/kernel-s-customer/pom.xml @@ -0,0 +1,35 @@ + + + 4.0.0 + + + cn.stylefeng.roses + roses-kernel + 7.0.4 + ../pom.xml + + + kernel-s-customer + + pom + + + customer-api + customer-business + customer-spring-boot-starter + + + + + + + cn.stylefeng.roses + kernel-a-rule + ${roses.version} + + + + + diff --git a/pom.xml b/pom.xml index 1fb0de07d..ee7c7d621 100644 --- a/pom.xml +++ b/pom.xml @@ -82,6 +82,9 @@ kernel-o-monitor + + kernel-s-customer + kernel-s-demo