21 changed files with 847 additions and 14 deletions
			
			
		| @ -0,0 +1,81 @@ | |||
| /** | |||
|  * Copyright 2018 人人开源 https://www.renren.io
 | |||
|  * <p> | |||
|  * 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. | |||
|  * <p> | |||
|  * 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. | |||
|  * <p> | |||
|  * You should have received a copy of the GNU General Public License | |||
|  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | |||
|  */ | |||
| 
 | |||
| package com.epmet.dto; | |||
| 
 | |||
| import java.io.Serializable; | |||
| import java.util.Date; | |||
| import lombok.Data; | |||
| 
 | |||
| 
 | |||
| /** | |||
|  * 客户菜单配置表 | |||
|  * | |||
|  * @author generator generator@elink-cn.com | |||
|  * @since v1.0.0 2021-03-16 | |||
|  */ | |||
| @Data | |||
| public class GovCustomerMenuDTO implements Serializable { | |||
| 
 | |||
|     private static final long serialVersionUID = 1L; | |||
| 
 | |||
|     /** | |||
|      * 主键ID | |||
|      */ | |||
| 	private String id; | |||
| 
 | |||
|     /** | |||
|      * 客户ID | |||
|      */ | |||
| 	private String customerId; | |||
| 
 | |||
|     /** | |||
|      * gov_menu表主键 | |||
|      */ | |||
| 	private String tableId; | |||
| 
 | |||
|     /** | |||
|      * 删除标识 0未删除、1已删除 | |||
|      */ | |||
| 	private String delFlag; | |||
| 
 | |||
|     /** | |||
|      * 乐观锁 | |||
|      */ | |||
| 	private Integer revision; | |||
| 
 | |||
|     /** | |||
|      * 创建人 | |||
|      */ | |||
| 	private String createdBy; | |||
| 
 | |||
|     /** | |||
|      * 创建时间 | |||
|      */ | |||
| 	private Date createdTime; | |||
| 
 | |||
|     /** | |||
|      * 更新人 | |||
|      */ | |||
| 	private String updatedBy; | |||
| 
 | |||
|     /** | |||
|      * 更新时间 | |||
|      */ | |||
| 	private Date updatedTime; | |||
| 
 | |||
| } | |||
| @ -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; | |||
| 
 | |||
| /** | |||
|  * 菜单配置 - 一菜单 多 客户 | |||
|  */ | |||
| @Data | |||
| public class MenuConfigFormDTO implements Serializable { | |||
|     private static final long serialVersionUID = -2898130727929596798L; | |||
| 
 | |||
|     /** | |||
|      * gov_menu表主键 | |||
|      */ | |||
|     @NotBlank(message = "菜单ID不能为空") | |||
|     private String tableId; | |||
| 
 | |||
|     /** | |||
|      * 客户id 列表 | |||
|      */ | |||
|     @NotBlank(message = "客户id 列表不能为空") | |||
|     private List<String> customerIds; | |||
| } | |||
| @ -0,0 +1,22 @@ | |||
| package com.epmet.dto.form; | |||
| 
 | |||
| import lombok.Data; | |||
| 
 | |||
| import javax.validation.constraints.NotBlank; | |||
| import java.io.Serializable; | |||
| import java.util.List; | |||
| 
 | |||
| /** | |||
|  * 菜单基础入参 | |||
|  */ | |||
| @Data | |||
| public class MenuFormDTO implements Serializable { | |||
|     private static final long serialVersionUID = -2898130727929596798L; | |||
| 
 | |||
|     /** | |||
|      * gov_menu表主键 | |||
|      */ | |||
|     @NotBlank(message = "菜单ID不能为空") | |||
|     private String tableId; | |||
| 
 | |||
| } | |||
| @ -0,0 +1,130 @@ | |||
| /** | |||
|  * Copyright 2018 人人开源 https://www.renren.io
 | |||
|  * <p> | |||
|  * 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. | |||
|  * <p> | |||
|  * 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. | |||
|  * <p> | |||
|  * You should have received a copy of the GNU General Public License | |||
|  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | |||
|  */ | |||
| 
 | |||
