公司项目结构熟悉

1.entity下面的实体类映射数据库的一张表数据库的

如下

boy表:

 映射boy表的数据库:

@Data
@Entity(name = "t_test_boy")
@Table(appliesTo ="t_test_boy" ,comment = "男孩")
@EntityListeners(AuditingEntityListener.class)
public class TTestBoy extends BaseEntity {

   /**
    * 年龄
    */
   @Column(name="age", columnDefinition = "int(11) COMMENT '年龄'" )
   private Long age;

   /**
    * 生日
    */
   @Column(name="birthday", columnDefinition = "varchar(12) COMMENT '生日'" )
   private String birthday;

   /**
    * 是否有女朋友
    */
   @Column(name="has_girl_friend", columnDefinition = "tinyint(4) COMMENT '是否有女朋友'" )
   private Integer hasGirlFriend;

   /**
    * 姓名
    */
   @Column(name="name", columnDefinition = "varchar(32) COMMENT '姓名'" )
   private String name;

}

注:继承的BaseEntity类是每个实体类必须继承的,里面提供了一些实体类的公共属性

如:

@MappedSuperclass
@Data
@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler"})
public abstract class BaseEntity implements Serializable {

    @Id
    @GeneratedValue
    private Long id;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @CreationTimestamp
    @Column(name = "create_time", columnDefinition = "DATETIME COMMENT '创建时间/注册时间'", updatable = false)
    private Date createTime;
    @Column(name = "create_by", columnDefinition = "bigint COMMENT '创建人'", updatable = false)
    @CreatedBy
    private Long createBy;
    @UpdateTimestamp
    @Column(name = "modify_time", columnDefinition = "DATETIME COMMENT '最后更新时间'")
    private Date modifyTime;
    @LastModifiedBy
    @Column(name = "modify_by", columnDefinition = "bigint COMMENT '最后更新人'")
    private Long modifyBy;

}

==================================================================================================================================================

2.controller层的控制类

实现controller来查看来查看:

继承了BasController类

过滤器(通过过滤属性,来以此达到查的功能),增,删,改

@RestController
@RequestMapping("/test/boy")
public class TTestBoyController extends BaseController {
	private  Logger logger = LoggerFactory.getLogger(getClass());
	@Autowired
	private TTestBoyService tTestBoyService;

	@RequestMapping(value = "/list",method = RequestMethod.GET)
	@RequiresPermissions(value = "/test/boy")
	public Object list(@RequestParam(required = false) Long id){
		Page<TTestBoy> page = new PageFactory<TTestBoy>().defaultPage();
		page.addFilter("id",id);
		page = tTestBoyService.queryPage(page);
		return Rets.success(page);
	}
	@RequestMapping(method = RequestMethod.POST)
	@BussinessLog(value = "新增男孩", key = "name")
	@RequiresPermissions(value = "/test/boy/add")
	public Object add(@ModelAttribute TTestBoy tTestBoy){
		tTestBoyService.insert(tTestBoy);
		return Rets.success();
	}
	@RequestMapping(method = RequestMethod.PUT)
	@BussinessLog(value = "更新男孩", key = "name")
	@RequiresPermissions(value = "/test/boy/update")
	public Object update(@ModelAttribute TTestBoy tTestBoy){
		tTestBoyService.update(tTestBoy);
		return Rets.success();
	}
	@RequestMapping(method = RequestMethod.DELETE)
	@BussinessLog(value = "删除男孩", key = "id")
	@RequiresPermissions(value = "/test/boy/delete")
	public Object remove(Long id){
		if (id == null) {
			throw new ApplicationException(BizExceptionEnum.REQUEST_NULL);
		}
		tTestBoyService.delete(id);
		return Rets.success();
	}
}

 ==================================================================================================================================================

3.业务层

通过业务层可以实现不同模块的不同业务

所以业务层是核心

@Service
public class TTestBoyService extends BaseService<TTestBoy,Long,TTestBoyRepository>  {
    private Logger logger = LoggerFactory.getLogger(getClass());
    @Autowired
    private TTestBoyRepository tTestBoyRepository;

}

==================================================================================================================================================

4.dao层

用来存储各种增删改查的jdbc

public interface TTestBoyRepository extends BaseRepository<TTestBoy,Long>{

}
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

程序员慕慕

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值