当前位置: 首页 > news >正文

建站之星怎么弄相册wordpress更改网站内容

建站之星怎么弄相册,wordpress更改网站内容,平面设计主要做什么,企业网站的首页设计模板继续上一节的内容#xff0c;本节完成新增员工、员工分页查询、启用禁用员工账号、编辑员工、导入分类模块功能代码。 目录 新增员工(完整流程分为以下五个部分)需求分析和设计代码开发功能测试代码完善 (ThreadLocal 线程局部变量)代码提交 员工分页查询代码完善 扩展Spring …继续上一节的内容本节完成新增员工、员工分页查询、启用禁用员工账号、编辑员工、导入分类模块功能代码。 目录 新增员工(完整流程分为以下五个部分)需求分析和设计代码开发功能测试代码完善 (ThreadLocal 线程局部变量)代码提交 员工分页查询代码完善 扩展Spring MVC消息转化器 extendMessageConverters 启用禁用员工账号编辑员工导入分类模块功能代码 新增员工(完整流程分为以下五个部分) 需求分析和设计 产品原型 一般在做需求分析时往往都是对照着产品原型进行分析因为产品原型比较直观便于我们理解业务。 当填写完表单信息, 点击保存按钮后, 会提交该表单的数据到服务端, 在服务端中需要接受数据, 然后将数据保存至数据库中。 注意事项账号必须是唯一的、手机号为合法的11位手机号码、身份证号为合法的18位身份证号码、密码默认为123456 接口设计 明确新增员工接口的请求路径、请求方式、请求参数、返回数据。 本项目约定 管理端发出的请求统一使用/admin作为前缀。用户端发出的请求统一使用/user作为前缀。 表设计 新增员工其实就是将我们新增页面录入的员工数据插入到employee表。status字段已经设置了默认值1表示状态正常。 代码开发 设计DTO类 前面看到前端传输过来的是json的数据是否可以使用对应的实体类来接收呢 由于上述传入参数和实体类有较大差别所以还是自定义DTO类。sky-pojo的com.sky.dto定义EmployeeDTO Data public class EmployeeDTO implements Serializable {private Long id;private String username;private String name;private String phone;private String sex;private String idNumber;}Controller层 sky-server的com.sky.controller.adminEmployeeController中创建新增员工方法 PostMapping ApiOperation(新增员工) public Result save(RequestBody EmployeeDTO employeeDTO){log.info(新增员工:{},employeeDTO);employeeService.save(employeeDTO);return Result.success(); }Service层 com.sky.server.impl.EmployeeServiceImpl需要在EmployeeService 接口中先声明该方法后续不再赘述。 public void save(EmployeeDTO employeeDTO) {Employee employee new Employee();//对象属性拷贝 employeeDTO拷贝给employee 前提是公有属性名字要一致BeanUtils.copyProperties(employeeDTO, employee);//设置账号的状态默认正常状态 1表示正常 0表示锁定employee.setStatus(StatusConstant.ENABLE);//设置密码默认密码123456employee.setPassword(DigestUtils.md5DigestAsHex(PasswordConstant.DEFAULT_PASSWORD.getBytes()));//设置当前记录的创建时间和修改时间employee.setCreateTime(LocalDateTime.now());employee.setUpdateTime(LocalDateTime.now());//设置当前记录创建人id和修改人id// TODO 后期需要修改为当前登录用户的idemployee.setCreateUser(10L);//目前写个假数据后期修改employee.setUpdateUser(10L);employeeMapper.insert(employee); }PS:上面的TODO注释会高亮显示提醒程序员要修复这段代码。 Mapper层 com.sky.EmployeeMapper中声明insert方法 Insert(insert into employee (name, username, password, phone, sex, id_number, create_time, update_time, create_user, update_user,status) values (#{name},#{username},#{password},#{phone},#{sex},#{idNumber},#{createTime},#{updateTime},#{createUser},#{updateUser},#{status})) void insert(Employee employee);在application.yml中已开启驼峰命名故id_number和idNumber可对应。 mybatis:configuration:#开启驼峰命名map-underscore-to-camel-case: true功能测试 重启服务访问http://localhost:8080/doc.html进入新增员工接口 响应码401 报错通过断点调试进入到JwtTokenAdminInterceptor拦截器发现由于JWT令牌校验失败导致EmployeeController的save方法没有被调用。 解决方法调用员工登录接口获得一个合法的JWT令牌 使用admin用户登录获取令牌 添加令牌将合法的JWT令牌添加到全局参数中文档管理–全局参数设置–添加参数 再次进行新增测试成功其中请求头部含有JWT令牌 注意由于开发阶段前端和后端是并行开发的后端完成某个功能后此时前端对应的功能可能还没有开发完成导致无法进行前后端联调测试。所以在开发阶段后端测试主要以接口文档测试为主。 注意后面在测试中再有401 报错可能是JWT令牌过期了。 代码完善 (ThreadLocal 线程局部变量) 目前程序存在的问题主要有两个1.录入的用户名已存抛出的异常后没有处理 2.新增员工时创建人id和修改人id设置为固定值 问题一 username已经添加了唯一约束不能重复。报错 解决通过全局异常处理器来处理。进入到sky-server模块com.sky.hander包下GlobalExceptionHandler.java添加方法 /*** 处理SQL异常* param ex* return*/ ExceptionHandler public Result exceptionHandler(SQLIntegrityConstraintViolationException ex){//录入的用户名已存在时报错:Duplicate entry zhangsan for key employee.idx_usernameString message ex.getMessage();if(message.contains(Duplicate entry)){String[] split message.split( );String username split[2];String msg username MessageConstant.ALREADY_EXISTS;return Result.error(msg);}else{return Result.error(MessageConstant.UNKNOWN_ERROR);} }进入到sky-common模块在MessageConstant.java添加 public static final String ALREADY_EXISTS 已存在;再次接口测试 问题二 描述新增员工时创建人id和修改人id设置为固定值,应该动态的设置为当前登录的用户id。 解决通过某种方式动态获取当前登录员工的id。员工登录成功后会生成JWT令牌并响应给前端后续请求中前端会携带JWT令牌通过JWT令牌可以解析出当前登录员工id但是解析出登录员工id后如何传递给Service的save方法 可以通过ThreadLocal进行传递。 ThreadLocal 并不是一个Thread而是Thread的局部变量。 ThreadLocal为每个线程提供单独一份存储空间具有线程隔离的效果只有在线程内才能获取到对应的值线程外则不能访问而客户端发起的每一次请求都是一个单独的线程。常用方法 public void set(T value) //设置当前线程的线程局部变量的值 public T get() //返回当前线程所对应的线程局部变量的值 public void remove() //移除当前线程的线程局部变量所以解决流程如下 初始工程中sky-common模块已经封装了 ThreadLocal 操作的工具类 package com.sky.context;public class BaseContext {public static ThreadLocalLong threadLocal new ThreadLocal();public static void setCurrentId(Long id) {threadLocal.set(id);}public static Long getCurrentId() {return threadLocal.get();}public static void removeCurrentId() {threadLocal.remove();}}sky-server模块在拦截器中解析出当前登录员工id并放入线程局部变量中 Component Slf4j public class JwtTokenAdminInterceptor implements HandlerInterceptor {...public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {...Long empId Long.valueOf(claims.get(JwtClaimsConstant.EMP_ID).toString());log.info(当前员工id, empId);/将用户id存储到ThreadLocalBaseContext.setCurrentId(empId);...} }在Service中获取线程局部变量中的值 public void save(EmployeeDTO employeeDTO) {//.............................//设置当前记录创建人id和修改人idemployee.setCreateUser(BaseContext.getCurrentId());employee.setUpdateUser(BaseContext.getCurrentId());employeeMapper.insert(employee); }测试使用admin(id1)用户登录后添加一条记录 代码提交 点击提交 提交过程中出现提示继续push。 员工分页查询 系统中的员工很多的时候如果在一个页面中全部展示出来会显得比较乱不便于查看所以一般的系统中都会以分页的方式来展示列表数据。而在我们的分页查询页面中, 除了分页条件以外还有一个查询条件 “员工姓名”。 业务规则 根据页码展示员工信息、每页展示10条数据、分页查询时可以根据需要输入员工姓名进行查询 请求参数类型为Query不是json格式提交在路径后直接拼接。/admin/employee/page?namezhangsan。返回数据中records数组中使用Employee实体类对属性进行封装。 设计DTO类根据请求参数进行封装在sky-pojo模块中EmployeePageQueryDTO Data public class EmployeePageQueryDTO implements Serializable {//员工姓名private String name;//页码private int page;//每页显示记录数private int pageSize; }后面所有的分页查询统一都封装为PageResult对象。在sky-common模块。 Data AllArgsConstructor NoArgsConstructor public class PageResult implements Serializable {private long total; //总记录数private List records; //当前页数据集合 }员工信息分页查询后端返回的对象类型为: Result Controller层 sky-server模块中com.sky.controller.admin.EmployeeController GetMapping(/page) ApiOperation(员工分页查询) public ResultPageResult page(EmployeePageQueryDTO employeePageQueryDTO){log.info(员工分页查询参数为{}, employeePageQueryDTO);PageResult pageResult employeeService.pageQuery(employeePageQueryDTO);//后续定义return Result.success(pageResult); }Service层实现类 在EmployeeServiceImpl中实现pageQuery方法 public PageResult pageQuery(EmployeePageQueryDTO employeePageQueryDTO) {// select * from employee limit 0,10//开始分页查询PageHelper.startPage(employeePageQueryDTO.getPage(), employeePageQueryDTO.getPageSize());PageEmployee page employeeMapper.pageQuery(employeePageQueryDTO);//后续定义long total page.getTotal();ListEmployee records page.getResult();return new PageResult(total, records); }注意此处使用 mybatis 的分页插件 PageHelper 来简化分页代码的开发。底层基于 mybatis 的拦截器实现。故在pom.xml文中添加依赖(初始工程已添加) dependencygroupIdcom.github.pagehelper/groupIdartifactIdpagehelper-spring-boot-starter/artifactIdversion${pagehelper}/version /dependencyMapper层 EmployeeMapper 中声明 pageQuery PageEmployee pageQuery(EmployeePageQueryDTO employeePageQueryDTO);src/main/resources/mapper/EmployeeMapper.xml 中编写动态SQL select idpageQuery resultTypecom.sky.entity.Employeeselect * from employeewhereif testname ! null and name ! and name like concat(%,#{name},%)/if/whereorder by create_time desc /select重启服务访问http://localhost:8080/doc.html进入员工分页查询 前后端联调测试发现最后操作时间格式不清晰在代码完善中解决。 代码完善 扩展Spring MVC消息转化器 extendMessageConverters 下面进行代码完善。 方式一 在属性上加上注解对日期进行格式化 Data Builder NoArgsConstructor AllArgsConstructor public class Employee implements Serializable {...JsonFormat(pattern yyyy-MM-dd HH:mm:ss)private LocalDateTime createTime;JsonFormat(pattern yyyy-MM-dd HH:mm:ss)private LocalDateTime updateTime;... }但这种方式需要在每个时间属性上都要加上该注解使用较麻烦且不能全局处理。 方式二推荐 ) 在配置类WebMvcConfiguration中扩展SpringMVC的消息转换器消息转换器的作用就是对我们后端返回给前端的数据进行统一处理我们这里需要统一对日期类型进行格式处理。 WebMvcConfiguration继承了父类WebMvcConfigurationSupport这个是spring给我们提供的web层的配置类一般都会去继承它拓展消息转换器就需要重写父类里的extendMessageConverters方法写的代码都是固定的。 WebMvcConfiguration /*** 扩展Spring MVC框架的消息转化器* param converters*/ protected void extendMessageConverters(ListHttpMessageConverter? converters) {//该方法在程序启动时就会被调用到log.info(扩展消息转换器...);//创建一个消息转换器对象MappingJackson2HttpMessageConverter converter new MappingJackson2HttpMessageConverter();//需要为消息转换器设置一个对象转换器对象转换器可以将Java对象序列化为json数据converter.setObjectMapper(new JacksonObjectMapper());//设置完对象转换器还需要将自己的消息转化器加入容器中 converters存放的是我们整个spring mvc框架使用到的消息转换器converters.add(0,converter);//存入容器时指定索引,否则如果插入到最后默认是使用不到的,我们希望优先使用自己的消息转换器,放在第一位 }时间格式的对象转换器JacksonObjectMapper已经提前写好存放在sky-common模块的json包下 /*** 对象映射器:基于jackson将Java对象转为json或者将json转为Java对象* 将JSON解析为Java对象的过程称为 [从JSON反序列化Java对象]* 从Java对象生成JSON的过程称为 [序列化Java对象到JSON]*/ public class JacksonObjectMapper extends ObjectMapper {//继承jackson包里的ObjectMapper类 是json处理的一个类 //代码写法比较固定,知道当前类起什么作用就行public static final String DEFAULT_DATE_FORMAT yyyy-MM-dd;//public static final String DEFAULT_DATE_TIME_FORMAT yyyy-MM-dd HH:mm:ss; //如果想加上秒就取消这段注释 注释下面这句public static final String DEFAULT_DATE_TIME_FORMAT yyyy-MM-dd HH:mm;public static final String DEFAULT_TIME_FORMAT HH:mm:ss;public JacksonObjectMapper() {super();//收到未知属性时不报异常this.configure(FAIL_ON_UNKNOWN_PROPERTIES, false);//反序列化时属性不存在的兼容处理this.getDeserializationConfig().withoutFeatures(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);//下面可以看到其实是对我们这种比如LocalDateTime这种类型设置了反序列化器(Deserializer)和序列化器(Serializer)//同时也针对转换的格式进行了指定SimpleModule simpleModule new SimpleModule().addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME_FORMAT))).addDeserializer(LocalDate.class, new LocalDateDeserializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT))).addDeserializer(LocalTime.class, new LocalTimeDeserializer(DateTimeFormatter.ofPattern(DEFAULT_TIME_FORMAT))).addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME_FORMAT))).addSerializer(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT))).addSerializer(LocalTime.class, new LocalTimeSerializer(DateTimeFormatter.ofPattern(DEFAULT_TIME_FORMAT)));//注册功能模块 例如可以添加自定义序列化器和反序列化器this.registerModule(simpleModule);} }添加后再次测试 功能完成提交代码和新增员工代码提交一致不再赘述。 启用禁用员工账号 可以对状态为“启用” 的员工账号进行“禁用”操作可以对状态为“禁用”的员工账号进行“启用”操作状态为“禁用”的员工账号不能登录系统。 路径参数携带状态值。同时把id传递过去id的类型是Query类型即通过地址栏传参的方式传入id明确对哪个用户进行操作。 Controller层 sky-server模块中EmployeeController 中创建启用禁用员工账号的方法 PostMapping(/status/{status}) ApiOperation(启用禁用员工账号) public Result startOrStop(PathVariable Integer status,Long id){log.info(启用禁用员工账号{},{},status,id);employeeService.startOrStop(status,id);//后绪步骤定义return Result.success(); }Service层实现类 EmployeeServiceImpl public void startOrStop(Integer status, Long id) {Employee employee Employee.builder().status(status).id(id).build();employeeMapper.update(employee); }Mapper层 EmployeeMapper 接口中声明 update 方法 void update(Employee employee);在 EmployeeMapper.xml 中编写动态SQL update idupdate parameterTypeEmployeeupdate employeesetif testname ! nullname #{name},/ifif testusername ! nullusername #{username},/ifif testpassword ! nullpassword #{password},/ifif testphone ! nullphone #{phone},/ifif testsex ! nullsex #{sex},/ifif testidNumber ! nullid_Number #{idNumber},/ifif testupdateTime ! nullupdate_Time #{updateTime},/ifif testupdateUser ! nullupdate_User #{updateUser},/ifif teststatus ! nullstatus #{status},/if/setwhere id #{id} /update测试 测试完毕提交代码。 编辑员工 注点击修改时数据应该正常回显到修改页面。点击 “保存” 按钮完成编辑操作。 编辑员工功能涉及到两个接口 根据id查询员工信息 编辑员工信息 回显员工信息功能 EmployeeController 中创建 getById GetMapping(/{id}) ApiOperation(根据id查询员工信息) public ResultEmployee getById(PathVariable Long id){Employee employee employeeService.getById(id);return Result.success(employee); }EmployeeServiceImpl 中实现 getById 方法 public Employee getById(Long id) {Employee employee employeeMapper.getById(id);employee.setPassword(****);//回显给前端展示的信息不展示密码return employee; }EmployeeMapper 接口中声明 getById 方法 Select(select * from employee where id #{id}) Employee getById(Long id);修改员工信息功能 EmployeeController 中创建 update 方法: PutMapping ApiOperation(编辑员工信息) public Result update(RequestBody EmployeeDTO employeeDTO){log.info(编辑员工信息{}, employeeDTO);employeeService.update(employeeDTO);return Result.success(); }EmployeeServiceImpl 中实现 update 方法 public void update(EmployeeDTO employeeDTO) {Employee employee new Employee();BeanUtils.copyProperties(employeeDTO, employee);employee.setUpdateTime(LocalDateTime.now());employee.setUpdateUser(BaseContext.getCurrentId());//获取线程局部变量中的值employeeMapper.update(employee);}在实现启用禁用员工账号功能时已实现employeeMapper.update(employee)所以在此不需写Mapper层代码。 分别测试根据id查询员工信息和编辑员工信息两个接口 前后端联调测试也通过提交代码。 导入分类模块功能代码 后台系统中可以管理分类信息分类包括两种类型分别是菜品分类和套餐分类。先来分析菜品分类相关功能。 新增菜品分类、菜品分类分页查询、根据id删除菜品分类要注意的是当分类关联了菜品或者套餐时此分类不允许删除、修改菜品分类点击修改按钮弹出修改窗口在修改窗口回显分类信息、启用禁用菜品分类、分类类型查询当点击分类类型下拉框时从数据库中查询所有的菜品分类数据进行展示 业务规则分类名称必须是唯一的、分类按照类型可以分为菜品分类和套餐分类、新添加的分类状态默认为“禁用” 根据上述原型图分析菜品分类模块共涉及如下6个接口 category表结构 字段名数据类型说明备注idbigint主键自增namevarchar(32)分类名称唯一typeint分类类型1菜品分类 2套餐分类sortint排序字段用于分类数据的排序statusint状态1启用 0禁用create_timedatetime创建时间update_timedatetime最后修改时间create_userbigint创建人idupdate_userbigint最后修改人id 导入资料中的分类管理模块功能代码即可 可按照mapper–service–controller依次导入这样代码不会显示相应的报错。进入到sky-server模块中 Mapper层 DishMapper.java Mapper public interface DishMapper {/*** 根据分类id查询菜品数量* param categoryId* return*/Select(select count(id) from dish where category_id #{categoryId})Integer countByCategoryId(Long categoryId);} SetmealMapper.java Mapper public interface SetmealMapper {/*** 根据分类id查询套餐的数量* param id* return*/Select(select count(id) from setmeal where category_id #{categoryId})Integer countByCategoryId(Long id);}CategoryMapper.java Mapper public interface CategoryMapper {/*** 插入数据* param category*/Insert(insert into category(type, name, sort, status, create_time, update_time, create_user, update_user) VALUES (#{type}, #{name}, #{sort}, #{status}, #{createTime}, #{updateTime}, #{createUser}, #{updateUser}))void insert(Category category);/*** 分页查询* param categoryPageQueryDTO* return*/PageCategory pageQuery(CategoryPageQueryDTO categoryPageQueryDTO);/*** 根据id删除分类* param id*/Delete(delete from category where id #{id})void deleteById(Long id);/*** 根据id修改分类* param category*/void update(Category category);/*** 根据类型查询分类* param type* return*/ListCategory list(Integer type); }CategoryMapper.xml,进入到resources/mapper目录下 ?xml version1.0 encodingUTF-8 ? !DOCTYPE mapper PUBLIC -//mybatis.org//DTD Mapper 3.0//ENhttp://mybatis.org/dtd/mybatis-3-mapper.dtd mapper namespacecom.sky.mapper.CategoryMapperselect idpageQuery resultTypecom.sky.entity.Categoryselect * from categorywhereif testname ! null and name ! and name like concat(%,#{name},%)/ifif testtype ! nulland type #{type}/if/whereorder by sort asc , create_time desc/selectupdate idupdate parameterTypeCategoryupdate categorysetif testtype ! nulltype #{type},/ifif testname ! nullname #{name},/ifif testsort ! nullsort #{sort},/ifif teststatus ! nullstatus #{status},/ifif testupdateTime ! nullupdate_time #{updateTime},/ifif testupdateUser ! nullupdate_user #{updateUser}/if/setwhere id #{id}/updateselect idlist resultTypeCategoryselect * from categorywhere status 1if testtype ! nulland type #{type}/iforder by sort asc,create_time desc/select /mapper Service层 CategoryService.java public interface CategoryService {/*** 新增分类* param categoryDTO*/void save(CategoryDTO categoryDTO);/*** 分页查询* param categoryPageQueryDTO* return*/PageResult pageQuery(CategoryPageQueryDTO categoryPageQueryDTO);/*** 根据id删除分类* param id*/void deleteById(Long id);/*** 修改分类* param categoryDTO*/void update(CategoryDTO categoryDTO);/*** 启用、禁用分类* param status* param id*/void startOrStop(Integer status, Long id);/*** 根据类型查询分类* param type* return*/ListCategory list(Integer type); } CategoryServiceImpl.java Service Slf4j public class CategoryServiceImpl implements CategoryService {Autowiredprivate CategoryMapper categoryMapper;Autowiredprivate DishMapper dishMapper;Autowiredprivate SetmealMapper setmealMapper;/*** 新增分类* param categoryDTO*/public void save(CategoryDTO categoryDTO) {Category category new Category();//属性拷贝BeanUtils.copyProperties(categoryDTO, category);//分类状态默认为禁用状态0category.setStatus(StatusConstant.DISABLE);//设置创建时间、修改时间、创建人、修改人category.setCreateTime(LocalDateTime.now());category.setUpdateTime(LocalDateTime.now());category.setCreateUser(BaseContext.getCurrentId());category.setUpdateUser(BaseContext.getCurrentId());categoryMapper.insert(category);}/*** 分页查询* param categoryPageQueryDTO* return*/public PageResult pageQuery(CategoryPageQueryDTO categoryPageQueryDTO) {PageHelper.startPage(categoryPageQueryDTO.getPage(),categoryPageQueryDTO.getPageSize());//下一条sql进行分页自动加入limit关键字分页PageCategory page categoryMapper.pageQuery(categoryPageQueryDTO);return new PageResult(page.getTotal(), page.getResult());}/*** 根据id删除分类* param id*/public void deleteById(Long id) {//查询当前分类是否关联了菜品如果关联了就抛出业务异常Integer count dishMapper.countByCategoryId(id);if(count 0){//当前分类下有菜品不能删除throw new DeletionNotAllowedException(MessageConstant.CATEGORY_BE_RELATED_BY_DISH);}//查询当前分类是否关联了套餐如果关联了就抛出业务异常count setmealMapper.countByCategoryId(id);if(count 0){//当前分类下有菜品不能删除throw new DeletionNotAllowedException(MessageConstant.CATEGORY_BE_RELATED_BY_SETMEAL);}//删除分类数据categoryMapper.deleteById(id);}/*** 修改分类* param categoryDTO*/public void update(CategoryDTO categoryDTO) {Category category new Category();BeanUtils.copyProperties(categoryDTO,category);//设置修改时间、修改人category.setUpdateTime(LocalDateTime.now());category.setUpdateUser(BaseContext.getCurrentId());categoryMapper.update(category);}/*** 启用、禁用分类* param status* param id*/public void startOrStop(Integer status, Long id) {Category category Category.builder().id(id).status(status).updateTime(LocalDateTime.now()).updateUser(BaseContext.getCurrentId()).build();categoryMapper.update(category);}/*** 根据类型查询分类* param type* return*/public ListCategory list(Integer type) {return categoryMapper.list(type);} }Controller层 CategoryController.java package com.sky.controller.admin;import com.sky.dto.CategoryDTO; import com.sky.dto.CategoryPageQueryDTO; import com.sky.entity.Category; import com.sky.result.PageResult; import com.sky.result.Result; import com.sky.service.CategoryService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.List;/*** 分类管理*/ RestController RequestMapping(/admin/category) Api(tags 分类相关接口) Slf4j public class CategoryController {Autowiredprivate CategoryService categoryService;/*** 新增分类* param categoryDTO* return*/PostMappingApiOperation(新增分类)public ResultString save(RequestBody CategoryDTO categoryDTO){log.info(新增分类{}, categoryDTO);categoryService.save(categoryDTO);return Result.success();}/*** 分类分页查询* param categoryPageQueryDTO* return*/GetMapping(/page)ApiOperation(分类分页查询)public ResultPageResult page(CategoryPageQueryDTO categoryPageQueryDTO){log.info(分页查询{}, categoryPageQueryDTO);PageResult pageResult categoryService.pageQuery(categoryPageQueryDTO);return Result.success(pageResult);}/*** 删除分类* param id* return*/DeleteMappingApiOperation(删除分类)public ResultString deleteById(Long id){log.info(删除分类{}, id);categoryService.deleteById(id);return Result.success();}/*** 修改分类* param categoryDTO* return*/PutMappingApiOperation(修改分类)public ResultString update(RequestBody CategoryDTO categoryDTO){categoryService.update(categoryDTO);return Result.success();}/*** 启用、禁用分类* param status* param id* return*/PostMapping(/status/{status})ApiOperation(启用禁用分类)public ResultString startOrStop(PathVariable(status) Integer status, Long id){categoryService.startOrStop(status,id);return Result.success();}/*** 根据类型查询分类* param type* return*/GetMapping(/list)ApiOperation(根据类型查询分类)public ResultListCategory list(Integer type){ListCategory list categoryService.list(type);return Result.success(list);} }导入完毕后还需要编译,确保代码无错误 重启服务功能太多直接前后端联调测试 测试通过提交代码。
http://www.tj-hxxt.cn/news/136419.html

