9 changed files with 619 additions and 4 deletions
@ -0,0 +1,120 @@ |
|||||
|
package com.zdxt.enforcementcode.controller; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
import cn.dev33.satoken.annotation.SaIgnore; |
||||
|
import com.zdxt.enforcementcode.domain.LinkageDict; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import jakarta.servlet.http.HttpServletResponse; |
||||
|
import jakarta.validation.constraints.*; |
||||
|
import cn.dev33.satoken.annotation.SaCheckPermission; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
import org.springframework.validation.annotation.Validated; |
||||
|
import org.dromara.common.idempotent.annotation.RepeatSubmit; |
||||
|
import org.dromara.common.log.annotation.Log; |
||||
|
import org.dromara.common.web.core.BaseController; |
||||
|
import org.dromara.common.mybatis.core.page.PageQuery; |
||||
|
import org.dromara.common.core.domain.R; |
||||
|
import org.dromara.common.core.validate.AddGroup; |
||||
|
import org.dromara.common.core.validate.EditGroup; |
||||
|
import org.dromara.common.log.enums.BusinessType; |
||||
|
import org.dromara.common.excel.utils.ExcelUtil; |
||||
|
import com.zdxt.enforcementcode.domain.vo.LinkageDictVo; |
||||
|
import com.zdxt.enforcementcode.domain.bo.LinkageDictBo; |
||||
|
import com.zdxt.enforcementcode.service.ILinkageDictService; |
||||
|
import org.dromara.common.mybatis.core.page.TableDataInfo; |
||||
|
|
||||
|
/** |
||||
|
* 联动字典 |
||||
|
* |
||||
|
* @author niujiyi |
||||
|
* @date 2026-05-22 |
||||
|
*/ |
||||
|
@Validated |
||||
|
@RequiredArgsConstructor |
||||
|
@RestController |
||||
|
@RequestMapping("/enforcementcode/dict") |
||||
|
public class LinkageDictController extends BaseController { |
||||
|
|
||||
|
private final ILinkageDictService linkageDictService; |
||||
|
|
||||
|
/** |
||||
|
* 查询联动字典列表 |
||||
|
*/ |
||||
|
@SaCheckPermission("enforcementcode:dict:list") |
||||
|
@GetMapping("/list") |
||||
|
public TableDataInfo<LinkageDictVo> list(LinkageDictBo bo, PageQuery pageQuery) { |
||||
|
return linkageDictService.queryPageList(bo, pageQuery); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 导出联动字典列表 |
||||
|
*/ |
||||
|
@SaCheckPermission("enforcementcode:dict:export") |
||||
|
@Log(title = "联动字典", businessType = BusinessType.EXPORT) |
||||
|
@PostMapping("/export") |
||||
|
public void export(LinkageDictBo bo, HttpServletResponse response) { |
||||
|
List<LinkageDictVo> list = linkageDictService.queryList(bo); |
||||
|
ExcelUtil.exportExcel(list, "联动字典", LinkageDictVo.class, response); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取联动字典详细信息 |
||||
|
* |
||||
|
* @param id 主键 |
||||
|
*/ |
||||
|
@SaCheckPermission("enforcementcode:dict:query") |
||||
|
@GetMapping("/{id}") |
||||
|
public R<LinkageDictVo> getInfo(@NotNull(message = "主键不能为空") |
||||
|
@PathVariable String id) { |
||||
|
return R.ok(linkageDictService.queryById(id)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 新增联动字典 |
||||
|
*/ |
||||
|
@SaCheckPermission("enforcementcode:dict:add") |
||||
|
@Log(title = "联动字典", businessType = BusinessType.INSERT) |
||||
|
@RepeatSubmit() |
||||
|
@PostMapping() |
||||
|
public R<Void> add(@Validated(AddGroup.class) @RequestBody LinkageDictBo bo) { |
||||
|
return toAjax(linkageDictService.insertByBo(bo)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 修改联动字典 |
||||
|
*/ |
||||
|
@SaCheckPermission("enforcementcode:dict:edit") |
||||
|
@Log(title = "联动字典", businessType = BusinessType.UPDATE) |
||||
|
@RepeatSubmit() |
||||
|
@PutMapping() |
||||
|
public R<Void> edit(@Validated(EditGroup.class) @RequestBody LinkageDictBo bo) { |
||||
|
return toAjax(linkageDictService.updateByBo(bo)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 删除联动字典 |
||||
|
* |
||||
|
* @param ids 主键串 |
||||
|
*/ |
||||
|
@SaCheckPermission("enforcementcode:dict:remove") |
||||
|
@Log(title = "联动字典", businessType = BusinessType.DELETE) |
||||
|
@DeleteMapping("/{ids}") |
||||
|
public R<Void> remove(@NotEmpty(message = "主键不能为空") |
||||
|
@PathVariable String[] ids) { |
||||
|
return toAjax(linkageDictService.deleteWithValidByIds(List.of(ids), true)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 执法端查询联动字典 |
||||
|
* |
||||
|
* @param bo 主键 |
||||
|
*/ |
||||
|
@SaIgnore |
||||
|
@GetMapping("/listByParentId") |
||||
|
public R<List<LinkageDictVo>> listByParentId(LinkageDictBo bo) |
||||
|
{ |
||||
|
List<LinkageDictVo> list = linkageDictService.selectLinkageDictByParentId(bo); |
||||
|
return R.ok(list); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,95 @@ |
|||||
|
package com.zdxt.enforcementcode.domain.bo; |
||||
|
|
||||
|
import com.zdxt.enforcementcode.domain.LinkageDict; |
||||
|
import org.dromara.common.mybatis.core.domain.BaseEntity; |
||||
|
import org.dromara.common.core.validate.AddGroup; |
||||
|
import org.dromara.common.core.validate.EditGroup; |
||||
|
import io.github.linpeilie.annotations.AutoMapper; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
import jakarta.validation.constraints.*; |
||||
|
|
||||
|
/** |
||||
|
* 联动字典业务对象 linkage_dict |
||||
|
* |
||||
|
* @author niujiyi |
||||
|
* @date 2026-05-22 |
||||
|
*/ |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper = true) |
||||
|
@AutoMapper(target = LinkageDict.class, reverseConvertGenerate = false) |
||||
|
public class LinkageDictBo extends BaseEntity { |
||||
|
|
||||
|
/** |
||||
|
* 主键 |
||||
|
*/ |
||||
|
@NotBlank(message = "主键不能为空", groups = { EditGroup.class }) |
||||
|
private String id; |
||||
|
|
||||
|
/** |
||||
|
* 标题 |
||||
|
*/ |
||||
|
private String title; |
||||
|
|
||||
|
/** |
||||
|
* 值 |
||||
|
*/ |
||||
|
private String value; |
||||
|
|
||||
|
/** |
||||
|
* 父节点 |
||||
|
*/ |
||||
|
private String parentId; |
||||
|
|
||||
|
/** |
||||
|
* 描述 |
||||
|
*/ |
||||
|
private String desc; |
||||
|
|
||||
|
/** |
||||
|
* 排序 |
||||
|
*/ |
||||
|
private Long srot; |
||||
|
|
||||
|
/** |
||||
|
* 状态(0:正常,1:停用) |
||||
|
*/ |
||||
|
private Long status; |
||||
|
|
||||
|
/** |
||||
|
* 创建者 |
||||
|
*/ |
||||
|
private String creator; |
||||
|
|
||||
|
/** |
||||
|
* 更新者 |
||||
|
*/ |
||||
|
private String updator; |
||||
|
|
||||
|
/** |
||||
|
* 检查领域 |
||||
|
*/ |
||||
|
private String domain; |
||||
|
|
||||
|
/** |
||||
|
* 执法部门 |
||||
|
*/ |
||||
|
private String dept; |
||||
|
|
||||
|
/** |
||||
|
* 检查要求 |
||||
|
*/ |
||||
|
private String demand; |
||||
|
|
||||
|
/** |
||||
|
* 检查依据 |
||||
|
*/ |
||||
|
private String basis; |
||||
|
|
||||
|
/** |
||||
|
* 部门ID |
||||
|
*/ |
||||
|
private String deptId; |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,116 @@ |
|||||
|
package com.zdxt.enforcementcode.domain.vo; |
||||
|
|
||||
|
import com.zdxt.enforcementcode.domain.LinkageDict; |
||||
|
import cn.idev.excel.annotation.ExcelIgnoreUnannotated; |
||||
|
import cn.idev.excel.annotation.ExcelProperty; |
||||
|
import org.dromara.common.excel.annotation.ExcelDictFormat; |
||||
|
import org.dromara.common.excel.convert.ExcelDictConvert; |
||||
|
import io.github.linpeilie.annotations.AutoMapper; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serial; |
||||
|
import java.io.Serializable; |
||||
|
import java.util.Date; |
||||
|
|
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 联动字典视图对象 linkage_dict |
||||
|
* |
||||
|
* @author niujiyi |
||||
|
* @date 2026-05-22 |
||||
|
*/ |
||||
|
@Data |
||||
|
@ExcelIgnoreUnannotated |
||||
|
@AutoMapper(target = LinkageDict.class) |
||||
|
public class LinkageDictVo implements Serializable { |
||||
|
|
||||
|
@Serial |
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* 主键 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "主键") |
||||
|
private String id; |
||||
|
|
||||
|
/** |
||||
|
* 标题 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "标题") |
||||
|
private String title; |
||||
|
|
||||
|
/** |
||||
|
* 值 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "值") |
||||
|
private String value; |
||||
|
|
||||
|
/** |
||||
|
* 父节点 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "父节点") |
||||
|
private String parentId; |
||||
|
|
||||
|
/** |
||||
|
* 描述 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "描述") |
||||
|
private String desc; |
||||
|
|
||||
|
/** |
||||
|
* 排序 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "排序") |
||||
|
private Long srot; |
||||
|
|
||||
|
/** |
||||
|
* 状态(0:正常,1:停用) |
||||
|
*/ |
||||
|
@ExcelProperty(value = "状态(0:正常,1:停用)") |
||||
|
private Long status; |
||||
|
|
||||
|
/** |
||||
|
* 创建者 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "创建者") |
||||
|
private String creator; |
||||
|
|
||||
|
/** |
||||
|
* 更新者 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "更新者") |
||||
|
private String updator; |
||||
|
|
||||
|
/** |
||||
|
* 检查领域 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "检查领域") |
||||
|
private String domain; |
||||
|
|
||||
|
/** |
||||
|
* 执法部门 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "执法部门") |
||||
|
private String dept; |
||||
|
|
||||
|
/** |
||||
|
* 检查要求 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "检查要求") |
||||
|
private String demand; |
||||
|
|
||||
|
/** |
||||
|
* 检查依据 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "检查依据") |
||||
|
private String basis; |
||||
|
|
||||
|
/** |
||||
|
* 部门ID |
||||
|
*/ |
||||
|
@ExcelProperty(value = "部门ID") |
||||
|
private String deptId; |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,70 @@ |
|||||
|
package com.zdxt.enforcementcode.service; |
||||
|
|
||||
|
import com.zdxt.enforcementcode.domain.LinkageDict; |
||||
|
import com.zdxt.enforcementcode.domain.bo.LinkageDictBo; |
||||
|
import com.zdxt.enforcementcode.domain.vo.LinkageDictVo; |
||||
|
import org.dromara.common.mybatis.core.page.PageQuery; |
||||
|
import org.dromara.common.mybatis.core.page.TableDataInfo; |
||||
|
|
||||
|
import java.util.Collection; |
||||
|
import java.util.List; |
||||
|
|
||||
|
public interface ILinkageDictService { |
||||
|
|
||||
|
/** |
||||
|
* 查询联动字典列表 |
||||
|
* @param bo |
||||
|
* @return |
||||
|
*/ |
||||
|
public List<LinkageDictVo> selectLinkageDictByParentId(LinkageDictBo bo); |
||||
|
|
||||
|
/** |
||||
|
* 查询联动字典 |
||||
|
* |
||||
|
* @param id 主键 |
||||
|
* @return 联动字典 |
||||
|
*/ |
||||
|
LinkageDictVo queryById(String id); |
||||
|
|
||||
|
/** |
||||
|
* 分页查询联动字典列表 |
||||
|
* |
||||
|
* @param bo 查询条件 |
||||
|
* @param pageQuery 分页参数 |
||||
|
* @return 联动字典分页列表 |
||||
|
*/ |
||||
|
TableDataInfo<LinkageDictVo> queryPageList(LinkageDictBo bo, PageQuery pageQuery); |
||||
|
|
||||
|
/** |
||||
|
* 查询符合条件的联动字典列表 |
||||
|
* |
||||
|
* @param bo 查询条件 |
||||
|
* @return 联动字典列表 |
||||
|
*/ |
||||
|
List<LinkageDictVo> queryList(LinkageDictBo bo); |
||||
|
|
||||
|
/** |
||||
|
* 新增联动字典 |
||||
|
* |
||||
|
* @param bo 联动字典 |
||||
|
* @return 是否新增成功 |
||||
|
*/ |
||||
|
Boolean insertByBo(LinkageDictBo bo); |
||||
|
|
||||
|
/** |
||||
|
* 修改联动字典 |
||||
|
* |
||||
|
* @param bo 联动字典 |
||||
|
* @return 是否修改成功 |
||||
|
*/ |
||||
|
Boolean updateByBo(LinkageDictBo bo); |
||||
|
|
||||
|
/** |
||||
|
* 校验并批量删除联动字典信息 |
||||
|
* |
||||
|
* @param ids 待删除的主键集合 |
||||
|
* @param isValid 是否进行有效性校验 |
||||
|
* @return 是否删除成功 |
||||
|
*/ |
||||
|
Boolean deleteWithValidByIds(Collection<String> ids, Boolean isValid); |
||||
|
} |
||||
@ -0,0 +1,152 @@ |
|||||
|
package com.zdxt.enforcementcode.service.impl; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
|
import com.zdxt.enforcementcode.domain.LinkageDict; |
||||
|
import com.zdxt.enforcementcode.domain.bo.LinkageDictBo; |
||||
|
import com.zdxt.enforcementcode.domain.vo.LinkageDictVo; |
||||
|
import com.zdxt.enforcementcode.mapper.LinkageDictMapper; |
||||
|
import com.zdxt.enforcementcode.service.ILinkageDictService; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.dromara.common.core.utils.MapstructUtils; |
||||
|
import org.dromara.common.core.utils.StringUtils; |
||||
|
import org.dromara.common.mybatis.core.page.PageQuery; |
||||
|
import org.dromara.common.mybatis.core.page.TableDataInfo; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.Collection; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
@Slf4j |
||||
|
@RequiredArgsConstructor |
||||
|
@Service |
||||
|
public class LinkageDictServiceImpl implements ILinkageDictService { |
||||
|
|
||||
|
|
||||
|
private final LinkageDictMapper baseMapper; |
||||
|
|
||||
|
/** |
||||
|
* 查询联动字典 |
||||
|
* @param bo |
||||
|
* @return |
||||
|
*/ |
||||
|
@Override |
||||
|
public List<LinkageDictVo> selectLinkageDictByParentId(LinkageDictBo bo) { |
||||
|
return baseMapper.selectLinkageDictByParentId(bo); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 查询联动字典 |
||||
|
* |
||||
|
* @param id 主键 |
||||
|
* @return 联动字典 |
||||
|
*/ |
||||
|
@Override |
||||
|
public LinkageDictVo queryById(String id){ |
||||
|
return baseMapper.selectVoById(id); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 分页查询联动字典列表 |
||||
|
* |
||||
|
* @param bo 查询条件 |
||||
|
* @param pageQuery 分页参数 |
||||
|
* @return 联动字典分页列表 |
||||
|
*/ |
||||
|
@Override |
||||
|
public TableDataInfo<LinkageDictVo> queryPageList(LinkageDictBo bo, PageQuery pageQuery) { |
||||
|
LambdaQueryWrapper<LinkageDict> lqw = buildQueryWrapper(bo); |
||||
|
Page<LinkageDictVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw); |
||||
|
return TableDataInfo.build(result); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 查询符合条件的联动字典列表 |
||||
|
* |
||||
|
* @param bo 查询条件 |
||||
|
* @return 联动字典列表 |
||||
|
*/ |
||||
|
@Override |
||||
|
public List<LinkageDictVo> queryList(LinkageDictBo bo) { |
||||
|
LambdaQueryWrapper<LinkageDict> lqw = buildQueryWrapper(bo); |
||||
|
return baseMapper.selectVoList(lqw); |
||||
|
} |
||||
|
|
||||
|
private LambdaQueryWrapper<LinkageDict> buildQueryWrapper(LinkageDictBo bo) { |
||||
|
Map<String, Object> params = bo.getParams(); |
||||
|
LambdaQueryWrapper<LinkageDict> lqw = Wrappers.lambdaQuery(); |
||||
|
lqw.orderByAsc(LinkageDict::getId); |
||||
|
lqw.eq(StringUtils.isNotBlank(bo.getTitle()), LinkageDict::getTitle, bo.getTitle()); |
||||
|
lqw.eq(StringUtils.isNotBlank(bo.getValue()), LinkageDict::getValue, bo.getValue()); |
||||
|
lqw.eq(StringUtils.isNotBlank(bo.getParentId()), LinkageDict::getParentId, bo.getParentId()); |
||||
|
lqw.eq(StringUtils.isNotBlank(bo.getDesc()), LinkageDict::getDesc, bo.getDesc()); |
||||
|
lqw.eq(bo.getSrot() != null, LinkageDict::getSrot, bo.getSrot()); |
||||
|
lqw.eq(bo.getStatus() != null, LinkageDict::getStatus, bo.getStatus()); |
||||
|
lqw.eq(StringUtils.isNotBlank(bo.getCreator()), LinkageDict::getCreator, bo.getCreator()); |
||||
|
lqw.eq(StringUtils.isNotBlank(bo.getUpdator()), LinkageDict::getUpdator, bo.getUpdator()); |
||||
|
lqw.eq(StringUtils.isNotBlank(bo.getDomain()), LinkageDict::getDomain, bo.getDomain()); |
||||
|
lqw.eq(StringUtils.isNotBlank(bo.getDept()), LinkageDict::getDept, bo.getDept()); |
||||
|
lqw.eq(StringUtils.isNotBlank(bo.getDemand()), LinkageDict::getDemand, bo.getDemand()); |
||||
|
lqw.eq(StringUtils.isNotBlank(bo.getBasis()), LinkageDict::getBasis, bo.getBasis()); |
||||
|
lqw.eq(StringUtils.isNotBlank(bo.getDeptId()), LinkageDict::getDeptId, bo.getDeptId()); |
||||
|
return lqw; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 新增联动字典 |
||||
|
* |
||||
|
* @param bo 联动字典 |
||||
|
* @return 是否新增成功 |
||||
|
*/ |
||||
|
@Override |
||||
|
public Boolean insertByBo(LinkageDictBo bo) { |
||||
|
LinkageDict add = MapstructUtils.convert(bo, LinkageDict.class); |
||||
|
validEntityBeforeSave(add); |
||||
|
boolean flag = baseMapper.insert(add) > 0; |
||||
|
if (flag) { |
||||
|
bo.setId(add.getId()); |
||||
|
} |
||||
|
return flag; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 修改联动字典 |
||||
|
* |
||||
|
* @param bo 联动字典 |
||||
|
* @return 是否修改成功 |
||||
|
*/ |
||||
|
@Override |
||||
|
public Boolean updateByBo(LinkageDictBo bo) { |
||||
|
LinkageDict update = MapstructUtils.convert(bo, LinkageDict.class); |
||||
|
validEntityBeforeSave(update); |
||||
|
return baseMapper.updateById(update) > 0; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 保存前的数据校验 |
||||
|
*/ |
||||
|
private void validEntityBeforeSave(LinkageDict entity){ |
||||
|
//TODO 做一些数据校验,如唯一约束
|
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 校验并批量删除联动字典信息 |
||||
|
* |
||||
|
* @param ids 待删除的主键集合 |
||||
|
* @param isValid 是否进行有效性校验 |
||||
|
* @return 是否删除成功 |
||||
|
*/ |
||||
|
@Override |
||||
|
public Boolean deleteWithValidByIds(Collection<String> ids, Boolean isValid) { |
||||
|
if(isValid){ |
||||
|
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
|
} |
||||
|
return baseMapper.deleteByIds(ids) > 0; |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue