package ${packageName};
|
|
import java.util.List;
|
import javax.annotation.Resource;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageInfo;
|
|
import com.hx.common.BaseController;
|
import com.hx.mybatisTool.SqlSentence;
|
import ${DAOPackageName}.${entityName}Mapper;
|
import ${entityPackageName}.${entityName};
|
import ${servicePackageName}.${entityName}Service;
|
import com.hx.resultTool.Result;
|
import com.hx.util.SimpleTool;
|
import net.sf.json.JSONObject;
|
import com.hx.phitab.common.AuthConstants;
|
|
@RestController
|
@RequestMapping("${entityNameSmall}")
|
public class ${entityName}Controller extends BaseController {
|
|
@Resource
|
private ${entityName}Service service;
|
|
/**列表*/
|
@Authority(tag = AuthConstants.${entityName}.SEE)
|
@RequestMapping("/list")
|
public Result listData(Integer pageNum,Integer pageSize) {
|
//pageNum当前第几页
|
//rowCount 拿几条
|
|
//分页插件
|
PageHelper.startPage(pageNum==null?1:pageNum,pageSize==null?20:pageSize);
|
SqlSentence sqlSentence = new SqlSentence();
|
List<${entityName}> ${entityNameSmall}s = service.selectList(sqlSentence);
|
PageInfo pageInfo = new PageInfo<${entityName}>(${entityNameSmall}s);
|
Map<String,Object> data = new HashMap<>();
|
data.put("pageNum",pageInfo.getPageNum());
|
data.put("pageSize",pageInfo.getPageSize());
|
data.put("total",pageInfo.getTotal());
|
data.put("isLastPage",pageInfo.isIsLastPage());
|
data.put("list",pageInfo.getList());
|
return Result.success(data);
|
}
|
|
/**新增*/
|
@Authority(tag = AuthConstants.${entityName}.ADD)
|
@RequestMapping("/add")
|
public Result addData(${entityName} ${entityNameSmall}) {
|
service.insert(${entityNameSmall});
|
return Result.success();
|
}
|
|
/**获取数据*/
|
@Authority(tag = AuthConstants.${entityName}.SEE)
|
@RequestMapping("/see")
|
public Result editeData(String id) {
|
${entityName} ${entityNameSmall} = service.selectOneByKeyBlob(id);
|
return Result.success(${entityNameSmall});
|
}
|
|
/**修改数据*/
|
@Authority(tag = AuthConstants.${entityName}.EDIT)
|
@RequestMapping("/update")
|
public Result updateData(${entityName} ${entityNameSmall}) {
|
service.updateAll(${entityNameSmall});
|
return Result.success();
|
}
|
|
/**删除数据(单个)*/
|
@Authority(tag = AuthConstants.${entityName}.DELETE)
|
@RequestMapping("/delete/one")
|
public Result deleteData(String id) {
|
service.deleteOne(id);
|
return Result.success();
|
}
|
}
|