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

百度推广登陆常德网站seo

百度推广登陆,常德网站seo,海原电商网站建设,不用js可以做网站吗一.新增分类 对员工操作完成后,我们要进行分类操作。分类就是对菜品进行集中管理,将菜品进行分类。分类总大类分为两类,一类是菜品分类,另一类是套餐分类。对于分类,我们定义实体类Category.class。DTO类CategoryDTO.…

一.新增分类

对员工操作完成后,我们要进行分类操作。分类就是对菜品进行集中管理,将菜品进行分类。分类总大类分为两类,一类是菜品分类,另一类是套餐分类。对于分类,我们定义实体类Category.class。DTO类CategoryDTO.class。

Category.class

package com.sky.entity;import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.time.LocalDateTime;@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Category implements Serializable {private static final long serialVersionUID = 1L;private Long id;//类型: 1菜品分类 2套餐分类private Integer type;//分类名称private String name;//顺序private Integer sort;//分类状态 0标识禁用 1表示启用private Integer status;//创建时间private LocalDateTime createTime;//更新时间private LocalDateTime updateTime;//创建人private Long createUser;//修改人private Long updateUser;
}

CategoryDTO.class 

package com.sky.dto;import lombok.Data;import java.io.Serializable;@Data
public class CategoryDTO implements Serializable {//主键private Long id;//类型 1 菜品分类 2 套餐分类private Integer type;//分类名称private String name;//排序private Integer sort;}

二.接口文档 

针对接口文档我们开发新增分类功能,使用post请求。传递过来的参数以JSON格式被封装在employeeDTO对象中。不用给前端返回数据。

三.controller层

package com.sky.controller.admin;import com.sky.dto.CategoryDTO;
import com.sky.entity.Category;
import com.sky.result.Result;
import com.sky.service.CategoryService;
import com.sky.service.impl.CategoryServiceImpl;
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.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;/*** 分类管理*/@RestController
@Api(tags = "分类相关接口")
@RequestMapping("/admin/category")
@Slf4j
public class CategoryController {@Autowiredprivate CategoryService categoryService;/*** 新增分类* @param categoryDTO* @return*/@PostMapping@ApiOperation("新增分类")public Result save(@RequestBody CategoryDTO categoryDTO){log.info("新增分类:{}",categoryDTO);categoryService.save(categoryDTO);return Result.success();}}

四.service层

接口

package com.sky.service;import com.sky.dto.CategoryDTO;public interface CategoryService {/*** 新增分类* @param categoryDTO*/void save(CategoryDTO categoryDTO);
}

实现类

package com.sky.service.impl;import com.sky.context.BaseContext;
import com.sky.dto.CategoryDTO;
import com.sky.entity.Category;
import com.sky.mapper.CategoryMapper;
import com.sky.service.CategoryService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;import java.time.LocalDateTime;@Service
public class CategoryServiceImpl implements CategoryService {@Autowiredprivate CategoryMapper categoryMapper;/*** 新增分类* @param categoryDTO*/@Overridepublic void save(CategoryDTO categoryDTO) {Category category = new Category();BeanUtils.copyProperties(category,categoryDTO);category.setStatus(StatusConstant.DISABLE);category.setCreateTime(LocalDateTime.now());category.setUpdateTime(LocalDateTime.now());category.setCreateUser(BaseContext.getCurrentId());category.setUpdateUser(BaseContext.getCurrentId());categoryMapper.insert(category);}
}

因为我们在mapper接口层和数据库进行连接时要新增一个category类的对象,因此我们在service层要创建一个category的实现类对象,然后将categoryDTO对象中的属性赋值给他,然后设置category中独有的属性。这其中status表示启用或者禁用该分类,我们要注意这里我们默认将其设置为0,这是因为我们当前的分类中还没有添加菜品,因此先不展示给用户。这里的setUpdateUser仍然使用ThreadLocal来获取。

五.mapper层

package com.sky.mapper;import com.sky.entity.Category;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;@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);
}

前后端联调 

可以看到数据已加入

 

http://www.dtcms.com/wzjs/374204.html

相关文章:

  • 什么是域名访问网站线上广告推广
  • 360网站怎么做ppt技术培训
  • 一键网站建站系统如何推广网站链接
  • 看一个网站是哪里做的seo关键词排名优化软件
  • 做网站的知识怎样做网络推广效果好
  • 网站开发的目的实习报告100大看免费行情的软件
  • 做淘宝客网站有什么服务器百度客服工作内容
  • 免费建设网站平台百度排名优化专家
  • 网站备案加速最大的推广平台
  • 网站商城维护怎么做北京优化seo公司
  • 爱玖货源站sem营销推广
  • 大理装饰公司做网站网络服务公司经营范围
  • 可以做进销存的网站系统网站seo关键词优化排名
  • 怎么把微信公众号的文章wordpress什么是seo和sem
  • 信阳网站开发专业做seo推广
  • 网站首页 动画案例石家庄seo关键词
  • 青岛谷歌网站建设网站查询
  • 做网站要遵守的基本原则seol英文啥意思
  • linux主机上传网站国内建站平台有哪些
  • 怎么做网站demo百度推广怎么提高关键词排名
  • 网站建设哪个平台最好青岛网站建设培训学校
  • 中英文建设网站企业整站优化
  • 做网站 做推广需要知道什么房产网站模板
  • 网站建设程序开发百度经验首页登录官网
  • 鲁谷做网站的公司seo怎么快速提高排名
  • 做网站客户最关心哪些问题优化方案模板
  • win10做网站服务器关于seo的行业岗位有哪些
  • 自己设置网站怎么做合肥网站制作公司
  • 如何美化wordpress主题seo网站优化知识
  • 优秀网站建设哪家专业网上推广app