ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TCrmDeviceController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TCrmDeviceMapper.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-system/src/main/java/com/ruoyi/system/query/TCrmDeviceQuery.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-system/src/main/java/com/ruoyi/system/service/TCrmDeviceService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TCrmDeviceServiceImpl.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-system/src/main/java/com/ruoyi/system/vo/TCrmDeviceVO.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-system/src/main/resources/mapper/system/TCrmDeviceMapper.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TCrmDeviceController.java
@@ -1,8 +1,23 @@ package com.ruoyi.web.controller.api; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.basic.PageInfo; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.framework.web.service.TokenService; import com.ruoyi.system.model.TCrmDevice; import com.ruoyi.system.query.TCrmDeviceQuery; import com.ruoyi.system.service.TCrmDeviceService; import com.ruoyi.system.vo.TCrmDeviceVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import java.util.List; /** * <p> @@ -12,9 +27,97 @@ * @author xiaochen * @since 2025-08-20 */ @Api(tags = "设备管理") @RestController @RequestMapping("/t-crm-device") public class TCrmDeviceController { private final TCrmDeviceService crmDeviceService; private final TokenService tokenService; @Autowired public TCrmDeviceController(TCrmDeviceService crmDeviceService, TokenService tokenService) { this.crmDeviceService = crmDeviceService; this.tokenService = tokenService; } /** * 获取设备管理管理列表 */ @ApiOperation(value = "获取设备管理分页列表") @PostMapping(value = "/pageList") public R<PageInfo<TCrmDeviceVO>> pageList(@RequestBody TCrmDeviceQuery query) { return R.ok(crmDeviceService.pageList(query)); } /** * 获取设备管理管理列表 */ @ApiOperation(value = "获取设备管理列表") @PostMapping(value = "/list") public R<List<TCrmDevice>> list() { return R.ok(crmDeviceService.list(Wrappers.lambdaQuery(TCrmDevice.class).orderByDesc(TCrmDevice::getCreateTime))); } /** * 添加设备管理管理 */ @Log(title = "设备管理信息-新增设备管理", businessType = BusinessType.INSERT) @ApiOperation(value = "添加设备管理") @PostMapping(value = "/add") public R<Boolean> add(@Validated @RequestBody TCrmDevice dto) { if (crmDeviceService.isExit(dto)) { return R.fail("设备识别码已存在"); } if (crmDeviceService.isBind(dto)) { return R.fail("该诊所已被绑定"); } return R.ok(crmDeviceService.save(dto)); } /** * 修改设备管理 */ @Log(title = "设备管理信息-修改设备管理", businessType = BusinessType.UPDATE) @ApiOperation(value = "修改设备管理") @PostMapping(value = "/update") public R<Boolean> update(@Validated @RequestBody TCrmDevice dto) { if (crmDeviceService.isExit(dto)) { return R.fail("设备识别码已存在"); } if (crmDeviceService.isBind(dto)) { return R.fail("该诊所已被绑定"); } return R.ok(crmDeviceService.updateById(dto)); } /** * 查看设备管理详情 */ @ApiOperation(value = "查看设备管理详情") @GetMapping(value = "/getDetailById") public R<TCrmDevice> getDetailById(@RequestParam String id) { return R.ok(crmDeviceService.getById(id)); } /** * 删除设备管理 */ @Log(title = "设备管理信息-删除设备管理", businessType = BusinessType.DELETE) @ApiOperation(value = "删除设备管理") @DeleteMapping(value = "/deleteById") public R<Boolean> deleteById(@RequestParam String id) { return R.ok(crmDeviceService.removeById(id)); } /** * 批量删除设备管理 */ @Log(title = "设备管理信息-删除设备管理", businessType = BusinessType.DELETE) @ApiOperation(value = "批量删除设备管理") @DeleteMapping(value = "/deleteByIds") public R<Boolean> deleteByIds(@RequestBody List<String> ids) { return R.ok(crmDeviceService.removeByIds(ids)); } } ruoyi-system/src/main/java/com/ruoyi/system/mapper/TCrmDeviceMapper.java
@@ -1,7 +1,13 @@ package com.ruoyi.system.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.common.basic.PageInfo; import com.ruoyi.system.model.TCrmDevice; import com.ruoyi.system.query.TCrmDeviceQuery; import com.ruoyi.system.vo.TCrmDeviceVO; import org.apache.ibatis.annotations.Param; import java.util.List; /** * <p> @@ -13,4 +19,11 @@ */ public interface TCrmDeviceMapper extends BaseMapper<TCrmDevice> { /** * 设备管理列表 * * @param query 查询参数 * @return 设备管理列表 */ List<TCrmDeviceVO> pageList(@Param("query") TCrmDeviceQuery query, @Param("pageInfo")PageInfo<TCrmDeviceVO> pageInfo); } ruoyi-system/src/main/java/com/ruoyi/system/query/TCrmDeviceQuery.java
New file @@ -0,0 +1,18 @@ package com.ruoyi.system.query; import com.ruoyi.common.core.domain.BasePage; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data @ApiModel(value = "设备管理查询参数TCrmDeviceQuery") public class TCrmDeviceQuery extends BasePage { @ApiModelProperty(value = "诊所id") private String clinicId; @ApiModelProperty(value = "设备识别码") private String deviceCode; } ruoyi-system/src/main/java/com/ruoyi/system/service/TCrmDeviceService.java
@@ -1,7 +1,10 @@ package com.ruoyi.system.service; import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.common.basic.PageInfo; import com.ruoyi.system.model.TCrmDevice; import com.ruoyi.system.query.TCrmDeviceQuery; import com.ruoyi.system.vo.TCrmDeviceVO; /** * <p> @@ -13,4 +16,24 @@ */ public interface TCrmDeviceService extends IService<TCrmDevice> { /** * 判断分类是否存在 * @param dto * @return */ boolean isExit(TCrmDevice dto); /** * 判断诊所是否绑定 * @param dto * @return */ boolean isBind(TCrmDevice dto); /** * 获取设备管理分页列表 * @param query * @return */ PageInfo<TCrmDeviceVO> pageList(TCrmDeviceQuery query); } ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TCrmDeviceServiceImpl.java
@@ -1,10 +1,19 @@ package com.ruoyi.system.service.impl; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.basic.PageInfo; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.system.mapper.TCrmDeviceMapper; import com.ruoyi.system.model.TCrmDevice; import com.ruoyi.system.model.TCrmDevice; import com.ruoyi.system.model.TCrmPosition; import com.ruoyi.system.query.TCrmDeviceQuery; import com.ruoyi.system.service.TCrmDeviceService; import com.ruoyi.system.vo.TCrmDeviceVO; import org.springframework.stereotype.Service; import java.util.List; /** * <p> @@ -17,4 +26,33 @@ @Service public class TCrmDeviceServiceImpl extends ServiceImpl<TCrmDeviceMapper, TCrmDevice> implements TCrmDeviceService { @Override public boolean isExit(TCrmDevice dto) { if(StringUtils.isNotEmpty(dto.getId())){ // 修改 return this.count(Wrappers.lambdaQuery(TCrmDevice.class).ne(TCrmDevice::getId, dto.getId()).eq(TCrmDevice::getDeviceCode, dto.getDeviceCode())) > 0; }else { // 新增 return this.count(Wrappers.lambdaQuery(TCrmDevice.class).eq(TCrmDevice::getDeviceCode, dto.getDeviceCode())) > 0; } } @Override public boolean isBind(TCrmDevice dto) { if(StringUtils.isNotEmpty(dto.getId())){ // 修改 return this.count(Wrappers.lambdaQuery(TCrmDevice.class).ne(TCrmDevice::getId, dto.getId()).eq(TCrmDevice::getClinicId, dto.getClinicId())) > 0; }else { // 新增 return this.count(Wrappers.lambdaQuery(TCrmDevice.class).eq(TCrmDevice::getClinicId, dto.getClinicId())) > 0; } } @Override public PageInfo<TCrmDeviceVO> pageList(TCrmDeviceQuery query) { PageInfo<TCrmDeviceVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); List<TCrmDeviceVO> list = this.baseMapper.pageList(query,pageInfo); pageInfo.setRecords(list); return pageInfo; } } ruoyi-system/src/main/java/com/ruoyi/system/vo/TCrmDeviceVO.java
New file @@ -0,0 +1,15 @@ package com.ruoyi.system.vo; import com.ruoyi.system.model.TCrmDevice; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data @ApiModel(value = "设备管理信息TCrmDeviceVO") public class TCrmDeviceVO extends TCrmDevice { @ApiModelProperty(value = "诊所名称") private String clinicName; } ruoyi-system/src/main/resources/mapper/system/TCrmDeviceMapper.xml
@@ -18,5 +18,21 @@ <sql id="Base_Column_List"> id, clinic_id, device_code, create_time, update_time, create_by, update_by, disabled </sql> <select id="pageList" resultType="com.ruoyi.system.vo.TCrmDeviceVO"> select tcd.id, tcd.clinic_id, tcd.device_code, tcd.create_time, tcd.update_time, tcd.create_by, tcd.update_by, tcd.disabled, tcc.clinic_name from t_crm_device tcd left join t_crm_clinic tcc on tcd.clinic_id = tcc.id <where> <if test="query.clinicId != null and query.clinicId != ''"> and tcd.clinic_id = #{query.clinicId} </if> <if test="query.deviceCode != null and query.deviceCode != ''"> and tcd.device_code LIKE concat('%',#{query.deviceCode},'%') </if> AND tcd.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()} </where> ORDER BY tcd.create_time DESC </select> </mapper>