服务指令包代码(临时版本)
This commit is contained in:
parent
1b97f617f8
commit
8bfc38f3b1
|
@ -0,0 +1,172 @@
|
|||
package com.nu.modules.directivePackage.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.nu.modules.directivePackage.entity.DirectivePackage;
|
||||
import com.nu.modules.directivePackage.service.IDirectivePackageService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @Description: 服务指令包
|
||||
* @Author: 张明远
|
||||
* @Date: 2025-03-24
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Api(tags = "服务指令包")
|
||||
@RestController
|
||||
@RequestMapping("/directivePackage/directivePackage")
|
||||
@Slf4j
|
||||
public class DirectivePackageController extends JeecgController<DirectivePackage, IDirectivePackageService> {
|
||||
@Autowired
|
||||
private IDirectivePackageService directivePackageService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param directivePackage
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
//@AutoLog(value = "服务指令包-分页列表查询")
|
||||
@ApiOperation(value = "服务指令包-分页列表查询", notes = "服务指令包-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<DirectivePackage>> queryPageList(DirectivePackage directivePackage,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<DirectivePackage> queryWrapper = QueryGenerator.initQueryWrapper(directivePackage, req.getParameterMap());
|
||||
Page<DirectivePackage> page = new Page<DirectivePackage>(pageNo, pageSize);
|
||||
queryWrapper.select("id");
|
||||
IPage<DirectivePackage> pageList = directivePackageService.page(page, queryWrapper);
|
||||
if (pageList.getRecords() != null && !pageList.getRecords().isEmpty()) {
|
||||
directivePackageService.queryList(directivePackage, pageList);
|
||||
}
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param directivePackage
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "服务指令包-添加")
|
||||
@ApiOperation(value = "服务指令包-添加", notes = "服务指令包-添加")
|
||||
@RequiresPermissions("directivePackage:directive_package:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody DirectivePackage directivePackage) {
|
||||
directivePackageService.save(directivePackage);
|
||||
if (directivePackage.getDirectives() != null && !directivePackage.getDirectives().isEmpty()) {
|
||||
directivePackageService.saveDirectives(directivePackage);
|
||||
}
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param directivePackage
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "服务指令包-编辑")
|
||||
@ApiOperation(value = "服务指令包-编辑", notes = "服务指令包-编辑")
|
||||
@RequiresPermissions("directivePackage:directive_package:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody DirectivePackage directivePackage) {
|
||||
directivePackageService.updateById(directivePackage);
|
||||
if (directivePackage.getDirectives() != null && !directivePackage.getDirectives().isEmpty()) {
|
||||
directivePackageService.saveDirectives(directivePackage);
|
||||
}
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "服务指令包-通过id删除")
|
||||
@ApiOperation(value = "服务指令包-通过id删除", notes = "服务指令包-通过id删除")
|
||||
@RequiresPermissions("directivePackage:directive_package:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
directivePackageService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "服务指令包-批量删除")
|
||||
@ApiOperation(value = "服务指令包-批量删除", notes = "服务指令包-批量删除")
|
||||
@RequiresPermissions("directivePackage:directive_package:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
this.directivePackageService.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<DirectivePackage> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
DirectivePackage directivePackage = directivePackageService.queryById(id);
|
||||
if (directivePackage == null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(directivePackage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param directivePackage
|
||||
*/
|
||||
@RequiresPermissions("directivePackage:directive_package:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, DirectivePackage directivePackage) {
|
||||
return super.exportXls(request, directivePackage, DirectivePackage.class, "服务指令包");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("directivePackage:directive_package:importExcel")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
return super.importExcel(request, response, DirectivePackage.class);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
package com.nu.modules.directivePackage.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Date;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.nu.modules.serviceDirective.entity.ConfigServiceDirective;
|
||||
import org.jeecg.common.constant.ProvinceCityArea;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.jeecg.common.aspect.annotation.Dict;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @Description: 服务指令包
|
||||
* @Author: 张明远
|
||||
* @Date: 2025-03-24
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("nu_directive_package")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="nu_directive_package对象", description="服务指令包")
|
||||
public class DirectivePackage implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**id*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "id")
|
||||
private java.lang.String id;
|
||||
/**服务指令包名称*/
|
||||
@Excel(name = "服务指令包名称", width = 15)
|
||||
@ApiModelProperty(value = "服务指令包名称")
|
||||
private java.lang.String packageName;
|
||||
/**备注*/
|
||||
@Excel(name = "备注", width = 15)
|
||||
@ApiModelProperty(value = "备注")
|
||||
private java.lang.String description;
|
||||
/**排序*/
|
||||
@Excel(name = "排序", width = 15)
|
||||
@ApiModelProperty(value = "排序")
|
||||
private java.lang.Integer sort;
|
||||
/**是否启用 0启用 1未启用*/
|
||||
@Excel(name = "是否启用", width = 15, dicCode = "iz_enabled")
|
||||
@Dict(dicCode = "iz_enabled")
|
||||
@ApiModelProperty(value = "是否启用")
|
||||
private java.lang.String izEnabled;
|
||||
/**是否删除 0未删除 1删除*/
|
||||
@Excel(name = "是否删除", width = 15)
|
||||
@ApiModelProperty(value = "是否删除")
|
||||
@TableLogic
|
||||
private java.lang.String delFlag;
|
||||
/**创建人*/
|
||||
@ApiModelProperty(value = "创建人")
|
||||
private java.lang.String createBy;
|
||||
/**创建日期*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "创建日期")
|
||||
private java.util.Date createTime;
|
||||
/**更新人*/
|
||||
@ApiModelProperty(value = "更新人")
|
||||
private java.lang.String updateBy;
|
||||
/**更新日期*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "更新日期")
|
||||
private java.util.Date updateTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<ConfigServiceDirective> directives;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.nu.modules.directivePackage.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.nu.modules.directivePackage.entity.DirectivePackage;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @Description: 服务指令包
|
||||
* @Author: 张明远
|
||||
* @Date: 2025-03-24
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface DirectivePackageMapper extends BaseMapper<DirectivePackage> {
|
||||
|
||||
int deleteDirectives(@Param("package") DirectivePackage directivePackage);
|
||||
|
||||
int saveDirectives(@Param("package") DirectivePackage directivePackage);
|
||||
|
||||
List<DirectivePackage> queryList( @Param("directivePackage") DirectivePackage directivePackage,@Param("ids") List<DirectivePackage> ids);
|
||||
|
||||
Long queryTotal(@Param("directivePackage") DirectivePackage directivePackage);
|
||||
}
|
|
@ -0,0 +1,147 @@
|
|||
<?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.nu.modules.directivePackage.mapper.DirectivePackageMapper">
|
||||
|
||||
<!-- 定义 resultMap -->
|
||||
<resultMap id="DirectivePackageResultMap" type="com.nu.modules.directivePackage.entity.DirectivePackage">
|
||||
<id property="id" column="id" />
|
||||
<result property="packageName" column="package_name" />
|
||||
<result property="description" column="description" />
|
||||
<result property="sort" column="sort" />
|
||||
<result property="izEnabled" column="iz_enabled" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<!-- 关联的指令列表 -->
|
||||
<collection property="directives" ofType="com.nu.modules.serviceDirective.entity.ConfigServiceDirective">
|
||||
<id property="id" column="directive_id" />
|
||||
<result property="directiveName" column="directive_name" />
|
||||
<result property="categoryId" column="category_id" />
|
||||
<result property="typeId" column="type_id" />
|
||||
<result property="instructionTagId" column="instruction_tag_id" />
|
||||
<result property="tollPrice" column="toll_price" />
|
||||
<result property="comPrice" column="com_price" />
|
||||
<result property="izReimbursement" column="iz_reimbursement" />
|
||||
<result property="izPreferential" column="iz_preferential" />
|
||||
<result property="chargingFrequency" column="charging_frequency" />
|
||||
<result property="cycleType" column="cycle_type" />
|
||||
<result property="serviceContent" column="service_content" />
|
||||
<result property="serviceDuration" column="service_duration" />
|
||||
<result property="izEnabled" column="directive_iz_enabled" />
|
||||
<result property="delFlag" column="directive_del_flag" />
|
||||
<result property="createBy" column="directive_create_by" />
|
||||
<result property="createTime" column="directive_create_time" />
|
||||
<result property="updateBy" column="directive_update_by" />
|
||||
<result property="updateTime" column="directive_update_time" />
|
||||
<result property="sysOrgCode" column="directive_sys_org_code" />
|
||||
<result property="mp3File" column="mp3_file" />
|
||||
<result property="mp4File" column="mp4_file" />
|
||||
<!-- 关联的标签列表 -->
|
||||
<collection property="tagList" ofType="com.nu.modules.directiveTag.entity.DirectiveTag">
|
||||
<id property="id" column="tag_id" />
|
||||
<result property="tagName" column="tag_name" />
|
||||
<result property="sort" column="tag_sort" />
|
||||
<result property="izEnabled" column="tag_iz_enabled" />
|
||||
<result property="delFlag" column="tag_del_flag" />
|
||||
<result property="createBy" column="tag_create_by" />
|
||||
<result property="createTime" column="tag_create_time" />
|
||||
<result property="updateBy" column="tag_update_by" />
|
||||
<result property="updateTime" column="tag_update_time" />
|
||||
<result property="sysOrgCode" column="tag_sys_org_code" />
|
||||
</collection>
|
||||
</collection>
|
||||
</resultMap>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="queryList" resultMap="DirectivePackageResultMap">
|
||||
SELECT
|
||||
dp.id,
|
||||
dp.package_name,
|
||||
dp.description,
|
||||
dp.sort,
|
||||
dp.iz_enabled,
|
||||
dp.del_flag,
|
||||
dp.create_by,
|
||||
dp.create_time,
|
||||
dp.update_by,
|
||||
dp.update_time,
|
||||
csd.id AS directive_id,
|
||||
csd.directive_name,
|
||||
csd.category_id,
|
||||
csd.type_id,
|
||||
csd.instruction_tag_id,
|
||||
csd.toll_price,
|
||||
csd.com_price,
|
||||
csd.iz_reimbursement,
|
||||
csd.iz_preferential,
|
||||
csd.charging_frequency,
|
||||
csd.cycle_type,
|
||||
csd.service_content,
|
||||
csd.service_duration,
|
||||
csd.iz_enabled AS directive_iz_enabled,
|
||||
csd.del_flag AS directive_del_flag,
|
||||
csd.create_by AS directive_create_by,
|
||||
csd.create_time AS directive_create_time,
|
||||
csd.update_by AS directive_update_by,
|
||||
csd.update_time AS directive_update_time,
|
||||
csd.sys_org_code AS directive_sys_org_code,
|
||||
csd.mp3_file,
|
||||
csd.mp4_file,
|
||||
cdt.id AS tag_id,
|
||||
cdt.tag_name,
|
||||
cdt.sort AS tag_sort,
|
||||
cdt.iz_enabled AS tag_iz_enabled,
|
||||
cdt.del_flag AS tag_del_flag,
|
||||
cdt.create_by AS tag_create_by,
|
||||
cdt.create_time AS tag_create_time,
|
||||
cdt.update_by AS tag_update_by,
|
||||
cdt.update_time AS tag_update_time,
|
||||
cdt.sys_org_code AS tag_sys_org_code
|
||||
FROM
|
||||
(SELECT * FROM nu_directive_package
|
||||
<where>
|
||||
del_flag = '0' and id in
|
||||
<foreach collection="ids" item="item" open="(" separator="," close=")">
|
||||
#{item.id}
|
||||
</foreach>
|
||||
</where>) dp
|
||||
LEFT JOIN nu_package_directive pd ON dp.id = pd.package_id
|
||||
LEFT JOIN nu_config_service_directive csd ON pd.directive_id = csd.id
|
||||
LEFT JOIN nu_directive_tag dt ON csd.id = dt.directive_id
|
||||
LEFT JOIN nu_config_directive_tag cdt ON dt.tag_id = cdt.id
|
||||
order by dp.create_time desc
|
||||
</select>
|
||||
|
||||
<!-- 查询总记录数 -->
|
||||
<select id="queryTotal" resultType="java.lang.Long">
|
||||
SELECT COUNT(*)
|
||||
FROM nu_directive_package
|
||||
<where>
|
||||
del_flag = '0'
|
||||
<if test="directivePackage.packageName != null and directivePackage.packageName != ''">
|
||||
AND package_name LIKE CONCAT('%', #{directivePackage.packageName}, '%')
|
||||
</if>
|
||||
<if test="directivePackage.izEnabled != null and directivePackage.izEnabled != ''">
|
||||
AND iz_enabled = #{directivePackage.izEnabled}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="queryByPackageId" resultType="com.nu.modules.directivePackage.entity.DirectivePackage">
|
||||
|
||||
|
||||
</select>
|
||||
|
||||
<delete id="deleteDirectives">
|
||||
delete from nu_package_directive where package_id = #{package.id}
|
||||
</delete>
|
||||
|
||||
<insert id="saveDirectives">
|
||||
INSERT INTO nu_package_directive (package_id, directive_id, sort)
|
||||
VALUES
|
||||
<foreach collection="package.getDirectives()" item="directive" separator=",">
|
||||
(#{package.id}, #{directive.id}, #{directive.sort})
|
||||
</foreach>
|
||||
</insert>
|
||||
</mapper>
|
|
@ -0,0 +1,27 @@
|
|||
package com.nu.modules.directivePackage.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.nu.modules.directivePackage.entity.DirectivePackage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 服务指令包
|
||||
* @Author: 张明远
|
||||
* @Date: 2025-03-24
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface IDirectivePackageService extends IService<DirectivePackage> {
|
||||
|
||||
/**
|
||||
* 存储服务指令包对应的服务指令
|
||||
* @param directivePackage
|
||||
*/
|
||||
void saveDirectives(DirectivePackage directivePackage);
|
||||
|
||||
void queryList(DirectivePackage directivePackage, IPage<DirectivePackage> pageList);
|
||||
|
||||
DirectivePackage queryById(String id);
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package com.nu.modules.directivePackage.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.nu.modules.directivePackage.entity.DirectivePackage;
|
||||
import com.nu.modules.directivePackage.mapper.DirectivePackageMapper;
|
||||
import com.nu.modules.directivePackage.service.IDirectivePackageService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Description: 服务指令包
|
||||
* @Author: 张明远
|
||||
* @Date: 2025-03-24
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class DirectivePackageServiceImpl extends ServiceImpl<DirectivePackageMapper, DirectivePackage> implements IDirectivePackageService {
|
||||
|
||||
@Override
|
||||
public void saveDirectives(DirectivePackage directivePackage) {
|
||||
baseMapper.deleteDirectives(directivePackage);
|
||||
baseMapper.saveDirectives(directivePackage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void queryList(DirectivePackage directivePackage, IPage<DirectivePackage> pageList) {
|
||||
List<DirectivePackage> record = baseMapper.queryList(directivePackage,pageList.getRecords());
|
||||
pageList.setRecords(record);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DirectivePackage queryById(String id) {
|
||||
List<DirectivePackage> query = Lists.newArrayList();
|
||||
DirectivePackage queryDto = new DirectivePackage().setId(id);
|
||||
query.add(queryDto);
|
||||
List<DirectivePackage> directivePackages = baseMapper.queryList(null, query);
|
||||
return directivePackages.stream().findFirst().orElse(null);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package com.nu.modules.serviceDirective.controller;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
@ -26,6 +27,7 @@ import java.util.Arrays;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Description: 服务指令
|
||||
|
@ -69,6 +71,14 @@ public class ConfigServiceDirectiveController extends JeecgController<ConfigServ
|
|||
customeRuleMap.put("izEnabled", QueryRuleEnum.LIKE_WITH_OR);
|
||||
QueryWrapper<ConfigServiceDirective> queryWrapper = QueryGenerator.initQueryWrapper(configServiceDirective, req.getParameterMap(), customeRuleMap);
|
||||
queryWrapper.select("id");
|
||||
//如果有服务指令需要提前查询下对应的服务指令id
|
||||
List<ConfigServiceDirective> directiveIds = null;
|
||||
if (StringUtils.isNotBlank(configServiceDirective.getTags())) {
|
||||
directiveIds = configServiceDirectiveService.queryDirectiveIdByTagIds(configServiceDirective.getTags());
|
||||
if(directiveIds != null && !directiveIds.isEmpty()){
|
||||
queryWrapper.in("id", directiveIds.stream().map(ConfigServiceDirective::getId).collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
Page<ConfigServiceDirective> page = new Page<ConfigServiceDirective>(pageNo, pageSize);
|
||||
IPage<ConfigServiceDirective> list = configServiceDirectiveService.page(page, queryWrapper);
|
||||
List<ConfigServiceDirective> pageList = service.pageList(configServiceDirective, list);
|
||||
|
@ -90,7 +100,7 @@ public class ConfigServiceDirectiveController extends JeecgController<ConfigServ
|
|||
configServiceDirectiveService.save(configServiceDirective);
|
||||
if (StringUtils.isNotBlank(configServiceDirective.getTags())) {
|
||||
configServiceDirectiveService.saveTags(configServiceDirective);
|
||||
}else{
|
||||
} else {
|
||||
configServiceDirectiveService.removeTags(configServiceDirective);
|
||||
}
|
||||
return Result.OK("添加成功!");
|
||||
|
@ -110,7 +120,7 @@ public class ConfigServiceDirectiveController extends JeecgController<ConfigServ
|
|||
configServiceDirectiveService.updateById(configServiceDirective);
|
||||
if (StringUtils.isNotBlank(configServiceDirective.getTags())) {
|
||||
configServiceDirectiveService.saveTags(configServiceDirective);
|
||||
}else{
|
||||
} else {
|
||||
configServiceDirectiveService.removeTags(configServiceDirective);
|
||||
}
|
||||
return Result.OK("编辑成功!");
|
||||
|
|
|
@ -35,6 +35,12 @@ public interface ConfigServiceDirectiveMapper extends BaseMapper<ConfigServiceDi
|
|||
|
||||
int saveTags(@Param("directive") ConfigServiceDirective configServiceDirective);
|
||||
|
||||
/**
|
||||
* 根据指令标签查询对应的服务指令id
|
||||
* @return
|
||||
*/
|
||||
List<ConfigServiceDirective> queryDirectiveIdByTagIds(@Param("tagIds") String tagIds);
|
||||
|
||||
/**
|
||||
* 查询指令标签是否被使用
|
||||
* @return
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
</resultMap>
|
||||
|
||||
|
||||
<!-- 分页查询SQL -->
|
||||
<select id="pageList" resultMap="ConfigServiceDirectiveResultMap" parameterType="map">
|
||||
SELECT
|
||||
c.id,
|
||||
|
@ -76,6 +75,13 @@
|
|||
ORDER BY c.category_id ASC, c.type_id ASC, c.instruction_tag_id ASC,c.create_time desc
|
||||
</select>
|
||||
|
||||
<select id="queryDirectiveIdByTagIds" resultType="com.nu.modules.serviceDirective.entity.ConfigServiceDirective">
|
||||
SELECT distinct directive_id as id FROM nu_directive_tag WHERE tag_id IN
|
||||
<foreach collection="tagIds.split(',')" item="tagId" open="(" separator="," close=")">
|
||||
#{tagId}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="queryCountByTagIds" resultType="java.lang.Integer">
|
||||
SELECT COUNT(*) FROM nu_directive_tag WHERE tag_id IN
|
||||
<foreach collection="tagIds" item="item" open="(" separator="," close=")">
|
||||
|
|
|
@ -32,4 +32,6 @@ public interface IConfigServiceDirectiveService extends IService<ConfigServiceDi
|
|||
* @param configServiceDirective
|
||||
*/
|
||||
void removeTags(ConfigServiceDirective configServiceDirective);
|
||||
|
||||
List<ConfigServiceDirective> queryDirectiveIdByTagIds(String tags);
|
||||
}
|
||||
|
|
|
@ -179,4 +179,9 @@ public class ConfigServiceDirectiveServiceImpl extends ServiceImpl<ConfigService
|
|||
public void removeTags(ConfigServiceDirective configServiceDirective) {
|
||||
baseMapper.deleteTags(configServiceDirective);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ConfigServiceDirective> queryDirectiveIdByTagIds(String tags) {
|
||||
return baseMapper.queryDirectiveIdByTagIds(tags);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue