6 changed files with 191 additions and 0 deletions
-
47modules/carbon-track/src/main/java/com/thing/carbontrack/dict/controller/IotCarbonUnitDictController.java
-
27modules/carbon-track/src/main/java/com/thing/carbontrack/dict/dto/IotCarbonUnitDictDTO.java
-
32modules/carbon-track/src/main/java/com/thing/carbontrack/dict/entity/IotCarbonUnitDictEntity.java
-
16modules/carbon-track/src/main/java/com/thing/carbontrack/dict/mapper/IotCarbonUnitDictMapper.java
-
19modules/carbon-track/src/main/java/com/thing/carbontrack/dict/service/IotCarbonUnitDictService.java
-
50modules/carbon-track/src/main/java/com/thing/carbontrack/dict/service/impl/IotCarbonUnitDictServiceImpl.java
@ -0,0 +1,47 @@ |
|||
package com.thing.carbontrack.dict.controller; |
|||
|
|||
import com.thing.carbontrack.dict.service.IotCarbonUnitDictService; |
|||
import com.thing.common.core.web.response.Result; |
|||
import io.swagger.v3.oas.annotations.Operation; |
|||
import io.swagger.v3.oas.annotations.tags.Tag; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 计量单位字典 |
|||
* |
|||
* @author xc |
|||
* @since 3.0 2024-09-23 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("v2/dict/iotcarbonunitdict") |
|||
@Tag(name="计量单位字典") |
|||
@RequiredArgsConstructor |
|||
public class IotCarbonUnitDictController { |
|||
|
|||
private final IotCarbonUnitDictService iotCarbonUnitDictService; |
|||
|
|||
|
|||
|
|||
@GetMapping("list") |
|||
@Operation(summary="一级结构列表") |
|||
public Result<List<String>> getList(){ |
|||
List<String> info = iotCarbonUnitDictService.getList(); |
|||
return new Result< List<String>>().ok(info); |
|||
} |
|||
|
|||
|
|||
@GetMapping("listByPName") |
|||
@Operation(summary="二级结构列表") |
|||
public Result<List<String>> listByPName(@RequestParam String pName){ |
|||
List<String> info = iotCarbonUnitDictService.listByPName(pName); |
|||
return new Result< List<String>>().ok(info); |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
package com.thing.carbontrack.dict.dto; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* 计量单位字典 |
|||
* |
|||
* @author xc |
|||
* @since 3.0 2024-09-23 |
|||
*/ |
|||
@Data |
|||
@Schema(description = "计量单位字典") |
|||
public class IotCarbonUnitDictDTO implements Serializable { |
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
private Long id; |
|||
private String pName; |
|||
private String pCode; |
|||
private String cName; |
|||
private String cCode; |
|||
|
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
package com.thing.carbontrack.dict.entity; |
|||
|
|||
import com.mybatisflex.annotation.Id; |
|||
import com.mybatisflex.annotation.Table; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
import lombok.experimental.Accessors; |
|||
|
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* 计量单位字典 |
|||
* |
|||
* @author xc |
|||
* @since 3.0 2024-09-23 |
|||
*/ |
|||
@Data |
|||
@Accessors(chain = true) |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@Table("iot_carbon_unit_dict") |
|||
public class IotCarbonUnitDictEntity implements Serializable { |
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@Id |
|||
private Long id; |
|||
private String pName; |
|||
private String pCode; |
|||
private String cName; |
|||
private String cCode; |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
package com.thing.carbontrack.dict.mapper; |
|||
|
|||
import com.thing.carbontrack.dict.entity.IotCarbonUnitDictEntity; |
|||
import com.thing.common.orm.mapper.PowerBaseMapper; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
/** |
|||
* 计量单位字典 |
|||
* |
|||
* @author xc |
|||
* @since 3.0 2024-09-23 |
|||
*/ |
|||
@Mapper |
|||
public interface IotCarbonUnitDictMapper extends PowerBaseMapper<IotCarbonUnitDictEntity> { |
|||
|
|||
} |
|||
@ -0,0 +1,19 @@ |
|||
package com.thing.carbontrack.dict.service; |
|||
|
|||
import com.thing.carbontrack.dict.entity.IotCarbonUnitDictEntity; |
|||
import com.thing.common.orm.service.IBaseService; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 计量单位字典 |
|||
* |
|||
* @author xc |
|||
* @since 3.0 2024-09-23 |
|||
*/ |
|||
public interface IotCarbonUnitDictService extends IBaseService<IotCarbonUnitDictEntity> { |
|||
|
|||
List<String> getList(); |
|||
|
|||
List<String> listByPName(String pName); |
|||
} |
|||
@ -0,0 +1,50 @@ |
|||
package com.thing.carbontrack.dict.service.impl; |
|||
|
|||
import com.mybatisflex.core.query.QueryColumn; |
|||
import com.mybatisflex.core.query.QueryWrapper; |
|||
import com.thing.carbontrack.dict.entity.IotCarbonUnitDictEntity; |
|||
import com.thing.carbontrack.dict.mapper.IotCarbonUnitDictMapper; |
|||
import com.thing.carbontrack.dict.service.IotCarbonUnitDictService; |
|||
import com.thing.common.orm.service.impl.BaseServiceImpl; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import static com.mybatisflex.core.query.QueryMethods.distinct; |
|||
|
|||
/** |
|||
* 计量单位字典 |
|||
* |
|||
* @author xc |
|||
* @since 3.0 2024-09-23 |
|||
*/ |
|||
@Service |
|||
public class IotCarbonUnitDictServiceImpl extends BaseServiceImpl<IotCarbonUnitDictMapper, IotCarbonUnitDictEntity> implements IotCarbonUnitDictService { |
|||
|
|||
@Override |
|||
public QueryWrapper getWrapper(Map<String, Object> params){ |
|||
QueryWrapper wrapper = new QueryWrapper(); |
|||
return wrapper; |
|||
} |
|||
|
|||
|
|||
@Override |
|||
public List<String> getList() { |
|||
QueryColumn pName = new QueryColumn("p_name"); |
|||
QueryWrapper wrapper = new QueryWrapper(); |
|||
wrapper.select(distinct(pName)) |
|||
.from("iot_carbon_unit_dict"); |
|||
return this.listAs(wrapper,String.class); |
|||
} |
|||
|
|||
@Override |
|||
public List<String> listByPName(String pName) { |
|||
QueryColumn cName = new QueryColumn("c_name"); |
|||
QueryWrapper wrapper = new QueryWrapper(); |
|||
wrapper.select(distinct(cName)) |
|||
.from("iot_carbon_unit_dict"); |
|||
wrapper.eq("p_name",pName); |
|||
return this.listAs(wrapper,String.class); |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue