fetch:我的模块数据
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
spring.datasource.driverClassName = com.mysql.cj.jdbc.Driver
|
||||
spring.datasource.url = jdbc:mysql://192.168.10.47:3306/foton_slrs_test?useUnicode=true&characterEncoding=utf8&serverTimezone=UTC&useSSL=false
|
||||
spring.datasource.username = root
|
||||
spring.datasource.password = roots
|
||||
spring.datasource.password = root
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -91,4 +91,11 @@ public interface TsRoleDao extends BaseMapper<TsRole> {
|
||||
* @return List<String>
|
||||
*/
|
||||
List<String> getResourceIdsByRoleIds(List<String> roleIds);
|
||||
|
||||
/**
|
||||
* 获取该角色的第一级权限
|
||||
* @param roleIds:角色ID
|
||||
* @return List<String>
|
||||
*/
|
||||
List<String> getRootMenuIdsByRoleIds(List<String> roleIds);
|
||||
}
|
||||
|
||||
@@ -78,4 +78,11 @@ public interface ITsRoleService extends IService<TsRole> {
|
||||
List<String> getResource(String roleId);
|
||||
|
||||
List<String> getResourceIdsByRoleIds(List<String> roleIds);
|
||||
|
||||
/**
|
||||
* 获取该角色的第一级权限
|
||||
* @param roleIds:角色ID
|
||||
* @return List<String>
|
||||
*/
|
||||
List<String> getRootMenuIdsByRoleIds(List<String> roleIds);
|
||||
}
|
||||
|
||||
+12
-1
@@ -256,7 +256,18 @@ public class TsRoleServiceImpl extends ServiceImpl<TsRoleDao, TsRole> implements
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取该角色的第一级权限
|
||||
* @param roleIds:角色ID
|
||||
* @return List<String>
|
||||
*/
|
||||
@Override
|
||||
public List<String> getRootMenuIdsByRoleIds(List<String> roleIds) {
|
||||
if(roleIds!=null&&roleIds.size()>0){
|
||||
return tsRoleDao.getRootMenuIdsByRoleIds(roleIds);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.adc.da.slrs.sarUrl.controller;
|
||||
|
||||
|
||||
import com.adc.da.http.ResponseMessage;
|
||||
import com.adc.da.http.Result;
|
||||
import com.adc.da.slrs.sarUrl.entity.TsUrl;
|
||||
import com.adc.da.slrs.sarUrl.service.ITsUrlService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 第三方链接
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2021-07-07
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Api(tags="第三方链接")
|
||||
@RestController
|
||||
@RequestMapping("/api/sarUrl/tsUrl")
|
||||
@Slf4j
|
||||
public class TsUrlController{
|
||||
@Autowired
|
||||
private ITsUrlService tsUrlService;
|
||||
|
||||
@ApiOperation("查询")
|
||||
@GetMapping
|
||||
public ResponseMessage<List<TsUrl>> getUrls(){
|
||||
QueryWrapper<TsUrl> tsUrlQueryWrapper=new QueryWrapper<>();
|
||||
tsUrlQueryWrapper.orderByAsc("order_by");
|
||||
List<TsUrl> tsUrls=tsUrlService.list(tsUrlQueryWrapper);
|
||||
return Result.success(tsUrls);
|
||||
}
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param tsUrl
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value="第三方链接-添加", notes="第三方链接-添加")
|
||||
@PostMapping(value = "/add")
|
||||
public ResponseMessage<?> add(@RequestBody TsUrl tsUrl) {
|
||||
tsUrlService.save(tsUrl);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param tsUrl
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value="第三方链接-编辑", notes="第三方链接-编辑")
|
||||
@PutMapping(value = "/edit")
|
||||
public ResponseMessage<Object> edit(@RequestBody TsUrl tsUrl) {
|
||||
tsUrl.setOrderBy(null);
|
||||
tsUrlService.updateById(tsUrl);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value="第三方链接-通过id删除", notes="第三方链接-通过id删除")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public ResponseMessage<Object> delete(@RequestParam(name="id",required=true) String id) {
|
||||
tsUrlService.removeById(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value="第三方链接-批量删除", notes="第三方链接-批量删除")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public ResponseMessage<Object> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
this.tsUrlService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value="第三方链接-通过id查询", notes="第三方链接-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public ResponseMessage<TsUrl> queryById(@RequestParam(name="id",required=true) String id) {
|
||||
TsUrl tsUrl = tsUrlService.getById(id);
|
||||
if(tsUrl==null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.success(tsUrl);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.adc.da.slrs.sarUrl.dao;
|
||||
|
||||
|
||||
import com.adc.da.slrs.sarUrl.entity.TsUrl;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @Description: 第三方链接
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2021-07-07
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface TsUrlDao extends BaseMapper<TsUrl> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.adc.da.slrs.sarUrl.entity;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Description: 第三方链接
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2021-07-07
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("ts_url")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="ts_url对象", description="第三方链接")
|
||||
public class TsUrl implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**主键*/
|
||||
@TableId(type = IdType.UUID)
|
||||
@ApiModelProperty(value = "主键")
|
||||
private String id;
|
||||
/**创建人*/
|
||||
@ApiModelProperty(value = "创建人")
|
||||
private String createById;
|
||||
/**创建日期*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "创建日期")
|
||||
private Date createTime;
|
||||
/**更新人*/
|
||||
@ApiModelProperty(value = "更新人")
|
||||
private String updateById;
|
||||
/**更新日期*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "更新日期")
|
||||
private Date updateTime;
|
||||
/**所属部门*/
|
||||
@ApiModelProperty(value = "所属部门")
|
||||
private String createDeptId;
|
||||
/**链接名称*/
|
||||
@ApiModelProperty(value = "链接名称")
|
||||
private String name;
|
||||
/**链接地址*/
|
||||
@ApiModelProperty(value = "链接地址")
|
||||
private String url;
|
||||
/**排序*/
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer orderBy;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.adc.da.slrs.sarUrl.service;
|
||||
|
||||
|
||||
import com.adc.da.slrs.sarUrl.entity.TsUrl;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @Description: 第三方链接
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2021-07-07
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface ITsUrlService extends IService<TsUrl> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.adc.da.slrs.sarUrl.service.impl;
|
||||
|
||||
|
||||
import com.adc.da.slrs.sarUrl.dao.TsUrlDao;
|
||||
import com.adc.da.slrs.sarUrl.entity.TsUrl;
|
||||
import com.adc.da.slrs.sarUrl.service.ITsUrlService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @Description: 第三方链接
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2021-07-07
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class TsUrlServiceImpl extends ServiceImpl<TsUrlDao, TsUrl> implements ITsUrlService {
|
||||
|
||||
}
|
||||
+1
-1
@@ -175,7 +175,7 @@ public class TsUserServiceImpl extends ServiceImpl<TsUserDao, TsUser> implements
|
||||
public List<SarMenu> getMenusByUserId(String userId){
|
||||
List<String> positionIds=tsUserDao.selectPositionIds(userId);
|
||||
List<String> roleIds=tsPositionService.getRoleIdsByPositionIds(positionIds);
|
||||
List<String> menuIds=tsRoleService.getMenuIdsByRoleIds(roleIds);
|
||||
List<String> menuIds=tsRoleService.getRootMenuIdsByRoleIds(roleIds);
|
||||
return sarMenuService.getMenuByIds(menuIds);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?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.adc.da.slrs.sarRole.dao.TsRoleDao">
|
||||
|
||||
<select id="getMenuIdsByRoleIds" resultType="String">
|
||||
select distinct menu_id from ts_role_menu
|
||||
where role_id in
|
||||
@@ -10,6 +11,7 @@
|
||||
</foreach>
|
||||
)
|
||||
</select>
|
||||
|
||||
<select id="getResourceIdsByRoleIds" resultType="String">
|
||||
select distinct resource_id from ts_role_resource
|
||||
where role_id in
|
||||
@@ -19,4 +21,15 @@
|
||||
</foreach>
|
||||
)
|
||||
</select>
|
||||
|
||||
<select id="getRootMenuIdsByRoleIds" resultType="String">
|
||||
select distinct menu_id from ts_role_menu
|
||||
where role_id in
|
||||
(
|
||||
<foreach collection="list" separator="," item="roleId">
|
||||
#{roleId}
|
||||
</foreach>
|
||||
) and (parent_id is null or parent_id='')
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<?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.adc.da.slrs.sarUrl.dao.TsUrlDao">
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user