提交修改

This commit is contained in:
quyixiao 2020-09-19 16:43:00 +08:00
parent 7ae003d594
commit 804747f3e3
8 changed files with 259 additions and 37 deletions

View File

@ -0,0 +1,89 @@
package com.lz.modules.app.controller;
import java.util.Arrays;
import java.util.Map;
import com.lz.common.utils.PageUtils;
import com.lz.common.utils.R;
import com.lz.modules.flow.entity.StaffRole;
import com.lz.modules.flow.service.StaffRoleService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* 流转关系表
*
* @author zgh
* @email zgh@ldxinyong.com
* @date 2020-09-19 15:22:13
*/
@RestController
@RequestMapping("user/lzstaffrole")
public class StaffRoleController {
@Autowired
private StaffRoleService staffRoleService;
/**
* 列表
*/
@RequestMapping("/list")
@RequiresPermissions("user:lzstaffrole:list")
public R list(@RequestParam Map<String, Object> params){
PageUtils page = staffRoleService.queryPage(params);
return R.ok().put("page", page);
}
/**
* 信息
*/
@RequestMapping("/info/{id}")
@RequiresPermissions("user:lzstaffrole:info")
public R info(@PathVariable("id") Long id){
StaffRole lzStaffRole = staffRoleService.selectByStaffId(id);
return R.ok().put("lzStaffRole", lzStaffRole);
}
/**
* 保存
*/
@RequestMapping("/save")
@RequiresPermissions("user:lzstaffrole:save")
public R save(@RequestBody StaffRole lzStaffRole){
staffRoleService.insertStaffRole(lzStaffRole);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
@RequiresPermissions("user:lzstaffrole:update")
public R update(@RequestBody StaffRole lzStaffRole){
staffRoleService.updateById(lzStaffRole);
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
@RequiresPermissions("user:lzstaffrole:delete")
public R delete(@RequestBody Long[] ids){
staffRoleService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
}

View File

@ -0,0 +1,11 @@
package com.lz.modules.app.dto;
import com.lz.modules.flow.entity.StaffRole;
import lombok.Data;
@Data
public class StaffRoleResp extends StaffRole {
private String staffName;
private String targetRole;
private String resultRole;
}

View File

@ -8,11 +8,13 @@ package com.lz.modules.flow.dao;
* @since 2020-08-18 * @since 2020-08-18
*/ */
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.lz.modules.flow.entity.StaffRole; import com.lz.modules.flow.entity.StaffRole;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
import java.util.Map;
@Mapper @Mapper
public interface StaffRoleMapper extends BaseMapper<StaffRole> { public interface StaffRoleMapper extends BaseMapper<StaffRole> {
@ -36,4 +38,6 @@ public interface StaffRoleMapper extends BaseMapper<StaffRole> {
StaffRole selectByStaffId(@Param("staffId") Long staffId); StaffRole selectByStaffId(@Param("staffId") Long staffId);
List<StaffRole> selectByRole(@Param("departmentLevel") String departmentLevel); List<StaffRole> selectByRole(@Param("departmentLevel") String departmentLevel);
List<StaffRole> selectByCondition(@Param("page") IPage page, @Param("params") Map<String, Object> params);
} }

View File

@ -1,9 +1,11 @@
package com.lz.modules.flow.service; package com.lz.modules.flow.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.lz.common.utils.PageUtils;
import com.lz.modules.flow.entity.StaffRole; import com.lz.modules.flow.entity.StaffRole;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* <p> * <p>
@ -35,4 +37,8 @@ public interface StaffRoleService extends IService<StaffRole> {
StaffRole selectByStaffId(Long staffId); StaffRole selectByStaffId(Long staffId);
List<StaffRole> selectByRole(String departmentLevel); List<StaffRole> selectByRole(String departmentLevel);
PageUtils queryPage(Map<String, Object> params);
void deleteBatchIds(List<Long> asList);
} }

View File

@ -1,73 +1,136 @@
package com.lz.modules.flow.service.impl; package com.lz.modules.flow.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Maps;
import com.lz.common.utils.NumberUtil;
import com.lz.common.utils.PageUtils;
import com.lz.modules.app.dao.StaffDao;
import com.lz.modules.app.dto.StaffRoleResp;
import com.lz.modules.app.entity.StaffEntity;
import com.lz.modules.flow.dao.RecordRoleMapper;
import com.lz.modules.flow.dao.StaffRoleMapper; import com.lz.modules.flow.dao.StaffRoleMapper;
import com.lz.modules.flow.entity.RecordRole;
import com.lz.modules.flow.entity.StaffRole; import com.lz.modules.flow.entity.StaffRole;
import com.lz.modules.flow.service.StaffRoleService; import com.lz.modules.flow.service.StaffRoleService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* <p> * <p>
* 流转关系表 服务类 * 流转关系表 服务类
* </p> * </p>
* *
* @author quyixiao * @author quyixiao
* @since 2020-08-18 * @since 2020-08-18
*/ */
@Service @Service
public class StaffRoleServiceImpl extends ServiceImpl<StaffRoleMapper, StaffRole> implements StaffRoleService { public class StaffRoleServiceImpl extends ServiceImpl<StaffRoleMapper, StaffRole> implements StaffRoleService {
@Autowired @Autowired
private StaffRoleMapper staffRoleMapper; private StaffRoleMapper staffRoleMapper;
@Autowired
private StaffDao staffDao;
@Autowired
@Override private RecordRoleMapper recordRoleMapper;
public StaffRole selectStaffRoleById(Long id){
return staffRoleMapper.selectStaffRoleById(id);
}
@Override
@Override public StaffRole selectStaffRoleById(Long id) {
public Long insertStaffRole(StaffRole staffRole){ return staffRoleMapper.selectStaffRoleById(id);
return staffRoleMapper.insertStaffRole(staffRole); }
}
@Override
@Override public Long insertStaffRole(StaffRole staffRole) {
public int updateStaffRoleById(StaffRole staffRole){ return staffRoleMapper.insertStaffRole(staffRole);
return staffRoleMapper.updateStaffRoleById(staffRole); }
}
@Override
@Override public int updateStaffRoleById(StaffRole staffRole) {
public int updateCoverStaffRoleById(StaffRole staffRole){ return staffRoleMapper.updateStaffRoleById(staffRole);
return staffRoleMapper.updateCoverStaffRoleById(staffRole); }
}
@Override
public int updateCoverStaffRoleById(StaffRole staffRole) {
return staffRoleMapper.updateCoverStaffRoleById(staffRole);
}
@Override
public int deleteStaffRoleById(Long id){ @Override
return staffRoleMapper.deleteStaffRoleById(id); public int deleteStaffRoleById(Long id) {
} return staffRoleMapper.deleteStaffRoleById(id);
}
@Override @Override
public StaffRole selectByStaffId(Long staffId) { public StaffRole selectByStaffId(Long staffId) {
return staffRoleMapper.selectByStaffId(staffId); return staffRoleMapper.selectByStaffId(staffId);
} }
@Override @Override
public List<StaffRole> selectByRole(String departmentLevel) { public List<StaffRole> selectByRole(String departmentLevel) {
return staffRoleMapper.selectByRole(departmentLevel); return staffRoleMapper.selectByRole(departmentLevel);
} }
@Override
public PageUtils queryPage(Map<String, Object> params) {
PageUtils pageUtils = PageUtils.startPage(
NumberUtil.objToIntDefault(params.get("page"), 1),
NumberUtil.objToIntDefault(params.get("limit"), 10)).doSelect(
page -> staffRoleMapper.selectByCondition(page, params)
);
List<StaffRole> staffRoles = pageUtils.getList();
List<StaffRoleResp> list = new ArrayList<>();
Map<Long, RecordRole> map = Maps.newHashMap();
for (StaffRole staffRole : staffRoles) {
StaffRoleResp resp = new StaffRoleResp();
BeanUtils.copyProperties(staffRole, resp);
StaffEntity staffEntity = staffDao.selectStaffById(resp.getStaffId());
if (staffEntity != null) {
resp.setStaffName(staffEntity.getName());
}
Map<String, Integer> types = JSONObject.parseObject(resp.getTypeRoleIds(), Map.class);
Long type1 = NumberUtil.objToLongDefault(types.get("type1"),0l);
Long type2 = NumberUtil.objToLongDefault(types.get("type2"),0l);
RecordRole recordRoleType1 = map.get(type1);
if (recordRoleType1 == null) {
recordRoleType1 = recordRoleMapper.selectById(type1);
}
RecordRole recordRoleType2 = map.get(type2);
if (recordRoleType2 == null) {
recordRoleType2 = recordRoleMapper.selectById(type2);
}
if (recordRoleType1 != null) {
map.put(recordRoleType1.getId(), recordRoleType1);
resp.setTargetRole(recordRoleType1.getName());
}
if (recordRoleType2 != null) {
map.put(recordRoleType2.getId(), recordRoleType2);
resp.setResultRole(recordRoleType2.getName());
}
list.add(resp);
}
pageUtils.setList(list);
return pageUtils;
}
@Override
public void deleteBatchIds(List<Long> asList) {
for (Long a : asList) {
staffRoleMapper.selectByStaffId(a);
}
}
} }

View File

@ -87,6 +87,10 @@
select * from lz_staff_role where is_delete = 0 and department_level = #{departmentLevel} select * from lz_staff_role where is_delete = 0 and department_level = #{departmentLevel}
</select> </select>
<select id="selectByCondition" resultType="com.lz.modules.flow.entity.StaffRole">
select * from lz_staff_role where is_delete = 0 order by id desc
</select>
</mapper> </mapper>

45
src/main/resources/sql Normal file
View File

@ -0,0 +1,45 @@
-- 菜单SQL
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
VALUES ('55', '记录表', 'user/lzrecordrole', NULL, '1', 'config', '6');
-- 按钮父菜单ID
set @parentId = @@identity;
-- 菜单对应按钮SQL
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '查看', null, 'user:lzrecordrole:list,user:lzrecordrole:info', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '新增', null, 'user:lzrecordrole:save', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '修改', null, 'user:lzrecordrole:update', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '删除', null, 'user:lzrecordrole:delete', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
VALUES ('55', '流转关系表', 'user/lzstaffrole', NULL, '1', 'config', '6');
-- 按钮父菜单ID
set @parentId = @@identity;
-- 菜单对应按钮SQL
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '查看', null, 'user:lzstaffrole:list,user:lzstaffrole:info', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '新增', null, 'user:lzstaffrole:save', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '修改', null, 'user:lzstaffrole:update', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '删除', null, 'user:lzstaffrole:delete', '2', null, '6';

View File

@ -63,7 +63,7 @@ public class MysqlMain {
} }
List<TablesBean> list = new ArrayList<TablesBean>(); List<TablesBean> list = new ArrayList<TablesBean>();
list.add(new TablesBean("lz_result_record")); list.add(new TablesBean("lz_staff_role"));
List<TablesBean> list2 = new ArrayList<TablesBean>(); List<TablesBean> list2 = new ArrayList<TablesBean>();
Map<String, String> map = MysqlUtil2ShowCreateTable.getComments(); Map<String, String> map = MysqlUtil2ShowCreateTable.getComments();