23 changed files with 927 additions and 1 deletions
@ -0,0 +1,42 @@ |
|||||
|
package com.elink.esua.epdc.feign; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
||||
|
import com.elink.esua.epdc.dto.rulecategory.form.HandleRoleCategoryFormDTO; |
||||
|
import com.elink.esua.epdc.feign.fallback.EventFeignClientFallback; |
||||
|
import org.springframework.cloud.openfeign.FeignClient; |
||||
|
import org.springframework.http.MediaType; |
||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||
|
import org.springframework.web.bind.annotation.PathVariable; |
||||
|
import org.springframework.web.bind.annotation.PostMapping; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @Auther: yinzuomei |
||||
|
* @Date: 2019/12/24 09:28 |
||||
|
* @Description: 事件接口 |
||||
|
*/ |
||||
|
@FeignClient(name = ServiceConstant.EPDC_EVENTS_SERVER, fallback = EventFeignClientFallback.class) |
||||
|
public interface EventFeignClient { |
||||
|
|
||||
|
/** |
||||
|
* @param orgTypeFormDTO |
||||
|
* @return com.elink.esua.epdc.commons.tools.utils.Result |
||||
|
* @Author yinzuomei |
||||
|
* @Description 保存项目处理类型权限 |
||||
|
* @Date 2019/12/24 17:17 |
||||
|
**/ |
||||
|
@PostMapping(value = "events/handlerolecategory/saveOrUpdate", consumes = MediaType.APPLICATION_JSON_VALUE) |
||||
|
Result saveOrUpdateHandleCategory(HandleRoleCategoryFormDTO orgTypeFormDTO); |
||||
|
|
||||
|
/** |
||||
|
* @param ruleId |
||||
|
* @return com.elink.esua.epdc.commons.tools.utils.Result<java.util.List<java.lang.String>> |
||||
|
* @Author yinzuomei |
||||
|
* @Description 查询角色对应的项目处理类型权限 |
||||
|
* @Date 2019/12/24 17:17 |
||||
|
**/ |
||||
|
@GetMapping(value = "events/handlerolecategory/queryCategoryIdList/{ruleId}") |
||||
|
Result<List<String>> queryCategoryIdList(@PathVariable("ruleId")Long ruleId); |
||||
|
} |
||||
@ -0,0 +1,30 @@ |
|||||
|
package com.elink.esua.epdc.feign.fallback; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.ModuleUtils; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
||||
|
import com.elink.esua.epdc.dto.rulecategory.form.HandleRoleCategoryFormDTO; |
||||
|
import com.elink.esua.epdc.feign.EventFeignClient; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @Description |
||||
|
* @Author yinzuomei |
||||
|
* @Date 2019/12/24 9:45 |
||||
|
*/ |
||||
|
@Component |
||||
|
public class EventFeignClientFallback implements EventFeignClient { |
||||
|
|
||||
|
@Override |
||||
|
public Result saveOrUpdateHandleCategory(HandleRoleCategoryFormDTO orgTypeFormDTO) { |
||||
|
return ModuleUtils.feignConError(ServiceConstant.EPDC_EVENTS_SERVER, "saveOrUpdate", orgTypeFormDTO); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Result<List<String>> queryCategoryIdList(Long ruleId) { |
||||
|
return ModuleUtils.feignConError(ServiceConstant.EPDC_EVENTS_SERVER, "queryCategoryIdList", ruleId); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,30 @@ |
|||||
|
package com.elink.esua.epdc.dto.handlecategory; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @Description 角色授权tree返参dto |
||||
|
* @Author yinzuomei |
||||
|
* @Date 2019/12/24 10:19 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class HandleCategoryTreeDTO implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = -445779738699117585L; |
||||
|
|
||||
|
/** |
||||
|
* 主键 |
||||
|
*/ |
||||
|
private String id; |
||||
|
|
||||
|
/** |
||||
|
* 处理类别显示信息 |
||||
|
*/ |
||||
|
private String name; |
||||
|
|
||||
|
private List<HandleCategoryTreeDTO> children= new ArrayList<>(); |
||||
|
} |
||||
@ -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.elink.esua.epdc.dto.rulecategory; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
import java.util.Date; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 角色和处理类别关系表 |
||||
|
* |
||||
|
* @author qu qu@elink-cn.com |
||||
|
* @since v1.0.0 2019-12-20 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class HandleRoleCategoryDTO implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* 主键 |
||||
|
*/ |
||||
|
private String id; |
||||
|
|
||||
|
/** |
||||
|
* 角色ID |
||||
|
*/ |
||||
|
private String roleId; |
||||
|
|
||||
|
/** |
||||
|
* 处理类别ID |
||||
|
*/ |
||||
|
private String categoryId; |
||||
|
|
||||
|
/** |
||||
|
* 乐观锁 |
||||
|
*/ |
||||
|
private Integer revision; |
||||
|
|
||||
|
/** |
||||
|
* 创建人 |
||||
|
*/ |
||||
|
private String createdBy; |
||||
|
|
||||
|
/** |
||||
|
* 创建时间 |
||||
|
*/ |
||||
|
private Date createdTime; |
||||
|
|
||||
|
/** |
||||
|
* 更新人 |
||||
|
*/ |
||||
|
private String updatedBy; |
||||
|
|
||||
|
/** |
||||
|
* 更新时间 |
||||
|
*/ |
||||
|
private Date updatedTime; |
||||
|
|
||||
|
/** |
||||
|
* 删除标识 0:未删除,1:已删除 |
||||
|
*/ |
||||
|
private String delFlag; |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,29 @@ |
|||||
|
package com.elink.esua.epdc.dto.rulecategory.form; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
import java.io.Serializable; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @Description 保存或修改 角色和处理类别关系 入参DTO |
||||
|
* @Author yinzuomei |
||||
|
* @Date 2019/12/24 12:12 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class HandleRoleCategoryFormDTO implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = -3295948468274114972L; |
||||
|
|
||||
|
/** |
||||
|
* 角色ID |
||||
|
*/ |
||||
|
@NotBlank(message = "角色id不能为空") |
||||
|
private Long roleId; |
||||
|
|
||||
|
/** |
||||
|
* 处理类别ID |
||||
|
*/ |
||||
|
private List<String> categoryIdList; |
||||
|
} |
||||
@ -0,0 +1,104 @@ |
|||||
|
/** |
||||
|
* 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.elink.esua.epdc.modules.rolecategory.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.UpdateGroup; |
||||
|
import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup; |
||||
|
import com.elink.esua.epdc.dto.rulecategory.HandleRoleCategoryDTO; |
||||
|
import com.elink.esua.epdc.dto.rulecategory.form.HandleRoleCategoryFormDTO; |
||||
|
import com.elink.esua.epdc.modules.rolecategory.excel.HandleRoleCategoryExcel; |
||||
|
import com.elink.esua.epdc.modules.rolecategory.service.HandleRoleCategoryService; |
||||
|
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 2019-12-20 |
||||
|
*/ |
||||
|
@RestController |
||||
|
@RequestMapping("handlerolecategory") |
||||
|
public class HandleRoleCategoryController { |
||||
|
|
||||
|
@Autowired |
||||
|
private HandleRoleCategoryService handleRoleCategoryService; |
||||
|
|
||||
|
@GetMapping("page") |
||||
|
public Result<PageData<HandleRoleCategoryDTO>> page(@RequestParam Map<String, Object> params){ |
||||
|
PageData<HandleRoleCategoryDTO> page = handleRoleCategoryService.page(params); |
||||
|
return new Result<PageData<HandleRoleCategoryDTO>>().ok(page); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("{id}") |
||||
|
public Result<HandleRoleCategoryDTO> get(@PathVariable("id") String id){ |
||||
|
HandleRoleCategoryDTO data = handleRoleCategoryService.get(id); |
||||
|
return new Result<HandleRoleCategoryDTO>().ok(data); |
||||
|
} |
||||
|
|
||||
|
@PostMapping |
||||
|
public Result save(@RequestBody HandleRoleCategoryDTO dto){ |
||||
|
//效验数据
|
||||
|
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
||||
|
handleRoleCategoryService.save(dto); |
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
@PutMapping |
||||
|
public Result update(@RequestBody HandleRoleCategoryDTO dto){ |
||||
|
//效验数据
|
||||
|
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); |
||||
|
handleRoleCategoryService.update(dto); |
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
@DeleteMapping |
||||
|
public Result delete(@RequestBody String[] ids){ |
||||
|
//效验数据
|
||||
|
AssertUtils.isArrayEmpty(ids, "id"); |
||||
|
handleRoleCategoryService.delete(ids); |
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("export") |
||||
|
public void export(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { |
||||
|
List<HandleRoleCategoryDTO> list = handleRoleCategoryService.list(params); |
||||
|
ExcelUtils.exportExcelToTarget(response, null, list, HandleRoleCategoryExcel.class); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("saveOrUpdate") |
||||
|
public Result saveOrUpdate(@RequestBody HandleRoleCategoryFormDTO formDTO){ |
||||
|
return handleRoleCategoryService.saveOrUpdate(formDTO); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("queryCategoryIdList/{ruleId}") |
||||
|
public Result<List<String>> queryCategoryIdList(@PathVariable("ruleId") String ruleId){ |
||||
|
return handleRoleCategoryService.listCategoryId(ruleId); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,38 @@ |
|||||
|
/** |
||||
|
* 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.elink.esua.epdc.modules.rolecategory.dao; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; |
||||
|
import com.elink.esua.epdc.modules.rolecategory.entity.HandleRoleCategoryEntity; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 角色和处理类别关系表 |
||||
|
* |
||||
|
* @author qu qu@elink-cn.com |
||||
|
* @since v1.0.0 2019-12-20 |
||||
|
*/ |
||||
|
@Mapper |
||||
|
public interface HandleRoleCategoryDao extends BaseDao<HandleRoleCategoryEntity> { |
||||
|
|
||||
|
int deleteByRoleId(Long roleId); |
||||
|
|
||||
|
List<String> selectListCategoryId(String ruleId); |
||||
|
} |
||||
@ -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.elink.esua.epdc.modules.rolecategory.entity; |
||||
|
|
||||
|
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@elink-cn.com |
||||
|
* @since v1.0.0 2019-12-20 |
||||
|
*/ |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper=false) |
||||
|
@TableName("epdc_handle_role_category") |
||||
|
public class HandleRoleCategoryEntity extends BaseEpdcEntity { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* 角色ID |
||||
|
*/ |
||||
|
private String roleId; |
||||
|
|
||||
|
/** |
||||
|
* 处理类别ID |
||||
|
*/ |
||||
|
private String categoryId; |
||||
|
|
||||
|
} |
||||
@ -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.elink.esua.epdc.modules.rolecategory.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 2019-12-20 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class HandleRoleCategoryExcel { |
||||
|
|
||||
|
@Excel(name = "主键") |
||||
|
private String id; |
||||
|
|
||||
|
@Excel(name = "角色ID") |
||||
|
private String roleId; |
||||
|
|
||||
|
@Excel(name = "处理类别ID") |
||||
|
private String categoryId; |
||||
|
|
||||
|
@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; |
||||
|
|
||||
|
@Excel(name = "删除标识 0:未删除,1:已删除") |
||||
|
private String delFlag; |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -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.elink.esua.epdc.modules.rolecategory.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 2019-12-20 |
||||
|
*/ |
||||
|
@Component |
||||
|
public class HandleRoleCategoryRedis { |
||||
|
@Autowired |
||||
|
private RedisUtils redisUtils; |
||||
|
|
||||
|
public void delete(Object[] ids) { |
||||
|
|
||||
|
} |
||||
|
|
||||
|
public void set(){ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
public String get(String id){ |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,116 @@ |
|||||
|
/** |
||||
|
* 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.elink.esua.epdc.modules.rolecategory.service; |
||||
|
|
||||
|
|
||||
|
import com.elink.esua.epdc.commons.mybatis.service.BaseService; |
||||
|
import com.elink.esua.epdc.commons.tools.page.PageData; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
||||
|
import com.elink.esua.epdc.dto.rulecategory.HandleRoleCategoryDTO; |
||||
|
import com.elink.esua.epdc.dto.rulecategory.form.HandleRoleCategoryFormDTO; |
||||
|
import com.elink.esua.epdc.modules.rolecategory.entity.HandleRoleCategoryEntity; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* 角色和处理类别关系表 |
||||
|
* |
||||
|
* @author qu qu@elink-cn.com |
||||
|
* @since v1.0.0 2019-12-20 |
||||
|
*/ |
||||
|
public interface HandleRoleCategoryService extends BaseService<HandleRoleCategoryEntity> { |
||||
|
|
||||
|
/** |
||||
|
* 默认分页 |
||||
|
* |
||||
|
* @param params |
||||
|
* @return PageData<HandleRoleCategoryDTO> |
||||
|
* @author generator |
||||
|
* @date 2019-12-20 |
||||
|
*/ |
||||
|
PageData<HandleRoleCategoryDTO> page(Map<String, Object> params); |
||||
|
|
||||
|
/** |
||||
|
* 默认查询 |
||||
|
* |
||||
|
* @param params |
||||
|
* @return java.util.List<HandleRoleCategoryDTO> |
||||
|
* @author generator |
||||
|
* @date 2019-12-20 |
||||
|
*/ |
||||
|
List<HandleRoleCategoryDTO> list(Map<String, Object> params); |
||||
|
|
||||
|
/** |
||||
|
* 单条查询 |
||||
|
* |
||||
|
* @param id |
||||
|
* @return HandleRoleCategoryDTO |
||||
|
* @author generator |
||||
|
* @date 2019-12-20 |
||||
|
*/ |
||||
|
HandleRoleCategoryDTO get(String id); |
||||
|
|
||||
|
/** |
||||
|
* 默认保存 |
||||
|
* |
||||
|
* @param dto |
||||
|
* @return void |
||||
|
* @author generator |
||||
|
* @date 2019-12-20 |
||||
|
*/ |
||||
|
void save(HandleRoleCategoryDTO dto); |
||||
|
|
||||
|
/** |
||||
|
* 默认更新 |
||||
|
* |
||||
|
* @param dto |
||||
|
* @return void |
||||
|
* @author generator |
||||
|
* @date 2019-12-20 |
||||
|
*/ |
||||
|
void update(HandleRoleCategoryDTO dto); |
||||
|
|
||||
|
/** |
||||
|
* 批量删除 |
||||
|
* |
||||
|
* @param ids |
||||
|
* @return void |
||||
|
* @author generator |
||||
|
* @date 2019-12-20 |
||||
|
*/ |
||||
|
void delete(String[] ids); |
||||
|
|
||||
|
/** |
||||
|
* @param formDTO |
||||
|
* @return com.elink.esua.epdc.commons.tools.utils.Result |
||||
|
* @Author yinzuomei |
||||
|
* @Description 保存或修改 角色和处理类别关系 |
||||
|
* @Date 2019/12/24 12:46 |
||||
|
**/ |
||||
|
Result saveOrUpdate(HandleRoleCategoryFormDTO formDTO); |
||||
|
|
||||
|
/** |
||||
|
* @param ruleId |
||||
|
* @return com.elink.esua.epdc.commons.tools.utils.Result<java.util.List<java.lang.String>> |
||||
|
* @Author yinzuomei |
||||
|
* @Description |
||||
|
* @Date 2019/12/24 16:11 |
||||
|
**/ |
||||
|
Result<List<String>> listCategoryId(String ruleId); |
||||
|
} |
||||
@ -0,0 +1,161 @@ |
|||||
|
/** |
||||
|
* 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.elink.esua.epdc.modules.rolecategory.service.impl; |
||||
|
|
||||
|
import cn.hutool.core.collection.CollUtil; |
||||
|
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.page.PageData; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
||||
|
import com.elink.esua.epdc.commons.tools.constant.FieldConstant; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
||||
|
import com.elink.esua.epdc.dto.rulecategory.HandleRoleCategoryDTO; |
||||
|
import com.elink.esua.epdc.dto.rulecategory.form.HandleRoleCategoryFormDTO; |
||||
|
import com.elink.esua.epdc.modules.rolecategory.dao.HandleRoleCategoryDao; |
||||
|
import com.elink.esua.epdc.modules.rolecategory.entity.HandleRoleCategoryEntity; |
||||
|
import com.elink.esua.epdc.modules.rolecategory.redis.HandleRoleCategoryRedis; |
||||
|
import com.elink.esua.epdc.modules.rolecategory.service.HandleRoleCategoryService; |
||||
|
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@elink-cn.com |
||||
|
* @since v1.0.0 2019-12-20 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class HandleRoleCategoryServiceImpl extends BaseServiceImpl<HandleRoleCategoryDao, HandleRoleCategoryEntity> implements HandleRoleCategoryService { |
||||
|
|
||||
|
@Autowired |
||||
|
private HandleRoleCategoryRedis handleRoleCategoryRedis; |
||||
|
|
||||
|
@Override |
||||
|
public PageData<HandleRoleCategoryDTO> page(Map<String, Object> params) { |
||||
|
IPage<HandleRoleCategoryEntity> page = baseDao.selectPage( |
||||
|
getPage(params, FieldConstant.CREATED_TIME, false), |
||||
|
getWrapper(params) |
||||
|
); |
||||
|
return getPageData(page, HandleRoleCategoryDTO.class); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<HandleRoleCategoryDTO> list(Map<String, Object> params) { |
||||
|
List<HandleRoleCategoryEntity> entityList = baseDao.selectList(getWrapper(params)); |
||||
|
|
||||
|
return ConvertUtils.sourceToTarget(entityList, HandleRoleCategoryDTO.class); |
||||
|
} |
||||
|
|
||||
|
private QueryWrapper<HandleRoleCategoryEntity> getWrapper(Map<String, Object> params){ |
||||
|
String id = (String)params.get(FieldConstant.ID_HUMP); |
||||
|
|
||||
|
QueryWrapper<HandleRoleCategoryEntity> wrapper = new QueryWrapper<>(); |
||||
|
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
||||
|
|
||||
|
return wrapper; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public HandleRoleCategoryDTO get(String id) { |
||||
|
HandleRoleCategoryEntity entity = baseDao.selectById(id); |
||||
|
return ConvertUtils.sourceToTarget(entity, HandleRoleCategoryDTO.class); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void save(HandleRoleCategoryDTO dto) { |
||||
|
HandleRoleCategoryEntity entity = ConvertUtils.sourceToTarget(dto, HandleRoleCategoryEntity.class); |
||||
|
insert(entity); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void update(HandleRoleCategoryDTO dto) { |
||||
|
HandleRoleCategoryEntity entity = ConvertUtils.sourceToTarget(dto, HandleRoleCategoryEntity.class); |
||||
|
updateById(entity); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void delete(String[] ids) { |
||||
|
// 逻辑删除(@TableLogic 注解)
|
||||
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @param formDTO |
||||
|
* @return com.elink.esua.epdc.commons.tools.utils.Result |
||||
|
* @Author yinzuomei |
||||
|
* @Description 保存或修改 角色和处理类别关系 |
||||
|
* @Date 2019/12/24 12:39 |
||||
|
**/ |
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public Result saveOrUpdate(HandleRoleCategoryFormDTO formDTO) { |
||||
|
//先删除角色处理类别权限关系
|
||||
|
deleteByRoleId(formDTO.getRoleId()); |
||||
|
|
||||
|
//角色没有一个处理类别的情况
|
||||
|
if (CollUtil.isEmpty(formDTO.getCategoryIdList())) { |
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
//保存角色和处理类别关系
|
||||
|
for (String categoryId : formDTO.getCategoryIdList()) { |
||||
|
HandleRoleCategoryEntity entity = new HandleRoleCategoryEntity(); |
||||
|
entity.setCategoryId(categoryId); |
||||
|
entity.setRoleId(formDTO.getRoleId().toString()); |
||||
|
//保存
|
||||
|
insert(entity); |
||||
|
} |
||||
|
|
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @param ruleId |
||||
|
* @return com.elink.esua.epdc.commons.tools.utils.Result<java.util.List < java.lang.String>> |
||||
|
* @Author yinzuomei |
||||
|
* @Description |
||||
|
* @Date 2019/12/24 16:11 |
||||
|
**/ |
||||
|
@Override |
||||
|
public Result<List<String>> listCategoryId(String ruleId) { |
||||
|
List<String> list=baseDao.selectListCategoryId(ruleId); |
||||
|
return new Result<List<String>>().ok(list); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @param roleId 角色id |
||||
|
* @return void |
||||
|
* @Author yinzuomei |
||||
|
* @Description |
||||
|
* @Date 2019/12/24 12:44 |
||||
|
**/ |
||||
|
private void deleteByRoleId(Long roleId) { |
||||
|
baseDao.deleteByRoleId(roleId); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,33 @@ |
|||||
|
<?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.elink.esua.epdc.modules.rolecategory.dao.HandleRoleCategoryDao"> |
||||
|
|
||||
|
<resultMap type="com.elink.esua.epdc.modules.rolecategory.entity.HandleRoleCategoryEntity" id="handleRoleCategoryMap"> |
||||
|
<result property="id" column="ID"/> |
||||
|
<result property="roleId" column="ROLE_ID"/> |
||||
|
<result property="categoryId" column="CATEGORY_ID"/> |
||||
|
<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"/> |
||||
|
<result property="delFlag" column="DEL_FLAG"/> |
||||
|
</resultMap> |
||||
|
|
||||
|
<!-- 根据角色id删除记录 --> |
||||
|
<delete id="deleteByRoleId"> |
||||
|
delete from epdc_handle_role_category where ROLE_ID = #{value} |
||||
|
</delete> |
||||
|
|
||||
|
<!-- 根据角色id查询项目处理类别id --> |
||||
|
<select id="selectListCategoryId" parameterType="java.lang.String" resultType="java.lang.String"> |
||||
|
SELECT |
||||
|
m.CATEGORY_ID |
||||
|
FROM |
||||
|
epdc_handle_role_category m |
||||
|
WHERE |
||||
|
m.DEL_FLAG = '0' |
||||
|
AND m.ROLE_ID =#{ruleId} |
||||
|
</select> |
||||
|
</mapper> |
||||
Loading…
Reference in new issue