Commit d69064ad by 周海峰

no message

parent 257f53c0
...@@ -18,3 +18,31 @@ CREATE TABLE `platform_role_application_app` ...@@ -18,3 +18,31 @@ CREATE TABLE `platform_role_application_app`
`applicationid` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, `applicationid` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='角色的三方应用app权限'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='角色的三方应用app权限';
-- 地铁工作菜单表
CREATE TABLE `platform_metrowork_menu`
(
`id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '主键ID',
`name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '菜单名称',
`code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '菜单编码',
`sort_order` int(11) NOT NULL DEFAULT 0 COMMENT '排序序号',
`status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '状态:0-停用,1-启用',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `uk_code` (`code`) USING BTREE,
KEY `idx_sort_order` (`sort_order`) USING BTREE,
KEY `idx_status` (`status`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='地铁工作菜单配置表';
-- 初始化地铁工作菜单数据
INSERT INTO `platform_auth`.`platform_metrowork_menu` (`id`, `name`, `code`, `sort_order`, `status`) VALUES
('1', '系统公告', 'menu_announcement', 1, 1),
('2', '政策法规', 'menu_law', 2, 1),
('3', '工作动态', 'menu_work', 3, 1),
('4', '安全管理', 'menu_anquan', 4, 1),
('5', '服务质量', 'menu_fuwu', 5, 1),
('6', '网上培训', 'menu_wangshang', 6, 1),
('7', '廉政文化', 'menu_lianzheng', 7, 1),
('8', '员工天地', 'menu_yuangong', 8, 1),
('9', '常用表格', 'menu_biaoge', 9, 1);
\ No newline at end of file
package com.metro.auth.platform.controller;
import com.github.pagehelper.PageInfo;
import com.metro.auth.platform.domain.ResultCode;
import com.metro.auth.platform.domain.ResultJson;
import com.metro.auth.platform.domain.auth.PlatformMetroworkMenu;
import com.metro.auth.platform.service.PlatformMetroworkMenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 地铁工作菜单管理控制器
*/
@RestController
@RequestMapping("/metrowork")
@Api(tags = "地铁工作菜单管理相关接口")
public class PlatformMetroworkMenuController {
@Autowired
private PlatformMetroworkMenuService platformMetroworkMenuService;
/**
* 获取所有启用的菜单(前端调用)
*/
@GetMapping("/menus")
@ApiOperation(value = "获取启用的菜单列表", notes = "获取所有状态为启用的菜单,按排序号排序")
public ResultJson<List<PlatformMetroworkMenu>> getEnabledMenus() {
List<PlatformMetroworkMenu> menus = platformMetroworkMenuService.getEnabledMenus();
return ResultJson.ok(menus);
}
/**
* 分页获取所有菜单(管理端调用)
*/
@GetMapping("/admin/list")
@ApiOperation(value = "分页获取菜单列表", notes = "分页获取所有菜单,支持条件查询")
public ResultJson<PageInfo<PlatformMetroworkMenu>> getMenusPaged(
@RequestParam(required = false, defaultValue = "1") int page,
@RequestParam(required = false, defaultValue = "10") int size,
@RequestParam(required = false) String name,
@RequestParam(required = false) String code) {
PlatformMetroworkMenu menu = new PlatformMetroworkMenu();
if (name != null && !name.trim().isEmpty()) {
menu.setName(name.trim());
}
if (code != null && !code.trim().isEmpty()) {
menu.setCode(code.trim());
}
PageInfo<PlatformMetroworkMenu> pageInfo = platformMetroworkMenuService.getMenusPaged(menu, page, size);
return ResultJson.ok(pageInfo);
}
/**
* 根据ID获取菜单详情
*/
@GetMapping("/admin/{id}")
@ApiOperation(value = "获取菜单详情", notes = "根据菜单ID获取详细信息")
public ResultJson<PlatformMetroworkMenu> getMenuById(@PathVariable String id) {
PlatformMetroworkMenu menu = platformMetroworkMenuService.getMenuById(id);
if (menu != null) {
return ResultJson.ok(menu);
} else {
return ResultJson.failure(ResultCode.NOT_FOUND);
}
}
/**
* 新增菜单
*/
@PostMapping("/admin/save")
@ApiOperation(value = "新增菜单", notes = "创建新的菜单项")
public ResultJson saveMenu(@RequestBody PlatformMetroworkMenu menu) {
platformMetroworkMenuService.saveMenu(menu);
return ResultJson.ok();
}
/**
* 更新菜单
*/
@PutMapping("/admin/update")
@ApiOperation(value = "更新菜单", notes = "更新菜单信息")
public ResultJson updateMenu(@RequestBody PlatformMetroworkMenu menu) {
platformMetroworkMenuService.updateMenu(menu);
return ResultJson.ok();
}
/**
* 删除菜单
*/
@DeleteMapping("/admin/{id}")
@ApiOperation(value = "删除菜单", notes = "根据ID删除菜单")
public ResultJson deleteMenu(@PathVariable String id) {
platformMetroworkMenuService.deleteMenu(id);
return ResultJson.ok();
}
/**
* 启用菜单
*/
@PutMapping("/admin/{id}/enable")
@ApiOperation(value = "启用菜单", notes = "启用指定的菜单")
public ResultJson enableMenu(@PathVariable String id) {
platformMetroworkMenuService.enableMenu(id);
return ResultJson.ok();
}
/**
* 停用菜单
*/
@PutMapping("/admin/{id}/disable")
@ApiOperation(value = "停用菜单", notes = "停用指定的菜单")
public ResultJson disableMenu(@PathVariable String id) {
platformMetroworkMenuService.disableMenu(id);
return ResultJson.ok();
}
}
package com.metro.auth.platform.domain.auth;
import java.io.Serializable;
import java.util.Date;
/**
* 地铁工作菜单配置表
*/
public class PlatformMetroworkMenu implements Serializable {
/**
* 主键ID
*/
private String id;
/**
* 菜单名称
*/
private String name;
/**
* 菜单编码
*/
private String code;
/**
* 排序序号
*/
private Integer sortOrder;
/**
* 状态:0-停用,1-启用
*/
private Integer status;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
private static final long serialVersionUID = 1L;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public Integer getSortOrder() {
return sortOrder;
}
public void setSortOrder(Integer sortOrder) {
this.sortOrder = sortOrder;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}
package com.metro.auth.platform.mapper;
import com.metro.auth.platform.domain.auth.PlatformMetroworkMenu;
import com.metro.auth.platform.domain.auth.PlatformMetroworkMenuExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
@Repository
public interface PlatformMetroworkMenuMapper {
long countByExample(PlatformMetroworkMenuExample example);
int deleteByExample(PlatformMetroworkMenuExample example);
int deleteByPrimaryKey(String id);
int insert(PlatformMetroworkMenu record);
int insertSelective(PlatformMetroworkMenu record);
List<PlatformMetroworkMenu> selectByExample(PlatformMetroworkMenuExample example);
PlatformMetroworkMenu selectByPrimaryKey(String id);
int updateByExampleSelective(@Param("record") PlatformMetroworkMenu record, @Param("example") PlatformMetroworkMenuExample example);
int updateByExample(@Param("record") PlatformMetroworkMenu record, @Param("example") PlatformMetroworkMenuExample example);
int updateByPrimaryKeySelective(PlatformMetroworkMenu record);
int updateByPrimaryKey(PlatformMetroworkMenu record);
}
<?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.metro.auth.platform.mapper.PlatformMetroworkMenuMapper">
<resultMap id="BaseResultMap" type="com.metro.auth.platform.domain.auth.PlatformMetroworkMenu">
<result column="id" jdbcType="VARCHAR" property="id" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="code" jdbcType="VARCHAR" property="code" />
<result column="sort_order" jdbcType="INTEGER" property="sortOrder" />
<result column="status" jdbcType="TINYINT" property="status" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, name, code, sort_order, status, create_time, update_time
</sql>
<select id="selectByExample" parameterType="com.metro.auth.platform.domain.auth.PlatformMetroworkMenuExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from platform_metrowork_menu
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from platform_metrowork_menu
where id = #{id,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from platform_metrowork_menu
where id = #{id,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="com.metro.auth.platform.domain.auth.PlatformMetroworkMenuExample">
delete from platform_metrowork_menu
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.metro.auth.platform.domain.auth.PlatformMetroworkMenu">
insert into platform_metrowork_menu (id, name, code, sort_order,
status, create_time, update_time)
values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{code,jdbcType=VARCHAR}, #{sortOrder,jdbcType=INTEGER},
#{status,jdbcType=TINYINT}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.metro.auth.platform.domain.auth.PlatformMetroworkMenu">
insert into platform_metrowork_menu
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="name != null">
name,
</if>
<if test="code != null">
code,
</if>
<if test="sortOrder != null">
sort_order,
</if>
<if test="status != null">
status,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=VARCHAR},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="code != null">
#{code,jdbcType=VARCHAR},
</if>
<if test="sortOrder != null">
#{sortOrder,jdbcType=INTEGER},
</if>
<if test="status != null">
#{status,jdbcType=TINYINT},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.metro.auth.platform.domain.auth.PlatformMetroworkMenuExample" resultType="java.lang.Long">
select count(*) from platform_metrowork_menu
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update platform_metrowork_menu
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=VARCHAR},
</if>
<if test="record.name != null">
name = #{record.name,jdbcType=VARCHAR},
</if>
<if test="record.code != null">
code = #{record.code,jdbcType=VARCHAR},
</if>
<if test="record.sortOrder != null">
sort_order = #{record.sortOrder,jdbcType=INTEGER},
</if>
<if test="record.status != null">
status = #{record.status,jdbcType=TINYINT},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if>
<if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
</if>
</set>
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update platform_metrowork_menu
set id = #{record.id,jdbcType=VARCHAR},
name = #{record.name,jdbcType=VARCHAR},
code = #{record.code,jdbcType=VARCHAR},
sort_order = #{record.sortOrder,jdbcType=INTEGER},
status = #{record.status,jdbcType=TINYINT},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP}
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.metro.auth.platform.domain.auth.PlatformMetroworkMenu">
update platform_metrowork_menu
<set>
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
</if>
<if test="code != null">
code = #{code,jdbcType=VARCHAR},
</if>
<if test="sortOrder != null">
sort_order = #{sortOrder,jdbcType=INTEGER},
</if>
<if test="status != null">
status = #{status,jdbcType=TINYINT},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.metro.auth.platform.domain.auth.PlatformMetroworkMenu">
update platform_metrowork_menu
set name = #{name,jdbcType=VARCHAR},
code = #{code,jdbcType=VARCHAR},
sort_order = #{sortOrder,jdbcType=INTEGER},
status = #{status,jdbcType=TINYINT},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>
package com.metro.auth.platform.service;
import com.github.pagehelper.PageInfo;
import com.metro.auth.platform.domain.auth.PlatformMetroworkMenu;
import java.util.List;
/**
* 地铁工作菜单服务接口
*/
public interface PlatformMetroworkMenuService {
/**
* 获取所有启用的菜单,按排序号排序
* @return 菜单列表
*/
List<PlatformMetroworkMenu> getEnabledMenus();
/**
* 获取所有菜单
* @return 菜单列表
*/
List<PlatformMetroworkMenu> getAllMenus();
/**
* 分页查询菜单
* @param menu 查询条件
* @param pageNum 页码
* @param pageSize 每页大小
* @return 分页结果
*/
PageInfo<PlatformMetroworkMenu> getMenusPaged(PlatformMetroworkMenu menu, int pageNum, int pageSize);
/**
* 根据ID获取菜单
* @param id 菜单ID
* @return 菜单对象
*/
PlatformMetroworkMenu getMenuById(String id);
/**
* 保存菜单
* @param menu 菜单对象
*/
void saveMenu(PlatformMetroworkMenu menu);
/**
* 更新菜单
* @param menu 菜单对象
*/
void updateMenu(PlatformMetroworkMenu menu);
/**
* 删除菜单
* @param id 菜单ID
*/
void deleteMenu(String id);
/**
* 启用菜单
* @param id 菜单ID
*/
void enableMenu(String id);
/**
* 停用菜单
* @param id 菜单ID
*/
void disableMenu(String id);
}
package com.metro.auth.platform.service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.metro.auth.platform.domain.auth.PlatformMetroworkMenu;
import com.metro.auth.platform.domain.auth.PlatformMetroworkMenuExample;
import com.metro.auth.platform.mapper.PlatformMetroworkMenuMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.Date;
import java.util.List;
import java.util.UUID;
/**
* 地铁工作菜单服务实现类
*/
@Service
public class PlatformMetroworkMenuServiceImpl implements PlatformMetroworkMenuService {
@Autowired
private PlatformMetroworkMenuMapper platformMetroworkMenuMapper;
@Override
public List<PlatformMetroworkMenu> getEnabledMenus() {
PlatformMetroworkMenuExample example = new PlatformMetroworkMenuExample();
example.createCriteria().andStatusEqualTo(1);
example.setOrderByClause("sort_order asc");
return platformMetroworkMenuMapper.selectByExample(example);
}
@Override
public List<PlatformMetroworkMenu> getAllMenus() {
PlatformMetroworkMenuExample example = new PlatformMetroworkMenuExample();
example.setOrderByClause("sort_order asc");
return platformMetroworkMenuMapper.selectByExample(example);
}
@Override
public PlatformMetroworkMenu getMenuById(String id) {
return platformMetroworkMenuMapper.selectByPrimaryKey(id);
}
@Override
public void saveMenu(PlatformMetroworkMenu menu) {
menu.setId(UUID.randomUUID().toString().replace("-", ""));
menu.setCreateTime(new Date());
menu.setUpdateTime(new Date());
platformMetroworkMenuMapper.insertSelective(menu);
}
@Override
public void updateMenu(PlatformMetroworkMenu menu) {
menu.setUpdateTime(new Date());
platformMetroworkMenuMapper.updateByPrimaryKeySelective(menu);
}
@Override
public void deleteMenu(String id) {
platformMetroworkMenuMapper.deleteByPrimaryKey(id);
}
@Override
public void enableMenu(String id) {
PlatformMetroworkMenu menu = new PlatformMetroworkMenu();
menu.setId(id);
menu.setStatus(1);
menu.setUpdateTime(new Date());
platformMetroworkMenuMapper.updateByPrimaryKeySelective(menu);
}
@Override
public void disableMenu(String id) {
PlatformMetroworkMenu menu = new PlatformMetroworkMenu();
menu.setId(id);
menu.setStatus(0);
menu.setUpdateTime(new Date());
platformMetroworkMenuMapper.updateByPrimaryKeySelective(menu);
}
@Override
public PageInfo<PlatformMetroworkMenu> getMenusPaged(PlatformMetroworkMenu menu, int pageNum, int pageSize) {
PageHelper.startPage(pageNum, pageSize);
PlatformMetroworkMenuExample example = new PlatformMetroworkMenuExample();
PlatformMetroworkMenuExample.Criteria criteria = example.createCriteria();
// 添加查询条件
if (StringUtils.hasText(menu.getName())) {
criteria.andNameLike("%" + menu.getName() + "%");
}
if (StringUtils.hasText(menu.getCode())) {
criteria.andCodeLike("%" + menu.getCode() + "%");
}
example.setOrderByClause("sort_order asc");
List<PlatformMetroworkMenu> list = platformMetroworkMenuMapper.selectByExample(example);
return new PageInfo<>(list);
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论