From 95d1f8efd10bde70b2fb75d8390ceb04aa4b633a Mon Sep 17 00:00:00 2001 From: zhangfh Date: Wed, 1 Sep 2021 18:00:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4=20?= =?UTF-8?q?=E5=85=9A=E5=91=98=E4=BA=AE=E8=BA=AB=E4=BB=BD-pc,=E5=B0=8F?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E7=AB=AFbug=E6=9B=B4=E6=96=B0=EF=BC=9A?= =?UTF-8?q?=E8=A9=B3=E6=83=85=E6=9F=A5=E8=A9=A2=E4=BC=A0=E5=8F=82=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E5=AF=B9=E8=B1=A1=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EpdcAppPartyMemberController.java | 41 +++---- .../epdc/controller/UserInfoController.java | 94 ++++++++++++++ .../com/elink/esua/epdc/dao/UserInfoDao.java | 31 ++--- .../esua/epdc/entity/UserInfoEntity.java | 16 +++ .../elink/esua/epdc/excel/UserInfoExcel.java | 77 ++++++++++++ .../elink/esua/epdc/redis/UserInfoRedis.java | 47 +++++++ .../esua/epdc/service/UserInfoService.java | 115 +++++++++++++++--- .../service/impl/UserInfoServiceImpl.java | 115 +++++++++++++++--- .../src/main/resources/mapper/UserInfoDao.xml | 33 +++++ 9 files changed, 489 insertions(+), 80 deletions(-) create mode 100644 epdc-cloud-user/src/main/java/com/elink/esua/epdc/controller/UserInfoController.java create mode 100644 epdc-cloud-user/src/main/java/com/elink/esua/epdc/excel/UserInfoExcel.java create mode 100644 epdc-cloud-user/src/main/java/com/elink/esua/epdc/redis/UserInfoRedis.java diff --git a/epdc-cloud-user/src/main/java/com/elink/esua/epdc/controller/EpdcAppPartyMemberController.java b/epdc-cloud-user/src/main/java/com/elink/esua/epdc/controller/EpdcAppPartyMemberController.java index 36bda32..b11bd32 100644 --- a/epdc-cloud-user/src/main/java/com/elink/esua/epdc/controller/EpdcAppPartyMemberController.java +++ b/epdc-cloud-user/src/main/java/com/elink/esua/epdc/controller/EpdcAppPartyMemberController.java @@ -4,6 +4,7 @@ import com.elink.esua.epdc.commons.tools.utils.Result; 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.dto.epdc.form.EpdcAppIdentityDetailFormDTO; import com.elink.esua.epdc.dto.epdc.form.EpdcAppShowIdentityFormDTO; import com.elink.esua.epdc.dto.epdc.result.EpdcAppIdentityDetailResultDTO; import com.elink.esua.epdc.service.UserInfoService; @@ -22,6 +23,13 @@ public class EpdcAppPartyMemberController { @Autowired private UserInfoService userInfoService; + /** + * 小程序-党员亮身份 + * @params [formDto] + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author zhangfenghe + * @since 2021/9/1 9:26 + */ @PostMapping("showIdentity") public Result saveShowIdentity(@RequestBody EpdcAppShowIdentityFormDTO formDto){ ValidatorUtils.validateEntity(formDto, AddGroup.class, DefaultGroup.class); @@ -29,33 +37,18 @@ public class EpdcAppPartyMemberController { return new Result(); } - @GetMapping("dentityDetail/{userId}") - public Result getDentityDetail(@PathVariable("userId") String userId){ - EpdcAppIdentityDetailResultDTO data = userInfoService.getDentityDetail(userId); - return new Result().ok(data); - } - /** - * 党建引领-党员亮身份推荐 - * @params [id] - * @return void + * 小程序-党员亮身份详情查询 + * @params [userDetail] + * @return com.elink.esua.epdc.commons.tools.utils.Result * @author zhangfenghe - * @since 2021/8/30 9:26 + * @since 2021/9/1 9:27 */ - @PostMapping("brightIdentity/recommended/{id}") - public Result recommended(@PathVariable("id") String id){ - return userInfoService.recommended(id); + @GetMapping("dentityDetail") + public Result getDentityDetail(@RequestBody EpdcAppIdentityDetailFormDTO userDetail){ + ValidatorUtils.validateEntity(userDetail); + EpdcAppIdentityDetailResultDTO data = userInfoService.getDentityDetail(userDetail.getUserId()); + return new Result().ok(data); } - /** - * 党建引领-党员亮身份取消推荐 - * @params [id] - * @return void - * @author zhangfenghe - * @since 2021/8/30 9:26 - */ - @PostMapping("brightIdentity/recommendedCancel/{id}") - public Result recommendedCancel(@PathVariable("id") String id){ - return userInfoService.recommendedCancel(id); - } } diff --git a/epdc-cloud-user/src/main/java/com/elink/esua/epdc/controller/UserInfoController.java b/epdc-cloud-user/src/main/java/com/elink/esua/epdc/controller/UserInfoController.java new file mode 100644 index 0000000..166ae52 --- /dev/null +++ b/epdc-cloud-user/src/main/java/com/elink/esua/epdc/controller/UserInfoController.java @@ -0,0 +1,94 @@ +/** + * 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.UserInfoDTO; +import com.elink.esua.epdc.excel.UserInfoExcel; +import com.elink.esua.epdc.service.UserInfoService; +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@elink-cn.com + * @since v1.0.0 2021-08-31 + */ +@RestController +@RequestMapping("userinfo") +public class UserInfoController { + + @Autowired + private UserInfoService userInfoService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = userInfoService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + UserInfoDTO data = userInfoService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody UserInfoDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + userInfoService.save(dto); + return new Result(); + } + + @PutMapping("update") + public Result update(@RequestBody UserInfoDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + userInfoService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + userInfoService.delete(ids); + return new Result(); + } + + @GetMapping("export") + public void export(@RequestParam Map params, HttpServletResponse response) throws Exception { + List list = userInfoService.list(params); + ExcelUtils.exportExcelToTarget(response, null, list, UserInfoExcel.class); + } + +} \ No newline at end of file diff --git a/epdc-cloud-user/src/main/java/com/elink/esua/epdc/dao/UserInfoDao.java b/epdc-cloud-user/src/main/java/com/elink/esua/epdc/dao/UserInfoDao.java index 2cb465d..7447f25 100644 --- a/epdc-cloud-user/src/main/java/com/elink/esua/epdc/dao/UserInfoDao.java +++ b/epdc-cloud-user/src/main/java/com/elink/esua/epdc/dao/UserInfoDao.java @@ -1,9 +1,14 @@ package com.elink.esua.epdc.dao; import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; +import com.elink.esua.epdc.dto.UserInfoDTO; import com.elink.esua.epdc.dto.epdc.result.EpdcAppIdentityDetailResultDTO; import com.elink.esua.epdc.entity.UserInfoEntity; import org.apache.ibatis.annotations.Mapper; + +import java.util.List; +import java.util.Map; + /** * * 用户信息表-党员亮身份 @@ -14,6 +19,14 @@ import org.apache.ibatis.annotations.Mapper; public interface UserInfoDao extends BaseDao { String selectDentityIdByUserId(String userId); + /** + * pc-党员亮身份列表查询 + * @params [params] + * @return java.util.List + * @author jyyzz + * @since 2021/9/1 9:24 + */ + List selectListUserInfoDtos(Map params); /** *获取党员亮身份详情接口 @@ -24,22 +37,4 @@ public interface UserInfoDao extends BaseDao { */ EpdcAppIdentityDetailResultDTO selectDentityDetail(String userId); - /** - * 党建引领-党员亮身份推荐 - * @params [id] - * @return void - * @author zhangfenghe - * @since 2021/8/30 9:26 - */ - void recommended(String id); - - /** - * 党建引领-党员亮身份取消推荐 - * @params [id] - * @return void - * @author zhangfenghe - * @since 2021/8/30 9:26 - */ - void recommendedCancel(String id); - } diff --git a/epdc-cloud-user/src/main/java/com/elink/esua/epdc/entity/UserInfoEntity.java b/epdc-cloud-user/src/main/java/com/elink/esua/epdc/entity/UserInfoEntity.java index ce84d7e..9a441ec 100644 --- a/epdc-cloud-user/src/main/java/com/elink/esua/epdc/entity/UserInfoEntity.java +++ b/epdc-cloud-user/src/main/java/com/elink/esua/epdc/entity/UserInfoEntity.java @@ -5,6 +5,8 @@ import com.elink.esua.epdc.commons.mybatis.entity.BaseEpdcEntity; import lombok.Data; import lombok.EqualsAndHashCode; +import java.util.Date; + /** * create by: zhangfenghe * description: 用户信息表 @@ -16,6 +18,10 @@ import lombok.EqualsAndHashCode; public class UserInfoEntity extends BaseEpdcEntity { private static final long serialVersionUID = 1L; + /** + * 主键id + */ + private String id; /** * 用户id */ @@ -41,4 +47,14 @@ public class UserInfoEntity extends BaseEpdcEntity { */ private String serviceArea; + /** + * 推荐标识 0-否,1-是 + */ + private String recommendFlag; + + /** + * 推荐时间 + */ + private Date recommendTime; + } diff --git a/epdc-cloud-user/src/main/java/com/elink/esua/epdc/excel/UserInfoExcel.java b/epdc-cloud-user/src/main/java/com/elink/esua/epdc/excel/UserInfoExcel.java new file mode 100644 index 0000000..e8aa34f --- /dev/null +++ b/epdc-cloud-user/src/main/java/com/elink/esua/epdc/excel/UserInfoExcel.java @@ -0,0 +1,77 @@ +/** + * 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@elink-cn.com + * @since v1.0.0 2021-08-31 + */ +@Data +public class UserInfoExcel { + + @Excel(name = "标识号") + private String id; + + @Excel(name = "用户ID") + private String userId; + + @Excel(name = "头像地址") + private String headUrl; + + @Excel(name = "格言") + private String motto; + + @Excel(name = "承诺") + private String promise; + + @Excel(name = "服务范围") + private String serviceArea; + + @Excel(name = "推荐标识 0-否,1-是") + private String recommendFlag; + + @Excel(name = "推荐时间") + private Date recommendTime; + + @Excel(name = "删除标识 0-否,1-是") + private String delFlag; + + @Excel(name = "乐观锁") + private Integer revision; + + @Excel(name = "创建人") + private String createdBy; + + @Excel(name = "创建时间") + private Date createdTime; + + @Excel(name = "更新人") + private String updatedBy; + + @Excel(name = "更新时间") + private Date updatedTime; + + +} \ No newline at end of file diff --git a/epdc-cloud-user/src/main/java/com/elink/esua/epdc/redis/UserInfoRedis.java b/epdc-cloud-user/src/main/java/com/elink/esua/epdc/redis/UserInfoRedis.java new file mode 100644 index 0000000..e349651 --- /dev/null +++ b/epdc-cloud-user/src/main/java/com/elink/esua/epdc/redis/UserInfoRedis.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.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@elink-cn.com + * @since v1.0.0 2021-08-31 + */ +@Component +public class UserInfoRedis { + @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/epdc-cloud-user/src/main/java/com/elink/esua/epdc/service/UserInfoService.java b/epdc-cloud-user/src/main/java/com/elink/esua/epdc/service/UserInfoService.java index 4122d4a..0ca7ee1 100644 --- a/epdc-cloud-user/src/main/java/com/elink/esua/epdc/service/UserInfoService.java +++ b/epdc-cloud-user/src/main/java/com/elink/esua/epdc/service/UserInfoService.java @@ -1,40 +1,115 @@ +/** + * 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.utils.Result; +import com.elink.esua.epdc.commons.tools.page.PageData; +import com.elink.esua.epdc.dto.UserInfoDTO; import com.elink.esua.epdc.dto.epdc.form.EpdcAppShowIdentityFormDTO; import com.elink.esua.epdc.dto.epdc.result.EpdcAppIdentityDetailResultDTO; import com.elink.esua.epdc.entity.UserInfoEntity; +import java.util.List; +import java.util.Map; + +/** + * 用户信息表 用户信息表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2021-08-31 + */ public interface UserInfoService extends BaseService { + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2021-08-31 + */ + PageData page(Map params); - /** - * 用户信息表 - * @params [dto] - * @return void - * @author zhangfenghe - * @since 2021/8/29 11:00 - */ - void save(EpdcAppShowIdentityFormDTO dto); + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2021-08-31 + */ + List list(Map params); - EpdcAppIdentityDetailResultDTO getDentityDetail(String userId); + /** + * 单条查询 + * + * @param id + * @return UserInfoDTO + * @author generator + * @date 2021-08-31 + */ + UserInfoDTO get(String id); /** - * 党建引领-党员亮身份推荐 - * @params [id] + * 默认保存 + * + * @param dto * @return void - * @author zhangfenghe - * @since 2021/8/30 9:26 + * @author generator + * @date 2021-08-31 */ - Result recommended(String id); + void save(UserInfoDTO dto); /** - * 党建引领-党员亮身份取消推荐 - * @params [id] + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2021-08-31 + */ + void update(UserInfoDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2021-08-31 + */ + void delete(String[] ids); + + /** + * 用户信息表 + * @params [dto] * @return void * @author zhangfenghe - * @since 2021/8/30 9:26 + * @since 2021/8/29 11:00 */ - Result recommendedCancel(String id); -} + void save(EpdcAppShowIdentityFormDTO dto); + + /** + * 党员亮身份详情查询 + * @params [userId] + * @return com.elink.esua.epdc.dto.epdc.result.EpdcAppIdentityDetailResultDTO + * @author zhangfenghe + * @since 2021/9/1 9:23 + */ + EpdcAppIdentityDetailResultDTO getDentityDetail(String userId); +} \ No newline at end of file diff --git a/epdc-cloud-user/src/main/java/com/elink/esua/epdc/service/impl/UserInfoServiceImpl.java b/epdc-cloud-user/src/main/java/com/elink/esua/epdc/service/impl/UserInfoServiceImpl.java index 7dd5abb..e03ea42 100644 --- a/epdc-cloud-user/src/main/java/com/elink/esua/epdc/service/impl/UserInfoServiceImpl.java +++ b/epdc-cloud-user/src/main/java/com/elink/esua/epdc/service/impl/UserInfoServiceImpl.java @@ -1,26 +1,117 @@ +/** + * 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.FieldConstant; +import com.elink.esua.epdc.commons.tools.page.PageData; +import com.elink.esua.epdc.commons.tools.security.user.SecurityUser; +import com.elink.esua.epdc.commons.tools.security.user.UserDetail; import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; -import com.elink.esua.epdc.commons.tools.utils.Result; -import com.elink.esua.epdc.commons.tools.validator.AssertUtils; import com.elink.esua.epdc.dao.UserInfoDao; +import com.elink.esua.epdc.dto.UserInfoDTO; import com.elink.esua.epdc.dto.epdc.form.EpdcAppShowIdentityFormDTO; import com.elink.esua.epdc.dto.epdc.result.EpdcAppIdentityDetailResultDTO; import com.elink.esua.epdc.entity.UserInfoEntity; +import com.elink.esua.epdc.redis.UserInfoRedis; import com.elink.esua.epdc.service.UserInfoService; +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.Date; +import java.util.List; +import java.util.Map; + /** + * 用户信息表 用户信息表 * - * create by: zhangfenghe - * description: 党员亮身份 - * create time: 2021/8/29$ 11:27$ + * @author qu qu@elink-cn.com + * @since v1.0.0 2021-08-31 */ @Service public class UserInfoServiceImpl extends BaseServiceImpl implements UserInfoService { + @Autowired + private UserInfoRedis userInfoRedis; + + @Override + public PageData page(Map params) { + UserDetail userDetail = SecurityUser.getUser(); + params.put("deptIds",userDetail.getDeptIdList()); + IPage iPage = this.getPage(params); + List userDtoList = this.baseDao.selectListUserInfoDtos(params); + return new PageData<>(userDtoList, iPage.getTotal()); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, UserInfoDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public UserInfoDTO get(String id) { + UserInfoEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, UserInfoDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(UserInfoDTO dto) { + UserInfoEntity entity = ConvertUtils.sourceToTarget(dto, UserInfoEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(UserInfoDTO dto) { + if("1".equals(dto.getRecommendFlag())){ + dto.setRecommendFlag("0"); + }else{ + dto.setRecommendTime(new Date()); + dto.setRecommendFlag("1"); + } + UserInfoEntity entity = ConvertUtils.sourceToTarget(dto, UserInfoEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + @Override @Transactional(rollbackFor = Exception.class) public void save(EpdcAppShowIdentityFormDTO dto) { @@ -40,17 +131,5 @@ public class UserInfoServiceImpl extends BaseServiceImpl +