From cce4d38d4ed877c0ba708a2334bbb630e8b0594c Mon Sep 17 00:00:00 2001 From: qushutong <1976590620@qq.com> Date: Tue, 3 Sep 2019 15:57:24 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fallback/UserFeignClientFallback.java | 2 +- .../java/com/elink/esua/epdc/dto/UserDTO.java | 149 +++++++++++++++ .../esua/epdc/controller/UserController.java | 101 ++++++++++ .../java/com/elink/esua/epdc/dao/UserDao.java | 33 ++++ .../elink/esua/epdc/entity/UserEntity.java | 173 ++++++++++++++++++ .../com/elink/esua/epdc/excel/UserExcel.java | 110 +++++++++++ .../com/elink/esua/epdc/redis/UserRedis.java | 46 +++++ .../elink/esua/epdc/service/UserService.java | 47 +++++ .../epdc/service/impl/UserServiceImpl.java | 112 ++++++++++++ .../epdc/service/impl/UserTagServiceImpl.java | 3 +- .../src/main/resources/mapper/UserDao.xml | 49 +++++ 11 files changed, 823 insertions(+), 2 deletions(-) create mode 100644 esua-epdc/epdc-module/epdc-user/epdc-user-client/src/main/java/com/elink/esua/epdc/dto/UserDTO.java create mode 100644 esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/controller/UserController.java create mode 100644 esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/dao/UserDao.java create mode 100644 esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/entity/UserEntity.java create mode 100644 esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/excel/UserExcel.java create mode 100644 esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/redis/UserRedis.java create mode 100644 esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/UserService.java create mode 100644 esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/UserServiceImpl.java create mode 100644 esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/resources/mapper/UserDao.xml diff --git a/esua-epdc/epdc-auth/src/main/java/com/elink/esua/epdc/feign/fallback/UserFeignClientFallback.java b/esua-epdc/epdc-auth/src/main/java/com/elink/esua/epdc/feign/fallback/UserFeignClientFallback.java index 76a676fcd..ee760cd1e 100644 --- a/esua-epdc/epdc-auth/src/main/java/com/elink/esua/epdc/feign/fallback/UserFeignClientFallback.java +++ b/esua-epdc/epdc-auth/src/main/java/com/elink/esua/epdc/feign/fallback/UserFeignClientFallback.java @@ -28,7 +28,7 @@ public class UserFeignClientFallback implements UserFeignClient { } @Override - public Result getByUsername(String username) { + public Result getByUsername(String username) { return new Result<>(); } } diff --git a/esua-epdc/epdc-module/epdc-user/epdc-user-client/src/main/java/com/elink/esua/epdc/dto/UserDTO.java b/esua-epdc/epdc-module/epdc-user/epdc-user-client/src/main/java/com/elink/esua/epdc/dto/UserDTO.java new file mode 100644 index 000000000..889fa2cf3 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-user/epdc-user-client/src/main/java/com/elink/esua/epdc/dto/UserDTO.java @@ -0,0 +1,149 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.dto; + + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 用户信息表 + * + * @author qu qu@gmail.com + * @since v1.0.0 2019-09-02 + */ +@Data +public class UserDTO implements Serializable { + private static final long serialVersionUID = 1L; + + private String id; + + private String nickname; + + private String mobile; + + private String password; + + private Date registerTime; + + private String faceImg; + +// @ApiModelProperty(value = "性别(女性-female,男性-male)") + private String sex; + +// @ApiModelProperty(value = "生日") + private Date birthday; + +// @ApiModelProperty(value = "邮箱") + private String email; + +// @ApiModelProperty(value = "电话") + private String telephone; + +// @ApiModelProperty(value = "邮编") + private String zipCode; + +// @ApiModelProperty(value = "职业") + private String profession; + +// @ApiModelProperty(value = "爱好") + private String hobbies; + +// @ApiModelProperty(value = "个性签名") + private String userSign; + +// @ApiModelProperty(value = "邀请码") + private String invitationCode; + +// @ApiModelProperty(value = "最近登录时间") + private Date lastLoginTime; + +// @ApiModelProperty(value = "最近登录IP") + private String lastLoginIp; + +// @ApiModelProperty(value = "最近登录位置经度") + private String lastLongitude; + +// @ApiModelProperty(value = "最近登录位置维度") + private String lastLatitude; + +// @ApiModelProperty(value = "真实姓名") + private String realName; + +// @ApiModelProperty(value = "身份证号") + private String identityNo; + +// @ApiModelProperty(value = "居民住址") + private String address; + +// @ApiModelProperty(value = "微信OPENID") + private String wxOpenId; + +// @ApiModelProperty(value = "是否是党员(0-否,1-是)") + private String partyFlag; + +// @ApiModelProperty(value = "注册方式(wx:微信注册)") + private String registerWay; + +// @ApiModelProperty(value = "用户来源(wp:公众号)") + private String registerSource; + +// @ApiModelProperty(value = "手机号所属省份") + private String phoneProvince; + +// @ApiModelProperty(value = "手机号所属城市") + private String phoneCity; + +// @ApiModelProperty(value = "手机号所属运营商") + private String phoneCarrier; + +// @ApiModelProperty(value = "用户积分") + private Integer points; + +// @ApiModelProperty(value = "邀请人ID") + private String inviteUserId; + +// @ApiModelProperty(value = "乐观锁") + private Integer revision; + +// @ApiModelProperty(value = "网格ID") + private String gridId; + +// @ApiModelProperty(value = "创建人") + private String createdBy; + +// @ApiModelProperty(value = "创建时间") + private Date createdTime; + +// @ApiModelProperty(value = "更新人") + private String updatedBy; + +// @ApiModelProperty(value = "更新时间") + private Date updatedTime; + +// @ApiModelProperty(value = "删除标记") + private String delFlag; + + /** + * 审核状态 + */ + private Integer state; + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/controller/UserController.java b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/controller/UserController.java new file mode 100644 index 000000000..644c3c5f6 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/controller/UserController.java @@ -0,0 +1,101 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.controller; + +import com.elink.esua.epdc.commons.tools.page.PageData; +import com.elink.esua.epdc.commons.tools.utils.ExcelUtils; +import com.elink.esua.epdc.commons.tools.utils.Result; +import com.elink.esua.epdc.commons.tools.validator.AssertUtils; +import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils; +import com.elink.esua.epdc.commons.tools.validator.group.AddGroup; +import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup; +import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup; +import com.elink.esua.epdc.dto.UserDTO; +import com.elink.esua.epdc.excel.UserExcel; +import com.elink.esua.epdc.service.UserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + + +/** + * 用户信息表 + * + * @author qu qu@gmail.com + * @since v1.0.0 2019-09-02 + */ +@RestController +@RequestMapping("epdc/user") +public class UserController { + @Autowired + private UserService userService; + + @GetMapping("page") + public Result> page( @RequestParam Map params){ + PageData page = userService.page(params); + + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + UserDTO data = userService.get(id); + + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody UserDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + + userService.save(dto); + + return new Result(); + } + + @PutMapping + public Result update(@RequestBody UserDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + + userService.update(dto); + + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + + userService.delete(ids); + + return new Result(); + } + + @GetMapping("export") + public void export( @RequestParam Map params, HttpServletResponse response) throws Exception { + List list = userService.list(params); + + ExcelUtils.exportExcelToTarget(response, null, list, UserExcel.class); + } + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/dao/UserDao.java b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/dao/UserDao.java new file mode 100644 index 000000000..dd75d4c29 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/dao/UserDao.java @@ -0,0 +1,33 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.dao; + +import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; +import com.elink.esua.epdc.entity.UserEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 用户信息表 + * + * @author qu qu@gmail.com + * @since v1.0.0 2019-09-02 + */ +@Mapper +public interface UserDao extends BaseDao { + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/entity/UserEntity.java b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/entity/UserEntity.java new file mode 100644 index 000000000..b8ff4847d --- /dev/null +++ b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/entity/UserEntity.java @@ -0,0 +1,173 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; + +import com.elink.esua.epdc.commons.mybatis.entity.BaseEpdcEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 用户信息表 + * + * @author qu qu@gmail.com + * @since v1.0.0 2019-09-02 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("epdc_user") +public class UserEntity extends BaseEpdcEntity { + private static final long serialVersionUID = 1L; + + /** + * 昵称 + */ + private String nickname; + /** + * 手机号 + */ + private String mobile; + /** + * 密码 + */ + private String password; + /** + * 注册时间 + */ + private Date registerTime; + /** + * 头像 + */ + private String faceImg; + /** + * 性别(女性-female,男性-male) + */ + private String sex; + /** + * 生日 + */ + private Date birthday; + /** + * 邮箱 + */ + private String email; + /** + * 电话 + */ + private String telephone; + /** + * 邮编 + */ + private String zipCode; + /** + * 职业 + */ + private String profession; + /** + * 爱好 + */ + private String hobbies; + /** + * 个性签名 + */ + private String userSign; + /** + * 邀请码 + */ + private String invitationCode; + /** + * 最近登录时间 + */ + private Date lastLoginTime; + /** + * 最近登录IP + */ + private String lastLoginIp; + /** + * 最近登录位置经度 + */ + private String lastLongitude; + /** + * 最近登录位置维度 + */ + private String lastLatitude; + /** + * 真实姓名 + */ + private String realName; + /** + * 身份证号 + */ + private String identityNo; + /** + * 居民住址 + */ + private String address; + /** + * 微信OPENID + */ + private String wxOpenId; + /** + * 是否是党员(0-否,1-是) + */ + private String partyFlag; + /** + * 注册方式(wx:微信注册) + */ + private String registerWay; + /** + * 用户来源(wp:公众号) + */ + private String registerSource; + /** + * 手机号所属省份 + */ + private String phoneProvince; + /** + * 手机号所属城市 + */ + private String phoneCity; + /** + * 手机号所属运营商 + */ + private String phoneCarrier; + /** + * 用户积分 + */ + private Integer points; + /** + * 邀请人ID + */ + private String inviteUserId; + /** + * 网格ID + */ + private String gridId; + + /** + * 审核状态 + */ + private Integer state; + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/excel/UserExcel.java b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/excel/UserExcel.java new file mode 100644 index 000000000..ea5990a00 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/excel/UserExcel.java @@ -0,0 +1,110 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.excel; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +import java.util.Date; + +/** + * 用户信息表 + * + * @author qu qu@gmail.com + * @since v1.0.0 2019-09-02 + */ +@Data +public class UserExcel { + @Excel(name = "主键") + private String id; + @Excel(name = "昵称") + private String nickname; + @Excel(name = "手机号") + private String mobile; + @Excel(name = "密码") + private String password; + @Excel(name = "注册时间") + private Date registerTime; + @Excel(name = "头像") + private String faceImg; + @Excel(name = "性别(女性-female,男性-male)") + private String sex; + @Excel(name = "生日") + private Date birthday; + @Excel(name = "邮箱") + private String email; + @Excel(name = "电话") + private String telephone; + @Excel(name = "邮编") + private String zipCode; + @Excel(name = "职业") + private String profession; + @Excel(name = "爱好") + private String hobbies; + @Excel(name = "个性签名") + private String userSign; + @Excel(name = "邀请码") + private String invitationCode; + @Excel(name = "最近登录时间") + private Date lastLoginTime; + @Excel(name = "最近登录IP") + private String lastLoginIp; + @Excel(name = "最近登录位置经度") + private String lastLongitude; + @Excel(name = "最近登录位置维度") + private String lastLatitude; + @Excel(name = "真实姓名") + private String realName; + @Excel(name = "身份证号") + private String identityNo; + @Excel(name = "居民住址") + private String address; + @Excel(name = "微信OPENID") + private String wxOpenId; + @Excel(name = "是否是党员(0-否,1-是)") + private String partyFlag; + @Excel(name = "注册方式(wx:微信注册)") + private String registerWay; + @Excel(name = "用户来源(wp:公众号)") + private String registerSource; + @Excel(name = "手机号所属省份") + private String phoneProvince; + @Excel(name = "手机号所属城市") + private String phoneCity; + @Excel(name = "手机号所属运营商") + private String phoneCarrier; + @Excel(name = "用户积分") + private Integer points; + @Excel(name = "邀请人ID") + private String inviteUserId; + @Excel(name = "乐观锁") + private Integer revision; + @Excel(name = "网格ID") + private String gridId; + @Excel(name = "创建人") + private String createdBy; + @Excel(name = "创建时间") + private Date createdTime; + @Excel(name = "更新人") + private String updatedBy; + @Excel(name = "更新时间") + private Date updatedTime; + @Excel(name = "删除标记") + private String delFlag; + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/redis/UserRedis.java b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/redis/UserRedis.java new file mode 100644 index 000000000..ab9556b81 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/redis/UserRedis.java @@ -0,0 +1,46 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.redis; +import com.elink.esua.epdc.commons.tools.redis.RedisUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 用户信息表 + * + * @author qu qu@gmail.com + * @since v1.0.0 2019-09-02 + */ +@Component +public class UserRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete(Object[] ids) { + + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/UserService.java b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/UserService.java new file mode 100644 index 000000000..28e105742 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/UserService.java @@ -0,0 +1,47 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.service; + +import com.elink.esua.epdc.commons.mybatis.service.BaseService; +import com.elink.esua.epdc.commons.tools.page.PageData; +import com.elink.esua.epdc.dto.UserDTO; +import com.elink.esua.epdc.entity.UserEntity; + +import java.util.List; +import java.util.Map; + +/** + * 用户信息表 + * + * @author qu qu@gmail.com + * @since v1.0.0 2019-09-02 + */ +public interface UserService extends BaseService { + + PageData page(Map params); + + List list(Map params); + + UserDTO get(String id); + + void save(UserDTO dto); + + void update(UserDTO dto); + + void delete(String[] ids); +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/UserServiceImpl.java b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/UserServiceImpl.java new file mode 100644 index 000000000..4d0b820e0 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/UserServiceImpl.java @@ -0,0 +1,112 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; +import com.elink.esua.epdc.commons.tools.constant.Constant; +import com.elink.esua.epdc.commons.tools.constant.FieldConstant; +import com.elink.esua.epdc.commons.tools.page.PageData; +import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; +import com.elink.esua.epdc.dao.UserDao; +import com.elink.esua.epdc.dto.UserDTO; +import com.elink.esua.epdc.entity.UserEntity; +import com.elink.esua.epdc.redis.UserRedis; +import com.elink.esua.epdc.service.UserService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 用户信息表 + * + * @author qu qu@gmail.com + * @since v1.0.0 2019-09-02 + */ +@Service +public class UserServiceImpl extends BaseServiceImpl implements UserService { + @Autowired + private UserRedis userRedis; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + + return getPageData(page, UserDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, UserDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get("id"); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), "id", id); + //wrapper.eq(Constant.DEL_FLAG, DelFlagEnum.NORMAL.value()); + + return wrapper; + } + + @Override + public UserDTO get(String id) { + UserEntity entity = baseDao.selectById(id); + + return ConvertUtils.sourceToTarget(entity, UserDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(UserDTO dto) { + UserEntity entity = ConvertUtils.sourceToTarget(dto, UserEntity.class); + + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(UserDTO dto) { + UserEntity entity = ConvertUtils.sourceToTarget(dto, UserEntity.class); + + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + //逻辑删除 + //logicDelete(ids, UserEntity.class); + + //物理删除 + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/UserTagServiceImpl.java b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/UserTagServiceImpl.java index ce40103b3..dbc747c97 100755 --- a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/UserTagServiceImpl.java +++ b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/UserTagServiceImpl.java @@ -22,6 +22,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.elink.esua.epdc.commons.mybatis.enums.DelFlagEnum; import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; import com.elink.esua.epdc.commons.tools.constant.Constant; +import com.elink.esua.epdc.commons.tools.constant.FieldConstant; import com.elink.esua.epdc.commons.tools.exception.RenException; import com.elink.esua.epdc.commons.tools.page.PageData; import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; @@ -53,7 +54,7 @@ public class UserTagServiceImpl extends BaseServiceImpl page(Map params) { IPage page = baseDao.selectPage( - getPage(params, Constant.CREATED_TIME, false), + getPage(params, FieldConstant.CREATED_TIME, false), getWrapper(params) ); diff --git a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/resources/mapper/UserDao.xml b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/resources/mapper/UserDao.xml new file mode 100644 index 000000000..be9256fbe --- /dev/null +++ b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/resources/mapper/UserDao.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file