| package com.epmet.controller; | |||
| 
 | |||
| import com.epmet.commons.tools.exception.RenException; | |||
| import com.epmet.commons.tools.page.PageData; | |||
| import com.epmet.commons.tools.utils.ExcelUtils; | |||
| import com.epmet.commons.tools.utils.Result; | |||
| import com.epmet.commons.tools.validator.AssertUtils; | |||
| import com.epmet.commons.tools.validator.ValidatorUtils; | |||
| import com.epmet.commons.tools.validator.group.AddGroup; | |||
| import com.epmet.commons.tools.validator.group.UpdateGroup; | |||
| import com.epmet.commons.tools.validator.group.DefaultGroup; | |||
| import com.epmet.dto.GovCustomerMenuDTO; | |||
| import com.epmet.dto.form.MenuConfigFormDTO; | |||
| import com.epmet.dto.form.MenuFormDTO; | |||
| import com.epmet.excel.GovCustomerMenuExcel; | |||
| import com.epmet.service.GovCustomerMenuService; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| 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 generator generator@elink-cn.com | |||
|  * @since v1.0.0 2021-03-16 | |||
|  */ | |||
| @RestController | |||
| @RequestMapping("govcustomermenu") | |||
| public class GovCustomerMenuController { | |||
| 
 | |||
|     @Autowired | |||
|     private GovCustomerMenuService govCustomerMenuService; | |||
| 
 | |||
|     @GetMapping("page") | |||
|     public Result<PageData<GovCustomerMenuDTO>> page(@RequestParam Map<String, Object> params){ | |||
|         PageData<GovCustomerMenuDTO> page = govCustomerMenuService.page(params); | |||
|         return new Result<PageData<GovCustomerMenuDTO>>().ok(page); | |||
|     } | |||
| 
 | |||
|     @GetMapping("{id}") | |||
|     public Result<GovCustomerMenuDTO> get(@PathVariable("id") String id){ | |||
|         GovCustomerMenuDTO data = govCustomerMenuService.get(id); | |||
|         return new Result<GovCustomerMenuDTO>().ok(data); | |||
|     } | |||
| 
 | |||
|     @PostMapping | |||
|     public Result save(@RequestBody GovCustomerMenuDTO dto){ | |||
|         //效验数据
 | |||
|         ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); | |||
|         govCustomerMenuService.save(dto); | |||
|         return new Result(); | |||
|     } | |||
| 
 | |||
|     @PutMapping | |||
|     public Result update(@RequestBody GovCustomerMenuDTO dto){ | |||
|         //效验数据
 | |||
|         ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); | |||
|         govCustomerMenuService.update(dto); | |||
|         return new Result(); | |||
|     } | |||
| 
 | |||
|     @DeleteMapping | |||
|     public Result delete(@RequestBody String[] ids){ | |||
|         //效验数据
 | |||
|         AssertUtils.isArrayEmpty(ids, "id"); | |||
|         govCustomerMenuService.delete(ids); | |||
|         return new Result(); | |||
|     } | |||
| 
 | |||
