mirror of
https://github.com/tencentmusic/supersonic.git
synced 2026-04-24 08:24:19 +08:00
(improvement)(headless) add TagObject logic (#829)
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
package com.tencent.supersonic.headless;
|
||||
|
||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||
import com.tencent.supersonic.headless.api.pojo.request.TagObjectReq;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.TagObjectResp;
|
||||
import com.tencent.supersonic.headless.server.pojo.TagObjectFilter;
|
||||
import com.tencent.supersonic.headless.server.service.TagObjectService;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TagObjectTest extends BaseTest {
|
||||
|
||||
@Autowired
|
||||
private TagObjectService tagObjectService;
|
||||
|
||||
@Test
|
||||
void testCreateTagObject() throws Exception {
|
||||
User user = User.getFakeUser();
|
||||
TagObjectReq tagObjectReq = newTagObjectReq();
|
||||
TagObjectResp tagObjectResp = tagObjectService.create(tagObjectReq, user);
|
||||
tagObjectService.delete(tagObjectResp.getId(), user);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testUpdateTagObject() throws Exception {
|
||||
TagObjectReq tagObjectReq = newTagObjectReq();
|
||||
TagObjectResp tagObjectResp = tagObjectService.create(tagObjectReq, User.getFakeUser());
|
||||
TagObjectReq tagObjectReqUpdate = new TagObjectReq();
|
||||
BeanUtils.copyProperties(tagObjectResp, tagObjectReqUpdate);
|
||||
tagObjectReqUpdate.setName("艺人1");
|
||||
tagObjectService.update(tagObjectReqUpdate, User.getFakeUser());
|
||||
TagObjectResp tagObject = tagObjectService.getTagObject(tagObjectReqUpdate.getId(), User.getFakeUser());
|
||||
tagObjectService.delete(tagObject.getId(), User.getFakeUser());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testQueryTagObject() throws Exception {
|
||||
TagObjectReq tagObjectReq = newTagObjectReq();
|
||||
TagObjectResp tagObjectResp = tagObjectService.create(tagObjectReq, User.getFakeUser());
|
||||
TagObjectFilter filter = new TagObjectFilter();
|
||||
List<TagObjectResp> tagObjects = tagObjectService.getTagObjects(filter, User.getFakeUser());
|
||||
tagObjects.size();
|
||||
tagObjectService.delete(tagObjectResp.getId(), User.getFakeUser());
|
||||
}
|
||||
|
||||
private TagObjectReq newTagObjectReq() {
|
||||
TagObjectReq tagObjectReq = new TagObjectReq();
|
||||
tagObjectReq.setDomainId(2L);
|
||||
tagObjectReq.setName("艺人");
|
||||
tagObjectReq.setBizName("singer");
|
||||
return tagObjectReq;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -120,6 +120,7 @@ CREATE TABLE IF NOT EXISTS `s2_model` (
|
||||
`name` varchar(255) DEFAULT NULL , -- domain name
|
||||
`biz_name` varchar(255) DEFAULT NULL , -- internal name
|
||||
`domain_id` INT DEFAULT '0' , -- parent domain ID
|
||||
`tag_object_id` INT DEFAULT '0' ,
|
||||
`alias` varchar(255) DEFAULT NULL , -- internal name
|
||||
`status` INT DEFAULT NULL,
|
||||
`description` varchar(500) DEFAULT NULL ,
|
||||
@@ -594,4 +595,22 @@ CREATE TABLE IF NOT EXISTS `s2_tag` (
|
||||
`ext` LONGVARCHAR DEFAULT NULL ,
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
COMMENT ON TABLE s2_tag IS 'tag information';
|
||||
COMMENT ON TABLE s2_tag IS 'tag information';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `s2_tag_object` (
|
||||
`id` INT NOT NULL AUTO_INCREMENT,
|
||||
`domain_id` INT NOT NULL ,
|
||||
`name` varchar(255) NOT NULL ,
|
||||
`biz_name` varchar(255) NOT NULL ,
|
||||
`description` varchar(500) DEFAULT NULL ,
|
||||
`status` INT NOT NULL ,
|
||||
`sensitive_level` INT NOT NULL ,
|
||||
`created_at` TIMESTAMP NOT NULL ,
|
||||
`created_by` varchar(100) NOT NULL ,
|
||||
`updated_at` TIMESTAMP DEFAULT NULL ,
|
||||
`updated_by` varchar(100) DEFAULT NULL ,
|
||||
`ext` LONGVARCHAR DEFAULT NULL ,
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
COMMENT ON TABLE s2_tag IS 'tag object information';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user