75 lines
2.0 KiB
Java
75 lines
2.0 KiB
Java
package com.hivekion.icon.controller;
|
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
import com.hivekion.baseData.controller.BaseController;
|
|
import com.hivekion.common.entity.PagedResultVo;
|
|
import com.hivekion.common.entity.ResponseData;
|
|
import com.hivekion.icon.entity.Icon;
|
|
import com.hivekion.icon.service.IconService;
|
|
import java.time.LocalDateTime;
|
|
import java.util.List;
|
|
import javax.annotation.Resource;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
/**
|
|
* <p>
|
|
* 前端控制器
|
|
* </p>
|
|
*
|
|
* @author liDongYu
|
|
* @since 2025-09-07
|
|
*/
|
|
@RestController
|
|
@RequestMapping("/icon")
|
|
@Slf4j
|
|
public class IconController extends BaseController {
|
|
|
|
@Resource
|
|
private IconService iconService;
|
|
|
|
@GetMapping("/list")
|
|
public PagedResultVo<Icon> list(Icon search) {
|
|
|
|
//设置开始索引
|
|
search.setStart(search.getPageSize() * (search.getPageNum() - 1));
|
|
//查询结果列表
|
|
List<Icon> list = iconService.list(search);
|
|
//查询总数
|
|
Long total = iconService.count(search);
|
|
return list(search, list, total);
|
|
}
|
|
|
|
@PostMapping("/save")
|
|
public ResponseData<Object> save(@RequestBody Icon icon) {
|
|
if (icon.getId() == null) {
|
|
|
|
icon.setId(IdUtil.simpleUUID());
|
|
icon.setCreateTime(LocalDateTime.now());
|
|
icon.setOperator(getCurrentUserId());
|
|
iconService.save(icon);
|
|
}else{
|
|
|
|
iconService.updateById(icon);
|
|
}
|
|
|
|
return ResponseData.success(true);
|
|
}
|
|
|
|
@GetMapping("/remove/{id}")
|
|
public ResponseData<Object> delete(@PathVariable("id") String id) {
|
|
iconService.removeById(id);
|
|
return ResponseData.success(true);
|
|
}
|
|
|
|
@GetMapping("/{id}")
|
|
public ResponseData<Icon> view(@PathVariable("id") String id) {
|
|
return ResponseData.success(iconService.getById(id));
|
|
}
|
|
}
|