|     @GetMapping("export") | |||
|     public void export(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { | |||
|         List<GovCustomerMenuDTO> list = govCustomerMenuService.list(params); | |||
|         ExcelUtils.exportExcelToTarget(response, null, list, GovCustomerMenuExcel.class); | |||
|     } | |||
| 
 | |||
|     /** | |||
|      * 给每个客户 配置可见菜单 | |||
|      *    先删除,后新增 | |||
|      * | |||
|      * @param formDTO | |||
|      * @return com.epmet.commons.tools.utils.Result | |||
|      * @Author zhangyong | |||
|      * @Date 14:15 2021-03-16 | |||
|      **/ | |||
|     @PostMapping("addcustomermenu") | |||
|     public Result addCustomerMenu(@RequestBody MenuConfigFormDTO formDTO) { | |||
|         //效验数据
 | |||
|         if (StringUtils.isBlank(formDTO.getTableId())) { | |||
|             throw new RenException("菜单ID不能为空"); | |||
|         } | |||
|         govCustomerMenuService.saveCustomerMenu(formDTO); | |||
|         return new Result(); | |||
|     } | |||
| 
 | |||
|     /** | |||
|      * 根据gov_menu表主键,查询拥有这项菜单的所有客户(customerIds) | |||
|      * | |||
|      * @param formDTO | |||
|      * @return com.epmet.commons.tools.utils.Result<java.util.List<java.lang.String>> | |||
|      * @Author zhangyong | |||
|      * @Date 16:26 2021-03-16 | |||
|      **/ | |||
|     @PostMapping("getcustomerids") | |||
|     public Result<List<String>> getcustomerids(@RequestBody MenuFormDTO formDTO){ | |||
|         List<String> data = govCustomerMenuService.getcustomerIds(formDTO.getTableId()); | |||
|         return new Result<List<String>>().ok(data); | |||
|     } | |||
| } | |||
| @ -0,0 +1,55 @@ | |||
| /** | |||
|  * Copyright 2018 人人开源 https://www.renren.io
 | |||
|  * <p> | |||
|  * 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. | |||
|  * <p> | |||
|  * 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. | |||
|  * <p> | |||
|  * You should have received a copy of the GNU General Public License | |||
|  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | |||
|  */ | |||
| 
 | |||
| package com.epmet.dao; | |||
| 
 | |||
| import com.epmet.commons.mybatis.dao.BaseDao; | |||
| import com.epmet.entity.GovCustomerMenuEntity; | |||
| import org.apache.ibatis.annotations.Mapper; | |||
| import org.apache.ibatis.annotations.Param; | |||
| 
 | |||
| import java.util.List; | |||
| 
 | |||
| /** | |||
|  * 客户菜单配置表 | |||
|  * | |||
|  * @author generator generator@elink-cn.com | |||
|  * @since v1.0.0 2021-03-16 | |||
|  */ | |||
| @Mapper | |||
| public interface GovCustomerMenuDao extends BaseDao<GovCustomerMenuEntity> { | |||
| 
 | |||
|     /** | |||
|      * 根据gov_menu表主键,先清除之前配置的客户信息 | |||
|      * | |||
|      * @param tableId | |||
|      * @return void | |||
|      * @Author zhangyong | |||
|      * @Date 14:24 2021-03-16 | |||
|      **/ | |||
|     void deleteBatchTableIds(@Param("tableId") String tableId); | |||
| 
 | |||
|     /** | |||
|      * 根据gov_menu表主键,查询拥有这项菜单的所有客户(customerIds) | |||
|      * | |||
|      * @param tableId | |||
|      * @return java.util.List<java.lang.String> | |||
|      * @Author zhangyong | |||
|      * @Date 16:29 2021-03-16 | |||
|      **/ | |||
|     List<String> selectListcustomerIds(@Param("tableId") String tableId); | |||
| } | |||
| @ -0,0 +1,51 @@ | |||
| /** | |||
|  * Copyright 2018 人人开源 https://www.renren.io
 | |||
|  * <p> | |||
|  * 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. | |||
|  * <p> | |||
|  * 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. | |||
|  * <p> | |||
|  * You should have received a copy of the GNU General Public License | |||
|  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | |||
|  */ | |||
| 
 | |||
| package com.epmet.entity; | |||
| 
 | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| 
 | |||
| import com.epmet.commons.mybatis.entity.BaseEpmetEntity; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| 
 | |||
| import java.util.Date; | |||
| 
 | |||
| /** | |||
|  * 客户菜单配置表 | |||
|  * | |||
|  * @author generator generator@elink-cn.com | |||
|  * @since v1.0.0 2021-03-16 | |||
|  */ | |||
| @Data | |||
| @EqualsAndHashCode(callSuper=false) | |||
| @TableName("gov_customer_menu") | |||
| public class GovCustomerMenuEntity extends BaseEpmetEntity { | |||
| 
 | |||
| 	private static final long serialVersionUID = 1L; | |||
| 
 | |||
|     /** | |||
|      * 客户ID | |||
|      */ | |||
| 	private String customerId; | |||
| 
 | |||
|     /** | |||
|      * gov_menu表主键 | |||
|      */ | |||
| 	private String tableId; | |||
| 
 | |||
| } | |||
| @ -0,0 +1,62 @@ | |||
| /** | |||
|  * Copyright 2018 人人开源 https://www.renren.io
 | |||
|  * <p> | |||
|  * 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. | |||
|  * <p> | |||
|  * 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. | |||
|  * <p> | |||
|  * You should have received a copy of the GNU General Public License | |||
|  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | |||
|  */ | |||
| 
 | |||
| package com.epmet.excel; | |||
| 
 | |||
| import cn.afterturn.easypoi.excel.annotation.Excel; | |||
| import lombok.Data; | |||
| 
 | |||
| import java.util.Date; | |||
| 
 | |||
| /** | |||
|  * 客户菜单配置表 | |||
|  * | |||
|  * @author generator generator@elink-cn.com | |||
|  * @since v1.0.0 2021-03-16 | |||
|  */ | |||
| @Data | |||
| public class GovCustomerMenuExcel { | |||
| 
 | |||
|     @Excel(name = "主键ID") | |||
|     private String id; | |||
| 
 | |||
|     @Excel(name = "客户ID") | |||
|     private String customerId; | |||
| 
 | |||
|     @Excel(name = "gov_menu表主键") | |||
|     private String tableId; | |||
| 
 | |||
|     @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; | |||
| 
 | |||
| 
 | |||
| } | |||
| @ -0,0 +1,47 @@ | |||
| /** | |||
|  * Copyright 2018 人人开源 https://www.renren.io
 | |||
|  * <p> | |||
|  * 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. | |||
|  * <p> | |||
|  * 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. | |||
|  * <p> | |||
|  * You should have received a copy of the GNU General Public License | |||
|  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | |||
|  */ | |||
| 
 | |||
| package com.epmet.redis; | |||
| 
 | |||
| import com.epmet.commons.tools.redis.RedisUtils; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Component; | |||
| 
 | |||
| /** | |||
|  * 客户菜单配置表 | |||
|  * | |||
|  * @author generator generator@elink-cn.com | |||
|  * @since v1.0.0 2021-03-16 | |||
|  */ | |||
| @Component | |||
| public class GovCustomerMenuRedis { | |||
|     @Autowired | |||
|     private RedisUtils redisUtils; | |||
| 
 | |||
|     public void delete(Object[] ids) { | |||
| 
 | |||
|     } | |||
| 
 | |||
|     public void set(){ | |||
| 
 | |||
|     } | |||
| 
 | |||
|     public String get(String id){ | |||
|         return null; | |||
|     } | |||
| 
 | |||
| } | |||
| @ -0,0 +1,126 @@ | |||
| /** | |||
|  * Copyright 2018 人人开源 https://www.renren.io
 | |||
|  * <p> | |||
|  * 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. | |||
|  * <p> | |||
|  * 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. | |||
|  * <p> | |||
|  * You should have received a copy of the GNU General Public License | |||
|  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | |||
|  */ | |||
| 
 | |||
| package com.epmet.service; | |||
| 
 | |||
| import com.epmet.commons.mybatis.service.BaseService; | |||
| import com.epmet.commons.tools.page.PageData; | |||
| import com.epmet.dto.GovCustomerMenuDTO; | |||
| import com.epmet.dto.form.MenuConfigFormDTO; | |||
| import com.epmet.entity.GovCustomerMenuEntity; | |||
| 
 | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| 
 | |||
| /** | |||
|  * 客户菜单配置表 | |||
|  * | |||
|  * @author generator generator@elink-cn.com | |||
|  * @since v1.0.0 2021-03-16 | |||
|  */ | |||
| public interface GovCustomerMenuService extends BaseService<GovCustomerMenuEntity> { | |||
| 
 | |||
|     /** | |||
|      * 默认分页 | |||
|      * | |||
|      * @param params | |||
|      * @return PageData<GovCustomerMenuDTO> | |||
|      * @author generator | |||
|      * @date 2021-03-16 | |||
|      */ | |||
|     PageData<GovCustomerMenuDTO> page(Map<String, Object> params); | |||
| 
 | |||
|     /** | |||
|      * 默认查询 | |||
|      * | |||
|      * @param params | |||
|      * @return java.util.List<GovCustomerMenuDTO> | |||
|      * @author generator | |||
|      * @date 2021-03-16 | |||
|      */ | |||
|     List<GovCustomerMenuDTO> list(Map<String, Object> params); | |||
| 
 | |||
|     /** | |||
|      * 单条查询 | |||
|      * | |||
|      * @param id | |||
|      * @return GovCustomerMenuDTO | |||
|      * @author generator | |||
|      * @date 2021-03-16 | |||
|      */ | |||
|     GovCustomerMenuDTO get(String id); | |||
| 
 | |||
|     /** | |||
|      * 默认保存 | |||
|      * | |||
|      * @param dto | |||
|      * @return void | |||
|      * @author generator | |||
|      * @date 2021-03-16 | |||
|      */ | |||
|     void save(GovCustomerMenuDTO dto); | |||
| 
 | |||
|     /** | |||
|      * 默认更新 | |||
|      * | |||
|      * @param dto | |||
|      * @return void | |||
|      * @author generator | |||
|      * @date 2021-03-16 | |||
|      */ | |||
|     void update(GovCustomerMenuDTO dto); | |||
| 
 | |||
|     /** | |||
|      * 批量删除 | |||
|      * | |||
|      * @param ids | |||
|      * @return void | |||
|      * @author generator | |||
|      * @date 2021-03-16 | |||
|      */ | |||
|     void delete(String[] ids); | |||
| 
 | |||
|     /** | |||
|      * 给每个客户 配置可见菜单 | |||
|      * | |||
|      * @param formDTO | |||
|      * @return void | |||
|      * @Author zhangyong | |||
|      * @Date 14:16 2021-03-16 | |||
|      **/ | |||
|     void saveCustomerMenu(MenuConfigFormDTO formDTO); | |||
| 
 | |||
|     /** | |||
|      * 根据gov_menu表主键,查询拥有这项菜单的所有客户(customerIds) | |||
|      * | |||
|      * @param tableId | |||
|      * @return java.util.List<java.lang.String> | |||
|      * @Author zhangyong | |||
|      * @Date 16:29 2021-03-16 | |||
|      **/ | |||
|     List<String> getcustomerIds(String tableId); | |||
| 
 | |||
|     /** | |||
|      * 根据gov_menu表主键,先清除之前配置的客户信息 | |||
|      * | |||
|      * @param tableId | |||
|      * @return void | |||
|      * @Author zhangyong | |||
|      * @Date 14:24 2021-03-16 | |||
|      **/ | |||
|     void deleteBatchTableIds(String tableId); | |||
| } | |||
| @ -0,0 +1,132 @@ | |||
| /** | |||
|  * Copyright 2018 人人开源 https://www.renren.io
 | |||
|  * <p> | |||
|  * 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. | |||
|  * <p> | |||
|  * 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. | |||
|  * <p> | |||
|  * You should have received a copy of the GNU General Public License | |||
|  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | |||
|  */ | |||
| 
 | |||
| package com.epmet.service.impl; | |||
| 
 | |||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
| import com.baomidou.mybatisplus.core.metadata.IPage; | |||
| import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; | |||
| import com.epmet.commons.tools.constant.NumConstant; | |||
| import com.epmet.commons.tools.page.PageData; | |||
| import com.epmet.commons.tools.utils.ConvertUtils; | |||
| import com.epmet.commons.tools.constant.FieldConstant; | |||
| import com.epmet.dao.GovCustomerMenuDao; | |||
| import com.epmet.dto.GovCustomerMenuDTO; | |||
| import com.epmet.dto.form.MenuConfigFormDTO; | |||
| import com.epmet.entity.GovCustomerMenuEntity; | |||
| import com.epmet.redis.GovCustomerMenuRedis; | |||
| import com.epmet.service.GovCustomerMenuService; | |||
| 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.ArrayList; | |||
| import java.util.Arrays; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| 
 | |||
| /** | |||
|  * 客户菜单配置表 | |||
|  * | |||
|  * @author generator generator@elink-cn.com | |||
|  * @since v1.0.0 2021-03-16 | |||
|  */ | |||
| @Service | |||
| public class GovCustomerMenuServiceImpl extends BaseServiceImpl<GovCustomerMenuDao, GovCustomerMenuEntity> implements GovCustomerMenuService { | |||
| 
 | |||
|     @Autowired | |||
|     private GovCustomerMenuRedis govCustomerMenuRedis; | |||
| 
 | |||
|     @Override | |||
|     public PageData<GovCustomerMenuDTO> page(Map<String, Object> params) { | |||
|         IPage<GovCustomerMenuEntity> page = baseDao.selectPage( | |||
|                 getPage(params, FieldConstant.CREATED_TIME, false), | |||
|                 getWrapper(params) | |||
|         ); | |||
|         return getPageData(page, GovCustomerMenuDTO.class); | |||
|     } | |||
| 
 | |||
|     @Override | |||
|     public List<GovCustomerMenuDTO> list(Map<String, Object> params) { | |||
|         List<GovCustomerMenuEntity> entityList = baseDao.selectList(getWrapper(params)); | |||
| 
 | |||
|         return ConvertUtils.sourceToTarget(entityList, GovCustomerMenuDTO.class); | |||
|     } | |||
| 
 | |||
|     private QueryWrapper<GovCustomerMenuEntity> getWrapper(Map<String, Object> params){ | |||
|         String id = (String)params.get(FieldConstant.ID_HUMP); | |||
| 
 | |||
|         QueryWrapper<GovCustomerMenuEntity> wrapper = new QueryWrapper<>(); | |||
|         wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); | |||
| 
 | |||
|         return wrapper; | |||
|     } | |||
| 
 | |||
|     @Override | |||
|     public GovCustomerMenuDTO get(String id) { | |||
|         GovCustomerMenuEntity entity = baseDao.selectById(id); | |||
|         return ConvertUtils.sourceToTarget(entity, GovCustomerMenuDTO.class); | |||
|     } | |||
| 
 | |||
|     @Override | |||
|     @Transactional(rollbackFor = Exception.class) | |||
|     public void save(GovCustomerMenuDTO dto) { | |||
|         GovCustomerMenuEntity entity = ConvertUtils.sourceToTarget(dto, GovCustomerMenuEntity.class); | |||
|         insert(entity); | |||
|     } | |||
| 
 | |||
|     @Override | |||
|     @Transactional(rollbackFor = Exception.class) | |||
|     public void update(GovCustomerMenuDTO dto) { | |||
|         GovCustomerMenuEntity entity = ConvertUtils.sourceToTarget(dto, GovCustomerMenuEntity.class); | |||
|         updateById(entity); | |||
|     } | |||
| 
 | |||
|     @Override | |||
|     @Transactional(rollbackFor = Exception.class) | |||
|     public void delete(String[] ids) { | |||
|         // 逻辑删除(@TableLogic 注解)
 | |||
|         baseDao.deleteBatchIds(Arrays.asList(ids)); | |||
|     } | |||
| 
 | |||
