From 7d26c40c1e5228fd6bec660ce0b430937644f206 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Wed, 28 Jul 2021 15:49:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/form/SyncFootBar4CustomerFormDTO.java | 27 ++++++++++ .../controller/CustomerFootBarController.java | 10 ++-- .../com/epmet/dao/CustomerFootBarDao.java | 24 +++++++++ .../epmet/service/CustomerFootBarService.java | 3 +- .../impl/CustomerFootBarServiceImpl.java | 52 +++++++++++++------ .../resources/mapper/CustomerFootBarDao.xml | 42 ++++++++++++++- 6 files changed, 137 insertions(+), 21 deletions(-) create mode 100644 epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/form/SyncFootBar4CustomerFormDTO.java diff --git a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/form/SyncFootBar4CustomerFormDTO.java b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/form/SyncFootBar4CustomerFormDTO.java new file mode 100644 index 0000000000..1662bd2928 --- /dev/null +++ b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/form/SyncFootBar4CustomerFormDTO.java @@ -0,0 +1,27 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.util.List; + +/** + * 客户定制化-同步footbar + * + * @author yinzuomei@elink-cn.com + * @date 2021/7/28 15:21 + */ +@Data +public class SyncFootBar4CustomerFormDTO implements Serializable { + private static final long serialVersionUID = 8879950597580438204L; + @NotBlank(message = "customerId不能为空") + private String customerId; + @NotBlank(message = "appType不能为空") + private String appType; + private List syncBarKeyList; + private List addBarKeyList; + + @NotBlank(message = "操作用户不能为空") + private String userId; +} diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/CustomerFootBarController.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/CustomerFootBarController.java index a670f37aea..ee7f82c6ba 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/CustomerFootBarController.java +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/CustomerFootBarController.java @@ -17,10 +17,12 @@ package com.epmet.controller; +import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.redis.RedisKeys; import com.epmet.commons.tools.redis.RedisUtils; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ExcelUtils; import com.epmet.commons.tools.utils.Result; @@ -33,6 +35,7 @@ import com.epmet.dto.CustomerFootBarDTO; import com.epmet.dto.form.CheckFloatFootBarFormDTO; import com.epmet.dto.form.CustomerFootBarFormDTO; import com.epmet.dto.form.NotOnlineFootBarFormDTO; +import com.epmet.dto.form.SyncFootBar4CustomerFormDTO; import com.epmet.dto.result.CheckFloatFootBarResultDTO; import com.epmet.dto.result.CustomerFootBarResultDTO; import com.epmet.entity.CustomerFootBarEntity; @@ -281,9 +284,10 @@ public class CustomerFootBarController { * @author yinzuomei * @date 2021/7/28 10:01 */ - @PostMapping("createfootbar-customer") - public Result createFootBarCustomer(@RequestBody CustomerFootBarFormDTO form) { - ValidatorUtils.validateEntity(form, CustomerFootBarFormDTO.CreateFootBarGroup.class); + @PostMapping("syncfootbar4customer") + public Result createFootBarCustomer(@LoginUser TokenDto tokenDto, @RequestBody SyncFootBar4CustomerFormDTO form) { + form.setUserId(tokenDto.getUserId()); + ValidatorUtils.validateEntity(form); customerFootBarService.createFootBarCustomer(form); return new Result(); } diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/dao/CustomerFootBarDao.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/dao/CustomerFootBarDao.java index b7d32e8a90..8e4e0b5a88 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/dao/CustomerFootBarDao.java +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/dao/CustomerFootBarDao.java @@ -95,4 +95,28 @@ public interface CustomerFootBarDao extends BaseDao { * @date 2021/7/28 9:49 */ List selectNotOnlineFootBars(@Param("customerId") String customerId, @Param("appType")String appType); + + /** + * 根据key查询 + * + * @param customerId + * @param appType + * @param barKeyList + * @return com.epmet.entity.CustomerFootBarEntity + * @author yinzuomei + * @date 2021/7/28 15:27 + */ + List selectListByKey(@Param("customerId")String customerId, + @Param("appType")String appType, + @Param("barKeyList")List barKeyList); + + int updateCustomerFootBarByKey(@Param("customerId")String customerId, + @Param("appType")String appType, + @Param("barKey")String barKey, + @Param("userId")String userId, + @Param("pageTitle")String pageTitle, + @Param("barName")String barName, + @Param("iconPath")String iconPath, + @Param("selectedIconPath")String selectedIconPath, + @Param("floatIconPath")String floatIconPath); } \ No newline at end of file diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/CustomerFootBarService.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/CustomerFootBarService.java index 20cc992a37..aa27acbf8b 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/CustomerFootBarService.java +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/CustomerFootBarService.java @@ -24,6 +24,7 @@ import com.epmet.dto.CustomerFootBarDTO; import com.epmet.dto.form.CheckFloatFootBarFormDTO; import com.epmet.dto.form.CustomerFootBarFormDTO; import com.epmet.dto.form.NotOnlineFootBarFormDTO; +import com.epmet.dto.form.SyncFootBar4CustomerFormDTO; import com.epmet.dto.result.CheckFloatFootBarResultDTO; import com.epmet.dto.result.CustomerFootBarResultDTO; import com.epmet.entity.CustomerFootBarEntity; @@ -138,7 +139,7 @@ public interface CustomerFootBarService extends BaseService syncList = baseDao.selectListByKey(Constant.DEFAULT_CUSTOMER, form.getAppType(), form.getSyncBarKeyList()); + syncList.forEach(syncEntity -> { + baseDao.updateCustomerFootBarByKey(form.getCustomerId(), + form.getAppType(), + syncEntity.getBarKey(), + form.getUserId(), + syncEntity.getPageTitle(), + syncEntity.getBarName(), + syncEntity.getIconPath(), + syncEntity.getSelectedIconPath(), + syncEntity.getFloatIconPath() + ); + }); + } + if (!CollectionUtils.isEmpty(form.getAddBarKeyList())) { + List addList = baseDao.selectListByKey(Constant.DEFAULT_CUSTOMER, form.getAppType(), form.getAddBarKeyList()); + addList.forEach(addEntity -> { + CustomerFootBarFormDTO footBarFormDTO = new CustomerFootBarFormDTO(); + footBarFormDTO.setCustomerId(form.getCustomerId()); + footBarFormDTO.setAppType(form.getAppType()); + footBarFormDTO.setBarKey(addEntity.getBarKey()); + footBarFormDTO.setBarName(addEntity.getBarName()); + validateBeforeCreate(footBarFormDTO); + + CustomerFootBarEntity entity = ConvertUtils.sourceToTarget(addEntity, CustomerFootBarEntity.class); + entity.setCustomerId(form.getCustomerId()); + entity.setOrderIndex(baseDao.fetchNextOrder(form.getCustomerId(), form.getAppType())); + entity.setDisplay(true); + baseDao.insert(entity); + }); + } } /** diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/resources/mapper/CustomerFootBarDao.xml b/epmet-module/oper-customize/oper-customize-server/src/main/resources/mapper/CustomerFootBarDao.xml index bb5117f8bb..3f6150942f 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/resources/mapper/CustomerFootBarDao.xml +++ b/epmet-module/oper-customize/oper-customize-server/src/main/resources/mapper/CustomerFootBarDao.xml @@ -171,6 +171,7 @@ page_title, icon_path, selected_icon_path, + FLOAT_ICON_PATH as floatIconPath, display, order_index, del_flag, @@ -200,6 +201,7 @@ page_title, icon_path, selected_icon_path, + FLOAT_ICON_PATH as floatIconPath, display, order_index, del_flag, @@ -221,7 +223,8 @@ m.app_type as appType, m.PAGE_TITLE as pageTitle, m.ICON_PATH as iconPath, - m.SELECTED_ICON_PATH as selectedIconPath + m.SELECTED_ICON_PATH as selectedIconPath, + m.FLOAT_ICON_PATH as floatIconPath from customer_foot_bar m where m.DEL_FLAG='0' and m.CUSTOMER_ID='default' @@ -235,4 +238,41 @@ and cfb.app_type=#{appType} )order by m.ORDER_INDEX asc + + + + + + UPDATE customer_foot_bar + SET BAR_NAME = #{barName}, + PAGE_TITLE = #{pageTitle}, + ICON_PATH = #{iconPath}, + SELECTED_ICON_PATH = #{selectedIconPath}, + FLOAT_ICON_PATH = #{floatIconPath}, + UPDATED_BY = #{userId}, + UPDATED_TIME = NOW() + WHERE + CUSTOMER_ID = #{customerId} + AND app_type = #{appType} + AND BAR_KEY = #{barKey} + AND DEL_FLAG = '0' + \ No newline at end of file