提交代码

dev_xd
姜玉琦 2025-03-09 15:43:21 +08:00
parent a9d0d7ad46
commit 10f6cad6cb
12 changed files with 223 additions and 367 deletions

View File

@ -5,11 +5,13 @@ import com.yanzhu.common.core.web.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.util.List;
/**
* wx_menu_config
*
* @author JiangYuQi
* @date 2024-12-29
* @date 2025-03-09
*/
public class WxMenuConfig extends BaseEntity
{
@ -49,6 +51,9 @@ public class WxMenuConfig extends BaseEntity
@Excel(name = "菜单类型")
private String menuType;
/** 菜单配置角色信息 */
private List<WxMenuConfigRole> wxMenuConfigRoleList;
public void setId(Long id)
{
this.id = id;
@ -131,6 +136,16 @@ public class WxMenuConfig extends BaseEntity
return menuType;
}
public List<WxMenuConfigRole> getWxMenuConfigRoleList()
{
return wxMenuConfigRoleList;
}
public void setWxMenuConfigRoleList(List<WxMenuConfigRole> wxMenuConfigRoleList)
{
this.wxMenuConfigRoleList = wxMenuConfigRoleList;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@ -144,6 +159,7 @@ public class WxMenuConfig extends BaseEntity
.append("menuSort", getMenuSort())
.append("createTime", getCreateTime())
.append("menuType", getMenuType())
.append("wxMenuConfigRoleList", getWxMenuConfigRoleList())
.toString();
}
}

View File

@ -9,7 +9,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
* wx_menu_config_role
*
* @author JiangYuQi
* @date 2024-12-29
* @date 2025-03-09
*/
public class WxMenuConfigRole extends BaseEntity
{

View File

@ -2,12 +2,13 @@ package com.yanzhu.manage.mapper;
import java.util.List;
import com.yanzhu.manage.domain.WxMenuConfig;
import com.yanzhu.manage.domain.WxMenuConfigRole;
/**
* Mapper
*
* @author JiangYuQi
* @date 2024-12-29
* @date 2025-03-09
*/
public interface WxMenuConfigMapper
{
@ -59,6 +60,31 @@ public interface WxMenuConfigMapper
*/
public int deleteWxMenuConfigByIds(Long[] ids);
/**
*
*
* @param ids
* @return
*/
public int deleteWxMenuConfigRoleBySmcids(Long[] ids);
/**
*
*
* @param wxMenuConfigRoleList
* @return
*/
public int batchWxMenuConfigRole(List<WxMenuConfigRole> wxMenuConfigRoleList);
/**
*
*
* @param id ID
* @return
*/
public int deleteWxMenuConfigRoleBySmcid(Long id);
/**
*
*
@ -66,5 +92,4 @@ public interface WxMenuConfigMapper
* @return
*/
public List<WxMenuConfig> findUserMenuList(WxMenuConfig wxMenuConfig);
}

View File

@ -1,61 +0,0 @@
package com.yanzhu.manage.mapper;
import java.util.List;
import com.yanzhu.manage.domain.WxMenuConfigRole;
/**
* Mapper
*
* @author JiangYuQi
* @date 2024-12-29
*/
public interface WxMenuConfigRoleMapper
{
/**
*
*
* @param smcid
* @return
*/
public WxMenuConfigRole selectWxMenuConfigRoleBySmcid(Long smcid);
/**
*
*
* @param wxMenuConfigRole
* @return
*/
public List<WxMenuConfigRole> selectWxMenuConfigRoleList(WxMenuConfigRole wxMenuConfigRole);
/**
*
*
* @param wxMenuConfigRole
* @return
*/
public int insertWxMenuConfigRole(WxMenuConfigRole wxMenuConfigRole);
/**
*
*
* @param wxMenuConfigRole
* @return
*/
public int updateWxMenuConfigRole(WxMenuConfigRole wxMenuConfigRole);
/**
*
*
* @param smcid
* @return
*/
public int deleteWxMenuConfigRoleBySmcid(Long smcid);
/**
*
*
* @param smcids
* @return
*/
public int deleteWxMenuConfigRoleBySmcids(Long[] smcids);
}

View File

@ -17,6 +17,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="menuType" column="menu_type" />
</resultMap>
<resultMap id="WxMenuConfigWxMenuConfigRoleResult" type="WxMenuConfig" extends="WxMenuConfigResult">
<collection property="wxMenuConfigRoleList" notNullColumn="sub_smcid" javaType="java.util.List" resultMap="WxMenuConfigRoleResult" />
</resultMap>
<resultMap type="WxMenuConfigRole" id="WxMenuConfigRoleResult">
<result property="smcid" column="sub_smcid" />
<result property="roleId" column="sub_role_id" />
<result property="userId" column="sub_user_id" />
</resultMap>
<sql id="selectWxMenuConfigVo">
select id, project_id, menu_name, menu_identi, menu_img, menu_url, del_flag, menu_sort, create_time, menu_type from wx_menu_config
</sql>
@ -27,14 +37,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="projectId != null "> and project_id = #{projectId}</if>
<if test="menuName != null and menuName != ''"> and menu_name like concat('%', #{menuName}, '%')</if>
<if test="menuType != null and menuType != ''"> and menu_type = #{menuType}</if>
<if test='activeTags == "sys"'> and project_id is null </if>
and del_flag = 0
</where>
</select>
<select id="selectWxMenuConfigById" parameterType="Long" resultMap="WxMenuConfigResult">
<include refid="selectWxMenuConfigVo"/>
where id = #{id}
<select id="selectWxMenuConfigById" parameterType="Long" resultMap="WxMenuConfigWxMenuConfigRoleResult">
select a.id, a.project_id, a.menu_name, a.menu_identi, a.menu_img, a.menu_url, a.del_flag, a.menu_sort, a.create_time, a.menu_type,
b.smcid as sub_smcid, b.role_id as sub_role_id, b.user_id as sub_user_id
from wx_menu_config a
left join wx_menu_config_role b on b.smcid = a.id
where a.id = #{id}
</select>
<insert id="insertWxMenuConfig" parameterType="WxMenuConfig" useGeneratedKeys="true" keyProperty="id">
@ -90,6 +101,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</delete>
<delete id="deleteWxMenuConfigRoleBySmcids" parameterType="String">
delete from wx_menu_config_role where smcid in
<foreach item="smcid" collection="array" open="(" separator="," close=")">
#{smcid}
</foreach>
</delete>
<delete id="deleteWxMenuConfigRoleBySmcid" parameterType="Long">
delete from wx_menu_config_role where smcid = #{smcid}
</delete>
<insert id="batchWxMenuConfigRole">
insert into wx_menu_config_role( smcid, role_id, user_id) values
<foreach item="item" index="index" collection="list" separator=",">
( #{item.smcid}, #{item.roleId}, #{item.userId})
</foreach>
</insert>
<!--查询角色相关菜单-->
<select id="findUserMenuList" parameterType="WxMenuConfig" resultMap="WxMenuConfigResult">
select

View File

@ -1,65 +0,0 @@
<?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.yanzhu.manage.mapper.WxMenuConfigRoleMapper">
<resultMap type="WxMenuConfigRole" id="WxMenuConfigRoleResult">
<result property="smcid" column="smcid" />
<result property="roleId" column="role_id" />
<result property="userId" column="user_id" />
</resultMap>
<sql id="selectWxMenuConfigRoleVo">
select smcid, role_id, user_id from wx_menu_config_role
</sql>
<select id="selectWxMenuConfigRoleList" parameterType="WxMenuConfigRole" resultMap="WxMenuConfigRoleResult">
<include refid="selectWxMenuConfigRoleVo"/>
<where>
<if test="smcid != null "> and smcid = #{smcid}</if>
<if test="roleId != null "> and role_id = #{roleId}</if>
<if test="userId != null "> and user_id = #{userId}</if>
</where>
</select>
<select id="selectWxMenuConfigRoleBySmcid" parameterType="Long" resultMap="WxMenuConfigRoleResult">
<include refid="selectWxMenuConfigRoleVo"/>
where smcid = #{smcid}
</select>
<insert id="insertWxMenuConfigRole" parameterType="WxMenuConfigRole">
insert into wx_menu_config_role
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="smcid != null">smcid,</if>
<if test="roleId != null">role_id,</if>
<if test="userId != null">user_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="smcid != null">#{smcid},</if>
<if test="roleId != null">#{roleId},</if>
<if test="userId != null">#{userId},</if>
</trim>
</insert>
<update id="updateWxMenuConfigRole" parameterType="WxMenuConfigRole">
update wx_menu_config_role
<trim prefix="SET" suffixOverrides=",">
<if test="roleId != null">role_id = #{roleId},</if>
<if test="userId != null">user_id = #{userId},</if>
</trim>
where smcid = #{smcid}
</update>
<delete id="deleteWxMenuConfigRoleBySmcid" parameterType="Long">
delete from wx_menu_config_role where smcid = #{smcid}
</delete>
<delete id="deleteWxMenuConfigRoleBySmcids" parameterType="String">
delete from wx_menu_config_role where smcid in
<foreach item="smcid" collection="array" open="(" separator="," close=")">
#{smcid}
</foreach>
</delete>
</mapper>

View File

@ -0,0 +1,98 @@
package com.yanzhu.manage.controller;
import com.yanzhu.common.core.utils.poi.ExcelUtil;
import com.yanzhu.common.core.web.controller.BaseController;
import com.yanzhu.common.core.web.domain.AjaxResult;
import com.yanzhu.common.core.web.page.TableDataInfo;
import com.yanzhu.common.log.annotation.Log;
import com.yanzhu.common.log.enums.BusinessType;
import com.yanzhu.common.security.annotation.RequiresPermissions;
import com.yanzhu.manage.domain.WxMenuConfig;
import com.yanzhu.manage.service.IWxMenuConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* Controller
*
* @author JiangYuQi
* @date 2025-03-09
*/
@RestController
@RequestMapping("/wxMenuConfig")
public class WxMenuConfigController extends BaseController
{
@Autowired
private IWxMenuConfigService wxMenuConfigService;
/**
*
*/
@RequiresPermissions("manage:wxMenuConfig:list")
@GetMapping("/list")
public TableDataInfo list(WxMenuConfig wxMenuConfig)
{
startPage();
List<WxMenuConfig> list = wxMenuConfigService.selectWxMenuConfigList(wxMenuConfig);
return getDataTable(list);
}
/**
*
*/
@RequiresPermissions("manage:wxMenuConfig:export")
@Log(title = "菜单配置", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, WxMenuConfig wxMenuConfig)
{
List<WxMenuConfig> list = wxMenuConfigService.selectWxMenuConfigList(wxMenuConfig);
ExcelUtil<WxMenuConfig> util = new ExcelUtil<WxMenuConfig>(WxMenuConfig.class);
util.exportExcel(response, list, "菜单配置数据");
}
/**
*
*/
@RequiresPermissions("manage:wxMenuConfig:query")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(wxMenuConfigService.selectWxMenuConfigById(id));
}
/**
*
*/
@RequiresPermissions("manage:wxMenuConfig:add")
@Log(title = "菜单配置", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody WxMenuConfig wxMenuConfig)
{
return toAjax(wxMenuConfigService.insertWxMenuConfig(wxMenuConfig));
}
/**
*
*/
@RequiresPermissions("manage:wxMenuConfig:edit")
@Log(title = "菜单配置", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody WxMenuConfig wxMenuConfig)
{
return toAjax(wxMenuConfigService.updateWxMenuConfig(wxMenuConfig));
}
/**
*
*/
@RequiresPermissions("manage:wxMenuConfig:remove")
@Log(title = "菜单配置", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(wxMenuConfigService.deleteWxMenuConfigByIds(ids));
}
}

View File

@ -6,7 +6,6 @@ import com.yanzhu.common.core.web.domain.AjaxResult;
import com.yanzhu.common.redis.service.RedisService;
import com.yanzhu.common.security.utils.SecurityUtils;
import com.yanzhu.manage.domain.WxMenuConfig;
import com.yanzhu.manage.service.IWxMenuConfigService;
import com.yanzhu.system.api.domain.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;

View File

@ -1,61 +0,0 @@
package com.yanzhu.manage.service;
import java.util.List;
import com.yanzhu.manage.domain.WxMenuConfigRole;
/**
* Service
*
* @author JiangYuQi
* @date 2024-12-29
*/
public interface IWxMenuConfigRoleService
{
/**
*
*
* @param smcid
* @return
*/
public WxMenuConfigRole selectWxMenuConfigRoleBySmcid(Long smcid);
/**
*
*
* @param wxMenuConfigRole
* @return
*/
public List<WxMenuConfigRole> selectWxMenuConfigRoleList(WxMenuConfigRole wxMenuConfigRole);
/**
*
*
* @param wxMenuConfigRole
* @return
*/
public int insertWxMenuConfigRole(WxMenuConfigRole wxMenuConfigRole);
/**
*
*
* @param wxMenuConfigRole
* @return
*/
public int updateWxMenuConfigRole(WxMenuConfigRole wxMenuConfigRole);
/**
*
*
* @param smcids
* @return
*/
public int deleteWxMenuConfigRoleBySmcids(Long[] smcids);
/**
*
*
* @param smcid
* @return
*/
public int deleteWxMenuConfigRoleBySmcid(Long smcid);
}

View File

@ -1,69 +0,0 @@
package com.yanzhu.manage.service;
import java.util.List;
import com.yanzhu.manage.domain.WxMenuConfig;
/**
* Service
*
* @author JiangYuQi
* @date 2024-12-29
*/
public interface IWxMenuConfigService
{
/**
*
*
* @param id
* @return
*/
public WxMenuConfig selectWxMenuConfigById(Long id);
/**
*
*
* @param wxMenuConfig
* @return
*/
public List<WxMenuConfig> selectWxMenuConfigList(WxMenuConfig wxMenuConfig);
/**
*
*
* @param wxMenuConfig
* @return
*/
public int insertWxMenuConfig(WxMenuConfig wxMenuConfig);
/**
*
*
* @param wxMenuConfig
* @return
*/
public int updateWxMenuConfig(WxMenuConfig wxMenuConfig);
/**
*
*
* @param ids
* @return
*/
public int deleteWxMenuConfigByIds(Long[] ids);
/**
*
*
* @param id
* @return
*/
public int deleteWxMenuConfigById(Long id);
/**
*
*
* @param wxMenuConfig
* @return
*/
public List<WxMenuConfig> findUserMenuList(WxMenuConfig wxMenuConfig);
}

View File

@ -1,93 +0,0 @@
package com.yanzhu.manage.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yanzhu.manage.mapper.WxMenuConfigRoleMapper;
import com.yanzhu.manage.domain.WxMenuConfigRole;
import com.yanzhu.manage.service.IWxMenuConfigRoleService;
/**
* Service
*
* @author JiangYuQi
* @date 2024-12-29
*/
@Service
public class WxMenuConfigRoleServiceImpl implements IWxMenuConfigRoleService
{
@Autowired
private WxMenuConfigRoleMapper wxMenuConfigRoleMapper;
/**
*
*
* @param smcid
* @return
*/
@Override
public WxMenuConfigRole selectWxMenuConfigRoleBySmcid(Long smcid)
{
return wxMenuConfigRoleMapper.selectWxMenuConfigRoleBySmcid(smcid);
}
/**
*
*
* @param wxMenuConfigRole
* @return
*/
@Override
public List<WxMenuConfigRole> selectWxMenuConfigRoleList(WxMenuConfigRole wxMenuConfigRole)
{
return wxMenuConfigRoleMapper.selectWxMenuConfigRoleList(wxMenuConfigRole);
}
/**
*
*
* @param wxMenuConfigRole
* @return
*/
@Override
public int insertWxMenuConfigRole(WxMenuConfigRole wxMenuConfigRole)
{
return wxMenuConfigRoleMapper.insertWxMenuConfigRole(wxMenuConfigRole);
}
/**
*
*
* @param wxMenuConfigRole
* @return
*/
@Override
public int updateWxMenuConfigRole(WxMenuConfigRole wxMenuConfigRole)
{
return wxMenuConfigRoleMapper.updateWxMenuConfigRole(wxMenuConfigRole);
}
/**
*
*
* @param smcids
* @return
*/
@Override
public int deleteWxMenuConfigRoleBySmcids(Long[] smcids)
{
return wxMenuConfigRoleMapper.deleteWxMenuConfigRoleBySmcids(smcids);
}
/**
*
*
* @param smcid
* @return
*/
@Override
public int deleteWxMenuConfigRoleBySmcid(Long smcid)
{
return wxMenuConfigRoleMapper.deleteWxMenuConfigRoleBySmcid(smcid);
}
}

View File

@ -1,19 +1,23 @@
package com.yanzhu.manage.service.impl;
import java.util.List;
import com.yanzhu.common.core.utils.DateUtils;
import com.yanzhu.common.core.utils.StringUtils;
import com.yanzhu.manage.domain.WxMenuConfig;
import com.yanzhu.manage.domain.WxMenuConfigRole;
import com.yanzhu.manage.mapper.WxMenuConfigMapper;
import com.yanzhu.manage.service.IWxMenuConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yanzhu.manage.mapper.WxMenuConfigMapper;
import com.yanzhu.manage.domain.WxMenuConfig;
import com.yanzhu.manage.service.IWxMenuConfigService;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
/**
* Service
*
* @author JiangYuQi
* @date 2024-12-29
* @date 2025-03-09
*/
@Service
public class WxMenuConfigServiceImpl implements IWxMenuConfigService
@ -51,11 +55,14 @@ public class WxMenuConfigServiceImpl implements IWxMenuConfigService
* @param wxMenuConfig
* @return
*/
@Transactional
@Override
public int insertWxMenuConfig(WxMenuConfig wxMenuConfig)
{
wxMenuConfig.setCreateTime(DateUtils.getNowDate());
return wxMenuConfigMapper.insertWxMenuConfig(wxMenuConfig);
int rows = wxMenuConfigMapper.insertWxMenuConfig(wxMenuConfig);
insertWxMenuConfigRole(wxMenuConfig);
return rows;
}
/**
@ -64,9 +71,12 @@ public class WxMenuConfigServiceImpl implements IWxMenuConfigService
* @param wxMenuConfig
* @return
*/
@Transactional
@Override
public int updateWxMenuConfig(WxMenuConfig wxMenuConfig)
{
wxMenuConfigMapper.deleteWxMenuConfigRoleBySmcid(wxMenuConfig.getId());
insertWxMenuConfigRole(wxMenuConfig);
return wxMenuConfigMapper.updateWxMenuConfig(wxMenuConfig);
}
@ -76,9 +86,11 @@ public class WxMenuConfigServiceImpl implements IWxMenuConfigService
* @param ids
* @return
*/
@Transactional
@Override
public int deleteWxMenuConfigByIds(Long[] ids)
{
wxMenuConfigMapper.deleteWxMenuConfigRoleBySmcids(ids);
return wxMenuConfigMapper.deleteWxMenuConfigByIds(ids);
}
@ -88,12 +100,38 @@ public class WxMenuConfigServiceImpl implements IWxMenuConfigService
* @param id
* @return
*/
@Transactional
@Override
public int deleteWxMenuConfigById(Long id)
{
wxMenuConfigMapper.deleteWxMenuConfigRoleBySmcid(id);
return wxMenuConfigMapper.deleteWxMenuConfigById(id);
}
/**
*
*
* @param wxMenuConfig
*/
public void insertWxMenuConfigRole(WxMenuConfig wxMenuConfig)
{
List<WxMenuConfigRole> wxMenuConfigRoleList = wxMenuConfig.getWxMenuConfigRoleList();
Long id = wxMenuConfig.getId();
if (StringUtils.isNotNull(wxMenuConfigRoleList))
{
List<WxMenuConfigRole> list = new ArrayList<WxMenuConfigRole>();
for (WxMenuConfigRole wxMenuConfigRole : wxMenuConfigRoleList)
{
wxMenuConfigRole.setSmcid(id);
list.add(wxMenuConfigRole);
}
if (list.size() > 0)
{
wxMenuConfigMapper.batchWxMenuConfigRole(list);
}
}
}
/**
*
*