新火炬后端单体项目初始化代码
feat(cms): 为 RatedLife 实体添加字典注解- 在 RatedLife 实体的 cuttingId 字段上添加了 @Dict 注解
- 优化了 RatedLifeController 中的代码格式和注释
已修改2个文件
232 ■■■■ 文件已修改
src/main/java/org/jeecg/modules/cms/controller/RatedLifeController.java 231 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/cms/entity/RatedLife.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/cms/controller/RatedLifeController.java
@@ -9,6 +9,7 @@
import java.net.URLDecoder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.oConvertUtils;
@@ -36,125 +37,125 @@
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog;
 /**
/**
 * @Description: 额定寿命
 * @Author: jeecg-boot
 * @Date:   2025-07-28
 * @Date: 2025-07-28
 * @Version: V1.0
 */
@Api(tags="额定寿命")
@Api(tags = "额定寿命")
@RestController
@RequestMapping("/cms/ratedLife")
@Slf4j
public class RatedLifeController extends JeecgController<RatedLife, IRatedLifeService> {
    @Autowired
    private IRatedLifeService ratedLifeService;
    /**
     * 分页列表查询
     *
     * @param ratedLife
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    //@AutoLog(value = "额定寿命-分页列表查询")
    @ApiOperation(value="额定寿命-分页列表查询", notes="额定寿命-分页列表查询")
    @GetMapping(value = "/list")
    public Result<IPage<RatedLife>> queryPageList(RatedLife ratedLife,
                                   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
                                   HttpServletRequest req) {
        QueryWrapper<RatedLife> queryWrapper = QueryGenerator.initQueryWrapper(ratedLife, req.getParameterMap());
        Page<RatedLife> page = new Page<RatedLife>(pageNo, pageSize);
        IPage<RatedLife> pageList = ratedLifeService.page(page, queryWrapper);
        return Result.OK(pageList);
    }
    /**
     *   添加
     *
     * @param ratedLife
     * @return
     */
    @AutoLog(value = "额定寿命-添加")
    @ApiOperation(value="额定寿命-添加", notes="额定寿命-添加")
    //@RequiresPermissions("org.jeecg.modules:cms_rated_life:add")
    @PostMapping(value = "/add")
    public Result<String> add(@RequestBody RatedLife ratedLife) {
        ratedLifeService.save(ratedLife);
        return Result.OK("添加成功!");
    }
    /**
     *  编辑
     *
     * @param ratedLife
     * @return
     */
    @AutoLog(value = "额定寿命-编辑")
    @ApiOperation(value="额定寿命-编辑", notes="额定寿命-编辑")
    //@RequiresPermissions("org.jeecg.modules:cms_rated_life:edit")
    @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
    public Result<String> edit(@RequestBody RatedLife ratedLife) {
        ratedLifeService.updateById(ratedLife);
        return Result.OK("编辑成功!");
    }
    /**
     *   通过id删除
     *
     * @param id
     * @return
     */
    @AutoLog(value = "额定寿命-通过id删除")
    @ApiOperation(value="额定寿命-通过id删除", notes="额定寿命-通过id删除")
    //@RequiresPermissions("org.jeecg.modules:cms_rated_life:delete")
    @DeleteMapping(value = "/delete")
    public Result<String> delete(@RequestParam(name="id",required=true) String id) {
        ratedLifeService.removeById(id);
        return Result.OK("删除成功!");
    }
    /**
     *  批量删除
     *
     * @param ids
     * @return
     */
    @AutoLog(value = "额定寿命-批量删除")
    @ApiOperation(value="额定寿命-批量删除", notes="额定寿命-批量删除")
    //@RequiresPermissions("org.jeecg.modules:cms_rated_life:deleteBatch")
    @DeleteMapping(value = "/deleteBatch")
    public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
        this.ratedLifeService.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<RatedLife> queryById(@RequestParam(name="id",required=true) String id) {
        RatedLife ratedLife = ratedLifeService.getById(id);
        if(ratedLife==null) {
            return Result.error("未找到对应数据");
        }
        return Result.OK(ratedLife);
    }
    @Autowired
    private IRatedLifeService ratedLifeService;
    /**
    * 导出excel
    *
    * @param request
    * @param ratedLife
    */
     * 分页列表查询
     *
     * @param ratedLife
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    //@AutoLog(value = "额定寿命-分页列表查询")
    @ApiOperation(value = "额定寿命-分页列表查询", notes = "额定寿命-分页列表查询")
    @GetMapping(value = "/list")
    public Result<IPage<RatedLife>> queryPageList(RatedLife ratedLife,
                                                  @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                  @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                  HttpServletRequest req) {
        QueryWrapper<RatedLife> queryWrapper = QueryGenerator.initQueryWrapper(ratedLife, req.getParameterMap());
        Page<RatedLife> page = new Page<RatedLife>(pageNo, pageSize);
        IPage<RatedLife> pageList = ratedLifeService.page(page, queryWrapper);
        return Result.OK(pageList);
    }
    /**
     * 添加
     *
     * @param ratedLife
     * @return
     */
    @AutoLog(value = "额定寿命-添加")
    @ApiOperation(value = "额定寿命-添加", notes = "额定寿命-添加")
    //@RequiresPermissions("org.jeecg.modules:cms_rated_life:add")
    @PostMapping(value = "/add")
    public Result<String> add(@RequestBody RatedLife ratedLife) {
        ratedLifeService.save(ratedLife);
        return Result.OK("添加成功!");
    }
    /**
     * 编辑
     *
     * @param ratedLife
     * @return
     */
    @AutoLog(value = "额定寿命-编辑")
    @ApiOperation(value = "额定寿命-编辑", notes = "额定寿命-编辑")
    //@RequiresPermissions("org.jeecg.modules:cms_rated_life:edit")
    @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
    public Result<String> edit(@RequestBody RatedLife ratedLife) {
        ratedLifeService.updateById(ratedLife);
        return Result.OK("编辑成功!");
    }
    /**
     * 通过id删除
     *
     * @param id
     * @return
     */
    @AutoLog(value = "额定寿命-通过id删除")
    @ApiOperation(value = "额定寿命-通过id删除", notes = "额定寿命-通过id删除")
    //@RequiresPermissions("org.jeecg.modules:cms_rated_life:delete")
    @DeleteMapping(value = "/delete")
    public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
        ratedLifeService.removeById(id);
        return Result.OK("删除成功!");
    }
    /**
     * 批量删除
     *
     * @param ids
     * @return
     */
    @AutoLog(value = "额定寿命-批量删除")
    @ApiOperation(value = "额定寿命-批量删除", notes = "额定寿命-批量删除")
    //@RequiresPermissions("org.jeecg.modules:cms_rated_life:deleteBatch")
    @DeleteMapping(value = "/deleteBatch")
    public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
        this.ratedLifeService.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<RatedLife> queryById(@RequestParam(name = "id", required = true) String id) {
        RatedLife ratedLife = ratedLifeService.getById(id);
        if (ratedLife == null) {
            return Result.error("未找到对应数据");
        }
        return Result.OK(ratedLife);
    }
    /**
     * 导出excel
     *
     * @param request
     * @param ratedLife
     */
    //@RequiresPermissions("org.jeecg.modules:cms_rated_life:exportXls")
    @RequestMapping(value = "/exportXls")
    public ModelAndView exportXls(HttpServletRequest request, RatedLife ratedLife) {
@@ -162,12 +163,12 @@
    }
    /**
      * 通过excel导入数据
    *
    * @param request
    * @param response
    * @return
    */
     * 通过excel导入数据
     *
     * @param request
     * @param response
     * @return
     */
    //@RequiresPermissions("cms_rated_life:importExcel")
    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
src/main/java/org/jeecg/modules/cms/entity/RatedLife.java
@@ -55,6 +55,7 @@
    /**刀具ID*/
    @Excel(name = "刀具ID", width = 15)
    @ApiModelProperty(value = "刀具ID")
    @Dict(dictTable = "cms_cutting_tool",dicCode = "id",dicText = "cutting_code")
    private String cuttingId;
    /**工件材质*/
    @Excel(name = "工件材质", width = 15)