|
|
|
@ -1,7 +1,6 @@ |
|
|
|
|
package org.jeecg.modules.modulex.controller; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
@ -13,207 +12,166 @@ import org.jeecg.common.aspect.annotation.AutoLog; |
|
|
|
|
import org.jeecg.common.system.base.controller.JeecgController; |
|
|
|
|
import org.jeecg.common.system.query.QueryGenerator; |
|
|
|
|
import org.jeecg.modules.modulex.entity.Modulex; |
|
|
|
|
import org.jeecg.modules.modulex.mapper.ModulexMapper; |
|
|
|
|
import org.jeecg.modules.modulex.service.IModulexService; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
import org.springframework.web.servlet.ModelAndView; |
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
import java.util.Arrays; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
/** |
|
|
|
|
* @Description: 模块管理 |
|
|
|
|
* @Author: jeecg-boot |
|
|
|
|
* @Date: 2023-04-10 |
|
|
|
|
* @Date: 2023-04-10 |
|
|
|
|
* @Version: V1.0 |
|
|
|
|
*/ |
|
|
|
|
@Api(tags = "模块管理") |
|
|
|
|
@Api(tags="模块管理") |
|
|
|
|
@RestController |
|
|
|
|
@RequestMapping("/modulex/modulex") |
|
|
|
|
@Slf4j |
|
|
|
|
public class ModulexController extends JeecgController<Modulex, IModulexService> { |
|
|
|
|
@Autowired |
|
|
|
|
private IModulexService modulexService; |
|
|
|
|
@Resource |
|
|
|
|
private ModulexMapper modulexMapper; |
|
|
|
|
@Autowired |
|
|
|
|
private IModulexService modulexService; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 分页列表查询 |
|
|
|
|
* |
|
|
|
|
* @param modulex |
|
|
|
|
* @param pageNo |
|
|
|
|
* @param pageSize |
|
|
|
|
* @param req |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@AutoLog(value = "模块管理-分页列表查询") |
|
|
|
|
@ApiOperation(value="模块管理-分页列表查询", notes="模块管理-分页列表查询") |
|
|
|
|
@GetMapping(value = "/list") |
|
|
|
|
public Result<?> queryPageList(Modulex modulex, |
|
|
|
|
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo, |
|
|
|
|
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize, |
|
|
|
|
HttpServletRequest req) { |
|
|
|
|
QueryWrapper<Modulex> queryWrapper = QueryGenerator.initQueryWrapper(modulex, req.getParameterMap()); |
|
|
|
|
Page<Modulex> page = new Page<Modulex>(pageNo, pageSize); |
|
|
|
|
IPage<Modulex> pageList = modulexService.page(page, queryWrapper); |
|
|
|
|
return Result.OK(pageList); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@GetMapping(value = "/fabu") |
|
|
|
|
public Result<?> fabu(@RequestParam(name="id") String id) { |
|
|
|
|
return modulexService.fabu(id); |
|
|
|
|
} |
|
|
|
|
@GetMapping(value = "/kaishi") |
|
|
|
|
public Result<?> kaishi(@RequestParam(name="id") String id) { |
|
|
|
|
return modulexService.kaishi(id); |
|
|
|
|
} |
|
|
|
|
@GetMapping(value = "/tijiao") |
|
|
|
|
public Result<?> tijiao(@RequestParam(name="id") String id) { |
|
|
|
|
return modulexService.tijiao(id); |
|
|
|
|
} |
|
|
|
|
@GetMapping(value = "/cehui") |
|
|
|
|
public Result<?> cehui(@RequestParam(name="id") String id) { |
|
|
|
|
return modulexService.cehui(id); |
|
|
|
|
} |
|
|
|
|
@GetMapping(value = "/shenhe") |
|
|
|
|
public Result<?> shenhe(@RequestParam(name="id") String id) { |
|
|
|
|
return modulexService.shenhe(id); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 添加 |
|
|
|
|
* |
|
|
|
|
* @param modulex |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@AutoLog(value = "模块管理-添加") |
|
|
|
|
@ApiOperation(value="模块管理-添加", notes="模块管理-添加") |
|
|
|
|
@PostMapping(value = "/add") |
|
|
|
|
public Result<?> add(@RequestBody Modulex modulex) { |
|
|
|
|
//版本号 顺序累加;初始值1
|
|
|
|
|
Integer newVersion = modulexService.getMaxVersion(modulex.getVerison()); |
|
|
|
|
modulex.setVerison(newVersion+1); |
|
|
|
|
modulexService.save(modulex); |
|
|
|
|
return Result.OK("添加成功!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 编辑 |
|
|
|
|
* |
|
|
|
|
* @param modulex |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@AutoLog(value = "模块管理-编辑") |
|
|
|
|
@ApiOperation(value="模块管理-编辑", notes="模块管理-编辑") |
|
|
|
|
@PutMapping(value = "/edit") |
|
|
|
|
public Result<?> edit(@RequestBody Modulex modulex) { |
|
|
|
|
modulexService.updateById(modulex); |
|
|
|
|
return Result.OK("编辑成功!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 通过id删除 |
|
|
|
|
* |
|
|
|
|
* @param id |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@AutoLog(value = "模块管理-通过id删除") |
|
|
|
|
@ApiOperation(value="模块管理-通过id删除", notes="模块管理-通过id删除") |
|
|
|
|
@DeleteMapping(value = "/delete") |
|
|
|
|
public Result<?> delete(@RequestParam(name="id",required=true) String id) { |
|
|
|
|
modulexService.removeById(id); |
|
|
|
|
return Result.OK("删除成功!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 批量删除 |
|
|
|
|
* |
|
|
|
|
* @param ids |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@AutoLog(value = "模块管理-批量删除") |
|
|
|
|
@ApiOperation(value="模块管理-批量删除", notes="模块管理-批量删除") |
|
|
|
|
@DeleteMapping(value = "/deleteBatch") |
|
|
|
|
public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) { |
|
|
|
|
this.modulexService.removeByIds(Arrays.asList(ids.split(","))); |
|
|
|
|
return Result.OK("批量删除成功!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 通过id查询 |
|
|
|
|
* |
|
|
|
|
* @param id |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@AutoLog(value = "模块管理-通过id查询") |
|
|
|
|
@ApiOperation(value="模块管理-通过id查询", notes="模块管理-通过id查询") |
|
|
|
|
@GetMapping(value = "/queryById") |
|
|
|
|
public Result<?> queryById(@RequestParam(name="id",required=true) String id) { |
|
|
|
|
Modulex modulex = modulexService.getById(id); |
|
|
|
|
if(modulex==null) { |
|
|
|
|
return Result.error("未找到对应数据"); |
|
|
|
|
} |
|
|
|
|
return Result.OK(modulex); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 分页列表查询 |
|
|
|
|
* |
|
|
|
|
* @param modulex |
|
|
|
|
* @param pageNo |
|
|
|
|
* @param pageSize |
|
|
|
|
* @param req |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@AutoLog(value = "模块管理-分页列表查询") |
|
|
|
|
@ApiOperation(value = "模块管理-分页列表查询", notes = "模块管理-分页列表查询") |
|
|
|
|
@GetMapping(value = "/list") |
|
|
|
|
public Result<?> queryPageList(Modulex modulex, |
|
|
|
|
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, |
|
|
|
|
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, |
|
|
|
|
HttpServletRequest req) { |
|
|
|
|
QueryWrapper<Modulex> queryWrapper = QueryGenerator.initQueryWrapper(modulex, req.getParameterMap()); |
|
|
|
|
Page<Modulex> page = new Page<Modulex>(pageNo, pageSize); |
|
|
|
|
IPage<Modulex> pageList = modulexService.page(page, queryWrapper); |
|
|
|
|
List<Modulex> modulexList = pageList.getRecords(); |
|
|
|
|
for (Modulex modu :modulexList) { |
|
|
|
|
if (!StringUtils.hasText(modu.getManagerUsers())){ |
|
|
|
|
break; |
|
|
|
|
}else { |
|
|
|
|
String[] split = modu.getManagerUsers().split(","); |
|
|
|
|
List<String> stringList = Arrays.asList(split); |
|
|
|
|
List<String> strings = new ArrayList<>(); |
|
|
|
|
stringList.forEach(manager -> { |
|
|
|
|
String realName = modulexMapper.getRealName(manager); |
|
|
|
|
if (StringUtils.hasText(realName)) { |
|
|
|
|
strings.add(realName); |
|
|
|
|
} else { |
|
|
|
|
strings.add(manager); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
String toString = strings.toString(); |
|
|
|
|
String substring = toString.substring(1, toString.length() - 1); |
|
|
|
|
modu.setManagerUsers_dictText(substring); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return Result.OK(pageList); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@GetMapping(value = "/fabu") |
|
|
|
|
public Result<?> fabu(@RequestParam(name = "id") String id) { |
|
|
|
|
return modulexService.fabu(id); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@GetMapping(value = "/kaishi") |
|
|
|
|
public Result<?> kaishi(@RequestParam(name = "id") String id) { |
|
|
|
|
return modulexService.kaishi(id); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@GetMapping(value = "/tijiao") |
|
|
|
|
public Result<?> tijiao(@RequestParam(name = "id") String id) { |
|
|
|
|
return modulexService.tijiao(id); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@GetMapping(value = "/cehui") |
|
|
|
|
public Result<?> cehui(@RequestParam(name = "id") String id) { |
|
|
|
|
return modulexService.chehui(id); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@GetMapping(value = "/shenhe") |
|
|
|
|
public Result<?> shenhe(@RequestParam(name = "id") String id) { |
|
|
|
|
return modulexService.shenhe(id); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 添加 |
|
|
|
|
* moduleName 中文名称 |
|
|
|
|
* 相同上级的模块不能重名 |
|
|
|
|
*/ |
|
|
|
|
@AutoLog(value = "模块管理-添加") |
|
|
|
|
@ApiOperation(value = "模块管理-添加", notes = "模块管理-添加") |
|
|
|
|
@PostMapping(value = "/add") |
|
|
|
|
public Result<?> add(@RequestBody Modulex modulex) { |
|
|
|
|
//版本号 顺序累加;初始值1
|
|
|
|
|
if (StringUtils.hasText(modulex.getPid())) { |
|
|
|
|
List<String> collect = modulexService.list( |
|
|
|
|
new LambdaQueryWrapper<Modulex>() |
|
|
|
|
.eq(StringUtils.hasText(modulex.getPid()), Modulex::getPid, modulex.getPid())) |
|
|
|
|
.stream().map(Modulex::getModuleName).collect(Collectors.toList()); |
|
|
|
|
collect.add(modulex.getModuleName()); |
|
|
|
|
HashSet<String> setList = new HashSet<>(collect); |
|
|
|
|
if (collect.size() != setList.size()){ |
|
|
|
|
return Result.error("相同上级的模块不能重名"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Integer newVersion = modulexService.getMaxVersion(modulex.getVerison()); |
|
|
|
|
modulex.setVerison(newVersion + 1); |
|
|
|
|
modulexService.save(modulex); |
|
|
|
|
return Result.OK("添加成功!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 编辑 |
|
|
|
|
* |
|
|
|
|
* @param modulex |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@AutoLog(value = "模块管理-编辑") |
|
|
|
|
@ApiOperation(value = "模块管理-编辑", notes = "模块管理-编辑") |
|
|
|
|
@PutMapping(value = "/edit") |
|
|
|
|
public Result<?> edit(@RequestBody Modulex modulex) { |
|
|
|
|
modulexService.updateById(modulex); |
|
|
|
|
return Result.OK("编辑成功!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 通过id删除 |
|
|
|
|
* |
|
|
|
|
* @param id |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@AutoLog(value = "模块管理-通过id删除") |
|
|
|
|
@ApiOperation(value = "模块管理-通过id删除", notes = "模块管理-通过id删除") |
|
|
|
|
@DeleteMapping(value = "/delete") |
|
|
|
|
public Result<?> delete(@RequestParam(name = "id", required = true) String id) { |
|
|
|
|
modulexService.removeById(id); |
|
|
|
|
return Result.OK("删除成功!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 批量删除 |
|
|
|
|
* |
|
|
|
|
* @param ids |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@AutoLog(value = "模块管理-批量删除") |
|
|
|
|
@ApiOperation(value = "模块管理-批量删除", notes = "模块管理-批量删除") |
|
|
|
|
@DeleteMapping(value = "/deleteBatch") |
|
|
|
|
public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) { |
|
|
|
|
this.modulexService.removeByIds(Arrays.asList(ids.split(","))); |
|
|
|
|
return Result.OK("批量删除成功!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 通过id查询 |
|
|
|
|
* |
|
|
|
|
* @param id |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@AutoLog(value = "模块管理-通过id查询") |
|
|
|
|
@ApiOperation(value = "模块管理-通过id查询", notes = "模块管理-通过id查询") |
|
|
|
|
@GetMapping(value = "/queryById") |
|
|
|
|
public Result<?> queryById(@RequestParam(name = "id", required = true) String id) { |
|
|
|
|
Modulex modulex = modulexService.getById(id); |
|
|
|
|
if (modulex == null) { |
|
|
|
|
return Result.error("未找到对应数据"); |
|
|
|
|
} |
|
|
|
|
return Result.OK(modulex); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 导出excel |
|
|
|
|
* |
|
|
|
|
* @param request |
|
|
|
|
* @param modulex |
|
|
|
|
*/ |
|
|
|
|
* 导出excel |
|
|
|
|
* |
|
|
|
|
* @param request |
|
|
|
|
* @param modulex |
|
|
|
|
*/ |
|
|
|
|
@RequestMapping(value = "/exportXls") |
|
|
|
|
public ModelAndView exportXls(HttpServletRequest request, Modulex modulex) { |
|
|
|
|
return super.exportXls(request, modulex, Modulex.class, "模块管理"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 通过excel导入数据 |
|
|
|
|
* |
|
|
|
|
* @param request |
|
|
|
|
* @param response |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
* 通过excel导入数据 |
|
|
|
|
* |
|
|
|
|
* @param request |
|
|
|
|
* @param response |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@RequestMapping(value = "/importExcel", method = RequestMethod.POST) |
|
|
|
|
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { |
|
|
|
|
return super.importExcel(request, response, Modulex.class); |
|
|
|
|