相关文章:

  • 开网站需要准备什么关键词排名查询api
  • 泰州网站制作软件网站没有备案怎么做支付
  • 开封景区网站建设方案wordpress主题二级菜单栏
  • 定做专业营销型网站浏览器在线进入
  • 苍溪网站建设制作如何在网站搜关键字
  • 国外大型门户网站大学生创新创业网站建设申报书
  • 免费网站空间10g电子商务之网站建设
  • 奉贤做网站公司什么浏览器可以看违规网站
  • 农业科技公司网站建设网站英文域名怎么查
  • 如何增加网站反链网页设计师资格证查询官网
  • 电子商务网站需要做那些准备工作主流网站宽度
  • 企业网站建设规划书ppt经典重庆网首页
  • 重庆做网站制作的公司做p2p网站的公司
  • 网站建设流程有视频网站用户增长怎么做
  • 佛山市制作网站网页界面设计ppt(完美版)百度文库
  • c苏宁网站开发商业模式包括哪些模式
  • 网站建设视频上传网站开发者不给源代码怎么办
  • 网站建设团队扬州珠海建网站的网络公司
  • 鸿邑网站建设仿制网站侵权吗
  • 手机微信小程序怎么制作佛山选择免费网站优化
  • 做设计的网站有哪些手机家装绘图软件
  • 做外贸搜索外国客户的网站淘宝网站SEO怎么做
  • 加强公司网站建设及数据库的通知代理网络怎么关闭
  • 新浪网站源代码网站后台管理图片
  • pc网站建设和推广简单的网站怎样做
  • 备份wordpress网站品牌网络推广方式
  • 做网站创业风险分析网站ping值
  • thinkphp怎么做网站cms开源建站系统
  • 上海市建设工程材料网站黄金网站软件入口免费
  • 广东圆心科技网站开发建站教程详解cms 导航网站