|     @Override | |||
|     public void saveCustomerMenu(MenuConfigFormDTO formDTO) { | |||
|         if (NumConstant.ZERO < formDTO.getCustomerIds().size()) { | |||
|             baseDao.deleteBatchTableIds(formDTO.getTableId()); | |||
| 
 | |||
|             List<GovCustomerMenuEntity> entities = new ArrayList<>(); | |||
|             for (String customerId : formDTO.getCustomerIds()) { | |||
|                 GovCustomerMenuEntity entity = new GovCustomerMenuEntity(); | |||
|                 entity.setCustomerId(customerId); | |||
|                 entity.setTableId(formDTO.getTableId()); | |||
|                 entities.add(entity); | |||
|             } | |||
|             insertBatch(entities); | |||
|         } | |||
|     } | |||
| 
 | |||
|     @Override | |||
|     public List<String> getcustomerIds(String tableId) { | |||
|         return baseDao.selectListcustomerIds(tableId); | |||
|     } | |||
| 
 | |||
|     @Override | |||
|     public void deleteBatchTableIds(String tableId) { | |||
|         baseDao.deleteBatchTableIds(tableId); | |||
|     } | |||
| } | |||
| @ -0,0 +1,12 @@ | |||
| CREATE TABLE `gov_customer_menu` ( | |||
|   `ID` varchar(32) NOT NULL COMMENT '主键ID', | |||
|   `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户ID', | |||
|   `TABLE_ID` varchar(32) NOT NULL COMMENT 'gov_menu表主键', | |||
|   `DEL_FLAG` varchar(1) NOT NULL DEFAULT '0' COMMENT '删除标识 0未删除、1已删除', | |||
|   `REVISION` int(11) DEFAULT '0' COMMENT '乐观锁', | |||
|   `CREATED_BY` varchar(32) DEFAULT NULL COMMENT '创建人', | |||
|   `CREATED_TIME` datetime DEFAULT NULL COMMENT '创建时间', | |||
|   `UPDATED_BY` varchar(32) DEFAULT NULL COMMENT '更新人', | |||
|   `UPDATED_TIME` datetime DEFAULT NULL COMMENT '更新时间', | |||
|   PRIMARY KEY (`ID`) | |||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='客户菜单配置表'; | |||
| @ -0,0 +1,29 @@ | |||
| <?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="com.epmet.dao.GovCustomerMenuDao"> | |||
| 
 | |||
|     <resultMap type="com.epmet.entity.GovCustomerMenuEntity" id="govCustomerMenuMap"> | |||
|         <result property="id" column="ID"/> | |||
|         <result property="customerId" column="CUSTOMER_ID"/> | |||
|         <result property="tableId" column="TABLE_ID"/> | |||
|         <result property="delFlag" column="DEL_FLAG"/> | |||
|         <result property="revision" column="REVISION"/> | |||
|         <result property="createdBy" column="CREATED_BY"/> | |||
|         <result property="createdTime" column="CREATED_TIME"/> | |||
|         <result property="updatedBy" column="UPDATED_BY"/> | |||
|         <result property="updatedTime" column="UPDATED_TIME"/> | |||
|     </resultMap> | |||
| 
 | |||
|     <update id="deleteBatchTableIds"> | |||
|         UPDATE gov_customer_menu SET DEL_FLAG = '1' | |||
|         WHERE DEL_FLAG = '0' | |||
|         AND TABLE_ID = #{tableId, jdbcType=VARCHAR} | |||
|     </update> | |||
| 
 | |||
|     <select id="selectListcustomerIds" resultType="String"> | |||
|         SELECT CUSTOMER_ID customerId | |||
|         FROM gov_customer_menu | |||
|         WHERE del_flag = 0 AND TABLE_ID = #{tableId, jdbcType=VARCHAR} | |||
|     </select> | |||
| </mapper> | |||
					Loading…
					
					
				
		Reference in new issue