-
@param status
-
@return 返回值表示受影响的记录的行数
*/
boolean modify${className}Status(Integer id, Integer status);
/**
-
根据条件修改${comment}信息
-
@param ${objName}
-
@return
*/
boolean modify(${className} ${objName});
}
package com.resume.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.resume.constant.GlobalConst;
import com.resume.domain.${className};
import com.resume.mapper.${className}Mapper;
import com.resume.service.${className}Service;
import org.springframework.stereotype.Service;
import java.util.List;
/**
-
@Author: 梁云亮
-
@Date: 2021/7/14 13:51
-
@Describe:
*/
@Service
public class c l a s s N a m e S e r v i c e I m p l e x t e n d s S e r v i c e I m p l < {className}ServiceImpl extends ServiceImpl< classNameServiceImplextendsServiceImpl<{className}Mapper, ${className}> implements ${className}Service {
@Override
public List< c l a s s N a m e > l i s t A l l U s a b l e {className}> listAllUsable className>listAllUsable{className}() {
QueryWrapper<${className}> queryWrapper = new QueryWrapper<>();
queryWrapper.select(“id”, “name”, “info”)
.eq(“status”, GlobalConst.Common.STATUS_ENABLE);// 1 表示显示
List<${className}> ${objName}List = baseMapper.selectList(queryWrapper);
return ${objName}List;
}
@Override
public boolean modify${className}Status(Integer id, Integer status) {
${className} ${objName} = ${className}.builder()
.id(id)
.status(status)
.build();
int res = baseMapper.updateById(${objName});
return res == 1 ? true : false;
}
@Override
public boolean modify(${className} ${objName}) {
QueryWrapper<${className}> queryWrapper = new QueryWrapper<>();
queryWrapper.eq(“id”,${objName}.getId());
int updateRes = baseMapper.update(${objName}, queryWrapper);
return updateRes == 1 ? true : false;
}
}
package com.resume.controller;
import com.resume.bean.DataTableResponse;
import com.resume.bean.Result;
import com.resume.bean.ResultUtil;
import com.resume.constant.GlobalConst;
import com.resume.domain.${className};
import com.resume.enums.ResultEnum;
import com.resume.ex.ResumeException;
import com.resume.service.${className}Service;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.List;
/**
-
@Author: 梁云亮
-
@Date: 2021/7/16 16:17
-
@Describe:
*/
@Api(value = “ c o m m e n t 控制器: {comment}控制器: comment控制器:{className}Controller”,tags = “ c l a s s N a m e C o n t r o l l e r : {className}Controller: classNameController:{comment}控制器”)
@Controller
@RequestMapping(“/${objName}”)
public class ${className}Controller {
@Resource
private ${className}Service ${objName}Service;
@ApiOperation(value = “打开 c o m m e n t 列表页面 " , n o t e s = " 打开 {comment}列表页面", notes = "打开 comment列表页面",notes="打开{comment}列表页面”)
@GetMapping(“/open${className}”)
public String open${className}(){
return “/base/${objName}”;
}
@ApiOperation(value = “显示 c o m m e n t 列表 " , n o t e s = " 显示 {comment}列表", notes = "显示 comment列表",notes="显示{comment}列表”)
@ResponseBody
@GetMapping(“/v1/list”)
public Result <DataTableResponse<${className}>> list() {
List<${className}> ${objName}List = o b j N a m e S e r v i c e . l i s t A l l U s a b l e {objName}Service.listAllUsable objNameService.listAllUsable{className}();
DataTableResponse<${className}> dataTableResponse = new DataTableResponse<>();
dataTableResponse.setSEcho(3);
dataTableResponse.setITotalRecords(80L);
dataTableResponse.setITotalDisplayRecords(70L);
dataTableResponse.setAaData(${objName}List);
return ResultUtil.success(200, “数据查询成功”, dataTableResponse);
}
@ApiOperation(value = “删除 c o m m e n t " , n o t e s = " 根据编号删除 {comment}", notes = "根据编号删除 comment",notes="根据编号删除{comment}”)
@ResponseBody
@GetMapping(“/v1/remove”)
public Result remove(Integer id) {
try {
o b j N a m e S e r v i c e . m o d i f y {objName}Service.modify objNameService.modify{className}Status(id, GlobalConst.Common.STATUS_DISABLE);
return ResultUtil.success(ResultEnum.SUCCESS);
} catch (Exception e) {
throw new ResumeException(ResultEnum.SQL_ERROR);
}
}
@ApiOperation(value = “修改 c o m m e n t " , n o t e s = " 根据编号修改 {comment}", notes = "根据编号修改 comment",notes="根据编号修改{comment}”)
@ResponseBody
@GetMapping(“/v1/modify”)
public Result modify(${className} ${objName}) {
try {
o b j N a m e S e r v i c e . m o d i f y ( {objName}Service.modify( objNameService.modify({objName});
return ResultUtil.success(ResultEnum.SUCCESS);
} catch (Exception e) {
throw new ResumeException(ResultEnum.SQL_ERROR);
}
}
@ApiOperation(value = “增加 c o m m e n t " , n o t e s = " 增加 {comment}", notes = "增加 comment",notes="增加{comment}”)
@ResponseBody
@GetMapping(“/v1/create”)
public Result create(${className} ${objName}) {
try {
o b j N a m e S e r v i c e . s a v e ( {objName}Service.save( objNameService.save({objName});
return ResultUtil.success(ResultEnum.SUCCESS);
} catch (Exception e) {
throw new ResumeException(ResultEnum.SQL_ERROR);
}
}
}
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.util.Map;
/**
-
@author 梁云亮
-
@description Freemarker工具类
*/
public class FreemarkerUtil {
/**
-
根据模板,利用提供的数据,生成文件
-
@param ftlNameWithPath 模板文件
-
@param data 数据
-
@param aimFileName 最终生成的文件
-
@throws IOException
-
@throws TemplateException
*/
public static void execute(String ftlNameWithPath, Map<String, Object> data, String aimFileName)
throws IOException, TemplateException {
Configuration cfg = new Configuration(Configuration.VERSION_2_3_25); // 创建Freemarker配置实例
最后
大厂面试问深度,小厂面试问广度,如果有同学想进大厂深造一定要有一个方向精通的惊艳到面试官,还要平时遇到问题后思考一下问题的本质,找方法解决是一个方面,看到问题本质是另一个方面。还有大家一定要有目标,我在很久之前就想着以后一定要去大厂,然后默默努力,每天看一些大佬们的文章,总是觉得只有再学深入一点才有机会,所以才有恒心一直学下去。